Commit d990df74 authored by Mike Greiling's avatar Mike Greiling

refactor TaskList class to ES module syntax

parent 571de11e
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
import 'vendor/jquery.waitforimages'; import 'vendor/jquery.waitforimages';
import '~/lib/utils/text_utility'; import '~/lib/utils/text_utility';
import './flash'; import './flash';
import './task_list'; import TaskList from './task_list';
import CreateMergeRequestDropdown from './create_merge_request_dropdown'; import CreateMergeRequestDropdown from './create_merge_request_dropdown';
class Issue { class Issue {
constructor() { constructor() {
if ($('a.btn-close').length) { if ($('a.btn-close').length) {
this.taskList = new gl.TaskList({ this.taskList = new TaskList({
dataType: 'issue', dataType: 'issue',
fieldName: 'description', fieldName: 'description',
selector: '.detail-page-description', selector: '.detail-page-description',
......
<script> <script>
import animateMixin from '../mixins/animate'; import animateMixin from '../mixins/animate';
import TaskList from '../../task_list';
export default { export default {
mixins: [animateMixin], mixins: [animateMixin],
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
if (this.canUpdate) { if (this.canUpdate) {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new gl.TaskList({ new TaskList({
dataType: 'issue', dataType: 'issue',
fieldName: 'description', fieldName: 'description',
selector: '.detail-page-description', selector: '.detail-page-description',
......
...@@ -151,7 +151,6 @@ import './star'; ...@@ -151,7 +151,6 @@ import './star';
import './subscription'; import './subscription';
import './subscription_select'; import './subscription_select';
import './syntax_highlight'; import './syntax_highlight';
import './task_list';
import './user'; import './user';
// eslint-disable-next-line global-require, import/no-commonjs // eslint-disable-next-line global-require, import/no-commonjs
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* global MergeRequestTabs */ /* global MergeRequestTabs */
import 'vendor/jquery.waitforimages'; import 'vendor/jquery.waitforimages';
import './task_list'; import TaskList from './task_list';
import './merge_request_tabs'; import './merge_request_tabs';
(function() { (function() {
...@@ -25,7 +25,7 @@ import './merge_request_tabs'; ...@@ -25,7 +25,7 @@ import './merge_request_tabs';
this.initMRBtnListeners(); this.initMRBtnListeners();
this.initCommitMessageListeners(); this.initCommitMessageListeners();
if ($("a.btn-close").length) { if ($("a.btn-close").length) {
this.taskList = new gl.TaskList({ this.taskList = new TaskList({
dataType: 'merge_request', dataType: 'merge_request',
fieldName: 'description', fieldName: 'description',
selector: '.detail-page-description', selector: '.detail-page-description',
......
...@@ -21,7 +21,7 @@ import CommentTypeToggle from './comment_type_toggle'; ...@@ -21,7 +21,7 @@ import CommentTypeToggle from './comment_type_toggle';
import loadAwardsHandler from './awards_handler'; import loadAwardsHandler from './awards_handler';
import './autosave'; import './autosave';
import './dropzone_input'; import './dropzone_input';
import './task_list'; import TaskList from './task_list';
window.autosize = autosize; window.autosize = autosize;
window.Dropzone = Dropzone; window.Dropzone = Dropzone;
...@@ -71,7 +71,7 @@ export default class Notes { ...@@ -71,7 +71,7 @@ export default class Notes {
this.addBinding(); this.addBinding();
this.setPollingInterval(); this.setPollingInterval();
this.setupMainTargetNoteForm(); this.setupMainTargetNoteForm();
this.taskList = new gl.TaskList({ this.taskList = new TaskList({
dataType: 'note', dataType: 'note',
fieldName: 'note', fieldName: 'note',
selector: '.notes' selector: '.notes'
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import 'deckar01-task_list'; import 'deckar01-task_list';
class TaskList { export default class TaskList {
constructor(options = {}) { constructor(options = {}) {
this.selector = options.selector; this.selector = options.selector;
this.dataType = options.dataType; this.dataType = options.dataType;
...@@ -48,6 +48,3 @@ class TaskList { ...@@ -48,6 +48,3 @@ class TaskList {
}); });
} }
} }
window.gl = window.gl || {};
window.gl.TaskList = TaskList;
...@@ -44,32 +44,34 @@ describe('Description component', () => { ...@@ -44,32 +44,34 @@ describe('Description component', () => {
}); });
}); });
it('re-inits the TaskList when description changed', (done) => { // TODO: gl.TaskList no longer exists. rewrite these tests once we have a way to rewire ES modules
spyOn(gl, 'TaskList');
vm.descriptionHtml = 'changed'; // it('re-inits the TaskList when description changed', (done) => {
// spyOn(gl, 'TaskList');
setTimeout(() => { // vm.descriptionHtml = 'changed';
expect( //
gl.TaskList, // setTimeout(() => {
).toHaveBeenCalled(); // expect(
// gl.TaskList,
done(); // ).toHaveBeenCalled();
}); //
}); // done();
// });
it('does not re-init the TaskList when canUpdate is false', (done) => { // });
spyOn(gl, 'TaskList');
vm.canUpdate = false; // it('does not re-init the TaskList when canUpdate is false', (done) => {
vm.descriptionHtml = 'changed'; // spyOn(gl, 'TaskList');
// vm.canUpdate = false;
setTimeout(() => { // vm.descriptionHtml = 'changed';
expect( //
gl.TaskList, // setTimeout(() => {
).not.toHaveBeenCalled(); // expect(
// gl.TaskList,
done(); // ).not.toHaveBeenCalled();
}); //
}); // done();
// });
// });
describe('taskStatus', () => { describe('taskStatus', () => {
it('adds full taskStatus', (done) => { it('adds full taskStatus', (done) => {
......
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