From f57f24e633d3e6d3913da5c470a3e315cec7a926 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Wed, 22 Jun 2016 09:57:33 -0700 Subject: [PATCH] delete document from document view --- .../components/document/document-toolbar.js | 10 +++++--- app/app/pods/document/index/controller.js | 15 +++++++++-- app/app/pods/document/index/template.hbs | 2 +- .../components/document/document-toolbar.hbs | 25 +++++++++++++++---- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/app/app/components/document/document-toolbar.js b/app/app/components/document/document-toolbar.js index 5caf1462..bbeb1471 100644 --- a/app/app/components/document/document-toolbar.js +++ b/app/app/components/document/document-toolbar.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// 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 . +// by contacting . // // https://documize.com @@ -87,6 +87,10 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { }, actions: { + deleteDocument() { + this.attrs.onDocumentDelete(); + }, + saveTemplate() { var templateName = this.get('saveTemplate.name'); var templateDescription = this.get('saveTemplate.description'); @@ -137,4 +141,4 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { return true; }, } -}); \ No newline at end of file +}); diff --git a/app/app/pods/document/index/controller.js b/app/app/pods/document/index/controller.js index 04b86079..fb3712e3 100644 --- a/app/app/pods/document/index/controller.js +++ b/app/app/pods/document/index/controller.js @@ -188,6 +188,17 @@ export default Ember.Controller.extend(NotifierMixin, { self.get('model.slug'), newPage.id); }); - } + }, + + onDocumentDelete() { + console.log("deleting " + this.get('model.id')); + let self = this; + + this.get('documentService').deleteDocument(this.get('model.id')).then(function() { + self.audit.record("deleted-page"); + self.send("showNotification", "Deleted"); + self.transitionToRoute('folders.folder', self.get('folder.id'), self.get('folder.slug')); + }); + } } -}); \ No newline at end of file +}); diff --git a/app/app/pods/document/index/template.hbs b/app/app/pods/document/index/template.hbs index 00596de4..7673b41f 100644 --- a/app/app/pods/document/index/template.hbs +++ b/app/app/pods/document/index/template.hbs @@ -3,7 +3,7 @@ {{/header/page-navigation}} {{document/document-toolbar document=model pages=pages meta=meta folder=folder isEditor=isEditor users=users owner=owner onSaveTemplate=(action 'onDocumentChange') onDocumentChange=(action 'onDocumentChange') onAttachmentUpload=(action -'onAttachmentUpload')}} +'onAttachmentUpload') onDocumentDelete=(action 'onDocumentDelete')}}
diff --git a/app/app/templates/components/document/document-toolbar.hbs b/app/app/templates/components/document/document-toolbar.hbs index a10a6dd2..0ab7a7c0 100644 --- a/app/app/templates/components/document/document-toolbar.hbs +++ b/app/app/templates/components/document/document-toolbar.hbs @@ -47,6 +47,10 @@ {{/link-to}} {{#if isEditor}} +
+
+ settings +
attach_file @@ -55,14 +59,25 @@
content_copy
-
-
- person -
-
{{/if}} +
+ + {{#if isEditor}} +
+
+ delete +
+ {{/if}} + + {{#if isEditor}} + {{#dropdown-dialog target="delete-document-button" position="bottom right" button="Delete" color="flat-red" onAction=(action 'deleteDocument')}} +

Are you sure you want to delete this document?

+

There is no undo!

+ {{/dropdown-dialog}} {{#dropdown-dialog target="save-template-button" position="bottom right" button="Save" color="flat-green" onAction=(action 'saveTemplate') focusOn="new-template-name"}}