2016-07-07 18:54:16 -07: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';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
2017-03-24 17:43:41 +00:00
|
|
|
folderService: Ember.inject.service('folder'),
|
2017-03-24 13:10:32 +00:00
|
|
|
moveTarget: null,
|
2016-07-07 18:54:16 -07:00
|
|
|
emptyState: Ember.computed('documents', function() {
|
2017-03-19 11:37:18 +00:00
|
|
|
return this.get('documents.length') === 0;
|
|
|
|
}),
|
2016-07-07 18:54:16 -07:00
|
|
|
|
|
|
|
didReceiveAttrs() {
|
2017-04-12 18:00:52 +01:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2017-03-24 17:43:41 +00:00
|
|
|
this.set('canCreate', this.get('folderService').get('canEditCurrentFolder'));
|
2017-03-24 13:10:32 +00:00
|
|
|
this.set('deleteTargets', this.get('folders').rejectBy('id', this.get('folder.id')));
|
2016-07-07 18:54:16 -07:00
|
|
|
},
|
|
|
|
|
2017-04-12 18:00:52 +01:00
|
|
|
didUpdateAttrs() {
|
|
|
|
this._super(...arguments);
|
2017-08-17 18:31:19 +01:00
|
|
|
|
2017-04-12 18:00:52 +01:00
|
|
|
this.setupAddWizard();
|
2017-08-17 18:31:19 +01:00
|
|
|
},
|
2017-04-12 18:00:52 +01:00
|
|
|
|
2017-03-24 17:43:41 +00:00
|
|
|
didInsertElement() {
|
|
|
|
this._super(...arguments);
|
2017-08-17 18:31:19 +01:00
|
|
|
|
2017-03-24 17:43:41 +00:00
|
|
|
this.setupAddWizard();
|
|
|
|
},
|
|
|
|
|
|
|
|
setupAddWizard() {
|
|
|
|
Ember.run.schedule('afterRender', () => {
|
|
|
|
$('.start-document:not(.start-document-empty-state)').off('.hoverIntent');
|
|
|
|
|
|
|
|
$('.start-document:not(.start-document-empty-state)').hoverIntent({interval: 100, over: function() {
|
|
|
|
// in
|
|
|
|
$(this).find('.start-button').velocity("transition.slideDownIn", {duration: 300});
|
|
|
|
}, out: function() {
|
|
|
|
// out
|
|
|
|
$(this).find('.start-button').velocity("transition.slideUpOut", {duration: 300});
|
|
|
|
} });
|
2017-08-17 18:31:19 +01:00
|
|
|
});
|
2017-03-24 17:43:41 +00:00
|
|
|
},
|
|
|
|
|
2016-07-07 18:54:16 -07:00
|
|
|
actions: {
|
|
|
|
selectDocument(documentId) {
|
|
|
|
let doc = this.get('documents').findBy('id', documentId);
|
|
|
|
let list = this.get('selectedDocuments');
|
|
|
|
|
|
|
|
doc.set('selected', !doc.get('selected'));
|
|
|
|
|
|
|
|
if (doc.get('selected')) {
|
2017-08-17 18:31:19 +01:00
|
|
|
list.pushObject(documentId);
|
2016-07-07 18:54:16 -07:00
|
|
|
} else {
|
2017-08-17 18:31:19 +01:00
|
|
|
list = _.without(list, documentId);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.set('selectedDocuments', list);
|
2017-03-24 13:10:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onDelete() {
|
|
|
|
this.get("onDeleteSpace")();
|
2017-03-24 17:43:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onImport() {
|
|
|
|
this.get('onImport')();
|
|
|
|
},
|
|
|
|
|
|
|
|
onShowDocumentWizard(docId) {
|
|
|
|
if ($("#new-document-wizard").is(':visible') && this.get('docId') === docId) {
|
|
|
|
this.send('onHideDocumentWizard');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.set('docId', docId);
|
|
|
|
|
2017-03-24 18:57:08 +00:00
|
|
|
if (docId === '') {
|
|
|
|
$("#new-document-wizard").insertAfter('#wizard-placeholder');
|
|
|
|
} else {
|
|
|
|
$("#new-document-wizard").insertAfter(`#document-${docId}`);
|
|
|
|
}
|
|
|
|
|
2017-03-24 17:43:41 +00:00
|
|
|
$("#new-document-wizard").velocity("transition.slideDownIn", { duration: 300, complete:
|
|
|
|
function() {
|
|
|
|
$("#new-document-name").focus();
|
|
|
|
}});
|
|
|
|
},
|
|
|
|
|
|
|
|
onHideDocumentWizard() {
|
|
|
|
$("#new-document-wizard").insertAfter('#wizard-placeholder');
|
|
|
|
$("#new-document-wizard").velocity("transition.slideUpOut", { duration: 300 });
|
|
|
|
}
|
2016-07-07 18:54:16 -07:00
|
|
|
}
|
|
|
|
});
|