diff --git a/gui/app/components/folder/invite-user.js b/gui/app/components/folder/invite-user.js deleted file mode 100644 index a18e3568..00000000 --- a/gui/app/components/folder/invite-user.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 Documize Inc. . 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 . -// -// https://documize.com - -import Component from '@ember/component'; - -import { inject as service } from '@ember/service'; -import NotifierMixin from '../../mixins/notifier'; - -export default Component.extend(NotifierMixin, { - folderService: service('folder'), - appMeta: service(), - inviteEmail: '', - inviteMessage: '', - - getDefaultInvitationMessage() { - return "Hey there, I am sharing the " + this.folder.get('name') + " space (in " + this.get("appMeta.title") + ") with you so we can both collaborate on 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('Invietd co-workers'); - $('#inviteEmail').removeClass('error'); - }); - } - } -}); diff --git a/gui/app/components/toolbar/for-space.js b/gui/app/components/toolbar/for-space.js index 8a729854..0aa71afe 100644 --- a/gui/app/components/toolbar/for-space.js +++ b/gui/app/components/toolbar/for-space.js @@ -17,6 +17,7 @@ import NotifierMixin from '../../mixins/notifier'; import AuthMixin from '../../mixins/auth'; export default Component.extend(NotifierMixin, AuthMixin, { + spaceService: service('folder'), session: service(), appMeta: service(), pinned: service(), @@ -34,6 +35,8 @@ export default Component.extend(NotifierMixin, AuthMixin, { return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage'); }), deleteSpaceName: '', + inviteEmail: '', + inviteMessage: '', didReceiveAttrs() { this._super(...arguments); @@ -54,24 +57,43 @@ export default Component.extend(NotifierMixin, AuthMixin, { didInsertElement() { this._super(...arguments); - $('#add-space-modal').on('show.bs.modal', function(event) { // eslint-disable-line no-unused-vars + $('#space-delete-modal').on('show.bs.modal', function(event) { // eslint-disable-line no-unused-vars schedule('afterRender', () => { - $("#new-document-name").focus(); + $("#delete-space-name").focus(); + }); + }); + + $('#space-invite-modal').on('show.bs.modal', () => { // eslint-disable-line no-unused-vars + schedule('afterRender', () => { + $("#space-invite-email").focus(); + if (this.get('inviteMessage').length === 0) { + this.set('inviteMessage', this.getDefaultInvitationMessage()); + } }); }); }, + willDestroyElement() { + this._super(...arguments); + + $('[data-toggle="tooltip"]').tooltip('dispose'); + }, + renderTooltips() { schedule('afterRender', () => { - $('#pin-space-button').tooltip('dispose'); - $('body').tooltip({selector: '#pin-space-button'}); + $('[data-toggle="tooltip"]').tooltip('dispose'); + $('body').tooltip({selector: '[data-toggle="tooltip"]', delay: 250}); }); }, + getDefaultInvitationMessage() { + return "Hey there, I am sharing the " + this.get('space.name') + " space (in " + this.get("appMeta.title") + ") with you so we can both collaborate on documents."; + }, + actions: { onUnpin() { this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => { - $('#pin-space-button').tooltip('dispose'); + $('#space-pin-button').tooltip('dispose'); this.set('pinState.isPinned', false); this.set('pinState.pinId', ''); this.eventBus.publish('pinChange'); @@ -87,7 +109,7 @@ export default Component.extend(NotifierMixin, AuthMixin, { }; this.get('pinned').pinItem(pin).then((pin) => { - $('#pin-space-button').tooltip('dispose'); + $('#space-pin-button').tooltip('dispose'); this.set('pinState.isPinned', true); this.set('pinState.pinId', pin.get('id')); this.eventBus.publish('pinChange'); @@ -97,7 +119,50 @@ export default Component.extend(NotifierMixin, AuthMixin, { return true; }, - onDeleteSpace(e) { + onSpaceInvite(e) { + e.preventDefault(); + + 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) { + $('#space-invite-email').addClass('is-invalid').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('spaceService').share(this.get('space.id'), result).then(() => { + $('#space-invite-email').removeClass('is-invalid'); + }); + + $('#space-invite-modal').modal('hide'); + $('#space-invite-modal').modal('dispose'); + }, + + onSpaceDelete(e) { e.preventDefault(); let spaceName = this.get('space').get('name'); @@ -113,37 +178,12 @@ export default Component.extend(NotifierMixin, AuthMixin, { this.attrs.onDeleteSpace(this.get('space.id')); - $('#delete-space-modal').modal('hide'); - $('#delete-space-modal').modal('dispose'); + $('#space-delete-modal').modal('hide'); + $('#space-delete-modal').modal('dispose'); }, 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.id', ''); - $("#new-space-name").removeClass("is-invalid"); - - $('#add-space-modal').modal('hide'); - $('#add-space-modal').modal('dispose'); - - this.attrs.onAddSpace(payload); }, onImport() { diff --git a/gui/app/components/ui/ui-confirm-dialog.js b/gui/app/components/ui/ui-dialog.js similarity index 100% rename from gui/app/components/ui/ui-confirm-dialog.js rename to gui/app/components/ui/ui-dialog.js diff --git a/gui/app/services/pinned.js b/gui/app/services/pinned.js index b84b8a3a..5918c829 100644 --- a/gui/app/services/pinned.js +++ b/gui/app/services/pinned.js @@ -10,7 +10,6 @@ // https://documize.com import { A } from '@ember/array'; - import ArrayProxy from '@ember/array/proxy'; import RSVP, { Promise as EmberPromise } from 'rsvp'; import Service, { inject as service } from '@ember/service'; @@ -27,26 +26,25 @@ export default Service.extend({ let userId = this.get('session.user.id'); if (!this.get('session.authenticated')) { - return new RSVP.resolve([]); + return new RSVP.resolve(A([])); + } + if (this.get('initialized')) { + return new RSVP.resolve(this.get('pins')); } return this.get('ajax').request(`pin/${userId}`, { method: 'GET' }).then((response) => { - if (is.not.array(response)) { - response = []; - } - let pins = ArrayProxy.create({ - content: A([]) - }); + if (is.not.array(response)) response = []; + let pins = ArrayProxy.create({ content: A([]) }); pins = response.map((pin) => { let data = this.get('store').normalize('pin', pin); return this.get('store').push(data); }); - this.set('pins', pins); this.set('initialized', true); + this.set('pins', pins); return pins; }); @@ -56,6 +54,8 @@ export default Service.extend({ pinItem(data) { let userId = this.get('session.user.id'); + this.set('initialized', false); + if(this.get('session.authenticated')) { return this.get('ajax').request(`pin/${userId}`, { method: 'POST', @@ -71,6 +71,8 @@ export default Service.extend({ unpinItem(pinId) { let userId = this.get('session.user.id'); + this.set('initialized', false); + if(this.get('session.authenticated')) { return this.get('ajax').request(`pin/${userId}/${pinId}`, { method: 'DELETE' @@ -107,52 +109,34 @@ export default Service.extend({ }, isDocumentPinned(documentId) { - let userId = this.get('session.user.id'); - let pins = this.get('pins'); + return new EmberPromise((resolve, reject) => { // eslint-disable-line no-unused-vars + let userId = this.get('session.user.id'); - return new EmberPromise((resolve) => { - if (this.get('initialized') === false) { - this.getUserPins().then((pins) => { - pins.forEach((pin) => { - if (pin.get('userId') === userId && pin.get('documentId') === documentId) { - resolve(pin.get('id')); - } - }); - }); - } else { + return this.getUserPins().then((pins) => { pins.forEach((pin) => { if (pin.get('userId') === userId && pin.get('documentId') === documentId) { resolve(pin.get('id')); } }); - } - resolve(''); + resolve(''); + }); }); }, isSpacePinned(spaceId) { - let userId = this.get('session.user.id'); - let pins = this.get('pins'); + return new EmberPromise((resolve, reject) => { // eslint-disable-line no-unused-vars + let userId = this.get('session.user.id'); - return new EmberPromise((resolve) => { - if (!this.get('initialized')) { - this.getUserPins().then((pins) => { + return this.getUserPins().then((pins) => { pins.forEach((pin) => { if (pin.get('userId') === userId && pin.get('documentId') === '' && pin.get('folderId') === spaceId) { resolve(pin.get('id')); } }); + + resolve(''); }); - } else { - pins.forEach((pin) => { - if (pin.get('userId') === userId && pin.get('documentId') === '' && pin.get('folderId') === spaceId) { - resolve(pin.get('id')); - } - }); - } - - resolve(''); }); } }); diff --git a/gui/app/templates/components/folder/documents-list.hbs b/gui/app/templates/components/folder/documents-list.hbs index 52014b75..27f13a26 100644 --- a/gui/app/templates/components/folder/documents-list.hbs +++ b/gui/app/templates/components/folder/documents-list.hbs @@ -39,14 +39,14 @@ -{{#ui/ui-confirm-dialog title="Delete Documents" confirmCaption="Delete" buttonType="btn-danger" show=showDeleteDialog onAction=(action 'onDeleteDocuments')}} +{{#ui/ui-dialog title="Delete Documents" confirmCaption="Delete" buttonType="btn-danger" show=showDeleteDialog onAction=(action 'onDeleteDocuments')}}

