diff --git a/app/app/components/document/document-history.js b/app/app/components/document/document-history.js index 73cf62bb..18d6f5d7 100644 --- a/app/app/components/document/document-history.js +++ b/app/app/components/document/document-history.js @@ -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); } diff --git a/app/app/components/document/editor-history.js b/app/app/components/document/editor-history.js deleted file mode 100644 index 815e656a..00000000 --- a/app/app/components/document/editor-history.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2016 Documize Inc. . 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 . -// -// 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')); - } - } - } -}); \ No newline at end of file diff --git a/app/app/components/document/sidebar-zone.js b/app/app/components/document/sidebar-zone.js index 1ad0b9f9..cc3ef139 100644 --- a/app/app/components/document/sidebar-zone.js +++ b/app/app/components/document/sidebar-zone.js @@ -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); diff --git a/app/app/pods/document/history/template.hbs b/app/app/pods/document/history/template.hbs index ac397cf6..69e3b421 100644 --- a/app/app/pods/document/history/template.hbs +++ b/app/app/pods/document/history/template.hbs @@ -1,2 +1,21 @@ -{{document/document-history document=model.document folder=model.folder pages=model.pages revisions=model.revisions diff=model.diff - onFetchDiff=(action 'onFetchDiff') onRollback=(action 'onRollback')}} +
+
+
+
+
+
+ {{#link-to 'document.index' model.folder.id model.folder.slug model.document.id model.document.slug}} + arrow_back {{model.document.name}} + {{/link-to}} +
+ {{document/document-heading document=model.document isEditor=false}} + {{document/document-history document=model.document folder=model.folder pages=model.pages + revisions=model.revisions diff=model.diff onFetchDiff=(action 'onFetchDiff') onRollback=(action 'onRollback')}} +
+
+
+
+
+ + + diff --git a/app/app/router.js b/app/app/router.js index 220cf51f..26cc39f2 100644 --- a/app/app/router.js +++ b/app/app/router.js @@ -38,6 +38,9 @@ export default Router.map(function () { this.route('block', { path: 'block/:block_id' }); + this.route('history', { + path: 'history' + }); }); this.route('customize', { diff --git a/app/app/styles/view/document/history.scss b/app/app/styles/view/document/history.scss index 9a954516..4c5acc19 100644 --- a/app/app/styles/view/document/history.scss +++ b/app/app/styles/view/document/history.scss @@ -1,72 +1,26 @@ -.document-history { - position: relative; +.zone-document-history { + margin-left: 60px; + padding: 20px 60px; + z-index: 777; + position: relative; - > .sidebar { + .diff-zone { + @extend .transition-all; + @include border-radius(2px); + @include ease-in(); position: relative; - overflow-y: scroll; + padding: 25px 50px; + box-shadow: 0 0 0 0.75pt $color-stroke,0 0 3pt 0.75pt $color-stroke; + background-color: $color-white; - > .heading { - font-size: 1.2rem; - font-family: $font-light; - color: $color-off-black; + > .canvas { + padding: 0; } - > .line { - width: 2px; - background-color: $color-stroke; - height: 100%; - position: absolute; - left: 17px; - z-index: -1; - } - - > .items { - list-style-type: none; - margin: 0; - padding: 20px 0 10px; - white-space: nowrap; - - > .item { - margin: 0; - padding: 10px 0; - width: 100%; - color: $color-off-black; - @include ease-in(); - cursor: pointer; - - > .avatar-box { - display: inline-block; - } - - > .date { - display: inline-block; - font-size: 1rem; - font-family: $font-light; - margin-left: 25px; - } - - > .detail { - display: block; - font-size: 1.2rem; - font-family: $font-semibold; - margin-left: 65px; - overflow: hidden; - text-overflow: ellipsis; - } - - &:hover { - color: $color-link; - } - } - - > .deleted { - color: $color-red; - cursor: not-allowed; - - &:hover { - color: $color-red; - } - } + .revision-picker { + width: 300px; + float: left; + margin-bottom: 30px; } } } diff --git a/app/app/templates/components/document/document-history.hbs b/app/app/templates/components/document/document-history.hbs index fce0ade8..8a69132a 100644 --- a/app/app/templates/components/document/document-history.hbs +++ b/app/app/templates/components/document/document-history.hbs @@ -1,40 +1,14 @@ -
-
- -
- {{#if hasDiff}} -
- Restore -
- {{#dropdown-dialog target="restore-history-button" position="bottom right" button="Restore" color="flat-green" onAction=(action 'rollback')}} -

Are you sure you want to roll back to this version?

- {{/dropdown-dialog}} -
-
- {{{diff}}} -
- {{/if}} +
+ {{ui-select tagName="div" class="revision-picker" content=revisions action=(action 'onSelectRevision') optionValuePath="id" optionLabelPath="label"}} + {{#if hasDiff}} +
Restore
+ {{#dropdown-dialog target="restore-history-button" position="bottom right" button="Restore" color="flat-green" onAction=(action 'onRollback')}} +

Are you sure you want to roll back to this version?

+ {{/dropdown-dialog}} +
+
+ {{{diff}}}
- -
-
- -
- -
+ {{/if}} +
diff --git a/app/app/templates/components/document/editor-history.hbs b/app/app/templates/components/document/editor-history.hbs deleted file mode 100644 index 650aa76c..00000000 --- a/app/app/templates/components/document/editor-history.hbs +++ /dev/null @@ -1,43 +0,0 @@ -
-
-

Revision History

-
-
- - -
-
-
- -
-
-
    - {{#each revisions key="id" as |revision index|}} -
  • -
    {{revision.initials}}
    -
    - {{revision.firstname}} {{revision.lastname}} -
    -
    - {{time-ago revision.created}} -
    -
  • - {{/each}} -
-
-
-
-
Added
-
Removed
-
Formatted
-
- {{#if busy}} -
- -
Preparing
-
- {{/if}} - {{diffReport}} -
-
-
diff --git a/app/app/templates/components/document/sidebar-zone.hbs b/app/app/templates/components/document/sidebar-zone.hbs index dc2ef48f..b572c35b 100644 --- a/app/app/templates/components/document/sidebar-zone.hbs +++ b/app/app/templates/components/document/sidebar-zone.hbs @@ -15,6 +15,18 @@
timeline
+
+
+ chat_bubble +
+
+
+ person +
+
+
+ share +
{{/if}}
@@ -38,6 +50,18 @@ {{#if (is-equal tab 'activity')}} {{document/sidebar-view-activity document=document pages=pages isEditor=isEditor}} {{/if}} + + {{#if (is-equal tab 'feedback')}} + {{enterprise/sidebar-view-feedback document=document isEditor=isEditor}} + {{/if}} + + {{#if (is-equal tab 'actions')}} + {{enterprise/sidebar-view-actions document=document folder=folder isEditor=isEditor}} + {{/if}} + + {{#if (is-equal tab 'share')}} + {{enterprise/sidebar-view-share document=document isEditor=isEditor}} + {{/if}}
{{#dropdown-menu target="sidebar-zone-more-button" position="bottom right" open="click" onOpenCallback=(action 'onMenuOpen') onCloseCallback=(action 'onMenuOpen')}} @@ -48,13 +72,20 @@ {{else}}
  • Pin
  • {{/if}} +
  • + {{#link-to 'document.history'}}History{{/link-to}} +
  • +
  • + {{/if}} + + {{#if isEditor}} +
  • Template
  • +
  • {{/if}} {{#if isEditor}} -
  • -
  • Template
  • Delete
  • {{/if}} diff --git a/core/api/endpoint/page_endpoint.go b/core/api/endpoint/page_endpoint.go index 5f35d89a..1c9a19bf 100644 --- a/core/api/endpoint/page_endpoint.go +++ b/core/api/endpoint/page_endpoint.go @@ -790,6 +790,10 @@ func GetDocumentRevisions(w http.ResponseWriter, r *http.Request) { revisions, _ := p.GetDocumentRevisions(documentID) + if len(revisions) == 0 { + revisions = []entity.Revision{} + } + payload, err := json.Marshal(revisions) if err != nil { @@ -832,6 +836,10 @@ func GetDocumentPageRevisions(w http.ResponseWriter, r *http.Request) { revisions, _ := p.GetPageRevisions(pageID) + if len(revisions) == 0 { + revisions = []entity.Revision{} + } + payload, err := json.Marshal(revisions) if err != nil {