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,31 +2,41 @@ import Vue from 'vue'; ...@@ -2,31 +2,41 @@ 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'),
const issuableTitleElement = issuableElement.querySelector('.title'); components: {
const issuableDescriptionElement = issuableElement.querySelector('.wiki'); issuableApp,
const issuableDescriptionTextarea = issuableElement.querySelector('.js-task-list-field'); },
const { data() {
canUpdate, const issuableElement = this.$options.el;
endpoint, const issuableTitleElement = issuableElement.querySelector('.title');
issuableRef, const issuableDescriptionElement = issuableElement.querySelector('.wiki');
} = issuableElement.dataset; const issuableDescriptionTextarea = issuableElement.querySelector('.js-task-list-field');
const {
canUpdate,
endpoint,
issuableRef,
} = issuableElement.dataset;
return new Vue({ return {
el: issuableElement, canUpdate: gl.utils.convertPermissionToBoolean(canUpdate),
components: { endpoint,
issuableApp, issuableRef,
}, initialTitle: issuableTitleElement.innerHTML,
render: createElement => createElement('issuable-app', { initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '',
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '',
};
},
render(createElement) {
return createElement('issuable-app', {
props: { props: {
canUpdate: gl.utils.convertPermissionToBoolean(canUpdate), canUpdate: this.canUpdate,
endpoint, endpoint: this.endpoint,
issuableRef, issuableRef: this.issuableRef,
initialTitle: issuableTitleElement.innerHTML, initialTitle: this.initialTitle,
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '', initialDescriptionHtml: this.initialDescriptionHtml,
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '', 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