Skip to content

Commit

Permalink
fix #281 reset group/sort
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Apr 6, 2020
1 parent 05034e0 commit 8eb7574
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/ui/dialogs/GroupDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ function sortOrder(node: HTMLElement, column: Column, idPrefix: string): IToolba
elems: `input[name=grouped], #${id}P`,
submit() {
const enabled = node.querySelector<HTMLInputElement>('input[name=grouped]:checked')!.value === 'true';
const order = Number.parseInt(node.querySelector<HTMLInputElement>(`#${id}P`)!.value, 10);
const order = Number.parseInt(node.querySelector<HTMLInputElement>(`#${id}P`)!.value, 10) - 1;
ranking.groupBy(column, !enabled ? -1 : order);
return true;
},
reset() {
// things need to be done?
node.querySelector<HTMLInputElement>('input[name=grouped][value=false]')!.checked = true;
node.querySelector<HTMLInputElement>(`#${id}P`)!.value = (current.length + (!enabled ? 1 : 0)).toString();
updateDisabled(true);
},
cancel() {
ranking.groupBy(column, current.indexOf(column));
Expand Down
6 changes: 4 additions & 2 deletions src/ui/dialogs/SortDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function sortOrder(node: HTMLElement, column: Column, idPrefix: string, groupSor
elems: `input[name=sortorder], #${id}P`,
submit() {
const asc = node.querySelector<HTMLInputElement>('input[name=sortorder]:checked')!.value;
const priority = Number.parseInt(node.querySelector<HTMLInputElement>(`#${id}P`)!.value, 10);
const priority = Number.parseInt(node.querySelector<HTMLInputElement>(`#${id}P`)!.value, 10) - 1;

if (groupSortBy) {
ranking.groupSortBy(column, asc === 'asc', asc === 'none' ? -1 : priority);
Expand All @@ -97,7 +97,9 @@ function sortOrder(node: HTMLElement, column: Column, idPrefix: string, groupSor
return true;
},
reset() {
// things need to be done?
node.querySelector<HTMLInputElement>('input[name=sortorder][value=none]')!.checked = true;
node.querySelector<HTMLInputElement>(`#${id}P`)!.value = (current.length + (order.priority === undefined ? 1 : 0)).toString();
updateDisabled(true);
},
cancel() {
if (groupSortBy) {
Expand Down

0 comments on commit 8eb7574

Please sign in to comment.