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"}} + +
+{{#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}} + + +Are you sure you want to roll back to this version?
- {{/dropdown-dialog}} -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" }} -