2016-10-26 04:02:58 -04:00
|
|
|
/* eslint-disable */
|
2016-07-26 06:56:36 -04:00
|
|
|
((w) => {
|
|
|
|
w.CommentsStore = {
|
|
|
|
state: {},
|
|
|
|
get: function (discussionId, noteId) {
|
2016-07-29 06:19:56 -04:00
|
|
|
return this.state[discussionId].getNote(noteId);
|
2016-07-26 06:56:36 -04:00
|
|
|
},
|
2016-08-12 16:10:05 -04:00
|
|
|
createDiscussion: function (discussionId, canResolve) {
|
2016-07-29 06:19:56 -04:00
|
|
|
let discussion = this.state[discussionId];
|
2016-07-26 06:56:36 -04:00
|
|
|
if (!this.state[discussionId]) {
|
2016-07-29 06:19:56 -04:00
|
|
|
discussion = new DiscussionModel(discussionId);
|
|
|
|
Vue.set(this.state, discussionId, discussion);
|
2016-07-26 06:56:36 -04:00
|
|
|
}
|
|
|
|
|
2016-08-12 16:10:05 -04:00
|
|
|
if (canResolve !== undefined) {
|
|
|
|
discussion.canResolve = canResolve;
|
|
|
|
}
|
|
|
|
|
|
|
|
return discussion;
|
|
|
|
},
|
|
|
|
create: function (discussionId, noteId, canResolve, resolved, resolved_by) {
|
|
|
|
const discussion = this.createDiscussion(discussionId);
|
|
|
|
|
2016-08-04 04:52:17 -04:00
|
|
|
discussion.createNote(noteId, canResolve, resolved, resolved_by);
|
2016-07-26 06:56:36 -04:00
|
|
|
},
|
2016-08-01 05:06:31 -04:00
|
|
|
update: function (discussionId, noteId, resolved, resolved_by) {
|
2016-07-29 06:19:56 -04:00
|
|
|
const discussion = this.state[discussionId];
|
|
|
|
const note = discussion.getNote(noteId);
|
|
|
|
note.resolved = resolved;
|
2016-08-01 05:06:31 -04:00
|
|
|
note.resolved_by = resolved_by;
|
2016-07-26 06:56:36 -04:00
|
|
|
},
|
|
|
|
delete: function (discussionId, noteId) {
|
2016-07-29 06:19:56 -04:00
|
|
|
const discussion = this.state[discussionId];
|
|
|
|
discussion.deleteNote(noteId);
|
2016-07-26 06:56:36 -04:00
|
|
|
|
2016-08-01 05:06:31 -04:00
|
|
|
if (discussion.notesCount() === 0) {
|
2016-07-26 06:56:36 -04:00
|
|
|
Vue.delete(this.state, discussionId);
|
|
|
|
}
|
2016-08-04 06:02:04 -04:00
|
|
|
},
|
|
|
|
unresolvedDiscussionIds: function () {
|
|
|
|
let ids = [];
|
|
|
|
|
|
|
|
for (const discussionId in this.state) {
|
|
|
|
const discussion = this.state[discussionId];
|
|
|
|
|
|
|
|
if (!discussion.isResolved()) {
|
|
|
|
ids.push(discussion.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2016-07-26 08:44:51 -04:00
|
|
|
}
|
2016-07-26 06:56:36 -04:00
|
|
|
};
|
2016-07-28 10:07:47 -04:00
|
|
|
})(window);
|