Have got adjusting processor arguments working
This commit is contained in:
parent
488942db2e
commit
f9a65c8ca9
6 changed files with 151 additions and 14 deletions
|
|
@ -24,9 +24,17 @@ const processorUIs = {
|
|||
"shadow": {
|
||||
label: "Shadow",
|
||||
template: Handlebars.compile(`
|
||||
<div class="mb-3">
|
||||
<label for="{{id}}_width" class="form-label">Colour</label>
|
||||
<input name="width" class="form-control" id="{{id}}_{{props.color}}" type="color" value="{{color}}" {{{submit_on id 'change'}}}>
|
||||
<div class="row mb-3 align-items-center">
|
||||
<label for="{{id}}_color" class="col-sm col-form-label">Colour</label>
|
||||
<div class="col-sm">
|
||||
<input name="color" class="form-control" id="{{id}}_color" type="color" value="{{props.color}}" {{{submit_on id 'change'}}}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="{{id}}_offset_y" class="col-sm col-form-label">Offset Y</label>
|
||||
<div class="col-sm">
|
||||
<input name="offset_y" class="form-control" id="{{id}}_{{props.color}}" type="number" value="{{props.offset_y}}" {{{submit_on id 'blur'}}}>
|
||||
</div>
|
||||
</div>
|
||||
`),
|
||||
},
|
||||
|
|
@ -67,10 +75,19 @@ export default class UploadEditController extends Controller {
|
|||
async removeProcessor(ev) {
|
||||
ev.preventDefault();
|
||||
let id = ev.params.id;
|
||||
console.log(ev.params);
|
||||
await this._removeProcessor(id);
|
||||
}
|
||||
|
||||
async updateProcessor(ev) {
|
||||
ev.preventDefault();
|
||||
let id = ev.params.id;
|
||||
|
||||
let paramParentEl = ev.target.closest('[data-role="processor-params"]');
|
||||
let params = Object.fromEntries(new FormData(paramParentEl).entries());
|
||||
|
||||
await this._updateProcessor(id, params);
|
||||
}
|
||||
|
||||
_rebuildProcessList() {
|
||||
let el = this.processListTarget;
|
||||
|
||||
|
|
@ -135,6 +152,25 @@ export default class UploadEditController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
async _updateProcessor(processorID, params) {
|
||||
await this._doReturningState(async () => {
|
||||
return (await fetch(`/sites/${this.siteIdValue}/imageedit/${this._state.session.guid}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
processor: {
|
||||
id: processorID,
|
||||
props: params,
|
||||
}
|
||||
})
|
||||
})).json();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
async _removeProcessor(processorID) {
|
||||
await this._doReturningState(async () => {
|
||||
return (await fetch(`/sites/${this.siteIdValue}/imageedit/${this._state.session.guid}/processors/${processorID}`, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue