mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
new document toolbar
This commit is contained in:
parent
9fd53142f3
commit
72615ba77b
3 changed files with 112 additions and 7 deletions
84
gui/app/components/toolbar/for-document.js
Normal file
84
gui/app/components/toolbar/for-document.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
// 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 Component from '@ember/component';
|
||||
// import { schedule } from '@ember/runloop';
|
||||
import { inject as service } from '@ember/service';
|
||||
import AuthMixin from '../../mixins/auth';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
|
||||
export default Component.extend(TooltipMixin, AuthMixin, {
|
||||
spaceService: service('folder'),
|
||||
session: service(),
|
||||
appMeta: service(),
|
||||
pinned: service(),
|
||||
pinState : {
|
||||
isPinned: false,
|
||||
pinId: '',
|
||||
newName: ''
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
let doc = this.get('document');
|
||||
|
||||
this.get('pinned').isDocumentPinned(doc.get('id')).then((pinId) => {
|
||||
this.set('pinState.pinId', pinId);
|
||||
this.set('pinState.isPinned', pinId !== '');
|
||||
this.set('pinState.newName', doc.get('name'));
|
||||
this.renderTooltips();
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
this.removeTooltips();
|
||||
},
|
||||
|
||||
actions: {
|
||||
onPrintDocument() {
|
||||
window.print();
|
||||
},
|
||||
|
||||
onUnpin() {
|
||||
this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
|
||||
$('#document-pin-button').tooltip('dispose');
|
||||
this.set('pinState.isPinned', false);
|
||||
this.set('pinState.pinId', '');
|
||||
this.eventBus.publish('pinChange');
|
||||
this.renderTooltips();
|
||||
});
|
||||
},
|
||||
|
||||
onPin() {
|
||||
let pin = {
|
||||
pin: this.get('pinState.newName'),
|
||||
documentId: this.get('document.id'),
|
||||
folderId: this.get('space.id')
|
||||
};
|
||||
|
||||
this.get('pinned').pinItem(pin).then((pin) => {
|
||||
$('#document-pin-button').tooltip('dispose');
|
||||
this.set('pinState.isPinned', true);
|
||||
this.set('pinState.pinId', pin.get('id'));
|
||||
this.eventBus.publish('pinChange');
|
||||
this.renderTooltips();
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
});
|
|
@ -1,13 +1,7 @@
|
|||
{{layout/nav-bar}}
|
||||
|
||||
<div class="container">
|
||||
{{#toolbar/t-toolbar}}
|
||||
{{#toolbar/t-links}}
|
||||
{{#link-to "folders" class="link" tagName="li"}}Spaces{{/link-to}}
|
||||
{{#link-to "folder" model.folder.id model.folder.slug class="link" tagName="li"}}{{model.folder.name}}{{/link-to}}
|
||||
{{/toolbar/t-links}}
|
||||
{{/toolbar/t-toolbar}}
|
||||
|
||||
{{toolbar/for-document document=model.document spaces=model.folders space=model.folder permissions=model.permissions}}
|
||||
{{document/document-heading document=model.document permissions=model.permissions onSaveDocument=(action 'onSaveDocument')}}
|
||||
{{document/document-meta document=model.document folder=model.folder folders=model.folders permissions=model.permissions onSaveDocument=(action 'onSaveDocument')}}
|
||||
|
||||
|
|
27
gui/app/templates/components/toolbar/for-document.hbs
Normal file
27
gui/app/templates/components/toolbar/for-document.hbs
Normal file
|
@ -0,0 +1,27 @@
|
|||
{{#toolbar/t-toolbar}}
|
||||
|
||||
{{#toolbar/t-links}}
|
||||
{{#link-to "folders" class="link" tagName="li"}}Spaces{{/link-to}}
|
||||
{{#link-to "folder" space.id space.slug class="link" tagName="li"}}{{space.name}}{{/link-to}}
|
||||
{{/toolbar/t-links}}
|
||||
|
||||
{{#toolbar/t-actions}}
|
||||
<div id="document-print-button" class="button-icon-gray align-middle" data-toggle="tooltip" data-placement="top" title="Print" {{action 'onPrintDocument'}}>
|
||||
<i class="material-icons">print</i>
|
||||
</div>
|
||||
<div class="button-icon-gap" />
|
||||
|
||||
{{#if pinState.isPinned}}
|
||||
<div id="document-pin-button" class="button-icon-gold align-middle" data-toggle="tooltip" data-placement="top" title="Remove favorite" {{action 'onUnpin'}}>
|
||||
<i class="material-icons">star</i>
|
||||
</div>
|
||||
{{!-- <div class="button-icon-gap" /> --}}
|
||||
{{else if session.authenticated}}
|
||||
<div id="document-pin-button" class="button-icon-gray align-middle" data-toggle="tooltip" data-placement="top" title="Save favorite" {{action 'onPin'}}>
|
||||
<i class="material-icons">star</i>
|
||||
</div>
|
||||
{{!-- <div class="button-icon-gap" /> --}}
|
||||
{{/if}}
|
||||
{{/toolbar/t-actions}}
|
||||
|
||||
{{/toolbar/t-toolbar}}
|
Loading…
Add table
Add a link
Reference in a new issue