From d499888cfda6ba52727b687a36edba955cf6d89a Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Wed, 21 Nov 2018 11:52:33 +0000 Subject: [PATCH] Revision history will respect doc lifecycle stage Protected documents cannot be rolled back! --- gui/app/components/document/view-revision.js | 11 ++++- .../components/document/view-revision.hbs | 42 +++++++++---------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/gui/app/components/document/view-revision.js b/gui/app/components/document/view-revision.js index 4cb9873d..97e3a799 100644 --- a/gui/app/components/document/view-revision.js +++ b/gui/app/components/document/view-revision.js @@ -11,12 +11,13 @@ import { computed, set } from '@ember/object'; import { inject as service } from '@ember/service'; -import Component from '@ember/component'; import ModalMixin from '../../mixins/modal'; +import Component from '@ember/component'; export default Component.extend(ModalMixin, { documentService: service('document'), revision: null, + revisions: null, diff: '', hasRevisions: computed('revisions', function() { return this.get('revisions').length > 0; @@ -24,6 +25,14 @@ export default Component.extend(ModalMixin, { hasDiff: computed('diff', function() { return this.get('diff').length > 0; }), + canRollback: computed('permissions.documentEdit', 'document.protection', function() { + let constants = this.get('constants'); + + if (this.get('document.protection') === constants.ProtectionType.Lock) return false; + + return this.get('permissions.documentEdit') && + this.get('document.protection') === constants.ProtectionType.None; + }), init() { this._super(...arguments); diff --git a/gui/app/templates/components/document/view-revision.hbs b/gui/app/templates/components/document/view-revision.hbs index b921205c..efb484d9 100644 --- a/gui/app/templates/components/document/view-revision.hbs +++ b/gui/app/templates/components/document/view-revision.hbs @@ -1,5 +1,7 @@
- {{#if hasRevisions}} + {{#unless hasRevisions}} +

No revisions made

+ {{else}}
@@ -18,7 +20,7 @@
- {{#if permissions.documentEdit}} + {{#if canRollback}}
@@ -26,23 +28,21 @@
- - {{/if}} - {{else}} -

No revisions made

- {{/if}} -
\ No newline at end of file + {{/unless}} + + +