1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 21:29:42 +02:00

implemented scroll-to-page functionality

This commit is contained in:
Harvey Kandola 2017-03-09 17:18:50 +00:00
parent 9f7585e2a5
commit 079e53ff0d
12 changed files with 45 additions and 26 deletions

View file

@ -72,6 +72,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
return; return;
} }
this.get('toEdit', '');
// this.set('pageId', this.get('page.id'));
this.set('editMode', true); this.set('editMode', true);
}, },

View file

@ -46,6 +46,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
actions: { actions: {
onExpand() { onExpand() {
this.set('pageId', this.get('page.id'));
this.set('expanded', !this.get('expanded')); this.set('expanded', !this.get('expanded'));
}, },

View file

@ -33,16 +33,18 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this._super(...arguments); this._super(...arguments);
this.loadBlocks(); this.loadBlocks();
Ember.run.schedule('afterRender', () => {
let jumpTo = "#page-" + this.get('pageId');
if (!$(jumpTo).inView()) {
$(jumpTo).velocity("scroll", { duration: 250, offset: -100 });
}
});
}, },
didRender() { didRender() {
this._super(...arguments); this._super(...arguments);
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(); this.contentLinkHandler();
}, },
@ -130,7 +132,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
model.page.level = level; model.page.level = level;
this.send('onHideSectionWizard'); this.send('onHideSectionWizard');
this.set('pageId', '');
return this.get('onInsertSection')(model); return this.get('onInsertSection')(model);
}, },
@ -180,6 +181,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
page = { id: '0' }; page = { id: '0' };
} }
this.set('pageId', '');
let beforePage = this.get('beforePage'); let beforePage = this.get('beforePage');
if (is.not.null(beforePage) && $("#new-section-wizard").is(':visible') && beforePage.get('id') === page.id) { if (is.not.null(beforePage) && $("#new-section-wizard").is(':visible') && beforePage.get('id') === page.id) {
this.send('onHideSectionWizard'); this.send('onHideSectionWizard');
@ -241,8 +244,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
const promise = this.addSection(model); const promise = this.addSection(model);
promise.then((id) => { promise.then((id) => {
this.set('pageId', id);
if (model.page.pageType === 'section') { if (model.page.pageType === 'section') {
this.set('toEdit', id); this.set('toEdit', id);
} else {
this.set('toEdit', '');
} }
}); });
}, },
@ -279,8 +286,16 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.audit.record("added-content-block-" + block.get('contentType')); this.audit.record("added-content-block-" + block.get('contentType'));
const promise = this.addSection(model);
promise.then((id) => {
this.set('pageId', id);
this.addSection(model); // if (model.page.pageType === 'section') {
// this.set('toEdit', id);
// } else {
// this.set('toEdit', '');
// }
});
}, },
onDeleteBlock(id) { onDeleteBlock(id) {

View file

@ -40,6 +40,7 @@ export default Ember.Controller.extend(NotifierMixin, {
// refresh data if copied to same document // refresh data if copied to same document
if (documentId === targetDocumentId) { if (documentId === targetDocumentId) {
this.set('pageId', '');
this.get('target.router').refresh(); this.get('target.router').refresh();
} }
}); });
@ -62,7 +63,7 @@ export default Ember.Controller.extend(NotifierMixin, {
}; };
this.get('documentService').updatePage(documentId, page.get('id'), model).then(() => { this.get('documentService').updatePage(documentId, page.get('id'), model).then(() => {
this.get('target.router').refresh(); this.set('pageId', page.get('id'));
}); });
this.audit.record("edited-page"); this.audit.record("edited-page");
@ -93,6 +94,8 @@ export default Ember.Controller.extend(NotifierMixin, {
}); });
} }
this.set('pageId', '');
if (deleteChildren) { if (deleteChildren) {
// nuke of page tree // nuke of page tree
pendingChanges.push({ pendingChanges.push({
@ -109,7 +112,11 @@ export default Ember.Controller.extend(NotifierMixin, {
} }
this.set('model.pages', _.sortBy(pages, "sequence")); this.set('model.pages', _.sortBy(pages, "sequence"));
this.get('target.router').refresh(); this.transitionToRoute('document.index',
this.get('model.folder.id'),
this.get('model.folder.slug'),
this.get('model.document.id'),
this.get('model.document.slug'));
}); });
} else { } else {
// page delete followed by re-leveling child pages // page delete followed by re-leveling child pages
@ -128,6 +135,7 @@ export default Ember.Controller.extend(NotifierMixin, {
this.get('documentService').addPage(this.get('model.document.id'), data).then((newPage) => { this.get('documentService').addPage(this.get('model.document.id'), data).then((newPage) => {
let data = this.get('store').normalize('page', newPage); let data = this.get('store').normalize('page', newPage);
this.get('store').push(data); this.get('store').push(data);
this.set('pageId', newPage.id);
this.get('documentService').getPages(this.get('model.document.id')).then((pages) => { this.get('documentService').getPages(this.get('model.document.id')).then((pages) => {
this.set('model.pages', pages); this.set('model.pages', pages);
@ -216,7 +224,9 @@ export default Ember.Controller.extend(NotifierMixin, {
}, },
onGotoPage(id) { onGotoPage(id) {
if (this.get('pageId') !== id && id !== '') {
this.set('pageId', id); this.set('pageId', id);
} }
} }
}
}); });

View file

@ -18,11 +18,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
folderService: Ember.inject.service('folder'), folderService: Ember.inject.service('folder'),
userService: Ember.inject.service('user'), userService: Ember.inject.service('user'),
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 : 'index');
},
model() { model() {
let document = this.modelFor('document').document; let document = this.modelFor('document').document;
this.browser.setTitle(document.get('name')); this.browser.setTitle(document.get('name'));
@ -35,8 +30,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
pages: this.get('documentService').getPages(this.modelFor('document').document.get('id')), pages: this.get('documentService').getPages(this.modelFor('document').document.get('id')),
links: this.modelFor('document').links, 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') isEditor: this.get('folderService').get('canEditCurrentFolder')
}); });
} }

