gitlab-org--gitlab-foss/app/assets/javascripts/diff_notes/models/discussion.js.es6
Phil Hughes 9878356dbc Added JS spec tests for CommentsStore
Updated other tests
2016-07-29 15:03:58 +01:00

52 lines
987 B
JavaScript

class DiscussionModel {
constructor (discussionId) {
this.id = discussionId;
this.notes = {};
this.loading = false;
}
createNote (noteId, resolved, user) {
Vue.set(this.notes, noteId, new NoteModel(this.id, noteId, resolved, user));
}
deleteNote (noteId) {
Vue.delete(this.notes, noteId);
}
getNote (noteId) {
return this.notes[noteId];
}
isResolved () {
for (const noteId in this.notes) {
const note = this.notes[noteId];
if (!note.resolved) {
return false;
}
}
return true;
}
resolveAllNotes (user) {
for (const noteId in this.notes) {
const note = this.notes[noteId];
if (!note.resolved) {
note.resolved = true;
note.user = user;
}
}
}
unResolveAllNotes (user) {
for (const noteId in this.notes) {
const note = this.notes[noteId];
if (note.resolved) {
note.resolved = false;
note.user = null;
}
}
}
}