mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
parent
99a5418dba
commit
8baad7e2f0
22 changed files with 229 additions and 102 deletions
|
@ -19,6 +19,7 @@ export default Controller.extend(Notifier, {
|
|||
templateService: service('template'),
|
||||
sectionService: service('section'),
|
||||
linkService: service('link'),
|
||||
localStore: service('local-storage'),
|
||||
appMeta: service(),
|
||||
router: service(),
|
||||
sidebarTab: 'toc',
|
||||
|
@ -263,6 +264,36 @@ export default Controller.extend(Notifier, {
|
|||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Expand all if nothing is expanded at the moment.
|
||||
// Collapse all if something is expanded at the moment.
|
||||
onExpandAll() {
|
||||
let expandState = this.get('localStore').getDocSectionHide(this.get('document.id'));
|
||||
|
||||
if (expandState.length === 0) {
|
||||
let pages = this.get('pages');
|
||||
pages.forEach((item) => {
|
||||
expandState.push(item.get('page.id'));
|
||||
})
|
||||
} else {
|
||||
expandState = [];
|
||||
}
|
||||
|
||||
this.get('localStore').setDocSectionHide(this.get('document.id'), expandState);
|
||||
this.set('expandState', expandState);
|
||||
},
|
||||
|
||||
onExpand(pageId, show) {
|
||||
let expandState = this.get('localStore').getDocSectionHide(this.get('document.id'));
|
||||
|
||||
if (show) {
|
||||
expandState = _.without(expandState, pageId)
|
||||
} else {
|
||||
expandState.push(pageId);
|
||||
}
|
||||
|
||||
this.get('localStore').setDocSectionHide(this.get('document.id'), expandState);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,6 +19,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
|
|||
linkService: service('link'),
|
||||
folderService: service('folder'),
|
||||
userService: service('user'),
|
||||
localStore: service('local-storage'),
|
||||
contributionStatus: '',
|
||||
approvalStatus: '',
|
||||
|
||||
|
@ -69,6 +70,9 @@ export default Route.extend(AuthenticatedRouteMixin, {
|
|||
controller.set('blocks', model.blocks);
|
||||
controller.set('versions', model.versions);
|
||||
controller.set('attachments', model.attachments);
|
||||
|
||||
// For persistence of section expand/collapse state.
|
||||
controller.set('expandState', this.get('localStore').getDocSectionHide(model.document.id));
|
||||
},
|
||||
|
||||
activate: function () {
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
<Layout::Grid::Sidebar>
|
||||
<div class="sidebar-content">
|
||||
<Layout::Grid::SidebarGoTop />
|
||||
<Layout::Grid::SidebarCustomAction>
|
||||
<i class="dicon {{constants.Icon.Expand}} {{if (gt expandState.length 0) 'color-green-500'}}" {{action "onExpandAll"}}>
|
||||
{{#attach-tooltip showDelay=750}}Expand/collapse{{/attach-tooltip}}
|
||||
</i>
|
||||
</Layout::Grid::SidebarCustomAction>
|
||||
|
||||
<Ui::UiSpacer @size="200" />
|
||||
|
||||
|
@ -72,6 +77,7 @@
|
|||
</div>
|
||||
|
||||
{{document/view-content
|
||||
expandState=expandState
|
||||
roles=roles
|
||||
links=links
|
||||
pages=pages
|
||||
|
@ -84,6 +90,7 @@
|
|||
attachments=attachments
|
||||
currentPageId=currentPageId
|
||||
refresh=(action "refresh")
|
||||
onExpand=(action "onExpand")
|
||||
onSavePage=(action "onSavePage")
|
||||
onCopyPage=(action "onCopyPage")
|
||||
onMovePage=(action "onMovePage")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue