diff options
author | Joseph Frazier <1212jtraceur@gmail.com> | 2016-09-01 07:58:09 -0400 |
---|---|---|
committer | Joseph Frazier <1212jtraceur@gmail.com> | 2016-10-03 12:16:02 -0400 |
commit | ad2b6cae0b299868eba9f8acf76bafe919408ccd (patch) | |
tree | 988c97e3bc4b52a547f25671e59fee56a24f5dae /app/assets/javascripts/blob/template_selector.js | |
parent | a1aea3266e4b90869d5a9bcc334272996ab80fda (diff) | |
download | gitlab-ce-ad2b6cae0b299868eba9f8acf76bafe919408ccd.tar.gz |
Append issue template to existing description
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/21733
Add two newlines before the template if the existing description isn't
empty. This makes it easier to see where the template begins.
Don't append the template when "Reset template" is selected, of course.
Don't append template if it equals the existing description. This makes
it so that selecting a template twice doesn't duplicate it.
Diffstat (limited to 'app/assets/javascripts/blob/template_selector.js')
-rw-r--r-- | app/assets/javascripts/blob/template_selector.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/assets/javascripts/blob/template_selector.js b/app/assets/javascripts/blob/template_selector.js index 95352164d76..26852aadea5 100644 --- a/app/assets/javascripts/blob/template_selector.js +++ b/app/assets/javascripts/blob/template_selector.js @@ -72,8 +72,13 @@ // To be implemented on the extending class // e.g. // Api.gitignoreText item.name, @requestFileSuccess.bind(@) - TemplateSelector.prototype.requestFileSuccess = function(file, skipFocus) { - this.editor.setValue(file.content, 1); + TemplateSelector.prototype.requestFileSuccess = function(file, skipFocus, append) { + var oldValue = this.editor.getValue(); + var newValue = file.content; + if (append && oldValue.length && oldValue !== newValue) { + newValue = oldValue + '\n\n' + newValue; + } + this.editor.setValue(newValue, 1); if (!skipFocus) this.editor.focus(); if (this.editor instanceof jQuery) { |