diff options
author | Fatih Acet <acetfatih@gmail.com> | 2019-01-24 00:44:15 +0100 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2019-01-30 23:18:17 +0100 |
commit | edba6ee3ccdd8efcb60057d604fbf3b1a62e56ae (patch) | |
tree | 53e52d6b4a531b48e2dd8320bb136ffe72497d90 | |
parent | 968e35a692b94ad0fe3bc8be03f64b5e8fec30c0 (diff) | |
download | gitlab-ce-edba6ee3ccdd8efcb60057d604fbf3b1a62e56ae.tar.gz |
Toggle individual task list group while requesting
-rw-r--r-- | app/assets/javascripts/task_list.js | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/app/assets/javascripts/task_list.js b/app/assets/javascripts/task_list.js index 9ea6cba7281..38c9e28e8b1 100644 --- a/app/assets/javascripts/task_list.js +++ b/app/assets/javascripts/task_list.js @@ -10,6 +10,7 @@ export default class TaskList { this.fieldName = options.fieldName; this.lockVersion = options.lockVersion; this.onSuccess = options.onSuccess || (() => {}); + this.taskListContainerSelector = `${this.selector} .js-task-list-container`; this.onError = options.onError || function showFlash(e) { @@ -28,25 +29,31 @@ export default class TaskList { init() { // Prevent duplicate event bindings this.disable(); - $(`${this.selector} .js-task-list-container`).taskList('enable'); + $(this.taskListContainerSelector).taskList('enable'); $(document).on( 'tasklist:changed', - `${this.selector} .js-task-list-container`, + this.taskListContainerSelector, this.update.bind(this), ); } - disableTaskListItems() { - $(`${this.selector} .js-task-list-container`).taskList('disable'); + getTaskListTarget(e = {}) { + const $currentTarget = $(e.currentTarget); + + return $currentTarget.taskList ? $currentTarget : $(this.taskListContainerSelector); + } + + disableTaskListItems(e) { + this.getTaskListTarget(e).taskList('disable'); } - enableTaskListItems() { - $(`${this.selector} .js-task-list-container`).taskList('enable'); + enableTaskListItems(e) { + this.getTaskListTarget(e).taskList('enable'); } disable() { this.disableTaskListItems(); - $(document).off('tasklist:changed', `${this.selector} .js-task-list-container`); + $(document).off('tasklist:changed', this.taskListContainerSelector); } update(e) { @@ -65,18 +72,18 @@ export default class TaskList { }, }; - this.disableTaskListItems(); + this.disableTaskListItems(e); return axios .patch($target.data('updateUrl') || $('form.js-issuable-update').attr('action'), patchData) .then(({ data }) => { this.lockVersion = data.lock_version; - this.enableTaskListItems(); + this.enableTaskListItems(e); return this.onSuccess(data); }) .catch(({ response }) => { - this.enableTaskListItems(); + this.enableTaskListItems(e); return this.onError(response.data); }); |