Skip to content

Commit

Permalink
adapt demo and only false is invalid submission
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Mar 31, 2020
1 parent 8a2607b commit 08c6b27
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
13 changes: 11 additions & 2 deletions demo/custom_column.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@
<input type="number" name="count" step="1" min="1" value="${val}">
`);
const input = node.lastElementChild;
input.onchange = () => {
col.setFirstN(input.valueAsNumber);
return {
elems: [input],
submit() {
col.setFirstN(input.valueAsNumber);
},
cancel() {
col.setFirstN(val);
},
reset() {
input.value = '1';
}
};
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/ui/dialogs/ADialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ abstract class ADialog {
if (!this.node.checkValidity()) {
return false;
}
if (this.submit()) {
if (this.submit() !== false) {
this.destroy('confirm');
}
return false;
Expand Down Expand Up @@ -177,7 +177,7 @@ abstract class ADialog {

protected abstract reset(): void;

protected abstract submit(): boolean;
protected abstract submit(): boolean | undefined;

protected abstract cancel(): void;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/AddonDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class AddonDialog extends ADialog {

protected submit(): boolean {
for (const handler of this.handlers) {
if (!handler.submit()) {
if (handler.submit() === false) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/GroupDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class GroupDialog extends ADialog {

protected submit() {
for (const handler of this.handlers) {
if (!handler.submit()) {
if (handler.submit() === false) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/SortDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class SortDialog extends ADialog {

protected submit() {
for (const handler of this.handlers) {
if (!handler.submit()) {
if (handler.submit() === false) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface IToolbarAction {
export interface IToolbarDialogAddonHandler {
elems: string | (HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement)[];
reset(): void;
submit(): boolean;
submit(): boolean | undefined;
cancel(): void;
}

Expand Down

0 comments on commit 08c6b27

Please sign in to comment.