Commit 0c55c889 authored by Phil Hughes's avatar Phil Hughes

Remove some weird code to add/remove the task status

Moved the data into the data method
Renamed edited ago class name
parent 1ed0673c
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
return { return {
preAnimation: false, preAnimation: false,
pulseAnimation: false, pulseAnimation: false,
timeAgoEl: $('.issue_edited_ago'), timeAgoEl: $('.js-issue-edited-ago'),
}; };
}, },
watch: { watch: {
...@@ -49,22 +49,15 @@ ...@@ -49,22 +49,15 @@
taskStatus() { taskStatus() {
const taskRegexMatches = this.taskStatus.match(/(\d+) of (\d+)/); const taskRegexMatches = this.taskStatus.match(/(\d+) of (\d+)/);
const $issuableHeader = $('.issuable-meta'); const $issuableHeader = $('.issuable-meta');
let $tasks = $('#task_status', $issuableHeader); const $tasks = $('#task_status', $issuableHeader);
let $tasksShort = $('#task_status_short', $issuableHeader); const $tasksShort = $('#task_status_short', $issuableHeader);
if (this.taskStatus.indexOf('0 of 0') >= 0 || this.taskStatus.trim() === '') {
$tasks.remove();
$tasksShort.remove();
} else if (!$tasks.length && !$tasksShort.length) {
$tasks = $issuableHeader.append('<span id="task_status" class="hidden-xs hidden-sm"></span>')
.find('#task_status');
$tasksShort = $issuableHeader.append('<span id="task_status_short" class="hidden-md hidden-lg"></span>')
.find('#task_status_short');
}
if (taskRegexMatches) { if (taskRegexMatches) {
$tasks.text(this.taskStatus); $tasks.text(this.taskStatus);
$tasksShort.text(`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ? 's' : ''}`); $tasksShort.text(`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ? 's' : ''}`);
} else {
$tasks.text('');
$tasksShort.text('');
} }
}, },
}, },
......
...@@ -2,8 +2,13 @@ import Vue from 'vue'; ...@@ -2,8 +2,13 @@ import Vue from 'vue';
import issuableApp from './components/app.vue'; import issuableApp from './components/app.vue';
import '../vue_shared/vue_resource_interceptor'; import '../vue_shared/vue_resource_interceptor';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => new Vue({
const issuableElement = document.getElementById('js-issuable-app'); el: document.getElementById('js-issuable-app'),
components: {
issuableApp,
},
data() {
const issuableElement = this.$options.el;
const issuableTitleElement = issuableElement.querySelector('.title'); const issuableTitleElement = issuableElement.querySelector('.title');
const issuableDescriptionElement = issuableElement.querySelector('.wiki'); const issuableDescriptionElement = issuableElement.querySelector('.wiki');
const issuableDescriptionTextarea = issuableElement.querySelector('.js-task-list-field'); const issuableDescriptionTextarea = issuableElement.querySelector('.js-task-list-field');
...@@ -13,20 +18,25 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -13,20 +18,25 @@ document.addEventListener('DOMContentLoaded', () => {
issuableRef, issuableRef,
} = issuableElement.dataset; } = issuableElement.dataset;
return new Vue({ return {
el: issuableElement,
components: {
issuableApp,
},
render: createElement => createElement('issuable-app', {
props: {
canUpdate: gl.utils.convertPermissionToBoolean(canUpdate), canUpdate: gl.utils.convertPermissionToBoolean(canUpdate),
endpoint, endpoint,
issuableRef, issuableRef,
initialTitle: issuableTitleElement.innerHTML, initialTitle: issuableTitleElement.innerHTML,
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '', initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '',
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '', initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '',
};
},
render(createElement) {
return createElement('issuable-app', {
props: {
canUpdate: this.canUpdate,
endpoint: this.endpoint,
issuableRef: this.issuableRef,
initialTitle: this.initialTitle,
initialDescriptionHtml: this.initialDescriptionHtml,
initialDescriptionText: this.initialDescriptionText,
}, },
}),
}); });
}); },
}));
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
} }
} }
.issue_edited_ago, .issue-edited-ago,
.note_edited_ago { .note_edited_ago {
display: none; display: none;
} }
......
...@@ -136,11 +136,9 @@ module IssuablesHelper ...@@ -136,11 +136,9 @@ module IssuablesHelper
author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "hidden-sm hidden-md hidden-lg") author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "hidden-sm hidden-md hidden-lg")
end end
if issuable.tasks?
output << "&ensp;".html_safe output << "&ensp;".html_safe
output << content_tag(:span, issuable.task_status, id: "task_status", class: "hidden-xs hidden-sm") output << content_tag(:span, issuable.task_status, id: "task_status", class: "hidden-xs hidden-sm")
output << content_tag(:span, issuable.task_status_short, id: "task_status_short", class: "hidden-md hidden-lg") output << content_tag(:span, issuable.task_status_short, id: "task_status_short", class: "hidden-md hidden-lg")
end
output output
end end
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
.wiki= markdown_field(@issue, :description) .wiki= markdown_field(@issue, :description)
%textarea.hidden.js-task-list-field= @issue.description %textarea.hidden.js-task-list-field= @issue.description
= edited_time_ago_with_tooltip(@issue, placement: 'bottom', html_class: 'issue_edited_ago') = edited_time_ago_with_tooltip(@issue, placement: 'bottom', html_class: 'issue-edited-ago js-issue-edited-ago')
#merge-requests{ data: { url: referenced_merge_requests_namespace_project_issue_url(@project.namespace, @project, @issue) } } #merge-requests{ data: { url: referenced_merge_requests_namespace_project_issue_url(@project.namespace, @project, @issue) } }
// This element is filled in using JavaScript. // This element is filled in using JavaScript.
......
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