1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

document sidebar index view

This commit is contained in:
Harvey Kandola 2017-03-07 16:10:13 +00:00
parent 891f0ccd18
commit 3f109a9d1d
18 changed files with 139 additions and 578 deletions

View file

@ -18,24 +18,19 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
sectionService: Ember.inject.service('section'),
editMode: false,
init() {
didReceiveAttrs() {
this._super(...arguments);
let page = this.get('page');
this.get('documentService').getPageMeta(page.get('documentId'), page.get('id')).then((meta) => {
this.set('meta', meta);
if (this.get('toEdit') === this.get('page.id') && this.get('isEditor')) {
this.send('onEdit');
}
});
},
didReceiveAttrs() {
this._super(...arguments);
if (this.get('toEdit') === this.get('page.id') && this.get('isEditor')) {
this.send('onEdit');
}
},
actions: {
onSavePage(page, meta) {
this.set('page', page);

View file

@ -1,124 +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';
import TooltipMixin from '../../mixins/tooltip';
import NotifierMixin from '../../mixins/notifier';
export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
documentService: Ember.inject.service('document'),
sectionService: Ember.inject.service('section'),
document: {},
folder: {},
showToc: true,
showSections: false,
showScrollTool: false,
showingSections: false,
init() {
this._super(...arguments);
this.get('sectionService').getSpaceBlocks(this.get('folder.id')).then((b) => {
this.set('blocks', b);
});
},
didRender() {
if (this.session.authenticated) {
this.addTooltip(document.getElementById("section-tool"));
}
},
didInsertElement() {
this.eventBus.subscribe('resized', this, 'positionTool');
this.eventBus.subscribe('scrolled', this, 'positionTool');
},
willDestroyElement() {
this.eventBus.unsubscribe('resized');
this.eventBus.unsubscribe('scrolled');
this.destroyTooltips();
},
positionTool() {
if (this.get('isDestroyed') || this.get('isDestroying')) {
return;
}
let s = $(".scroll-tool");
let windowpos = $(window).scrollTop();
if (windowpos >= 300) {
this.set('showScrollTool', true);
s.addClass("stuck-tool");
s.css('left', parseInt($(".zone-navigation").css('width')) + parseInt($(".zone-sidebar").css('width')) - 16 + 'px');
} else {
this.set('showScrollTool', false);
s.removeClass("stuck-tool");
}
},
actions: {
// Page up - above pages shunt down.
onPageSequenceChange(pendingChanges) {
this.attrs.changePageSequence(pendingChanges);
},
// Move down - pages below shift up.
onPageLevelChange(pendingChanges) {
this.attrs.changePageLevel(pendingChanges);
},
gotoPage(id) {
return this.attrs.gotoPage(id);
},
showToc() {
this.set('showToc', true);
this.set('showSections', false);
this.set('showingSections', false);
},
showSections() {
this.set('showToc', false);
this.set('showSections', true);
this.set('showingSections', true);
},
onCancel() {
this.send('showToc');
this.set('showingSections', false);
},
onAddSection(section) {
this.send('showToc');
this.attrs.onAddSection(section);
},
onInsertBlock(block) {
this.send('showToc');
this.attrs.onInsertBlock(block);
},
onDeleteBlock(id) {
this.set('blocks', this.get('blocks').filter((item) => item.get('id') !== id));
this.attrs.onDeleteBlock(id);
},
scrollTop() {
this.set('showScrollTool', false);
$("html,body").animate({
scrollTop: 0
}, 500, "linear");
}
}
});

View file

@ -31,13 +31,18 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
}),
didReceiveAttrs: function () {
this._super(...arguments);
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'));
}
},
didRender: function () {
this._super(...arguments);
if (this.session.authenticated) {
this.addTooltip(document.getElementById("toc-up-button"));
this.addTooltip(document.getElementById("toc-down-button"));
@ -47,10 +52,14 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
},
didInsertElement() {
this._super(...arguments);
this.eventBus.subscribe('documentPageAdded', this, 'onDocumentPageAdded');
},
willDestroyElement() {
this._super(...arguments);
this.eventBus.unsubscribe('documentPageAdded');
this.destroyTooltips();
},
@ -89,7 +98,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
let pendingChanges = tocUtil.moveUp(state, pages, page);
if (pendingChanges.length > 0) {
this.attrs.changePageSequence(pendingChanges);
this.attrs.onPageSequenceChange(pendingChanges);
this.send('onEntryClick', this.get('page'));
this.audit.record("moved-page-up");
@ -109,7 +118,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
let pendingChanges = tocUtil.moveDown(state, pages, page);
if (pendingChanges.length > 0) {
this.attrs.changePageSequence(pendingChanges);
this.attrs.onPageSequenceChange(pendingChanges);
this.send('onEntryClick', this.get('page'));
this.audit.record("moved-page-down");
@ -129,7 +138,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
let pendingChanges = tocUtil.indent(state, pages, page);
if (pendingChanges.length > 0) {
this.attrs.changePageLevel(pendingChanges);
this.attrs.onPageLevelChange(pendingChanges);
this.showNotification("Indent");
this.audit.record("changed-page-sequence");
@ -149,7 +158,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
let pendingChanges = tocUtil.outdent(state, pages, page);
if (pendingChanges.length > 0) {
this.attrs.changePageLevel(pendingChanges);
this.attrs.onPageLevelChange(pendingChanges);
this.showNotification("Outdent");
this.audit.record("changed-page-sequence");
@ -159,7 +168,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
onEntryClick(id) {
this.setState(id);
this.attrs.gotoPage(id);
this.attrs.onGotoPage(id);
}
}
});

View file

@ -36,7 +36,7 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
this._super(...arguments);
if (is.empty(this.get('tab'))) {
this.set('tab', 'attachments');
this.set('tab', 'index');
}
},
@ -86,6 +86,18 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
window.print();
},
onPageSequenceChange(changes) {
this.get('onPageSequenceChange')(changes);
},
onPageLevelChange(changes) {
this.get('onPageLevelChange')(changes);
},
onGotoPage(id) {
this.get('onGotoPage')(id);
},
onUnpin() {
this.audit.record('unpinned-document');

View file

@ -23,7 +23,6 @@ export default Ember.Component.extend(TooltipMixin, {
editMode: true,
codeSyntax: null,
codeEditor: null,
editorId: Ember.computed('page', function () {
let page = this.get('page');
return `markdown-editor-${page.id}`;
@ -85,7 +84,6 @@ export default Ember.Component.extend(TooltipMixin, {
willDestroyElement() {
this.set('codeEditor', null);
this.destroyTooltips();
// $("#" + this.get('editorId')).off("keyup");
},
getBody() {