2022-06-05 22:46:37 +02:00
|
|
|
import SpacedUpdate from "../../../services/spaced_update.js";
|
|
|
|
import AbstractBulkAction from "../abstract_bulk_action.js";
|
2021-01-19 22:10:24 +01:00
|
|
|
|
|
|
|
const TPL = `
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
Delete relation:
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<div style="display: flex; align-items: center">
|
2021-01-20 20:31:24 +01:00
|
|
|
<input type="text"
|
|
|
|
class="form-control relation-name"
|
|
|
|
pattern="[\\p{L}\\p{N}_:]+"
|
2021-01-26 14:10:34 +01:00
|
|
|
placeholder="relation name"
|
2021-01-20 20:31:24 +01:00
|
|
|
title="Alphanumeric characters, underscore and colon are allowed characters."/>
|
2021-01-19 22:10:24 +01:00
|
|
|
</div>
|
|
|
|
</td>
|
2021-01-26 14:10:34 +01:00
|
|
|
<td class="button-column">
|
2021-01-26 10:48:28 +01:00
|
|
|
<span class="bx bx-x icon-action action-conf-del"></span>
|
2021-01-19 22:10:24 +01:00
|
|
|
</td>
|
|
|
|
</tr>`;
|
|
|
|
|
2022-06-05 22:32:23 +02:00
|
|
|
export default class DeleteRelationBulkAction extends AbstractBulkAction {
|
2021-01-19 22:10:24 +01:00
|
|
|
static get actionName() { return "deleteRelation"; }
|
2022-06-03 17:29:08 +02:00
|
|
|
static get actionTitle() { return "Delete relation"; }
|
2021-01-19 22:10:24 +01:00
|
|
|
|
|
|
|
doRender() {
|
|
|
|
const $action = $(TPL);
|
|
|
|
const $relationName = $action.find('.relation-name');
|
|
|
|
$relationName.val(this.actionDef.relationName || "");
|
|
|
|
|
|
|
|
const spacedUpdate = new SpacedUpdate(async () => {
|
|
|
|
await this.saveAction({ relationName: $relationName.val() });
|
|
|
|
}, 1000)
|
|
|
|
|
|
|
|
$relationName.on('input', () => spacedUpdate.scheduleUpdate());
|
|
|
|
|
|
|
|
return $action;
|
|
|
|
}
|
|
|
|
}
|