View file

@ -43,7 +43,7 @@ export default Ember.Controller.extend(NotifierMixin, {
this.get('model.folder.slug'), this.get('model.folder.slug'),
this.get('model.document.id'), this.get('model.document.id'),
this.get('model.document.slug'), this.get('model.document.slug'),
{ queryParams: { pageId: page.id }}); { queryParams: { pageId: page.get('id')}});
}); });
}, },
} }

View file

@ -37,6 +37,7 @@
word-wrap: break-word; word-wrap: break-word;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
@extend .no-select;
> .link { > .link {
color: $color-off-black; color: $color-off-black;

View file

@ -31,6 +31,7 @@
> .selected { > .selected {
background-color: $color-off-black !important; background-color: $color-off-black !important;
border: none;
> .material-icons { > .material-icons {
color: $color-white !important; color: $color-white !important;

View file

@ -225,7 +225,7 @@
} }
.button-black { .button-black {
border: 1px solid $color-stroke; border: none;
background-color: $color-off-black; background-color: $color-off-black;
color: $color-white; color: $color-white;
@include button-hover-state($color-black); @include button-hover-state($color-black);

View file

@ -14,13 +14,13 @@
<div class="section-divider" /> <div class="section-divider" />
{{/if}} {{/if}}
{{#if (is-equal page.pageType 'section')}} {{#if (is-equal page.pageType 'section')}}
{{#document/document-page document=document folder=folder page=page isEditor=isEditor toEdit=toEdit {{#document/document-page document=document folder=folder page=page isEditor=isEditor toEdit=toEdit pageId=pageId
onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock') onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock')
onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}} onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}}
{{/document/document-page}} {{/document/document-page}}
{{/if}} {{/if}}
{{#if (is-equal page.pageType 'tab')}} {{#if (is-equal page.pageType 'tab')}}
{{#document/document-tab document=document folder=folder page=page isEditor=isEditor {{#document/document-tab document=document folder=folder page=page isEditor=isEditor pageId=pageId
onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock') onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock')
onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}} onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}}
{{/document/document-tab}} {{/document/document-tab}}

View file

@ -198,10 +198,6 @@ func (p *Page) SetDefaults() {
p.ContentType = "wysiwyg" p.ContentType = "wysiwyg"
} }
// if p.IsTabType() {
// p.Sequence = 0
// }
p.Title = strings.TrimSpace(p.Title) p.Title = strings.TrimSpace(p.Title)
} }

View file

@ -1,6 +1,6 @@
/* community edition */ /* community edition */
ALTER TABLE page ADD COLUMN `pagetype` CHAR(10) NOT NULL DEFAULT 'section' AFTER `contenttype`; ALTER TABLE page ADD COLUMN `pagetype` CHAR(10) NOT NULL DEFAULT 'section' AFTER `contenttype`;
UPDATE page SET pagetype='tab', sequence=0 WHERE refid IN (SELECT pageid FROM pagemeta WHERE externalsource=1); -- UPDATE page SET pagetype='tab', sequence=0 WHERE refid IN (SELECT pageid FROM pagemeta WHERE externalsource=1);
ALTER TABLE revision ADD COLUMN `pagetype` CHAR(10) NOT NULL DEFAULT 'section' AFTER `contenttype`; ALTER TABLE revision ADD COLUMN `pagetype` CHAR(10) NOT NULL DEFAULT 'section' AFTER `contenttype`;
UPDATE revision SET pagetype='tab' WHERE pageid IN (SELECT pageid FROM pagemeta WHERE externalsource=1); UPDATE revision SET pagetype='tab' WHERE pageid IN (SELECT pageid FROM pagemeta WHERE externalsource=1);