1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 15:19:42 +02:00

delete space, pin space migrated to new UX

This commit is contained in:
Harvey Kandola 2017-11-22 11:02:35 +00:00
parent acc947c2ed
commit 9cbee80f51
11 changed files with 212 additions and 138 deletions

View file

@ -10,7 +10,6 @@
// https://documize.com // https://documize.com
import { computed } from '@ember/object'; import { computed } from '@ember/object';
import Component from '@ember/component'; import Component from '@ember/component';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import NotifierMixin from '../../mixins/notifier'; import NotifierMixin from '../../mixins/notifier';
@ -59,34 +58,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
renderTooltips() { renderTooltips() {
this.destroyTooltips(); this.destroyTooltips();
if (this.get('hasSelectedDocuments')) {
if (this.get('permissions.documentMove')) {
this.addTooltip(document.getElementById("move-documents-button"));
}
if (this.get('permissions.documentDelete')) {
this.addTooltip(document.getElementById("delete-documents-button"));
}
} else {
if (this.get('permissions.spaceOwner')) {
this.addTooltip(document.getElementById("space-delete-button"));
}
if (this.get('permissions.spaceManage')) {
this.addTooltip(document.getElementById("space-settings-button"));
}
if (this.get('pinState.isPinned')) {
this.addTooltip(document.getElementById("space-unpin-button"));
} else {
this.addTooltip(document.getElementById("space-pin-button"));
}
if (this.get('permissions.documentAdd')) {
this.addTooltip(document.getElementById("document-add-button"));
}
}
}, },
willDestroyElement() { willDestroyElement() {
@ -138,23 +109,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
this.attrs.onDeleteDocument(); this.attrs.onDeleteDocument();
}, },
deleteSpace() {
let spaceName = this.get('folder').get('name');
let spaceNameTyped = this.get('deleteSpaceName');
if (spaceNameTyped !== spaceName || spaceNameTyped === '' || spaceName === '') {
$("#delete-space-name").addClass("error").focus();
return false;
}
this.set('deleteSpaceName', '');
$("#delete-space-name").removeClass("error");
this.attrs.onDeleteSpace();
return true;
},
setMoveFolder(folderId) { setMoveFolder(folderId) {
this.set('moveFolderId', folderId); this.set('moveFolderId', folderId);

View file

@ -121,14 +121,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
}); });
}, },
onDeleteSpace() {
this.get('folderService').delete(this.get('folder.id')).then(() => { /* jshint ignore:line */
this.showNotification("Deleted");
this.get('localStorage').clearSessionItem('folder');
this.get('router').transitionTo('application');
});
},
onImport() { onImport() {
this.attrs.onRefresh(); this.attrs.onRefresh();
}, },

View file