Are you sure you want to delete {{selectedDocuments.length}} {{selectedCaption}}?

-{{/ui/ui-confirm-dialog}} +{{/ui/ui-dialog}} -{{#ui/ui-confirm-dialog title="Move Documents" confirmCaption="Move" buttonType="btn-success" show=showMoveDialog onAction=(action 'onMoveDocuments')}} +{{#ui/ui-dialog title="Move Documents" confirmCaption="Move" buttonType="btn-outline-success" show=showMoveDialog onAction=(action 'onMoveDocuments')}}

Select space for {{selectedDocuments.length}} {{selectedCaption}}

{{ui/ui-list-picker items=moveOptions nameField='name' singleSelect=true}} -{{/ui/ui-confirm-dialog}} +{{/ui/ui-dialog}} {{#if showAdd}} {{empty-state icon="direct" message="You can create new documents via the green + button"}} diff --git a/gui/app/templates/components/folder/invite-user.hbs b/gui/app/templates/components/folder/invite-user.hbs deleted file mode 100644 index 57ac70dd..00000000 --- a/gui/app/templates/components/folder/invite-user.hbs +++ /dev/null @@ -1,19 +0,0 @@ -
-
-
-
Invite
-
Share this space with co-workers
-
-
- -
Comma separate multiple email addresses
- {{focus-input id="inviteEmail" type="text" class="input-transparent" value=inviteEmail}} -
-
- -
Explain why they are being invited to this space
- {{textarea id="explainInvite" value=inviteMessage class="input-transparent" rows="5"}} -
-
Invite
-
-
diff --git a/gui/app/templates/components/toolbar/for-space.hbs b/gui/app/templates/components/toolbar/for-space.hbs index 3db9bf8d..f19de230 100644 --- a/gui/app/templates/components/toolbar/for-space.hbs +++ b/gui/app/templates/components/toolbar/for-space.hbs @@ -4,12 +4,12 @@ {{/toolbar/t-links}} {{#toolbar/t-actions}} {{#if pinState.isPinned}} -
+
star
{{else if session.authenticated}} -
+
star
@@ -17,60 +17,90 @@ {{#if spaceSettings}} {{#link-to 'folder.settings' space.id space.slug}} -
- settings +
+ security
{{/link-to}} + +
+ person_add +
+
+ {{/if}} {{#if permissions.spaceOwner}} -
- delete +
+ delete
-
diff --git a/gui/public/assets/font/icons/MaterialIcons-Regular.eot b/gui/public/assets/font/icons/MaterialIcons-Regular.eot index bf67d48b..70508eba 100755 Binary files a/gui/public/assets/font/icons/MaterialIcons-Regular.eot and b/gui/public/assets/font/icons/MaterialIcons-Regular.eot differ diff --git a/gui/public/assets/font/icons/MaterialIcons-Regular.ttf b/gui/public/assets/font/icons/MaterialIcons-Regular.ttf index 683dcd05..7015564a 100755 Binary files a/gui/public/assets/font/icons/MaterialIcons-Regular.ttf and b/gui/public/assets/font/icons/MaterialIcons-Regular.ttf differ diff --git a/gui/public/assets/font/icons/MaterialIcons-Regular.woff b/gui/public/assets/font/icons/MaterialIcons-Regular.woff index ddd6be3e..b648a3ee 100755 Binary files a/gui/public/assets/font/icons/MaterialIcons-Regular.woff and b/gui/public/assets/font/icons/MaterialIcons-Regular.woff differ diff --git a/gui/public/assets/font/icons/MaterialIcons-Regular.woff2 b/gui/public/assets/font/icons/MaterialIcons-Regular.woff2 index 974fea7c..9fa21125 100755 Binary files a/gui/public/assets/font/icons/MaterialIcons-Regular.woff2 and b/gui/public/assets/font/icons/MaterialIcons-Regular.woff2 differ