1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-22 22:59:43 +02:00

Revision history will respect doc lifecycle stage

Protected documents cannot be rolled back!
This commit is contained in:
Harvey Kandola 2018-11-21 11:52:33 +00:00
parent c152d029f2
commit d499888cfd
2 changed files with 31 additions and 22 deletions

View file

@ -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);

View file

@ -1,5 +1,7 @@
<div class="mt-5">
{{#if hasRevisions}}
{{#unless hasRevisions}}
<p>No revisions made</p>
{{else}}
<div class="row">
<div class="col-12">
<div class="form-group">
@ -18,7 +20,7 @@
</div>
</div>
</div>
{{#if permissions.documentEdit}}
{{#if canRollback}}
<div class="row">
<div class="col-12">
<div class="form-group">
@ -26,13 +28,16 @@
</div>
</div>
</div>
{{/if}}
{{/unless}}
</div>
<div id="document-rollback-modal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">Restore Document Section</div>
<div class="modal-header">Restore Section</div>
<div class="modal-body">
<p>Are you sure you want to roll back to this revision?</p>
<p>Are you sure you want to restore this revision?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Cancel</button>
@ -41,8 +46,3 @@
</div>
</div>
</div>
{{/if}}
{{else}}
<p>No revisions made</p>
{{/if}}
</div>