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

edit/delete reusable content blocks

This commit is contained in:
Harvey Kandola 2017-12-15 18:43:22 +00:00
parent f72b02cbb2
commit 5d3ddaa2d9
5 changed files with 28 additions and 47 deletions

View file

@ -39,7 +39,6 @@ export default Component.extend(ModalMixin, {
} }
this.modalInputFocus('#publish-page-modal-' + this.get('page.id'), '#block-title-' + this.get('page.id')); this.modalInputFocus('#publish-page-modal-' + this.get('page.id'), '#block-title-' + this.get('page.id'));
this.load(); this.load();
}, },

View file

@ -26,6 +26,8 @@ export default Component.extend(TooltipMixin, {
newSectionLocation: '', newSectionLocation: '',
beforePage: null, beforePage: null,
toEdit: '', toEdit: '',
showDeleteBlockDialog: false,
deleteBlockId: '',
didReceiveAttrs() { didReceiveAttrs() {
this._super(...arguments); this._super(...arguments);
@ -139,10 +141,6 @@ export default Component.extend(TooltipMixin, {
this.set('blocks', blocks); this.set('blocks', blocks);
this.set('hasBlocks', blocks.get('length') > 0); this.set('hasBlocks', blocks.get('length') > 0);
blocks.forEach((b) => {
b.set('deleteId', `delete-block-button-${b.id}`);
});
}); });
}, },
@ -288,10 +286,19 @@ export default Component.extend(TooltipMixin, {
}); });
}, },
onDeleteBlock(id) { onShowDeleteBlockModal(id) {
this.set('deleteBlockId', id);
this.set('showDeleteBlockDialog', true);
},
onDeleteBlock() {
this.set('showDeleteBlockDialog', false);
let id = this.get('deleteBlockId');
const promise = this.attrs.onDeleteBlock(id); const promise = this.attrs.onDeleteBlock(id);
promise.then(() => { promise.then(() => {
this.set('deleteBlockId', '');
this.loadBlocks(); this.loadBlocks();
}); });

View file

@ -186,18 +186,6 @@ export default Controller.extend(TooltipMixin, {
this.get('documentService').getPages(this.get('document.id')).then( (pages) => { this.get('documentService').getPages(this.get('document.id')).then( (pages) => {
this.set('pages', pages); this.set('pages', pages);
}); });
// _.each(changes, (change) => {
// let pageContent = _.findWhere(this.get('pages'), {
// id: change.pageId
// });
// if (is.not.undefined(pageContent)) {
// pageContent.set('sequence', change.sequence);
// }
// });
// this.set('pages', this.get('pages').sortBy('sequence'));
// this.get('target._routerMicrolib').refresh();
}); });
}, },
@ -206,22 +194,6 @@ export default Controller.extend(TooltipMixin, {
this.get('documentService').getPages(this.get('document.id')).then( (pages) => { this.get('documentService').getPages(this.get('document.id')).then( (pages) => {
this.set('pages', pages); this.set('pages', pages);
}); });
// _.each(changes, (change) => {
// let pageContent = _.findWhere(this.get('pages'), {
// id: change.pageId
// });
// if (is.not.undefined(pageContent)) {
// pageContent.set('level', change.level);
// }
// });
// let pages = this.get('pages');
// pages = pages.sortBy('sequence');
// this.set('pages', []);
// this.set('pages', pages);
// this.get('target._routerMicrolib').refresh();
}); });
}, },
@ -233,7 +205,7 @@ export default Controller.extend(TooltipMixin, {
if (!$(jumpTo).inView()) { if (!$(jumpTo).inView()) {
$(jumpTo).velocity("scroll", { duration: 250, offset: -100 }); $(jumpTo).velocity("scroll", { duration: 250, offset: -100 });
} }
} }
}, },
onTagChange(tags) { onTagChange(tags) {

View file

@ -116,17 +116,11 @@
} }
} }
> .block-actions { > .actions {
@include ease-in(); @include ease-in();
display: none;
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 8px; right: 8px;
.material-icons {
color: $color-stroke;
font-size: 1rem;
}
} }
> .details { > .details {

View file

@ -78,11 +78,16 @@
<ul class="block-list"> <ul class="block-list">
{{#each blocks as |block|}} {{#each blocks as |block|}}
<li class="item" title="{{block.firstname}} {{block.lastname}}, {{time-ago block.created}}, used: {{ block.used }}" data-toggle="tooltip" data-placement="top"> <li class="item" title="{{block.firstname}} {{block.lastname}}, {{time-ago block.created}}, used: {{ block.used }}" data-toggle="tooltip" data-placement="top">
<div class="block-actions"> <div class="actions">
{{#link-to 'document.block' folder.id folder.slug document.id document.slug block.id}} {{#if permissions.documentTemplate}}
<i class="material-icons">mode_edit</i> {{#link-to 'document.block' folder.id folder.slug document.id document.slug block.id class="button-icon-green button-icon-small align-middle"}}
{{/link-to}} <i class="material-icons">edit</i>
<i class="material-icons" id={{block.deleteId}}>delete</i> {{/link-to}}
<div class="button-icon-gap" />
<div id={{concat 'delete-block-button-' block.id}} class="button-icon-red button-icon-small align-middle" {{action 'onShowDeleteBlockModal' block.id}}>
<i class="material-icons">delete</i>
</div>
{{/if}}
</div> </div>
<div class="details" {{action 'onInsertBlock' block}}> <div class="details" {{action 'onInsertBlock' block}}>
<div class="title text-truncate">{{block.title}}</div> <div class="title text-truncate">{{block.title}}</div>
@ -98,3 +103,7 @@
</div> </div>
</div> </div>
</div> </div>
{{#ui/ui-dialog title="Delete Content Block" confirmCaption="Delete" buttonType="btn-danger" show=showDeleteBlockDialog onAction=(action 'onDeleteBlock')}}
<p>Are you sure you want to delete this re-usable content block?</p>
{{/ui/ui-dialog}}