| 
									
										
										
										
											2024-07-30 09:40:02 +08:00
										 |  |  | import { t } from "../../../services/i18n.js"; | 
					
						
							| 
									
										
										
										
											2022-06-05 22:46:37 +02:00
										 |  |  | import SpacedUpdate from "../../../services/spaced_update.js"; | 
					
						
							|  |  |  | import AbstractBulkAction from "../abstract_bulk_action.js"; | 
					
						
							|  |  |  | import noteAutocompleteService from "../../../services/note_autocomplete.js"; | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | const TPL = `
 | 
					
						
							|  |  |  | <tr> | 
					
						
							|  |  |  |     <td colspan="2"> | 
					
						
							|  |  |  |         <div style="display: flex; align-items: center"> | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |             <div style="margin-right: 10px;" class="text-nowrap">${t("move_note.move_note")}</div>  | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |                              | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |             <div style="margin-right: 10px;" class="text-nowrap">${t("move_note.to")}</div> | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |              | 
					
						
							|  |  |  |             <div class="input-group"> | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |                 <input type="text" class="form-control target-parent-note" placeholder="${t("move_note.target_parent_note")}"/> | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |             </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |     </td> | 
					
						
							|  |  |  |     <td class="button-column"> | 
					
						
							|  |  |  |         <div class="dropdown help-dropdown"> | 
					
						
							| 
									
										
										
										
											2024-09-03 17:08:07 +02:00
										 |  |  |             <span class="bx bx-help-circle icon-action" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span> | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |             <div class="dropdown-menu dropdown-menu-right p-4"> | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |                 <p>${t("move_note.on_all_matched_notes")}:</p> | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |                  | 
					
						
							| 
									
										
										
										
											2024-09-03 17:08:07 +02:00
										 |  |  |                 <ul style="margin-bottom: 0;"> | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |                     <li>${t("move_note.move_note_new_parent")}</li> | 
					
						
							|  |  |  |                     <li>${t("move_note.clone_note_new_parent")}</li> | 
					
						
							|  |  |  |                     <li>${t("move_note.nothing_will_happen")}</li> | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |                 </ul> | 
					
						
							|  |  |  |             </div>  | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |         <span class="bx bx-x icon-action action-conf-del"></span> | 
					
						
							|  |  |  |     </td> | 
					
						
							|  |  |  | </tr>`;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-05 22:32:23 +02:00
										 |  |  | export default class MoveNoteBulkAction extends AbstractBulkAction { | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     static get actionName() { | 
					
						
							|  |  |  |         return "moveNote"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     static get actionTitle() { | 
					
						
							|  |  |  |         return t("move_note.move_note"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     doRender() { | 
					
						
							|  |  |  |         const $action = $(TPL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |         const $targetParentNote = $action.find(".target-parent-note"); | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  |         noteAutocompleteService.initNoteAutocomplete($targetParentNote); | 
					
						
							|  |  |  |         $targetParentNote.setNote(this.actionDef.targetParentNoteId); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |         $targetParentNote.on("autocomplete:closed", () => spacedUpdate.scheduleUpdate()); | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const spacedUpdate = new SpacedUpdate(async () => { | 
					
						
							|  |  |  |             await this.saveAction({ | 
					
						
							|  |  |  |                 targetParentNoteId: $targetParentNote.getSelectedNoteId() | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |         }, 1000); | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |         $targetParentNote.on("input", () => spacedUpdate.scheduleUpdate()); | 
					
						
							| 
									
										
										
										
											2022-02-05 12:06:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return $action; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |