mirror of
https://github.com/documize/community.git
synced 2025-07-20 13:49:42 +02:00
force space delete
This commit is contained in:
parent
300b617583
commit
cd543a1506
10 changed files with 119 additions and 16 deletions
|
@ -315,8 +315,8 @@ func (s Scope) MoveDocumentSpace(ctx domain.RequestContext, id, move string) (er
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete delete the document pages in the database, updates the search subsystem, deletes the associated revisions and attachments,
|
// Delete removes the specified document.
|
||||||
// audits the deletion, then finally deletes the document itself.
|
// Remove document pages, revisions, attachments, updates the search subsystem.
|
||||||
func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64, err error) {
|
func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64, err error) {
|
||||||
b := mysql.BaseQuery{}
|
b := mysql.BaseQuery{}
|
||||||
rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE from page WHERE documentid=\"%s\" AND orgid=\"%s\"", documentID, ctx.OrgID))
|
rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE from page WHERE documentid=\"%s\" AND orgid=\"%s\"", documentID, ctx.OrgID))
|
||||||
|
@ -337,3 +337,26 @@ func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64,
|
||||||
|
|
||||||
return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, documentID)
|
return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, documentID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete removes all documents for given space.
|
||||||
|
// Remove document pages, revisions, attachments, updates the search subsystem.
|
||||||
|
func (s Scope) DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows int64, err error) {
|
||||||
|
b := mysql.BaseQuery{}
|
||||||
|
rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE from page WHERE labelid=\"%s\" AND orgid=\"%s\"", spaceID, ctx.OrgID))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE from revision WHERE labelid=\"%s\" AND orgid=\"%s\"", spaceID, ctx.OrgID))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE from attachment WHERE labelid=\"%s\" AND orgid=\"%s\"", spaceID, ctx.OrgID))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, spaceID)
|
||||||
|
}
|
||||||
|
|
|
@ -474,7 +474,7 @@ func (h *Handler) Remove(w http.ResponseWriter, r *http.Request) {
|
||||||
response.WriteEmpty(w)
|
response.WriteEmpty(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes empty space.
|
// Delete removes space.
|
||||||
func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
method := "space.Delete"
|
method := "space.Delete"
|
||||||
ctx := domain.GetRequestContext(r)
|
ctx := domain.GetRequestContext(r)
|
||||||
|
@ -503,6 +503,14 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = h.Store.Document.DeleteBySpace(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Transaction.Rollback()
|
||||||
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = h.Store.Space.Delete(ctx, id)
|
_, err = h.Store.Space.Delete(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Transaction.Rollback()
|
ctx.Transaction.Rollback()
|
||||||
|
|
|
@ -244,8 +244,7 @@ func (s Scope) GetPermissions(ctx domain.RequestContext, spaceID string) (r []sp
|
||||||
func (s Scope) DeletePermissions(ctx domain.RequestContext, spaceID string) (rows int64, err error) {
|
func (s Scope) DeletePermissions(ctx domain.RequestContext, spaceID string) (rows int64, err error) {
|
||||||
b := mysql.BaseQuery{}
|
b := mysql.BaseQuery{}
|
||||||
|
|
||||||
sql := fmt.Sprintf("DELETE FROM permission WHERE orgid='%s' AND location='space' AND refid='%s'",
|
sql := fmt.Sprintf("DELETE FROM permission WHERE orgid='%s' AND location='space' AND refid='%s'", ctx.OrgID, spaceID)
|
||||||
ctx.OrgID, spaceID)
|
|
||||||
|
|
||||||
return b.DeleteWhere(ctx.Transaction, sql)
|
return b.DeleteWhere(ctx.Transaction, sql)
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ type DocumentStorer interface {
|
||||||
ChangeDocumentSpace(ctx RequestContext, document, space string) (err error)
|
ChangeDocumentSpace(ctx RequestContext, document, space string) (err error)
|
||||||
MoveDocumentSpace(ctx RequestContext, id, move string) (err error)
|
MoveDocumentSpace(ctx RequestContext, id, move string) (err error)
|
||||||
Delete(ctx RequestContext, documentID string) (rows int64, err error)
|
Delete(ctx RequestContext, documentID string) (rows int64, err error)
|
||||||
|
DeleteBySpace(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SettingStorer defines required methods for persisting global and user level settings
|
// SettingStorer defines required methods for persisting global and user level settings
|
||||||
|
|
|
@ -33,6 +33,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
||||||
pinId: '',
|
pinId: '',
|
||||||
newName: '',
|
newName: '',
|
||||||
},
|
},
|
||||||
|
deleteSpaceName: '',
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
let targets = _.reject(this.get('folders'), {
|
let targets = _.reject(this.get('folders'), {
|
||||||
|
@ -108,6 +109,23 @@ export default Ember.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);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
{{folder/folder-toolbar folders=model.folders folder=model.folder
|
{{folder/folder-toolbar folders=model.folders folder=model.folder
|
||||||
permissions=model.permissions hasSelectedDocuments=hasSelectedDocuments
|
permissions=model.permissions hasSelectedDocuments=hasSelectedDocuments
|
||||||
onDeleteDocument=(action 'onDeleteDocument') onMoveDocument=(action 'onMoveDocument')}}
|
onDeleteDocument=(action 'onDeleteDocument') onMoveDocument=(action 'onMoveDocument')
|
||||||
|
onDeleteSpace=(action 'onDeleteSpace')}}
|
||||||
|
|
||||||
{{folder/documents-list documents=model.documents folders=model.folders folder=model.folder templates=model.templates
|
{{folder/documents-list documents=model.documents folders=model.folders folder=model.folder templates=model.templates
|
||||||
permissions=model.permissions selectedDocuments=(mut selectedDocuments)
|
permissions=model.permissions selectedDocuments=(mut selectedDocuments)
|
||||||
|
|
15
gui/app/pods/folder/settings/category/controller.js
Normal file
15
gui/app/pods/folder/settings/category/controller.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
export default Ember.Controller.extend({
|
||||||
|
});
|
25
gui/app/pods/folder/settings/category/route.js
Normal file
25
gui/app/pods/folder/settings/category/route.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||||
|
|
||||||
|
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||||
|
model() {
|
||||||
|
this.get('browser').setTitle(this.modelFor('folder').folder.get('name'));
|
||||||
|
|
||||||
|
return Ember.RSVP.hash({
|
||||||
|
folder: this.modelFor('folder').folder,
|
||||||
|
permissions: this.modelFor('folder').permissions,
|
||||||
|
folders: this.modelFor('folder').folders
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
1
gui/app/pods/folder/settings/category/template.hbs
Normal file
1
gui/app/pods/folder/settings/category/template.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{folder/invite-user folders=model.folders folder=model.folder}}
|
|
@ -35,7 +35,18 @@
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
|
{{#if pinState.isPinned}}
|
||||||
|
<div class="round-button button-gray" id="space-unpin-button" data-tooltip="Unpin space" data-tooltip-position="top center" {{action 'onUnpin'}}>
|
||||||
|
<i class="material-icons">favorite</i>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="round-button button-gray" id="space-pin-button" data-tooltip="Pin space" data-tooltip-position="top center">
|
||||||
|
<i class="material-icons">favorite_border</i>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if permissions.spaceManage}}
|
{{#if permissions.spaceManage}}
|
||||||
|
<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}}
|
||||||
<div class="round-button button-blue" id="space-settings-button" data-tooltip="Manage permissions" data-tooltip-position="top center">
|
<div class="round-button button-blue" id="space-settings-button" data-tooltip="Manage permissions" data-tooltip-position="top center">
|
||||||
<i class="material-icons">settings</i>
|
<i class="material-icons">settings</i>
|
||||||
|
@ -50,16 +61,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if pinState.isPinned}}
|
{{#unless pinState.isPinned}}
|
||||||
<div class="button-gap"></div>
|
|
||||||
<div class="round-button button-gray" id="space-unpin-button" data-tooltip="Pin space" data-tooltip-position="top center" {{action 'onUnpin'}}>
|
|
||||||
<i class="material-icons">favorite</i>
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
<div class="button-gap"></div>
|
|
||||||
<div class="round-button button-gray" id="space-pin-button" data-tooltip="Pin space" data-tooltip-position="top center">
|
|
||||||
<i class="material-icons">favorite_border</i>
|
|
||||||
</div>
|
|
||||||
{{#dropdown-dialog target="space-pin-button" position="bottom right" button="Pin" color="flat-green" onAction=(action 'onPin') focusOn="pin-space-name" }}
|
{{#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">
|
<div class="input-control">
|
||||||
<label>Pin Space</label>
|
<label>Pin Space</label>
|
||||||
|
@ -67,6 +69,16 @@
|
||||||
{{input type='text' id="pin-space-name" value=pinState.newName}}
|
{{input type='text' id="pin-space-name" value=pinState.newName}}
|
||||||
</div>
|
</div>
|
||||||
{{/dropdown-dialog}}
|
{{/dropdown-dialog}}
|
||||||
|
{{/unless}}
|
||||||
|
|
||||||
|
{{#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 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}}
|
{{/if}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue