Commit 92249756 authored by Robert Speicher's avatar Robert Speicher

Update task list behavior for Notes

parent a3d55db9
...@@ -11,6 +11,7 @@ class @Notes ...@@ -11,6 +11,7 @@ class @Notes
@setupMainTargetNoteForm() @setupMainTargetNoteForm()
@cleanBinding() @cleanBinding()
@addBinding() @addBinding()
@initTaskList()
addBinding: -> addBinding: ->
# add note to UI after creation # add note to UI after creation
...@@ -81,6 +82,9 @@ class @Notes ...@@ -81,6 +82,9 @@ class @Notes
$(document).off "click", ".js-note-target-reopen" $(document).off "click", ".js-note-target-reopen"
$(document).off "click", ".js-note-target-close" $(document).off "click", ".js-note-target-close"
$('.note .js-task-list-container').taskList('disable')
$(document).off 'tasklist:changed', '.note .js-task-list-container'
initRefresh: -> initRefresh: ->
clearInterval(Notes.interval) clearInterval(Notes.interval)
Notes.interval = setInterval => Notes.interval = setInterval =>
...@@ -114,6 +118,7 @@ class @Notes ...@@ -114,6 +118,7 @@ class @Notes
if @isNewNote(note) if @isNewNote(note)
@note_ids.push(note.id) @note_ids.push(note.id)
$('ul.main-notes-list').append(note.html) $('ul.main-notes-list').append(note.html)
@initTaskList()
### ###
Check if note does not exists on page Check if note does not exists on page
...@@ -268,6 +273,8 @@ class @Notes ...@@ -268,6 +273,8 @@ class @Notes
note_li.replaceWith(note.html) note_li.replaceWith(note.html)
note_li.find('.note-edit-form').hide() note_li.find('.note-edit-form').hide()
note_li.find('.note-body > .note-text').show() note_li.find('.note-body > .note-text').show()
note_li.find('js-task-list-container').taskList('enable')
@enableTaskList()
### ###
Called in response to clicking the edit note link Called in response to clicking the edit note link
...@@ -479,3 +486,13 @@ class @Notes ...@@ -479,3 +486,13 @@ class @Notes
else else
form.find('.js-note-target-reopen').text('Reopen') form.find('.js-note-target-reopen').text('Reopen')
form.find('.js-note-target-close').text('Close') form.find('.js-note-target-close').text('Close')
enableTaskList: ->
$('.note .js-task-list-container').taskList('enable')
initTaskList: ->
@enableTaskList()
$(document).on 'tasklist:changed', '.note .js-task-list-container', @updateTaskList
updateTaskList: ->
$('form', this).submit()
.note-edit-form .note-edit-form
= form_for note, url: namespace_project_note_path(@project.namespace, @project, note), method: :put, remote: true, authenticity_token: true do |f| = form_for note, url: namespace_project_note_path(@project.namespace, @project, note), method: :put, remote: true, authenticity_token: true do |f|
= note_target_fields(note) = note_target_fields(note)
= render layout: 'projects/md_preview', locals: { preview_class: "note-text" } do = render layout: 'projects/md_preview', locals: { preview_class: 'note-text' } do
= render 'projects/zen', f: f, attr: :note, = render 'projects/zen', f: f, attr: :note, classes: 'note_text js-note-text js-task-list-field'
classes: 'note_text js-note-text'
.comment-hints.clearfix .comment-hints.clearfix
.pull-left Comments are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"),{ target: '_blank', tabindex: -1 }} .pull-left Comments are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"),{ target: '_blank', tabindex: -1 }}
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
\-1 \-1
.note-body .note-body.js-task-list-container
.note-text .note-text
= preserve do = preserve do
= markdown(note.note, {no_header_anchors: true}) = markdown(note.note, {no_header_anchors: true})
......
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