BigW Consortium Gitlab

Commit 7a37ada1 by Regis

use refs when possible - style changes - better initial title and description data types

parent 4fd87421
...@@ -6,8 +6,14 @@ import tasks from './actions/tasks'; ...@@ -6,8 +6,14 @@ import tasks from './actions/tasks';
export default { export default {
props: { props: {
endpoint: { required: true, type: String }, endpoint: {
candescription: { required: true, type: String }, required: true,
type: String,
},
candescription: {
required: true,
type: String,
},
}, },
data() { data() {
const resource = new Service(this.$http, this.endpoint); const resource = new Service(this.$http, this.endpoint);
...@@ -32,17 +38,18 @@ export default { ...@@ -32,17 +38,18 @@ export default {
poll, poll,
apiData: {}, apiData: {},
timeoutId: null, timeoutId: null,
title: '<span></span>', title: null,
titleText: '', titleText: '',
description: '<span></span>', description: null,
descriptionText: '', descriptionText: '',
descriptionChange: false, descriptionChange: false,
tasks: '0 of 0', tasks: '0 of 0',
titleEl: document.querySelector('title'),
}; };
}, },
methods: { methods: {
renderResponse(res) { renderResponse(res) {
this.apiData = JSON.parse(res.body); this.apiData = res.json();
this.triggerAnimation(); this.triggerAnimation();
}, },
updateTaskHTML() { updateTaskHTML() {
...@@ -53,7 +60,7 @@ export default { ...@@ -53,7 +60,7 @@ export default {
if (!noTitleChange) { if (!noTitleChange) {
this.titleText = this.apiData.title_text; this.titleText = this.apiData.title_text;
elementStack.push(this.$el.querySelector('.title')); elementStack.push(this.$refs['issue-title']);
} }
if (!noDescriptionChange) { if (!noDescriptionChange) {
...@@ -61,21 +68,22 @@ export default { ...@@ -61,21 +68,22 @@ export default {
this.descriptionChange = true; this.descriptionChange = true;
this.updateTaskHTML(); this.updateTaskHTML();
this.tasks = this.apiData.task_status; this.tasks = this.apiData.task_status;
elementStack.push(this.$el.querySelector('.wiki')); elementStack.push(this.$refs['issue-content-container-gfm-entry']);
} }
elementStack.forEach((element) => { elementStack.forEach((element) => {
element.classList.remove('issue-realtime-trigger-pulse'); if (element) {
element.classList.add('issue-realtime-pre-pulse'); element.classList.remove('issue-realtime-trigger-pulse');
element.classList.add('issue-realtime-pre-pulse');
}
}); });
return elementStack; return elementStack;
}, },
setTabTitle() { setTabTitle() {
const currentTabTitle = document.querySelector('title'); const currentTabTitleScope = this.titleEl.innerText.split('·');
const currentTabTitleScope = currentTabTitle.innerText.split('·');
currentTabTitleScope[0] = `${this.titleText} (#${this.apiData.issue_number}) `; currentTabTitleScope[0] = `${this.titleText} (#${this.apiData.issue_number}) `;
currentTabTitle.innerText = currentTabTitleScope.join('·'); this.titleEl.innerText = currentTabTitleScope.join('·');
}, },
animate(title, description, elementsToVisualize) { animate(title, description, elementsToVisualize) {
this.timeoutId = setTimeout(() => { this.timeoutId = setTimeout(() => {
...@@ -84,11 +92,11 @@ export default { ...@@ -84,11 +92,11 @@ export default {
this.setTabTitle(); this.setTabTitle();
elementsToVisualize.forEach((element) => { elementsToVisualize.forEach((element) => {
element.classList.remove('issue-realtime-pre-pulse'); if (element) {
element.classList.add('issue-realtime-trigger-pulse'); element.classList.remove('issue-realtime-pre-pulse');
element.classList.add('issue-realtime-trigger-pulse');
}
}); });
clearTimeout(this.timeoutId);
}, 0); }, 0);
}, },
triggerAnimation() { triggerAnimation() {
...@@ -163,7 +171,12 @@ export default { ...@@ -163,7 +171,12 @@ export default {
<template> <template>
<div> <div>
<h2 class="title issue-realtime-trigger-pulse" v-html="title"></h2> <h2
class="title issue-realtime-trigger-pulse"
ref="issue-title"
v-html="title"
>
</h2>
<div <div
:class="descriptionClass" :class="descriptionClass"
v-if="description" v-if="description"
...@@ -174,7 +187,10 @@ export default { ...@@ -174,7 +187,10 @@ export default {
ref="issue-content-container-gfm-entry" ref="issue-content-container-gfm-entry"
> >
</div> </div>
<textarea class="hidden js-task-list-field" v-if="descriptionText">{{descriptionText}}</textarea> <textarea
class="hidden js-task-list-field"
v-if="descriptionText"
>{{descriptionText}}</textarea>
</div> </div>
</div> </div>
</template> </template>
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