Skip to content

Commit

Permalink
openDialog/closeDialog accepts variadic list of arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Jun 17, 2024
1 parent e9cec24 commit 7a4d8b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions client/django-formset/FormDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export abstract class FormDialog {
this.element.addEventListener('close', () => this.closeDialog(), {once: true});
}

protected closeDialog(returnValue?: string) {
this.element.close(returnValue);
protected closeDialog(...args: any[]) {
this.element.close(args[1]);
}

private handlePointerDown = (event: PointerEvent | TouchEvent) => {
private handlePointerDown = (event: PointerEvent|TouchEvent) => {
const viewport = window.visualViewport!;
const dialogRect = this.dialogRect!;
const dialogHeaderElement = this.dialogHeaderElement!;
Expand Down
20 changes: 10 additions & 10 deletions client/django-formset/RichtextArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,11 +774,11 @@ class RichtextFormDialog extends FormDialog {
this.richtext.textAreaElement.dispatchEvent(new Event('blur', {bubbles: true}));
}

protected closeDialog(returnValue?: string) {
if (!returnValue)
protected closeDialog(...args: any[]) {
if (!isString(args[1]))
return;
const editor = this.richtext.editor;
if (returnValue === 'apply') {
if (args[1] === 'apply') {
this.formElement.dispatchEvent(new Event('submit', {bubbles: true}));
if (!this.formElement.checkValidity()) {
// checkValidity() triggers the invalid event for each invalid input field
Expand All @@ -798,7 +798,7 @@ class RichtextFormDialog extends FormDialog {
attributes = {...attributes, ...mapFunction(this.formElement.elements)};
});
this.applyAttributes(editor, attributes);
} else if (returnValue === 'revert') {
} else if (args[1] === 'revert') {
this.revertAttributes(editor);
}
// reset form to be pristine for the next invocation
Expand Down Expand Up @@ -833,8 +833,8 @@ class RichtextFormDialog extends FormDialog {
editor.chain().focus().deleteRange({from, to}).run();
}

public updateOperability(action?: string) {
super.updateOperability(action);
public updateOperability(...args: any[]) {
super.updateOperability(...args);
if (this.applyButton?.hasAttribute('auto-disable')) {
this.applyButton.disabled = !this.formElement.checkValidity();
}
Expand Down Expand Up @@ -1136,8 +1136,8 @@ class RichtextArea {
return this.useJson ? this.editor.getJSON() : this.editor.getHTML();
}

public updateOperability(action: string) : void {
this.formDialogs.forEach(dialog => dialog.updateOperability(action));
public updateOperability(...args: any[]) : void {
this.formDialogs.forEach(dialog => dialog.updateOperability(...args));
}
}

Expand Down Expand Up @@ -1173,7 +1173,7 @@ export class RichTextAreaElement extends HTMLTextAreaElement {
return this[RA].isInitialized;
}

public updateOperability(action: string) : void {
this[RA].updateOperability(action);
public updateOperability(...args: any[]) : void {
this[RA].updateOperability(...args);
}
}

0 comments on commit 7a4d8b0

Please sign in to comment.