Commit edbf9880 authored by Regis's avatar Regis

update task_list n/n

parent 1f8226e1
...@@ -32,7 +32,9 @@ export default { ...@@ -32,7 +32,9 @@ export default {
timeoutId: null, timeoutId: null,
title: '<span></span>', title: '<span></span>',
description: '<span></span>', description: '<span></span>',
descriptionText: '',
descriptionChange: false, descriptionChange: false,
taskStatus: '',
}; };
}, },
methods: { methods: {
...@@ -40,46 +42,35 @@ export default { ...@@ -40,46 +42,35 @@ export default {
const body = JSON.parse(res.body); const body = JSON.parse(res.body);
this.triggerAnimation(body); this.triggerAnimation(body);
}, },
triggerAnimation(body) { updateTaskHTML(body) {
// always reset to false before checking the change this.taskStatus = body.task_status;
this.descriptionChange = false; document.querySelector('#task_status').innerText = this.taskStatus;
},
const { title, description } = body; elementsToVisualize(noTitleChange, noDescriptionChange) {
const elementStack = [];
this.descriptionText = body.description_text;
/**
* since opacity is changed, even if there is no diff for Vue to update
* we must check the title/description even on a 304 to ensure no visual change
*/
const noTitleChange = this.title === title;
const noDescriptionChange = this.description === description;
if (noTitleChange && noDescriptionChange) return;
const elementsToVisualize = [];
if (!noTitleChange) { if (!noTitleChange) {
elementsToVisualize.push(this.$el.querySelector('.title')); elementStack.push(this.$el.querySelector('.title'));
} }
if (!noDescriptionChange) { if (!noDescriptionChange) {
// only change to true when we need to bind TaskLists the html of description // only change to true when we need to bind TaskLists the html of description
this.descriptionChange = true; this.descriptionChange = true;
elementStack.push(this.$el.querySelector('.wiki'));
elementsToVisualize.push(this.$el.querySelector('.wiki'));
} }
elementsToVisualize.forEach((element) => { elementStack.forEach((element) => {
element.classList.remove('issue-realtime-trigger-pulse'); element.classList.remove('issue-realtime-trigger-pulse');
element.classList.add('issue-realtime-pre-pulse'); element.classList.add('issue-realtime-pre-pulse');
}); });
return elementStack;
},
animate(title, description, elementsToVisualize) {
this.timeoutId = setTimeout(() => { this.timeoutId = setTimeout(() => {
this.title = title; this.title = title;
document.querySelector('title').innerText = title;
this.description = description; this.description = description;
document.querySelector('title').innerText = title;
elementsToVisualize.forEach((element) => { elementsToVisualize.forEach((element) => {
element.classList.remove('issue-realtime-pre-pulse'); element.classList.remove('issue-realtime-pre-pulse');
...@@ -89,6 +80,29 @@ export default { ...@@ -89,6 +80,29 @@ export default {
clearTimeout(this.timeoutId); clearTimeout(this.timeoutId);
}, 0); }, 0);
}, },
triggerAnimation(body) {
// always reset to false before checking the change
this.descriptionChange = false;
const { title, description } = body;
this.descriptionText = body.description_text;
this.updateTaskHTML(body);
/**
* since opacity is changed, even if there is no diff for Vue to update
* we must check the title/description even on a 304 to ensure no visual change
*/
const noTitleChange = this.title === title;
const noDescriptionChange = this.description === description;
if (noTitleChange && noDescriptionChange) return;
const elementsToVisualize = this.elementsToVisualize(
noTitleChange,
noDescriptionChange,
);
this.animate(title, description, elementsToVisualize);
},
}, },
computed: { computed: {
descriptionClass() { descriptionClass() {
...@@ -118,7 +132,6 @@ export default { ...@@ -118,7 +132,6 @@ export default {
}); });
$(this.$refs['issue-content-container-gfm-entry']).renderGFM(); $(this.$refs['issue-content-container-gfm-entry']).renderGFM();
return tl; return tl;
} }
return null; return null;
......
...@@ -198,10 +198,12 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -198,10 +198,12 @@ class Projects::IssuesController < Projects::ApplicationController
def rendered_title def rendered_title
Gitlab::PollingInterval.set_header(response, interval: 3_000) Gitlab::PollingInterval.set_header(response, interval: 3_000)
render json: { render json: {
title: view_context.markdown_field(@issue, :title), title: view_context.markdown_field(@issue, :title),
description: view_context.markdown_field(@issue, :description), description: view_context.markdown_field(@issue, :description),
description_text: @issue.description, description_text: @issue.description,
task_status: @issue.task_status,
} }
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