@ -11,17 +11,45 @@
import Component from '@ember/component'; import Component from '@ember/component';
import { schedule } from '@ember/runloop'; import { schedule } from '@ember/runloop';
import { notEmpty } from '@ember/object/computed'; import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import NotifierMixin from '../../mixins/notifier'; import NotifierMixin from '../../mixins/notifier';
import AuthMixin from '../../mixins/auth'; import AuthMixin from '../../mixins/auth';
export default Component.extend(NotifierMixin, AuthMixin, { export default Component.extend(NotifierMixin, AuthMixin, {
session: service(),
appMeta: service(),
pinned: service(),
spaceName: '', spaceName: '',
copyTemplate: true, copyTemplate: true,
copyPermission: true, copyPermission: true,
copyDocument: false, copyDocument: false,
clonedSpace: { id: '' }, clonedSpace: { id: '' },
hasClone: notEmpty('clonedSpace.id'), pinState : {
isPinned: false,
pinId: '',
newName: ''
},
spaceSettings: computed('permissions', function() {
return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage');
}),
deleteSpaceName: '',
didReceiveAttrs() {
this._super(...arguments);
let folder = this.get('space');
let targets = _.reject(this.get('spaces'), {id: folder.get('id')});
this.get('pinned').isSpacePinned(folder.get('id')).then((pinId) => {
this.set('pinState.pinId', pinId);
this.set('pinState.isPinned', pinId !== '');
this.set('pinState.newName', folder.get('name'));
this.renderTooltips();
});
this.set('movedFolderOptions', targets);
},
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
@ -33,9 +61,65 @@ export default Component.extend(NotifierMixin, AuthMixin, {
}); });
}, },
renderTooltips() {
schedule('afterRender', () => {
$('#pin-space-button').tooltip('dispose');
$('body').tooltip({selector: '#pin-space-button'});
});
},
actions: { actions: {
onCloneSpaceSelect(sp) { onUnpin() {
this.set('clonedSpace', sp) this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
$('#pin-space-button').tooltip('dispose');
this.set('pinState.isPinned', false);
this.set('pinState.pinId', '');
this.eventBus.publish('pinChange');
this.renderTooltips();
});
},
onPin() {
let pin = {
pin: this.get('pinState.newName'),
documentId: '',
folderId: this.get('space.id')
};
if (is.empty(pin.pin)) {
$('#pin-space-name').addClass('error').focus();
return false;
}
this.get('pinned').pinItem(pin).then((pin) => {
$('#pin-space-button').tooltip('dispose');
this.set('pinState.isPinned', true);
this.set('pinState.pinId', pin.get('id'));
this.eventBus.publish('pinChange');
this.renderTooltips();
});
return true;
},
onDeleteSpace(e) {
e.preventDefault();
let spaceName = this.get('space').get('name');
let spaceNameTyped = this.get('deleteSpaceName');
if (spaceNameTyped !== spaceName || spaceNameTyped === '' || spaceName === '') {
$("#delete-space-name").addClass("is-invalid").focus();
return;
}
this.set('deleteSpaceName', '');
$("#delete-space-name").removeClass("is-invalid");
this.attrs.onDeleteSpace(this.get('space.id'));
$('#delete-space-modal').modal('hide');
$('#delete-space-modal').modal('dispose');
}, },
onAddSpace(e) { onAddSpace(e) {

View file

@ -18,8 +18,6 @@ export default Controller.extend(NotifierMixin, {
documentService: service('document'), documentService: service('document'),
folderService: service('folder'), folderService: service('folder'),
localStorage: service('localStorage'), localStorage: service('localStorage'),
queryParams: ['tab'],
tab: 'index',
actions: { actions: {
onAddSpace(payload) { onAddSpace(payload) {
@ -32,6 +30,14 @@ export default Controller.extend(NotifierMixin, {
}); });
}, },
onDeleteSpace(id) {
this.get('folderService').delete(id).then(() => { /* jshint ignore:line */
this.showNotification("Deleted");
this.get('localStorage').clearSessionItem('folder');
this.transitionToRoute('folders');
});
},
onRefresh() { onRefresh() {
this.get('target._routerMicrolib').refresh(); this.get('target._routerMicrolib').refresh();
} }

View file

@ -1,7 +1,7 @@
{{layout/nav-bar}} {{layout/nav-bar}}
<div class="container"> <div class="container">
{{toolbar/for-space spaces=model.folders space=model.folder permissions=model.permissions}} {{toolbar/for-space spaces=model.folders space=model.folder permissions=model.permissions onDeleteSpace=(action 'onDeleteSpace')}}
{{folder/space-view {{folder/space-view
folders=model.folders folders=model.folders

View file

@ -23,13 +23,14 @@ $color-off-white: #f5f5f5;
$color-dark: #434343; $color-dark: #434343;
$color-gray: #8b9096; $color-gray: #8b9096;
$color-gray-light: #d8d8d8;
$color-border: #d3d3d3; $color-border: #d3d3d3;
// colors // colors
$color-red: #b1251b; $color-red: #b1251b;
$color-green: #1b701e; $color-green: #1b701e;
$color-blue: #2667af; $color-blue: #2667af;
$color-goldy: #cc9933; $color-goldy: #FFD700;
// widgets // widgets
$color-checkbox: #2667af; $color-checkbox: #2667af;

View file

@ -12,6 +12,7 @@
margin-right: 30px; margin-right: 30px;
cursor: pointer; cursor: pointer;
@include ease-in(); @include ease-in();
border-bottom: 2px solid $color-gray-light;
&:hover { &:hover {
color: $color-link; color: $color-link;

View file

@ -344,6 +344,60 @@
} }
} }
.button-icon-gray {
display: inline-block;
cursor: default;
@include ease-in();
> i {
color: $color-gray-light;
font-size: 2rem;
@include ease-in();
}
&:hover {
> i {
color: darken($color-gray-light, 15%);
}
}
}
.button-icon-gold {
display: inline-block;
cursor: default;
@include ease-in();
> i {
color: $color-goldy;
font-size: 2rem;
@include ease-in();
}
&:hover {
> i {
color: darken($color-goldy, 5%);
}
}
}
.button-icon-danger {
display: inline-block;
cursor: default;
@include ease-in();
> i {
color: $color-gray-light;
font-size: 2rem;
@include ease-in();
}
&:hover {
> i {
color: $color-red;
}
}
}
.button-icon-gap { .button-icon-gap {
display: inline-block; display: inline-block;
margin-left: 5px; margin-left: 5px;

View file

@ -48,16 +48,6 @@
<div class="button-gap"></div> <div class="button-gap"></div>
{{/if}} {{/if}}
{{#if pinState.isPinned}}
<div class="round-button button-gray" id="space-unpin-button" data-tooltip="Remove favorite" data-tooltip-position="top center" {{action 'onUnpin'}}>
<i class="material-icons">favorite</i>
</div>
{{else if session.authenticated}}
<div class="round-button button-gray" id="space-pin-button" data-tooltip="Mark favorite" data-tooltip-position="top center">
<i class="material-icons">favorite_border</i>
</div>
{{/if}}
{{#if spaceSettings}} {{#if spaceSettings}}
<div class="button-gap"></div> <div class="button-gap"></div>
{{#link-to 'folder.settings' folder.id folder.slug}}{{model.document.name}} {{#link-to 'folder.settings' folder.id folder.slug}}{{model.document.name}}
@ -67,35 +57,6 @@
{{/link-to}} {{/link-to}}
{{/if}} {{/if}}
{{#if permissions.spaceOwner}}
<div class="button-gap"></div>
<div class="round-button button-gray" id="space-delete-button" data-tooltip="Delete everything" data-tooltip-position="top center">
<i class="material-icons">delete</i>
</div>
{{/if}}
{{#if session.authenticated}}
{{#unless pinState.isPinned}}
{{#dropdown-dialog target="space-pin-button" position="bottom right" button="Pin" color="flat-green" onAction=(action 'onPin') focusOn="pin-space-name"}}
<div class="input-control">
<label>Favorite Space</label>
<div class="tip">Provide short name</div>
{{input type='text' id="pin-space-name" value=pinState.newName}}
</div>
{{/dropdown-dialog}}
{{/unless}}
{{/if}}
{{#if permissions.spaceOwner}}
{{#dropdown-dialog target="space-delete-button" position="bottom right" button="Delete" color="flat-red" onAction=(action 'deleteSpace')}}
<p>Are you sure you want to delete this space and all associated documents?</p>
<div class="input-control">
<div class="tip">Please type the space name to confirm</div>
{{input type='text' id="delete-space-name" value=deleteSpaceName}}
</div>
{{/dropdown-dialog}}
{{/if}}
{{/if}} {{/if}}
</div> </div>

View file

@ -37,5 +37,5 @@
{{folder/space-toolbar folders=folders folder=folder {{folder/space-toolbar folders=folders folder=folder
permissions=permissions hasSelectedDocuments=hasSelectedDocuments permissions=permissions hasSelectedDocuments=hasSelectedDocuments
onDeleteDocument=(action 'onDeleteDocument') onMoveDocument=(action 'onMoveDocument') onDeleteDocument=(action 'onDeleteDocument') onMoveDocument=(action 'onMoveDocument')
onDeleteSpace=(action 'onDeleteSpace') onStartDocument=(action 'onStartDocument')}} onStartDocument=(action 'onStartDocument')}}

View file

@ -3,56 +3,77 @@
{{#link-to "folders" class="link" tagName="li"}}SPACES{{/link-to}} {{#link-to "folders" class="link" tagName="li"}}SPACES{{/link-to}}
{{/toolbar/t-links}} {{/toolbar/t-links}}
{{#toolbar/t-actions}} {{#toolbar/t-actions}}
{{#if session.isEditor}} {{#if pinState.isPinned}}
<button type="button" class="btn btn-success font-weight-bold" data-toggle="modal" data-target="#add-space-modal" data-backdrop="static">+ DOCUMENT</button> <div id="pin-space-button" class="button-icon-gold align-middle" data-placement="top" title="Favorite" {{action 'onUnpin'}}>
<div class="modal" tabindex="-1" role="dialog" id="add-space-modal"> <i class="material-icons">star</i>
</div>
<div class="button-icon-gap" />
{{else if session.authenticated}}
<div id="pin-space-button" class="button-icon-gray align-middle" data-placement="top" title="Favorite" {{action 'onPin'}}>
<i class="material-icons">star</i>
</div>
<div class="button-icon-gap" />
{{/if}}
{{#if spaceSettings}}
{{#link-to 'folder.settings' space.id space.slug}}
<div id="space-settings-button" class="button-icon-gray align-middle" data-placement="top" title="Permissions">
<i class="material-icons">settings</i>
</div>
<div class="button-icon-gap" />
{{/link-to}}
{{/if}}
{{#if permissions.spaceOwner}}
<div id="space-delete-button" class="button-icon-danger align-middle" data-placement="top" title="Delete" data-toggle="modal" data-target="#delete-space-modal" data-backdrop="static">
<i class="material-icons">delete</i>
</div>
<div class="button-icon-gap" />
<div class="modal" tabindex="-1" role="dialog" id="delete-space-modal">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header">Add Space</div> <div class="modal-header">Confirm Delete</div>
<div class="modal-body"> <div class="modal-body">
<form onsubmit={{action 'onAddSpace'}}> <form onsubmit={{action 'onDeleteSpace'}}>
<p>Are you sure you want to delete this space and all documents?</p>
<div class="form-group"> <div class="form-group">
<label for="new-space-name">Space Name</label> <label for="new-space-name">Please type space name to confirm</label>
{{input type='text' id="new-space-name" class="form-control mousetrap" placeholder="Space name" value=spaceName}} {{input type='text' id="delete-space-name" class="form-control mousetrap" placeholder="Space name" value=deleteSpaceName}}
<small id="emailHelp" class="form-text text-muted">Characters and numbers only</small> <small class="form-text text-muted">This will delete all documents and templates within this space!</small>
</div>
<div class="form-group">
<label for="clone-space-dropdown">Clone Space</label>
{{ui-select id="clone-space-dropdown" content=spaces prompt="select space" action=(action 'onCloneSpaceSelect') optionValuePath="id" optionLabelPath="name" selection=cloneSpace}}
<small id="emailHelp" class="form-text text-muted">Copy templates, permissions, documents from existing space</small>
<div class="margin-top-10" />
{{#if hasClone}}
{{#ui/ui-checkbox selected=copyTemplate}}Copy templates{{/ui/ui-checkbox}}
{{#ui/ui-checkbox selected=copyPermission}}Copy permissions{{/ui/ui-checkbox}}
{{#ui/ui-checkbox selected=copyDocument}}Copy documents{{/ui/ui-checkbox}}
{{/if}}
</div> </div>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success font-weight-bold" onclick={{action 'onAddSpace'}}>Add</button> <button type="button" class="btn btn-danger font-weight-bold" onclick={{action 'onDeleteSpace'}}>Delete</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{/toolbar/t-actions}}
{{/toolbar/t-toolbar}}
<div class="row">
<div class="col col-sm-8">
<div class="toolbar">
<ul class="links">
</ul>
</div>
</div>
<div class="col col-sm-4">
<div class="toolbar">
<div class="buttons">
<div class="button-icon-gap" />
<button type="button" class="btn btn-success font-weight-bold" data-toggle="modal" data-target="#add-space-modal" data-backdrop="static">+ DOCUMENT</button>
<div class="modal" tabindex="-1" role="dialog" id="add-space-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">Add Space</div>
<div class="modal-body">
<form onsubmit={{action 'onAddSpace'}}>
<div class="form-group">
<label for="new-space-name">Space Name</label>
{{input type='text' id="new-space-name" class="form-control mousetrap" placeholder="Space name" value=spaceName}}
<small id="emailHelp" class="form-text text-muted">Characters and numbers only</small>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success font-weight-bold" onclick={{action 'onAddSpace'}}>Add</button>
</div>
</div>
</div> </div>
</div> </div>
</div>
</div> {{/toolbar/t-actions}}
{{/toolbar/t-toolbar}}