check authorship to exclude editing possibility before starting

This commit is contained in:
dcore94 2022-07-21 18:58:14 +02:00
parent 4bc4769231
commit be9273af73
1 changed files with 14 additions and 6 deletions

View File

@ -292,6 +292,18 @@ class CCPMethodEditorController extends HTMLElement{
this.render()
}
cloneOrEditMethod(method){
const subject = this.#boot.subject
const matchingauthors = method.metadata ? method.metadata.filter(md=>md.role === "author" && md.href.endsWith("/" + subject)).length : 0
if(matchingauthors === 0) this.cloneMethod(method.id);
else
if(window.confirm("Do you want to create a new clone?")){
this.cloneMethod(method.id)
} else {
this.editMethod(method.id)
}
}
cloneMethod(method){
if(this.#locked) return;
this.lockRender()
@ -499,15 +511,11 @@ class CCPMethodEditorController extends HTMLElement{
this.#rootdoc.addEventListener("drop", ev=>{
if(ev.dataTransfer && ev.dataTransfer.getData('text/plain+ccpmethod')){
const id = ev.dataTransfer.getData('text/plain+ccpmethod')
const method = JSON.parse(ev.dataTransfer.getData('application/json+ccpmethod'))
ev.stopImmediatePropagation()
ev.preventDefault()
ev.stopPropagation()
if(window.confirm("Do you want to create a new clone?")){
this.cloneMethod(id)
} else {
this.editMethod(id)
}
this.cloneOrEditMethod(method)
}
})