check authorship to exclude editing possibility before starting
This commit is contained in:
parent
4bc4769231
commit
be9273af73
|
@ -292,6 +292,18 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
this.render()
|
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){
|
cloneMethod(method){
|
||||||
if(this.#locked) return;
|
if(this.#locked) return;
|
||||||
this.lockRender()
|
this.lockRender()
|
||||||
|
@ -499,15 +511,11 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
|
|
||||||
this.#rootdoc.addEventListener("drop", ev=>{
|
this.#rootdoc.addEventListener("drop", ev=>{
|
||||||
if(ev.dataTransfer && ev.dataTransfer.getData('text/plain+ccpmethod')){
|
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.stopImmediatePropagation()
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
ev.stopPropagation()
|
ev.stopPropagation()
|
||||||
if(window.confirm("Do you want to create a new clone?")){
|
this.cloneOrEditMethod(method)
|
||||||
this.cloneMethod(id)
|
|
||||||
} else {
|
|
||||||
this.editMethod(id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue