( context: TaskModalActionButtonContext, options: CreateTaskModalActionButtonsOptions )
| 17 | } |
| 18 | |
| 19 | export function createTaskModalActionButtons( |
| 20 | context: TaskModalActionButtonContext, |
| 21 | options: CreateTaskModalActionButtonsOptions |
| 22 | ): HTMLElement { |
| 23 | const buttonContainer = options.container.createDiv( |
| 24 | "modal-button-container tn-task-modal__button-bar" |
| 25 | ); |
| 26 | |
| 27 | for (const buttonConfig of options.leadingButtons ?? []) { |
| 28 | const button = buttonContainer.createEl("button", { |
| 29 | cls: buttonConfig.className, |
| 30 | text: buttonConfig.text, |
| 31 | }); |
| 32 | button.addEventListener("click", buttonConfig.onClick); |
| 33 | } |
| 34 | |
| 35 | const saveButton = buttonContainer.createEl("button", { |
| 36 | cls: "mod-cta", |
| 37 | text: context.translate("modals.task.buttons.save"), |
| 38 | }); |
| 39 | |
| 40 | saveButton.addEventListener("click", () => { |
| 41 | void runTaskModalSaveAction(saveButton, options.onSave, options.onSaved); |
| 42 | }); |
| 43 | |
| 44 | const cancelButton = buttonContainer.createEl("button", { |
| 45 | text: context.translate("common.cancel"), |
| 46 | }); |
| 47 | |
| 48 | cancelButton.addEventListener("click", options.onCancel); |
| 49 | |
| 50 | return buttonContainer; |
| 51 | } |
| 52 | |
| 53 | export async function runTaskModalSaveAction( |
| 54 | saveButton: HTMLButtonElement, |
no test coverage detected