From 9f7585e2a5b9f4bf52e39da2e78d77dc79039aa9 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Thu, 9 Mar 2017 12:51:21 +0000 Subject: [PATCH] fixes --- app/app/components/document/document-view.js | 25 ++++------ ...x-entry.js => sidebar-view-index-entry.js} | 0 .../components/document/sidebar-view-index.js | 24 +++++----- .../section/papertrail/type-editor.js | 1 - app/app/pods/document/history/controller.js | 10 ++-- app/app/pods/document/index/controller.js | 4 +- app/app/pods/document/index/route.js | 17 ++----- app/app/pods/document/section/controller.js | 5 +- app/app/services/pinned.js | 34 ++++++++++---- app/app/styles/section/table.scss | 2 +- app/app/styles/view/document/history.scss | 11 +++-- .../components/document/document-history.hbs | 15 +++--- ...entry.hbs => sidebar-view-index-entry.hbs} | 0 .../document/sidebar-view-index.hbs | 2 +- .../components/document/sidebar-zone.hbs | 46 +++++-------------- app/ember-cli-build.js | 1 + app/vendor/documize.js | 31 +++++++++++++ core/api/endpoint/page_endpoint.go | 1 + 18 files changed, 126 insertions(+), 103 deletions(-) rename app/app/components/document/{index-entry.js => sidebar-view-index-entry.js} (100%) rename app/app/templates/components/document/{index-entry.hbs => sidebar-view-index-entry.hbs} (100%) create mode 100644 app/vendor/documize.js diff --git a/app/app/components/document/document-view.js b/app/app/components/document/document-view.js index 0e99f79a..e3fbdbef 100644 --- a/app/app/components/document/document-view.js +++ b/app/app/components/document/document-view.js @@ -37,13 +37,13 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { didRender() { this._super(...arguments); - - this.contentLinkHandler(); - let self = this; - $(".tooltipped").each(function(i, el) { - self.addTooltip(el); - }); + let jumpTo = this.get('pageId'); + if (is.not.empty(jumpTo) && is.not.undefined(jumpTo) && !$("#page-" + jumpTo).inView()) { + $("#page-" + jumpTo).velocity("scroll", { duration: 250, offset: -100 }); + } + + this.contentLinkHandler(); }, didInsertElement() { @@ -57,15 +57,10 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { $(this).find('.start-button').velocity("transition.slideUpOut", {duration: 300}); } }); - let jumpTo = this.get('pageId'); - if (is.not.empty(jumpTo)) { - let self = this; - $("#page-" + jumpTo).velocity("scroll", { duration: 250, offset: -100, complete: - function() { - self.set('pageId', ''); - } - }); - } + let self = this; + $(".tooltipped").each(function(i, el) { + self.addTooltip(el); + }); }, willDestroyElement() { diff --git a/app/app/components/document/index-entry.js b/app/app/components/document/sidebar-view-index-entry.js similarity index 100% rename from app/app/components/document/index-entry.js rename to app/app/components/document/sidebar-view-index-entry.js diff --git a/app/app/components/document/sidebar-view-index.js b/app/app/components/document/sidebar-view-index.js index 0f3548fd..f5f79700 100644 --- a/app/app/components/document/sidebar-view-index.js +++ b/app/app/components/document/sidebar-view-index.js @@ -18,7 +18,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { document: {}, folder: {}, pages: [], - page: "", + currentPageId: "", state: { actionablePage: false, upDisabled: true, @@ -35,8 +35,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.set('showToc', is.not.undefined(this.get('pages')) && this.get('pages').get('length') > 0); - if (is.not.null(this.get('page'))) { - this.send('onEntryClick', this.get('page')); + if (is.not.null(this.get('currentPageId'))) { + this.send('onEntryClick', this.get('currentPageId')); } }, @@ -71,7 +71,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { // Controls what user can do with the toc (left sidebar). // Identifies the target pages. setState(pageId) { - this.set('page', pageId); + this.set('currentPageId', pageId); let toc = this.get('pages'); let page = _.findWhere(toc, { id: pageId }); @@ -94,13 +94,13 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { let state = this.get('state'); let pages = this.get('pages'); - let page = _.findWhere(pages, { id: this.get('page') }); + let page = _.findWhere(pages, { id: this.get('currentPageId') }); let pendingChanges = tocUtil.moveUp(state, pages, page); if (pendingChanges.length > 0) { this.attrs.onPageSequenceChange(pendingChanges); - this.send('onEntryClick', this.get('page')); + this.send('onEntryClick', this.get('currentPageId')); this.audit.record("moved-page-up"); this.showNotification("Moved up"); } @@ -114,13 +114,13 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { let state = this.get('state'); var pages = this.get('pages'); - var page = _.findWhere(pages, { id: this.get('page') }); + var page = _.findWhere(pages, { id: this.get('currentPageId') }); let pendingChanges = tocUtil.moveDown(state, pages, page); if (pendingChanges.length > 0) { this.attrs.onPageSequenceChange(pendingChanges); - this.send('onEntryClick', this.get('page')); + this.send('onEntryClick', this.get('currentPageId')); this.audit.record("moved-page-down"); this.showNotification("Moved down"); } @@ -134,7 +134,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { let state = this.get('state'); var pages = this.get('pages'); - var page = _.findWhere(pages, { id: this.get('page') }); + var page = _.findWhere(pages, { id: this.get('currentPageId') }); let pendingChanges = tocUtil.indent(state, pages, page); if (pendingChanges.length > 0) { @@ -142,7 +142,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.showNotification("Indent"); this.audit.record("changed-page-sequence"); - this.send('onEntryClick', this.get('page')); + this.send('onEntryClick', this.get('currentPageId')); } }, @@ -154,7 +154,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { let state = this.get('state'); var pages = this.get('pages'); - var page = _.findWhere(pages, { id: this.get('page') }); + var page = _.findWhere(pages, { id: this.get('currentPageId') }); let pendingChanges = tocUtil.outdent(state, pages, page); if (pendingChanges.length > 0) { @@ -162,7 +162,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.showNotification("Outdent"); this.audit.record("changed-page-sequence"); - this.send('onEntryClick', this.get('page')); + this.send('onEntryClick', this.get('currentPageId')); } }, diff --git a/app/app/components/section/papertrail/type-editor.js b/app/app/components/section/papertrail/type-editor.js index 127ced77..234c1dc2 100644 --- a/app/app/components/section/papertrail/type-editor.js +++ b/app/app/components/section/papertrail/type-editor.js @@ -74,7 +74,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, self.set('authenticated', true); self.set('items', response); self.set('config.APIToken', '********'); // reset the api token once it has been sent to the host - console.log("auth token OK"); self.get('sectionService').fetch(page, "options", config) .then(function (response) { diff --git a/app/app/pods/document/history/controller.js b/app/app/pods/document/history/controller.js index c7cd7d3b..d8ad5e7f 100644 --- a/app/app/pods/document/history/controller.js +++ b/app/app/pods/document/history/controller.js @@ -17,11 +17,11 @@ export default Ember.Controller.extend(NotifierMixin, { this.audit.record("restored-page"); this.get('documentService').rollbackPage(this.get('model.document.id'), pageId, revisionId).then(() => { - this.transitionToRoute('document', { - queryParams: { - page: pageId - } - }); + this.transitionToRoute('document.index', + this.get('model.folder.id'), + this.get('model.folder.slug'), + this.get('model.document.id'), + this.get('model.document.slug')); }); } } diff --git a/app/app/pods/document/index/controller.js b/app/app/pods/document/index/controller.js index c710817e..39f7ae3a 100644 --- a/app/app/pods/document/index/controller.js +++ b/app/app/pods/document/index/controller.js @@ -19,6 +19,9 @@ export default Ember.Controller.extend(NotifierMixin, { folder: {}, pages: [], toggled: false, + queryParams: ['pageId', 'tab'], + pageId: '', + tab: 'index', actions: { toggleSidebar() { @@ -212,7 +215,6 @@ export default Ember.Controller.extend(NotifierMixin, { }); }, - // tbd onGotoPage(id) { this.set('pageId', id); } diff --git a/app/app/pods/document/index/route.js b/app/app/pods/document/index/route.js index 55415078..9051f78f 100644 --- a/app/app/pods/document/index/route.js +++ b/app/app/pods/document/index/route.js @@ -17,18 +17,10 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { linkService: Ember.inject.service('link'), folderService: Ember.inject.service('folder'), userService: Ember.inject.service('user'), - queryParams: { - pageId: { - refreshModel: true - }, - tab: { - refreshModel: false - } - }, beforeModel(transition) { this.set('pageId', is.not.undefined(transition.queryParams.pageId) ? transition.queryParams.pageId : ''); - this.set('tab', is.not.undefined(transition.queryParams.tab) ? transition.queryParams.tab : ''); + this.set('tab', is.not.undefined(transition.queryParams.tab) ? transition.queryParams.tab : 'index'); }, model() { @@ -40,11 +32,12 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { folders: this.modelFor('document').folders, folder: this.modelFor('document').folder, document: this.modelFor('document').document, - pageId: this.get('pageId'), - isEditor: this.get('folderService').get('canEditCurrentFolder'), pages: this.get('documentService').getPages(this.modelFor('document').document.get('id')), links: this.modelFor('document').links, - sections: this.modelFor('document').sections + sections: this.modelFor('document').sections, + pageId: this.get('pageId'), + tab: this.get('tab'), + isEditor: this.get('folderService').get('canEditCurrentFolder') }); } }); diff --git a/app/app/pods/document/section/controller.js b/app/app/pods/document/section/controller.js index 974032bc..bf3f1b13 100644 --- a/app/app/pods/document/section/controller.js +++ b/app/app/pods/document/section/controller.js @@ -21,11 +21,12 @@ export default Ember.Controller.extend(NotifierMixin, { this.get('model.folder.id'), this.get('model.folder.slug'), this.get('model.document.id'), - this.get('model.document.slug')); + this.get('model.document.slug'), + { queryParams: { pageId: this.get('model.page.id') }}); }, onAction(page, meta) { - this.showNotification("Saving"); + this.showNotification("Saved"); let model = { page: page.toJSON({ includeId: true }), diff --git a/app/app/services/pinned.js b/app/app/services/pinned.js index 725c9d7c..975eb1ae 100644 --- a/app/app/services/pinned.js +++ b/app/app/services/pinned.js @@ -21,6 +21,7 @@ export default Ember.Service.extend({ appMeta: service(), store: service(), pins: [], + initialized: false, getUserPins() { let userId = this.get('session.user.id'); @@ -41,6 +42,7 @@ export default Ember.Service.extend({ }); this.set('pins', pins); + this.set('initialized', true); return pins; }); @@ -102,16 +104,32 @@ export default Ember.Service.extend({ isDocumentPinned(documentId) { let userId = this.get('session.user.id'); - let pins = this.get('pins'); - let pinId = ''; - pins.forEach((pin) => { - if (pin.get('userId') === userId && pin.get('documentId') === documentId) { - pinId = pin.get('id'); - } - }); + if (this.get('initialized') === false) { + this.getUserPins().then(() => { + let pins = this.get('pins'); + let pinId = ''; - return pinId; + pins.forEach((pin) => { + if (pin.get('userId') === userId && pin.get('documentId') === documentId) { + pinId = pin.get('id'); + } + }); + + return pinId; + }); + } else { + let pins = this.get('pins'); + let pinId = ''; + + pins.forEach((pin) => { + if (pin.get('userId') === userId && pin.get('documentId') === documentId) { + pinId = pin.get('id'); + } + }); + + return pinId; + } }, isSpacePinned(spaceId) { diff --git a/app/app/styles/section/table.scss b/app/app/styles/section/table.scss index 00b68d88..71fdc266 100644 --- a/app/app/styles/section/table.scss +++ b/app/app/styles/section/table.scss @@ -1,5 +1,5 @@ .table-editor-wrapper { - margin-top: 7px; + margin-top: 6px; } .fr-element, diff --git a/app/app/styles/view/document/history.scss b/app/app/styles/view/document/history.scss index 4c5acc19..9daa9a11 100644 --- a/app/app/styles/view/document/history.scss +++ b/app/app/styles/view/document/history.scss @@ -16,11 +16,12 @@ > .canvas { padding: 0; } + } - .revision-picker { - width: 300px; - float: left; - margin-bottom: 30px; - } + .revision-picker { + width: 300px; + float: left; + margin-top: 10px; + display: inline-block; } } diff --git a/app/app/templates/components/document/document-history.hbs b/app/app/templates/components/document/document-history.hbs index 8a69132a..2da5e482 100644 --- a/app/app/templates/components/document/document-history.hbs +++ b/app/app/templates/components/document/document-history.hbs @@ -1,11 +1,14 @@ +{{ui-select tagName="span" class="revision-picker" content=revisions action=(action 'onSelectRevision') optionValuePath="id" optionLabelPath="label"}} + +
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}} +
+
+
- {{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}}}
diff --git a/app/app/templates/components/document/index-entry.hbs b/app/app/templates/components/document/sidebar-view-index-entry.hbs similarity index 100% rename from app/app/templates/components/document/index-entry.hbs rename to app/app/templates/components/document/sidebar-view-index-entry.hbs diff --git a/app/app/templates/components/document/sidebar-view-index.hbs b/app/app/templates/components/document/sidebar-view-index.hbs index 2ab55275..b0a40b90 100644 --- a/app/app/templates/components/document/sidebar-view-index.hbs +++ b/app/app/templates/components/document/sidebar-view-index.hbs @@ -26,7 +26,7 @@
    {{#each pages key="id" as |p index|}} - {{document/index-entry page=p index=index onClick=(action 'onEntryClick')}} + {{document/sidebar-view-index-entry page=p index=index onClick=(action 'onEntryClick')}} {{/each}}
diff --git a/app/app/templates/components/document/sidebar-zone.hbs b/app/app/templates/components/document/sidebar-zone.hbs index b572c35b..f129301a 100644 --- a/app/app/templates/components/document/sidebar-zone.hbs +++ b/app/app/templates/components/document/sidebar-zone.hbs @@ -15,18 +15,6 @@
timeline
-
-
- chat_bubble -
-
-
- person -
-
-
- share -
{{/if}}
@@ -50,18 +38,6 @@ {{#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')}} @@ -93,6 +69,18 @@ {{/dropdown-menu}} {{#if session.authenticated}} + {{#if menuOpen}} + {{#unless pinState.isPinned}} + {{#dropdown-dialog target="pin-document-button" position="bottom right" button="Pin" color="flat-green" onAction=(action 'onPin') focusOn="pin-document-name" }} +
+ +
A 3 or 4 character name
+ {{input type='text' id="pin-document-name" value=pinState.newName}} +
+ {{/dropdown-dialog}} + {{/unless}} + {{/if}} + {{#if isEditor}} {{#if menuOpen}} {{#dropdown-dialog target="delete-document-button" position="bottom right" button="Delete" color="flat-red" onAction=(action 'onDeleteDocument')}} @@ -100,16 +88,6 @@

There is no undo, so be careful.

{{/dropdown-dialog}} - {{#unless pinState.isPinned}} - {{#dropdown-dialog target="pin-document-button" position="bottom right" button="Pin" color="flat-green" onAction=(action 'onPin') focusOn="pin-document-name" }} -
- -
A 3 or 4 character name
- {{input type='text' id="pin-document-name" value=pinState.newName}} -
- {{/dropdown-dialog}} - {{/unless}} - {{#dropdown-dialog target="save-template-button" position="bottom right" button="Save as Template" color="flat-green" onAction=(action 'onSaveTemplate') focusOn="new-template-name" }}
diff --git a/app/ember-cli-build.js b/app/ember-cli-build.js index 3c2821aa..6bc31797 100644 --- a/app/ember-cli-build.js +++ b/app/ember-cli-build.js @@ -41,6 +41,7 @@ module.exports = function (defaults) { } }); + app.import('vendor/documize.js'); app.import('vendor/dropzone.js'); app.import('vendor/is.js'); app.import('vendor/md5.js'); diff --git a/app/vendor/documize.js b/app/vendor/documize.js new file mode 100644 index 00000000..9700606f --- /dev/null +++ b/app/vendor/documize.js @@ -0,0 +1,31 @@ +// 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 + +$.fn.inView = function(){ + let win = $(window); + let obj = $(this); + + // trap for no object + if (obj.length === 0) { + return false; + } + + // the top Scroll Position in the page + let scrollPosition = win.scrollTop(); + + // the end of the visible area in the page, starting from the scroll position + let visibleArea = win.scrollTop() + win.height(); + + // we check to see if the start of object is in view + let objPos = obj.offset().top;// + obj.outerHeight(); + + return(visibleArea >= objPos && scrollPosition <= objPos ? true : false); +}; diff --git a/core/api/endpoint/page_endpoint.go b/core/api/endpoint/page_endpoint.go index 1c9a19bf..082d3cdf 100644 --- a/core/api/endpoint/page_endpoint.go +++ b/core/api/endpoint/page_endpoint.go @@ -1090,6 +1090,7 @@ func CopyPage(w http.ResponseWriter, r *http.Request) { newPageID := util.UniqueID() page.RefID = newPageID page.Level = 1 + page.Sequence = 0 page.DocumentID = targetID page.UserID = p.Context.UserID pageMeta.DocumentID = targetID