1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +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.load();
},

View file

@ -26,6 +26,8 @@ export default Component.extend(TooltipMixin, {
newSectionLocation: '',
beforePage: null,
toEdit: '',
showDeleteBlockDialog: false,
deleteBlockId: '',
didReceiveAttrs() {
this._super(...arguments);
@ -139,10 +141,6 @@ export default Component.extend(TooltipMixin, {
this.set('blocks', blocks);
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);
promise.then(() => {
this.set('deleteBlockId', '');
this.loadBlocks();
});

View file

@ -186,18 +186,6 @@ export default Controller.extend(TooltipMixin, {
this.get('documentService').getPages(this.get('document.id')).then( (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.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();
});
},

View file

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

View file

@ -78,11 +78,16 @@
<ul class="block-list">
{{#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">
<div class="block-actions">
{{#link-to 'document.block' folder.id folder.slug document.id document.slug block.id}}
<i class="material-icons">mode_edit</i>
<div class="actions">
{{#if permissions.documentTemplate}}
{{#link-to 'document.block' folder.id folder.slug document.id document.slug block.id class="button-icon-green button-icon-small align-middle"}}
<i class="material-icons">edit</i>
{{/link-to}}
<i class="material-icons" id={{block.deleteId}}>delete</i>
<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 class="details" {{action 'onInsertBlock' block}}>
<div class="title text-truncate">{{block.title}}</div>
@ -98,3 +103,7 @@
</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}}