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
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Controller from '@ember/controller';
|
2016-11-09 15:16:44 -08:00
|
|
|
|
2017-12-08 17:24:39 +00:00
|
|
|
export default Controller.extend({
|
2017-11-16 13:28:05 +00:00
|
|
|
documentService: service('document'),
|
2016-11-09 15:16:44 -08:00
|
|
|
|
|
|
|
actions: {
|
2017-03-03 20:17:49 +00:00
|
|
|
onCancel() {
|
|
|
|
this.transitionToRoute('document.index',
|
|
|
|
this.get('model.folder.id'),
|
|
|
|
this.get('model.folder.slug'),
|
|
|
|
this.get('model.document.id'),
|
2017-03-09 12:51:21 +00:00
|
|
|
this.get('model.document.slug'),
|
|
|
|
{ queryParams: { pageId: this.get('model.page.id') }});
|
2017-03-03 20:17:49 +00:00
|
|
|
},
|
|
|
|
|
2016-11-09 15:16:44 -08:00
|
|
|
onAction(page, meta) {
|
|
|
|
let model = {
|
|
|
|
page: page.toJSON({ includeId: true }),
|
|
|
|
meta: meta.toJSON({ includeId: true })
|
|
|
|
};
|
|
|
|
|
2016-11-11 16:17:43 -08:00
|
|
|
this.get('documentService').updatePage(page.get('documentId'), page.get('id'), model).then((page) => {
|
|
|
|
let data = this.get('store').normalize('page', page);
|
|
|
|
this.get('store').push(data);
|
2016-11-09 15:16:44 -08:00
|
|
|
|
2017-03-03 20:17:49 +00:00
|
|
|
this.transitionToRoute('document.index',
|
|
|
|
this.get('model.folder.id'),
|
|
|
|
this.get('model.folder.slug'),
|
|
|
|
this.get('model.document.id'),
|
2017-12-08 17:24:39 +00:00
|
|
|
this.get('model.document.slug'),
|
2018-01-25 13:20:22 +00:00
|
|
|
{ queryParams: { currentPageId: page.get('id')}});
|
2016-11-09 15:16:44 -08:00
|
|
|
});
|
2017-03-03 20:17:49 +00:00
|
|
|
},
|
2016-11-09 15:16:44 -08:00
|
|
|
}
|
|
|
|
});
|