import SpacedUpdate from "../../../services/spaced_update.js"; import AbstractBulkAction from "../abstract_bulk_action.js"; import noteAutocompleteService from "../../../services/note_autocomplete.js"; const TPL = `
Move note
to
`; export default class MoveNoteBulkAction extends AbstractBulkAction { static get actionName() { return "moveNote"; } static get actionTitle() { return "Move note"; } doRender() { const $action = $(TPL); const $targetParentNote = $action.find('.target-parent-note'); noteAutocompleteService.initNoteAutocomplete($targetParentNote); $targetParentNote.setNote(this.actionDef.targetParentNoteId); $targetParentNote.on('autocomplete:closed', () => spacedUpdate.scheduleUpdate()); const spacedUpdate = new SpacedUpdate(async () => { await this.saveAction({ targetParentNoteId: $targetParentNote.getSelectedNoteId() }); }, 1000) $targetParentNote.on('input', () => spacedUpdate.scheduleUpdate()); return $action; } }