mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
moved emberjs to gui folder
This commit is contained in:
parent
6a18d18f91
commit
dc49dbbeff
999 changed files with 677 additions and 651 deletions
39
gui/app/components/folder/document-tags.js
Normal file
39
gui/app/components/folder/document-tags.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
// 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({
|
||||
documentTags: [],
|
||||
tagz: [],
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
let tagz = [];
|
||||
|
||||
if (this.get('documentTags').length > 1) {
|
||||
let tags = this.get('documentTags').split('#');
|
||||
_.each(tags, function(tag) {
|
||||
if (tag.length > 0) {
|
||||
tagz.pushObject("#" + tag);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.set('tagz', tagz);
|
||||
},
|
||||
|
||||
actions: {
|
||||
filterByTag(tag) {
|
||||
this.get('filterByTag')(tag);
|
||||
}
|
||||
}
|
||||
});
|
109
gui/app/components/folder/documents-list.js
Normal file
109
gui/app/components/folder/documents-list.js
Normal file
|
@ -0,0 +1,109 @@
|
|||
// 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({
|
||||
folderService: Ember.inject.service('folder'),
|
||||
selectedDocuments: [],
|
||||
moveTarget: null,
|
||||
emptyState: Ember.computed('documents', function() {
|
||||
return this.get('documents.length') === 0;
|
||||
}),
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.set('selectedDocuments', []);
|
||||
this.set('canCreate', this.get('folderService').get('canEditCurrentFolder'));
|
||||
this.set('deleteTargets', this.get('folders').rejectBy('id', this.get('folder.id')));
|
||||
},
|
||||
|
||||
didUpdateAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.setupAddWizard();
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
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});
|
||||
} });
|
||||
});
|
||||
},
|
||||
|
||||
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')) {
|
||||
list.push(documentId);
|
||||
} else {
|
||||
var index = list.indexOf(documentId);
|
||||
if (index > -1) {
|
||||
list.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.set('selectedDocuments', list);
|
||||
this.get('onDocumentsChecked')(list);
|
||||
},
|
||||
|
||||
onDelete() {
|
||||
this.get("onDeleteSpace")();
|
||||
},
|
||||
|
||||
onImport() {
|
||||
this.get('onImport')();
|
||||
},
|
||||
|
||||
onShowDocumentWizard(docId) {
|
||||
if ($("#new-document-wizard").is(':visible') && this.get('docId') === docId) {
|
||||
this.send('onHideDocumentWizard');
|
||||
return;
|
||||
}
|
||||
|
||||
this.set('docId', docId);
|
||||
|
||||
if (docId === '') {
|
||||
$("#new-document-wizard").insertAfter('#wizard-placeholder');
|
||||
} else {
|
||||
$("#new-document-wizard").insertAfter(`#document-${docId}`);
|
||||
}
|
||||
|
||||
$("#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 });
|
||||
}
|
||||
}
|
||||
});
|
60
gui/app/components/folder/folder-heading.js
Normal file
60
gui/app/components/folder/folder-heading.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
// 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';
|
||||
|
||||
const {
|
||||
computed,
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||
folderService: Ember.inject.service('folder'),
|
||||
folderName: '',
|
||||
hasNameError: computed.empty('folderName'),
|
||||
editMode: false,
|
||||
isEditor: false,
|
||||
|
||||
keyUp(e) {
|
||||
if (e.keyCode === 27) { // escape key
|
||||
this.send('onCancel');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
toggleEdit() {
|
||||
this.set('folderName', this.get('folder.name'));
|
||||
this.set('editMode', true);
|
||||
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
$('#folder-name').select();
|
||||
});
|
||||
},
|
||||
|
||||
onSave() {
|
||||
if (this.get('hasNameError')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set('folder.name', this.get('folderName'));
|
||||
|
||||
this.get('folderService').save(this.get('folder'));
|
||||
this.showNotification('Saved');
|
||||
|
||||
this.set('editMode', false);
|
||||
},
|
||||
|
||||
onCancel() {
|
||||
this.set('editMode', false);
|
||||
}
|
||||
}
|
||||
});
|
91
gui/app/components/folder/folder-toolbar.js
Normal file
91
gui/app/components/folder/folder-toolbar.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
// 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';
|
||||
import AuthMixin from '../../mixins/auth';
|
||||
|
||||
const {
|
||||
computed
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
||||
folderService: Ember.inject.service('folder'),
|
||||
session: Ember.inject.service(),
|
||||
appMeta: Ember.inject.service(),
|
||||
showToolbar: false,
|
||||
folder: {},
|
||||
busy: false,
|
||||
isFolderOwner: computed.equal('folder.userId', 'session.user.id'),
|
||||
moveFolderId: "",
|
||||
drop: null,
|
||||
|
||||
didReceiveAttrs() {
|
||||
this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id"));
|
||||
|
||||
let show = this.get('session.authenticated') || this.get('isFolderOwner') || this.get('hasSelectedDocuments') || this.get('folderService').get('canEditCurrentFolder');
|
||||
this.set('showToolbar', show);
|
||||
|
||||
let targets = _.reject(this.get('folders'), {
|
||||
id: this.get('folder').get('id')
|
||||
});
|
||||
|
||||
this.set('movedFolderOptions', targets);
|
||||
},
|
||||
|
||||
didRender() {
|
||||
if (this.get('hasSelectedDocuments')) {
|
||||
this.addTooltip(document.getElementById("move-documents-button"));
|
||||
this.addTooltip(document.getElementById("delete-documents-button"));
|
||||
} else {
|
||||
if (this.get('isFolderOwner')) {
|
||||
this.addTooltip(document.getElementById("folder-share-button"));
|
||||
this.addTooltip(document.getElementById("folder-settings-button"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
if (is.not.null(this.get('drop'))) {
|
||||
this.get('drop').destroy();
|
||||
this.set('drop', null);
|
||||
}
|
||||
|
||||
this.destroyTooltips();
|
||||
},
|
||||
|
||||
actions: {
|
||||
deleteDocuments() {
|
||||
this.attrs.onDeleteDocument();
|
||||
},
|
||||
|
||||
setMoveFolder(folderId) {
|
||||
this.set('moveFolderId', folderId);
|
||||
|
||||
let folders = this.get('folders');
|
||||
|
||||
folders.forEach(folder => {
|
||||
folder.set('selected', folder.id === folderId);
|
||||
});
|
||||
},
|
||||
|
||||
moveDocuments() {
|
||||
if (this.get("moveFolderId") === "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.attrs.onMoveDocument(this.get('moveFolderId'));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
73
gui/app/components/folder/sidebar-folders-list.js
Normal file
73
gui/app/components/folder/sidebar-folders-list.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
// 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 constants from '../../utils/constants';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
import AuthMixin from '../../mixins/auth';
|
||||
|
||||
export default Ember.Component.extend(TooltipMixin, NotifierMixin, AuthMixin, {
|
||||
publicFolders: [],
|
||||
protectedFolders: [],
|
||||
privateFolders: [],
|
||||
hasPublicFolders: false,
|
||||
hasProtectedFolders: false,
|
||||
hasPrivateFolders: false,
|
||||
newFolder: '',
|
||||
|
||||
didReceiveAttrs() {
|
||||
let folders = this.get('folders');
|
||||
|
||||
// clear out state
|
||||
this.set('publicFolders', []);
|
||||
this.set('protectedFolders', []);
|
||||
this.set('privateFolders', []);
|
||||
|
||||
_.each(folders, folder => {
|
||||
if (folder.get('folderType') === constants.FolderType.Public) {
|
||||
let folders = this.get('publicFolders');
|
||||
folders.pushObject(folder);
|
||||
this.set('publicFolders', folders);
|
||||
}
|
||||
if (folder.get('folderType') === constants.FolderType.Private) {
|
||||
let folders = this.get('privateFolders');
|
||||
folders.pushObject(folder);
|
||||
this.set('privateFolders', folders);
|
||||
}
|
||||
if (folder.get('folderType') === constants.FolderType.Protected) {
|
||||
let folders = this.get('protectedFolders');
|
||||
folders.pushObject(folder);
|
||||
this.set('protectedFolders', folders);
|
||||
}
|
||||
});
|
||||
|
||||
this.set('hasPublicFolders', this.get('publicFolders.length') > 0);
|
||||
this.set('hasPrivateFolders', this.get('privateFolders.length') > 0);
|
||||
this.set('hasProtectedFolders', this.get('protectedFolders.length') > 0);
|
||||
},
|
||||
|
||||
actions: {
|
||||
addFolder() {
|
||||
var folderName = this.get('newFolder');
|
||||
|
||||
if (is.empty(folderName)) {
|
||||
$("#new-folder-name").addClass("error").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.attrs.onFolderAdd(folderName);
|
||||
|
||||
this.set('newFolder', '');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
135
gui/app/components/folder/sidebar-permissions.js
Normal file
135
gui/app/components/folder/sidebar-permissions.js
Normal file
|
@ -0,0 +1,135 @@
|
|||
// 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';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, {
|
||||
folderService: service('folder'),
|
||||
userService: service('user'),
|
||||
appMeta: service(),
|
||||
store: service(),
|
||||
|
||||
didReceiveAttrs() {
|
||||
this.get('userService').getAll().then((users) => {
|
||||
this.set('users', users);
|
||||
|
||||
var folderPermissions = [];
|
||||
|
||||
users.forEach((user) => {
|
||||
let isActive = user.get('active');
|
||||
|
||||
let u = {
|
||||
userId: user.get('id'),
|
||||
fullname: user.get('fullname'),
|
||||
orgId: this.get('folder.orgId'),
|
||||
folderId: this.get('folder.id'),
|
||||
canEdit: false,
|
||||
canView: false,
|
||||
canViewPrevious: false
|
||||
};
|
||||
|
||||
if (isActive) {
|
||||
folderPermissions.pushObject(u);
|
||||
}
|
||||
});
|
||||
|
||||
var u = {
|
||||
userId: "",
|
||||
fullname: " Everyone",
|
||||
orgId: this.get('folder.orgId'),
|
||||
folderId: this.get('folder.id'),
|
||||
canEdit: false,
|
||||
canView: false
|
||||
};
|
||||
|
||||
folderPermissions.pushObject(u);
|
||||
|
||||
this.get('folderService').getPermissions(this.get('folder.id')).then((permissions) => {
|
||||
permissions.forEach((permission, index) => { // eslint-disable-line no-unused-vars
|
||||
var folderPermission = folderPermissions.findBy('userId', permission.get('userId'));
|
||||
if (is.not.undefined(folderPermission)) {
|
||||
Ember.setProperties(folderPermission, {
|
||||
orgId: permission.get('orgId'),
|
||||
folderId: permission.get('folderId'),
|
||||
canEdit: permission.get('canEdit'),
|
||||
canView: permission.get('canView'),
|
||||
canViewPrevious: permission.get('canView')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
folderPermissions.map((permission) => {
|
||||
let data = this.get('store').normalize('folder-permission', permission);
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
this.set('permissions', folderPermissions.sortBy('fullname'));
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getDefaultInvitationMessage() {
|
||||
return "Hey there, I am sharing the " + this.get('folder.name') + " (in " + this.get("appMeta.title") + ") with you so we can both access the same documents.";
|
||||
},
|
||||
|
||||
actions: {
|
||||
setPermissions() {
|
||||
let message = this.getDefaultInvitationMessage();
|
||||
let folder = this.get('folder');
|
||||
let permissions = this.get('permissions');
|
||||
|
||||
this.get('permissions').forEach((permission, index) => { // eslint-disable-line no-unused-vars
|
||||
Ember.set(permission, 'canView', $("#canView-" + permission.userId).prop('checked'));
|
||||
Ember.set(permission, 'canEdit', $("#canEdit-" + permission.userId).prop('checked'));
|
||||
});
|
||||
|
||||
var data = permissions.map((obj) => {
|
||||
let permission = {
|
||||
'orgId': obj.orgId,
|
||||
'folderId': obj.folderId,
|
||||
'userId': obj.userId,
|
||||
'canEdit': obj.canEdit,
|
||||
'canView': obj.canView
|
||||
};
|
||||
|
||||
return permission;
|
||||
});
|
||||
|
||||
var payload = { Message: message, Roles: data };
|
||||
|
||||
this.get('folderService').savePermissions(folder.get('id'), payload).then(() => {
|
||||
});
|
||||
|
||||
var hasEveryone = _.find(data, function (permission) {
|
||||
return permission.userId === "" && (permission.canView || permission.canEdit);
|
||||
});
|
||||
|
||||
if (is.not.undefined(hasEveryone)) {
|
||||
folder.markAsPublic();
|
||||
} else {
|
||||
if (data.length > 1) {
|
||||
folder.markAsRestricted();
|
||||
} else {
|
||||
folder.markAsPrivate();
|
||||
}
|
||||
}
|
||||
|
||||
this.get('folderService').save(folder).then(function () {
|
||||
// window.location.href = "/folder/" + folder.get('id') + "/" + folder.get('slug');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
74
gui/app/components/folder/sidebar-share.js
Normal file
74
gui/app/components/folder/sidebar-share.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
// 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';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, {
|
||||
folderService: service('folder'),
|
||||
appMeta: service(),
|
||||
inviteEmail: '',
|
||||
inviteMessage: '',
|
||||
|
||||
getDefaultInvitationMessage() {
|
||||
return "Hey there, I am sharing the " + this.folder.get('name') + " (in " + this.get("appMeta.title") + ") with you so we can both access the same documents.";
|
||||
},
|
||||
|
||||
willRender() {
|
||||
if (this.get('inviteMessage').length === 0) {
|
||||
this.set('inviteMessage', this.getDefaultInvitationMessage());
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
onShare() {
|
||||
var email = this.get('inviteEmail').trim().replace(/ /g, '');
|
||||
var message = this.get('inviteMessage').trim();
|
||||
|
||||
if (message.length === 0) {
|
||||
message = this.getDefaultInvitationMessage();
|
||||
}
|
||||
|
||||
if (email.length === 0) {
|
||||
$('#inviteEmail').addClass('error').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
var result = {
|
||||
Message: message,
|
||||
Recipients: []
|
||||
};
|
||||
|
||||
// Check for multiple email addresses
|
||||
if (email.indexOf(",") > -1) {
|
||||
result.Recipients = email.split(',');
|
||||
}
|
||||
if (email.indexOf(";") > -1 && result.Recipients.length === 0) {
|
||||
result.Recipients = email.split(';');
|
||||
}
|
||||
|
||||
// Handle just one email address
|
||||
if (result.Recipients.length === 0 && email.length > 0) {
|
||||
result.Recipients.push(email);
|
||||
}
|
||||
|
||||
this.set('inviteEmail', '');
|
||||
|
||||
this.get('folderService').share(this.folder.get('id'), result).then(() => {
|
||||
this.showNotification('Shared');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
101
gui/app/components/folder/sidebar-zone.js
Normal file
101
gui/app/components/folder/sidebar-zone.js
Normal file
|
@ -0,0 +1,101 @@
|
|||
// 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 TooltipMixin from '../../mixins/tooltip';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
import AuthMixin from '../../mixins/auth';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(TooltipMixin, NotifierMixin, AuthMixin, {
|
||||
folderService: service('folder'),
|
||||
templateService: service('template'),
|
||||
appMeta: service(),
|
||||
pinned: service(),
|
||||
publicFolders: [],
|
||||
protectedFolders: [],
|
||||
privateFolders: [],
|
||||
hasPublicFolders: false,
|
||||
hasProtectedFolders: false,
|
||||
hasPrivateFolders: false,
|
||||
newFolder: "",
|
||||
menuOpen: false,
|
||||
pinState : {
|
||||
isPinned: false,
|
||||
pinId: '',
|
||||
newName: '',
|
||||
},
|
||||
tab: '',
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (is.empty(this.get('tab')) || is.undefined(this.get('tab'))) {
|
||||
this.set('tab', 'index');
|
||||
}
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
if (!this.get('noFolder')) {
|
||||
let folder = this.get('folder');
|
||||
this.set('pinState.pinId', this.get('pinned').isSpacePinned(folder.get('id')));
|
||||
this.set('pinState.isPinned', this.get('pinState.pinId') !== '');
|
||||
this.set('pinState.newName', folder.get('name').substring(0,3).toUpperCase());
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
onFolderAdd(folderName) {
|
||||
this.attrs.onFolderAdd(folderName);
|
||||
return true;
|
||||
},
|
||||
|
||||
onChangeTab(tab) {
|
||||
this.set('tab', tab);
|
||||
},
|
||||
|
||||
onMenuOpen() {
|
||||
this.set('menuOpen', !this.get('menuOpen'));
|
||||
},
|
||||
|
||||
onUnpin() {
|
||||
this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
|
||||
this.set('pinState.isPinned', false);
|
||||
this.set('pinState.pinId', '');
|
||||
this.eventBus.publish('pinChange');
|
||||
});
|
||||
},
|
||||
|
||||
onPin() {
|
||||
let pin = {
|
||||
pin: this.get('pinState.newName'),
|
||||
documentId: '',
|
||||
folderId: this.get('folder.id')
|
||||
};
|
||||
|
||||
if (is.empty(pin.pin)) {
|
||||
$('#pin-space-name').addClass('error').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.get('pinned').pinItem(pin).then((pin) => {
|
||||
this.set('pinState.isPinned', true);
|
||||
this.set('pinState.pinId', pin.get('id'));
|
||||
this.eventBus.publish('pinChange');
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
});
|
154
gui/app/components/folder/start-document.js
Normal file
154
gui/app/components/folder/start-document.js
Normal file
|
@ -0,0 +1,154 @@
|
|||
// 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';
|
||||
|
||||
|
||||
const {
|
||||
computed,
|
||||
} = Ember;
|
||||
export default Ember.Component.extend(NotifierMixin, {
|
||||
localStorage: Ember.inject.service(),
|
||||
appMeta: Ember.inject.service(),
|
||||
templateService: Ember.inject.service('template'),
|
||||
canEditTemplate: "",
|
||||
importedDocuments: [],
|
||||
savedTemplates: [],
|
||||
drop: null,
|
||||
newDocumentName: 'New Document',
|
||||
newDocumentNameMissing: computed.empty('newDocumentName'),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.get('templateService').getSavedTemplates().then((saved) => {
|
||||
let emptyTemplate = {
|
||||
id: "0",
|
||||
title: "Empty",
|
||||
description: "An empty canvas for your words",
|
||||
layout: "doc",
|
||||
locked: true
|
||||
};
|
||||
|
||||
saved.unshiftObject(emptyTemplate);
|
||||
this.set('savedTemplates', saved);
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this.setupImport();
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
if (is.not.null(this.get('drop'))) {
|
||||
this.get('drop').destroy();
|
||||
this.set('drop', null);
|
||||
}
|
||||
},
|
||||
|
||||
setupImport() {
|
||||
// already done init?
|
||||
if (is.not.null(this.get('drop'))) {
|
||||
this.get('drop').destroy();
|
||||
this.set('drop', null);
|
||||
}
|
||||
|
||||
let self = this;
|
||||
let folderId = this.get('folder.id');
|
||||
let url = this.get('appMeta.endpoint');
|
||||
let importUrl = `${url}/import/folder/${folderId}`;
|
||||
|
||||
let dzone = new Dropzone("#import-document-button", {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + self.get('session.session.content.authenticated.token')
|
||||
},
|
||||
url: importUrl,
|
||||
method: "post",
|
||||
paramName: 'attachment',
|
||||
acceptedFiles: ".doc,.docx,.md,.markdown,.htm,.html",
|
||||
clickable: true,
|
||||
maxFilesize: 10,
|
||||
parallelUploads: 3,
|
||||
uploadMultiple: false,
|
||||
addRemoveLinks: false,
|
||||
autoProcessQueue: true,
|
||||
|
||||
init: function () {
|
||||
this.on("success", function (document) {
|
||||
self.send('onDocumentImported', document.name, document);
|
||||
});
|
||||
|
||||
this.on("error", function (x) {
|
||||
console.log("Conversion failed for ", x.name, " obj ", x); // eslint-disable-line no-console
|
||||
});
|
||||
|
||||
this.on("queuecomplete", function () {});
|
||||
|
||||
this.on("addedfile", function (file) {
|
||||
self.send('onDocumentImporting', file.name);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dzone.on("complete", function (file) {
|
||||
dzone.removeFile(file);
|
||||
});
|
||||
|
||||
this.set('drop', dzone);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onHideDocumentWizard() {
|
||||
this.get('onHideDocumentWizard')();
|
||||
},
|
||||
|
||||
editTemplate(template) {
|
||||
this.get('router').transitionTo('document', this.get('folder.id'), this.get('folder.slug'), template.get('id'), template.get('slug'));
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
startDocument(template) {
|
||||
this.send("showNotification", "Creating");
|
||||
|
||||
this.get('templateService').importSavedTemplate(this.folder.get('id'), template.id, this.get('newDocumentName')).then((document) => {
|
||||
this.get('router').transitionTo('document', this.get('folder.id'), this.get('folder.slug'), document.get('id'), document.get('slug'));
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
onDocumentImporting(filename) {
|
||||
this.send("showNotification", `Importing ${filename}`);
|
||||
this.get('onHideDocumentWizard')();
|
||||
|
||||
let documents = this.get('importedDocuments');
|
||||
documents.push(filename);
|
||||
this.set('importedDocuments', documents);
|
||||
},
|
||||
|
||||
onDocumentImported(filename /*, document*/ ) {
|
||||
this.send("showNotification", `${filename} ready`);
|
||||
|
||||
let documents = this.get('importedDocuments');
|
||||
documents.pop(filename);
|
||||
this.set('importedDocuments', documents);
|
||||
|
||||
this.get('onImport')();
|
||||
|
||||
if (documents.length === 0) {
|
||||
// this.get('showDocument')(this.get('folder'), document);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue