1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 21:29:42 +02:00
documize/gui/app/pods/folders/controller.js

71 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-07-07 18:54:16 -07:00
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
2016-11-06 20:11:21 -08:00
// This software (Documize Community Edition) is licensed under
2016-07-07 18:54:16 -07:00
// 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
2016-11-06 20:11:21 -08:00
// by contacting <sales@documize.com>.
2016-07-07 18:54:16 -07:00
//
// https://documize.com
import $ from 'jquery';
import { inject as service } from '@ember/service';
import { notEmpty } from '@ember/object/computed';
import AuthMixin from '../../mixins/auth';
import Modals from '../../mixins/modal';
import Controller from '@ember/controller';
2016-07-07 18:54:16 -07:00
export default Controller.extend(AuthMixin, Modals, {
2018-05-23 15:57:30 +01:00
appMeta: service(),
folderService: service('folder'),
2016-11-06 20:11:21 -08:00
spaceName: '',
copyTemplate: true,
copyPermission: true,
copyDocument: false,
hasClone: notEmpty('clonedSpace.id'),
clonedSpace: null,
2016-11-06 20:11:21 -08:00
actions: {
onShowModal() {
this.modalOpen('#add-space-modal', {'show': true}, '#new-space-name');
},
onCloneSpaceSelect(sp) {
this.set('clonedSpace', sp)
},
onAddSpace(e) {
e.preventDefault();
let spaceName = this.get('spaceName');
let clonedId = this.get('clonedSpace.id');
if (is.empty(spaceName)) {
$("#new-space-name").addClass("is-invalid").focus();
return false;
}
let payload = {
name: spaceName,
cloneId: clonedId,
copyTemplate: this.get('copyTemplate'),
copyPermission: this.get('copyPermission'),
copyDocument: this.get('copyDocument'),
}
this.set('spaceName', '');
this.set('clonedSpace', null);
$("#new-space-name").removeClass("is-invalid");
this.modalClose('#add-space-modal');
this.get('folderService').add(payload).then((sp) => {
this.get('folderService').setCurrentFolder(sp);
this.transitionToRoute('folder', sp.get('id'), sp.get('slug'));
2016-11-06 20:11:21 -08:00
});
}
}
});