resolve_all_btn.js.es6 1.1 KB
Newer Older
P
Phil Hughes 已提交
1
((w) => {
2 3 4 5
  w.ResolveAllBtn = Vue.extend({
    mixins: [
      ButtonMixins
    ],
P
Phil Hughes 已提交
6 7
    props: {
      discussionId: String,
8 9 10
      mergeRequestId: Number,
      namespacePath: String,
      projectPath: String,
P
Phil Hughes 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    },
    data: function() {
      return {
        comments: CommentsStore.state,
        loadingObject: CommentsStore.loading,
      };
    },
    computed: {
      allResolved: function () {
        let isResolved = true;
        for (const noteId in this.comments[this.discussionId]) {
          const resolved = this.comments[this.discussionId][noteId];

          if (!resolved) {
            isResolved = false;
          }
        }
        return isResolved;
      },
      buttonText: function () {
        if (this.allResolved) {
          return "Unresolve discussion";
        } else {
          return "Resolve discussion";
        }
      },
      loading: function () {
        return this.loadingObject[this.discussionId];
      }
    },
    methods: {
      resolve: function () {
43
        ResolveService.toggleResolveForDiscussion(this.namespace, this.mergeRequestId, this.discussionId);
P
Phil Hughes 已提交
44 45 46 47
      }
    }
  });
}(window));