mirror of
https://github.com/documize/community.git
synced 2025-08-05 05:25:27 +02:00
revision history UI
This commit is contained in:
parent
5c8db2a873
commit
0d9400965d
10 changed files with 106 additions and 268 deletions
|
@ -12,7 +12,7 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
revision: {},
|
||||
revision: null,
|
||||
hasDiff: Ember.computed('diff', function () {
|
||||
return this.get('diff').length > 0;
|
||||
}),
|
||||
|
@ -20,38 +20,28 @@ export default Ember.Component.extend({
|
|||
didReceiveAttrs() {
|
||||
let revisions = this.get('revisions');
|
||||
|
||||
revisions.forEach((revision) => {
|
||||
Ember.set(revision, 'deleted', revision.revisions === 0);
|
||||
revisions.forEach((r) => {
|
||||
Ember.set(r, 'deleted', r.revisions === 0);
|
||||
Ember.set(r, 'label', `${r.created} - ${r.firstname} ${r.lastname} - ${r.title}`);
|
||||
});
|
||||
|
||||
if (revisions.length > 0 && is.null(this.get('revision'))) {
|
||||
this.send('onSelectRevision', revisions[0]);
|
||||
}
|
||||
|
||||
this.set('revisions', revisions);
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.eventBus.subscribe('resized', this, 'sizeSidebar');
|
||||
this.sizeSidebar();
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this.eventBus.unsubscribe('resized');
|
||||
},
|
||||
|
||||
sizeSidebar() {
|
||||
let size = $(window).height() - 200;
|
||||
this.$('.document-history > .sidebar').css('height', size + "px");
|
||||
},
|
||||
|
||||
actions: {
|
||||
getDiff(revision) {
|
||||
onSelectRevision(revision) {
|
||||
this.set('revision', revision);
|
||||
|
||||
if (!revision.deleted) {
|
||||
this.attrs.onFetchDiff(revision.pageId, revision.id);
|
||||
}
|
||||
},
|
||||
|
||||
rollback() {
|
||||
onRollback() {
|
||||
let revision = this.get('revision');
|
||||
this.attrs.onRollback(revision.pageId, revision.id);
|
||||
}
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
documentService: Ember.inject.service('document'),
|
||||
|
||||
revisions: [],
|
||||
diffReport: "",
|
||||
busy: false,
|
||||
currentRevisionId: "",
|
||||
|
||||
didReceiveAttrs() {
|
||||
if (is.undefined(this.get('model'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
let self = this;
|
||||
|
||||
this.get('documentService').getPageRevisions(this.get('model.documentId'), this.get('model.pageId')).then(function(response) {
|
||||
if (is.array(response)) {
|
||||
self.set('revisions', response);
|
||||
if (response.length > 0) {
|
||||
self.send('produceReport', response[0].id);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
didRender() {
|
||||
let self = this;
|
||||
Ember.run.schedule('afterRender', function() {
|
||||
Mousetrap.bind('esc', function() {
|
||||
self.send('cancelAction');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
produceReport(revisionId) {
|
||||
this.set('busy', true);
|
||||
this.set('diffReport', "");
|
||||
this.set('currentRevisionId', revisionId);
|
||||
|
||||
// visually mark active revision
|
||||
let revisions = this.get('revisions');
|
||||
|
||||
revisions.forEach(function(revision) {
|
||||
Ember.set(revision, 'selected', false);
|
||||
});
|
||||
|
||||
let revision = _.findWhere(revisions, {
|
||||
id: revisionId
|
||||
});
|
||||
Ember.set(revision, 'selected', true);
|
||||
|
||||
let self = this;
|
||||
|
||||
this.get('documentService').getPageRevisionDiff(this.get('model.documentId'),
|
||||
this.get('model.pageId'), revisionId).then(function(response) {
|
||||
self.set('busy', false);
|
||||
self.set('diffReport', Ember.String.htmlSafe(response));
|
||||
});
|
||||
},
|
||||
|
||||
cancelAction() {
|
||||
this.attrs.editorClose();
|
||||
},
|
||||
|
||||
primaryAction() {
|
||||
if (this.session.isEditor) {
|
||||
this.attrs.editorAction(this.get('model.pageId'), this.get('currentRevisionId'));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
|
@ -51,18 +51,6 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
|||
this.set('pinState.newName', this.get('document.name').substring(0,3).toUpperCase());
|
||||
},
|
||||
|
||||
didRender() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onChangeTab(tab) {
|
||||
this.set('tab', tab);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue