mirror of
https://github.com/documize/community.git
synced 2025-08-04 21:15:24 +02:00
space sidebar
This commit is contained in:
parent
27ce8507d5
commit
5bfd3bb247
33 changed files with 834 additions and 664 deletions
|
@ -13,6 +13,7 @@ import Ember from 'ember';
|
|||
|
||||
export default Ember.Component.extend({
|
||||
selectedDocuments: [],
|
||||
moveTarget: null,
|
||||
|
||||
emptyState: Ember.computed('documents', function() {
|
||||
return this.get('documents.length') === 0;
|
||||
|
@ -21,6 +22,8 @@ export default Ember.Component.extend({
|
|||
didReceiveAttrs() {
|
||||
this.set('selectedDocuments', []);
|
||||
this.audit.record('viewed-space');
|
||||
|
||||
this.set('deleteTargets', this.get('folders').rejectBy('id', this.get('folder.id')));
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -41,6 +44,10 @@ export default Ember.Component.extend({
|
|||
|
||||
this.set('selectedDocuments', list);
|
||||
this.get('onDocumentsChecked')(list);
|
||||
}
|
||||
},
|
||||
|
||||
onDelete() {
|
||||
this.get("onDeleteSpace")();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
60
app/app/components/folder/folder-heading.js
Normal file
60
app/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);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -33,83 +33,11 @@ export default Ember.Component.extend(AuthMixin, {
|
|||
},
|
||||
|
||||
willRender() {
|
||||
if (this.inviteMessage.length === 0) {
|
||||
this.set('inviteMessage', this.getDefaultInvitationMessage());
|
||||
}
|
||||
|
||||
if (this.roleMessage.length === 0) {
|
||||
this.set('roleMessage', this.getDefaultInvitationMessage());
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
rename() {
|
||||
if (is.empty(this.folder.get('name'))) {
|
||||
$("#folderName").addClass("error").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendAction("onRename", this.folder);
|
||||
},
|
||||
|
||||
remove() {
|
||||
if (is.null(this.get('moveTarget'))) {
|
||||
$("#delete-target > select").addClass("error").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendAction("onRemove", this.get('moveTarget').get('id'));
|
||||
},
|
||||
|
||||
share() {
|
||||
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.sendAction("onShare", result);
|
||||
},
|
||||
|
||||
setPermissions() {
|
||||
var message = this.get('roleMessage').trim();
|
||||
|
||||
if (message.length === 0) {
|
||||
message = this.getDefaultInvitationMessage();
|
||||
}
|
||||
|
||||
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'));
|
||||
});
|
||||
|
||||
this.sendAction("onPermission", this.get('folder'), message, this.get('permissions'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -28,12 +28,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
isFolderOwner: computed.equal('folder.userId', 'session.user.id'),
|
||||
moveFolderId: "",
|
||||
drop: null,
|
||||
pinned: Ember.inject.service(),
|
||||
pinState : {
|
||||
isPinned: false,
|
||||
pinId: '',
|
||||
newName: '',
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id"));
|
||||
|
@ -46,11 +40,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
});
|
||||
|
||||
this.set('movedFolderOptions', targets);
|
||||
|
||||
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());
|
||||
},
|
||||
|
||||
didRender() {
|
||||
|
@ -97,39 +86,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
this.attrs.onMoveDocument(this.get('moveFolderId'));
|
||||
this.set("moveFolderId", "");
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
unpin() {
|
||||
this.audit.record('unpinned-space');
|
||||
|
||||
this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
|
||||
this.set('pinState.isPinned', false);
|
||||
this.set('pinState.pinId', '');
|
||||
this.eventBus.publish('pinChange');
|
||||
});
|
||||
},
|
||||
|
||||
pin() {
|
||||
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.audit.record('pinned-space');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,193 +0,0 @@
|
|||
// 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';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
||||
folderService: Ember.inject.service('folder'),
|
||||
templateService: Ember.inject.service('template'),
|
||||
appMeta: service(),
|
||||
publicFolders: [],
|
||||
protectedFolders: [],
|
||||
privateFolders: [],
|
||||
savedTemplates: [],
|
||||
hasPublicFolders: false,
|
||||
hasProtectedFolders: false,
|
||||
hasPrivateFolders: false,
|
||||
newFolder: "",
|
||||
showScrollTool: false,
|
||||
showingDocument: false,
|
||||
showingList: true,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (this.get('noFolder')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let _this = this;
|
||||
this.get('templateService').getSavedTemplates().then(function(saved) {
|
||||
let emptyTemplate = {
|
||||
id: "0",
|
||||
title: "Empty",
|
||||
description: "An empty canvas for your words",
|
||||
img: "insert_drive_file",
|
||||
layout: "doc",
|
||||
locked: true
|
||||
};
|
||||
|
||||
saved.forEach(function(t) {
|
||||
Ember.set(t, 'img', 'content_copy');
|
||||
});
|
||||
|
||||
saved.unshiftObject(emptyTemplate);
|
||||
_this.set('savedTemplates', saved);
|
||||
});
|
||||
},
|
||||
|
||||
didRender() {
|
||||
if (this.get('noFolder')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.get('folderService').get('canEditCurrentFolder')) {
|
||||
this.addTooltip(document.getElementById("start-document-button"));
|
||||
}
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
if (this.get('noFolder')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.eventBus.subscribe('resized', this, 'positionTool');
|
||||
this.eventBus.subscribe('scrolled', this, 'positionTool');
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this.eventBus.unsubscribe('resized');
|
||||
this.eventBus.unsubscribe('scrolled');
|
||||
this.destroyTooltips();
|
||||
},
|
||||
|
||||
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);
|
||||
},
|
||||
|
||||
positionTool() {
|
||||
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let s = $(".scroll-space-tool");
|
||||
let windowpos = $(window).scrollTop();
|
||||
|
||||
if (windowpos >= 300) {
|
||||
this.set('showScrollTool', true);
|
||||
s.addClass("stuck-space-tool");
|
||||
s.css('left', parseInt($(".zone-navigation").css('width')) + parseInt($(".zone-sidebar").css('width')) - 17 + 'px');
|
||||
} else {
|
||||
this.set('showScrollTool', false);
|
||||
s.removeClass("stuck-space-tool");
|
||||
}
|
||||
},
|
||||
|
||||
navigateToDocument(document) {
|
||||
this.attrs.showDocument(this.get('folder'), document);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onImport() {
|
||||
this.attrs.onImport();
|
||||
},
|
||||
|
||||
scrollTop() {
|
||||
this.set('showScrollTool', false);
|
||||
|
||||
$("html,body").animate({
|
||||
scrollTop: 0
|
||||
}, 500, "linear");
|
||||
},
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
showDocument() {
|
||||
this.set('showingDocument', true);
|
||||
this.set('showingList', false);
|
||||
},
|
||||
|
||||
showList() {
|
||||
this.set('showingDocument', false);
|
||||
this.set('showingList', true);
|
||||
},
|
||||
|
||||
onEditTemplate(template) {
|
||||
this.navigateToDocument(template);
|
||||
},
|
||||
|
||||
onDocumentTemplate(id /*, title, type*/ ) {
|
||||
let self = this;
|
||||
|
||||
this.send("showNotification", "Creating");
|
||||
|
||||
this.get('templateService').importSavedTemplate(this.folder.get('id'), id).then(function(document) {
|
||||
self.navigateToDocument(document);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
128
app/app/components/folder/sidebar-folders-list.js
Normal file
128
app/app/components/folder/sidebar-folders-list.js
Normal file
|
@ -0,0 +1,128 @@
|
|||
// 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: '',
|
||||
|
||||
// init() {
|
||||
// this._super(...arguments);
|
||||
|
||||
// if (this.get('noFolder')) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// let _this = this;
|
||||
// this.get('templateService').getSavedTemplates().then(function(saved) {
|
||||
// let emptyTemplate = {
|
||||
// id: "0",
|
||||
// title: "Empty",
|
||||
// description: "An empty canvas for your words",
|
||||
// img: "insert_drive_file",
|
||||
// layout: "doc",
|
||||
// locked: true
|
||||
// };
|
||||
|
||||
// saved.forEach(function(t) {
|
||||
// Ember.set(t, 'img', 'content_copy');
|
||||
// });
|
||||
|
||||
// saved.unshiftObject(emptyTemplate);
|
||||
// _this.set('savedTemplates', saved);
|
||||
// });
|
||||
// },
|
||||
|
||||
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: {
|
||||
// onImport() {
|
||||
// this.attrs.onImport();
|
||||
// },
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
// showDocument() {
|
||||
// this.set('showingDocument', true);
|
||||
// this.set('showingList', false);
|
||||
// },
|
||||
|
||||
// showList() {
|
||||
// this.set('showingDocument', false);
|
||||
// this.set('showingList', true);
|
||||
// },
|
||||
|
||||
// onEditTemplate(template) {
|
||||
// this.navigateToDocument(template);
|
||||
// },
|
||||
|
||||
// onDocumentTemplate(id /*, title, type*/ ) {
|
||||
// let self = this;
|
||||
|
||||
// this.send("showNotification", "Creating");
|
||||
|
||||
// this.get('templateService').importSavedTemplate(this.folder.get('id'), id).then(function(document) {
|
||||
// self.navigateToDocument(document);
|
||||
// });
|
||||
// },
|
||||
}
|
||||
});
|
135
app/app/components/folder/sidebar-permissions.js
Normal file
135
app/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
app/app/components/folder/sidebar-share.js
Normal file
74
app/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');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
154
app/app/components/folder/sidebar-zone.js
Normal file
154
app/app/components/folder/sidebar-zone.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 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');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// this._super(...arguments);
|
||||
|
||||
// if (this.get('noFolder')) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// let _this = this;
|
||||
// this.get('templateService').getSavedTemplates().then(function(saved) {
|
||||
// let emptyTemplate = {
|
||||
// id: "0",
|
||||
// title: "Empty",
|
||||
// description: "An empty canvas for your words",
|
||||
// img: "insert_drive_file",
|
||||
// layout: "doc",
|
||||
// locked: true
|
||||
// };
|
||||
|
||||
// saved.forEach(function(t) {
|
||||
// Ember.set(t, 'img', 'content_copy');
|
||||
// });
|
||||
|
||||
// saved.unshiftObject(emptyTemplate);
|
||||
// _this.set('savedTemplates', saved);
|
||||
// });
|
||||
// },
|
||||
|
||||
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());
|
||||
}
|
||||
},
|
||||
|
||||
// navigateToDocument(document) {
|
||||
// this.attrs.showDocument(this.get('folder'), document);
|
||||
// },
|
||||
|
||||
actions: {
|
||||
// onImport() {
|
||||
// this.attrs.onImport();
|
||||
// },
|
||||
|
||||
onFolderAdd(folderName) {
|
||||
this.attrs.onFolderAdd(folderName);
|
||||
return true;
|
||||
},
|
||||
|
||||
// onEditTemplate(template) {
|
||||
// this.navigateToDocument(template);
|
||||
// },
|
||||
|
||||
// onDocumentTemplate(id /*, title, type*/ ) {
|
||||
// let self = this;
|
||||
|
||||
// this.send("showNotification", "Creating");
|
||||
|
||||
// this.get('templateService').importSavedTemplate(this.folder.get('id'), id).then(function(document) {
|
||||
// self.navigateToDocument(document);
|
||||
// });
|
||||
// },
|
||||
|
||||
onChangeTab(tab) {
|
||||
this.set('tab', tab);
|
||||
},
|
||||
|
||||
onMenuOpen() {
|
||||
this.set('menuOpen', !this.get('menuOpen'));
|
||||
},
|
||||
|
||||
onUnpin() {
|
||||
this.audit.record('unpinned-space');
|
||||
|
||||
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.audit.record('pinned-space');
|
||||
|
||||
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;
|
||||
},
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue