2022-06-12 23:29:11 +02:00
|
|
|
import SpacedUpdate from "../../../services/spaced_update.js";
|
|
|
|
import AbstractBulkAction from "../abstract_bulk_action.js";
|
2024-07-30 09:40:02 +08:00
|
|
|
import { t } from "../../../services/i18n.js";
|
2022-06-12 23:29:11 +02:00
|
|
|
|
|
|
|
const TPL = `
|
|
|
|
<tr>
|
|
|
|
<td colspan="2">
|
|
|
|
<div style="display: flex; align-items: center">
|
2024-07-30 09:40:02 +08:00
|
|
|
<div style="margin-right: 10px; flex-shrink: 0;">${t('rename_note.rename_note_title_to')}</div>
|
2022-06-12 23:29:11 +02:00
|
|
|
|
|
|
|
<input type="text"
|
|
|
|
class="form-control new-title"
|
2024-07-30 09:40:02 +08:00
|
|
|
placeholder="${t('rename_note.new_note_title')}"
|
|
|
|
title="${t('rename_note.click_help_icon')}"/>
|
2022-06-12 23:29:11 +02:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td class="button-column">
|
|
|
|
<div class="dropdown help-dropdown">
|
|
|
|
<span class="bx bx-help-circle icon-action" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
|
|
|
<div class="dropdown-menu dropdown-menu-right p-4">
|
2024-07-30 09:40:02 +08:00
|
|
|
<p>${t('rename_note.evaluated_as_js_string')}</p>
|
2022-06-12 23:29:11 +02:00
|
|
|
|
|
|
|
<ul>
|
2024-07-30 09:40:02 +08:00
|
|
|
<li>${t('rename_note.example_note')}</li>
|
|
|
|
<li>${t('rename_note.example_new_title')}</li>
|
|
|
|
<li>${t('rename_note.example_date_prefix')}</li>
|
2022-06-12 23:29:11 +02:00
|
|
|
</ul>
|
|
|
|
|
2024-07-30 09:40:02 +08:00
|
|
|
${t('rename_note.api_docs')}
|
2022-06-12 23:29:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<span class="bx bx-x icon-action action-conf-del"></span>
|
|
|
|
</td>
|
|
|
|
</tr>`;
|
|
|
|
|
|
|
|
export default class RenameNoteBulkAction extends AbstractBulkAction {
|
|
|
|
static get actionName() { return "renameNote"; }
|
2024-07-30 09:40:02 +08:00
|
|
|
static get actionTitle() { return t('rename_note.rename_note'); }
|
2022-06-12 23:29:11 +02:00
|
|
|
|
|
|
|
doRender() {
|
|
|
|
const $action = $(TPL);
|
|
|
|
|
|
|
|
const $newTitle = $action.find('.new-title');
|
|
|
|
$newTitle.val(this.actionDef.newTitle || "");
|
|
|
|
|
|
|
|
const spacedUpdate = new SpacedUpdate(async () => {
|
|
|
|
await this.saveAction({
|
|
|
|
newTitle: $newTitle.val(),
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
$newTitle.on('input', () => spacedUpdate.scheduleUpdate());
|
|
|
|
|
|
|
|
return $action;
|
|
|
|
}
|
|
|
|
}
|