Commit 739cb052 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch 'temporarily-revert-appending-templates-before-long-term-ux-fix' into 'master'

Stop appending templates - Temporary fix

## What does this MR do?

This is the temporary fix for #23315. This stops the templates appending to any existing text.

## Are there points in the code the reviewer needs to double check?

## Why was this MR needed?

Temporary fix for #23315.

## Screenshots (if relevant)

![2016-10-21_21.58.55](/uploads/ba54d89fcb2fb9cf99ff24c8623ae413/2016-10-21_21.58.55.gif)

## Does this MR meet the acceptance criteria?

- [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG.md) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [ ] Added for this feature/bug
  - [ ] All builds are passing
- [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

See merge request !7050
parents 926b2fb7 7664c76a
...@@ -68,14 +68,10 @@ ...@@ -68,14 +68,10 @@
// To be implemented on the extending class // To be implemented on the extending class
// e.g. // e.g.
// Api.gitignoreText item.name, @requestFileSuccess.bind(@) // Api.gitignoreText item.name, @requestFileSuccess.bind(@)
requestFileSuccess(file, { skipFocus, append } = {}) { requestFileSuccess(file, { skipFocus } = {}) {
const oldValue = this.editor.getValue(); const oldValue = this.editor.getValue();
let newValue = file.content; let newValue = file.content;
if (append && oldValue.length && oldValue !== newValue) {
newValue = oldValue + '\n\n' + newValue;
}
this.editor.setValue(newValue, 1); this.editor.setValue(newValue, 1);
if (!skipFocus) this.editor.focus(); if (!skipFocus) this.editor.focus();
...@@ -99,4 +95,3 @@ ...@@ -99,4 +95,3 @@
global.TemplateSelector = TemplateSelector; global.TemplateSelector = TemplateSelector;
})(window.gl || ( window.gl = {})); })(window.gl || ( window.gl = {}));
...@@ -32,24 +32,22 @@ ...@@ -32,24 +32,22 @@
this.currentTemplate = currentTemplate; this.currentTemplate = currentTemplate;
if (err) return; // Error handled by global AJAX error handler if (err) return; // Error handled by global AJAX error handler
this.stopLoadingSpinner(); this.stopLoadingSpinner();
this.setInputValueToTemplateContent(true); this.setInputValueToTemplateContent();
}); });
return; return;
} }
setInputValueToTemplateContent(append) { setInputValueToTemplateContent() {
// `this.requestFileSuccess` sets the value of the description input field // `this.requestFileSuccess` sets the value of the description input field
// to the content of the template selected. If `append` is true, the // to the content of the template selected.
// template content will be appended to the previous value of the field,
// separated by a blank line if the previous value is non-empty.
if (this.titleInput.val() === '') { if (this.titleInput.val() === '') {
// If the title has not yet been set, focus the title input and // If the title has not yet been set, focus the title input and
// skip focusing the description input by setting `true` as the // skip focusing the description input by setting `true` as the
// `skipFocus` option to `requestFileSuccess`. // `skipFocus` option to `requestFileSuccess`.
this.requestFileSuccess(this.currentTemplate, {skipFocus: true, append}); this.requestFileSuccess(this.currentTemplate, {skipFocus: true});
this.titleInput.focus(); this.titleInput.focus();
} else { } else {
this.requestFileSuccess(this.currentTemplate, {skipFocus: false, append}); this.requestFileSuccess(this.currentTemplate, {skipFocus: false});
} }
return; return;
} }
......
...@@ -77,7 +77,7 @@ feature 'issuable templates', feature: true, js: true do ...@@ -77,7 +77,7 @@ feature 'issuable templates', feature: true, js: true do
scenario 'user selects "bug" template' do scenario 'user selects "bug" template' do
select_template 'bug' select_template 'bug'
wait_for_ajax wait_for_ajax
preview_template("#{prior_description}\n\n#{template_content}") preview_template("#{template_content}")
save_changes save_changes
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment