2016-11-09 15:16:44 -08:00
|
|
|
// 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 NotifierMixin from '../../mixins/notifier';
|
|
|
|
import TooltipMixin from '../../mixins/tooltip';
|
|
|
|
|
|
|
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
2016-11-10 12:01:06 -08:00
|
|
|
sectionService: Ember.inject.service('section'),
|
2016-11-09 15:16:44 -08:00
|
|
|
viewMode: true,
|
|
|
|
editMode: false,
|
|
|
|
|
2016-11-10 12:01:06 -08:00
|
|
|
didInsertElement() {
|
2017-03-06 18:30:55 +00:00
|
|
|
this.get('sectionService').refresh(this.get('document.id')).then((changes) => {
|
|
|
|
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let oldPage = this.get('page');
|
|
|
|
|
|
|
|
if (is.undefined(changes) || is.undefined(oldPage)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
changes.forEach((newPage) => {
|
|
|
|
if (oldPage.get('id') === newPage.get('id')) {
|
2016-11-10 12:01:06 -08:00
|
|
|
oldPage.set('body', newPage.get('body'));
|
|
|
|
oldPage.set('revised', newPage.get('revised'));
|
2017-03-06 18:30:55 +00:00
|
|
|
this.showNotification(`Refreshed ${oldPage.get('title')}`);
|
2016-11-10 12:01:06 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-11-09 15:16:44 -08:00
|
|
|
actions: {
|
2017-03-03 20:17:49 +00:00
|
|
|
onExpand() {
|
2017-03-09 17:18:50 +00:00
|
|
|
this.set('pageId', this.get('page.id'));
|
2017-03-03 20:17:49 +00:00
|
|
|
this.set('expanded', !this.get('expanded'));
|
|
|
|
},
|
|
|
|
|
|
|
|
onSavePageAsBlock(block) {
|
|
|
|
this.attrs.onSavePageAsBlock(block);
|
2016-11-09 15:16:44 -08:00
|
|
|
},
|
|
|
|
|
2017-03-03 20:17:49 +00:00
|
|
|
onCopyPage(documentId) {
|
|
|
|
this.attrs.onCopyPage(this.get('page.id'), documentId);
|
2016-11-09 15:16:44 -08:00
|
|
|
},
|
|
|
|
|
2017-03-03 20:17:49 +00:00
|
|
|
onMovePage(documentId) {
|
|
|
|
this.attrs.onMovePage(this.get('page.id'), documentId);
|
2016-11-09 15:16:44 -08:00
|
|
|
},
|
2017-03-03 20:17:49 +00:00
|
|
|
|
|
|
|
onDeletePage(deleteChildren) {
|
|
|
|
let page = this.get('page');
|
|
|
|
|
|
|
|
if (is.undefined(page)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
id: page.get('id'),
|
|
|
|
title: page.get('title'),
|
|
|
|
children: deleteChildren
|
|
|
|
};
|
2016-11-09 15:16:44 -08:00
|
|
|
|
2017-03-03 20:17:49 +00:00
|
|
|
this.attrs.onDeletePage(params);
|
2017-03-06 18:30:55 +00:00
|
|
|
}
|
2016-11-09 15:16:44 -08:00
|
|
|
}
|
|
|
|
});
|