From 599a803bc4ced58897a9a82f574a13b9a102b8e4 Mon Sep 17 00:00:00 2001 From: Jeremy Zagorski Date: Wed, 18 Apr 2018 15:12:20 -0400 Subject: [PATCH 1/4] fix(editors): use indexOf in multiple select editor to load value indexOf must be used because defaultValue is an array. the current state is broken and values are not loaded when the multiple select list is opened --- .../src/aurelia-slickgrid/editors/multipleSelectEditor.ts | 2 +- aurelia-slickgrid/src/examples/slickgrid/example3.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts b/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts index 178c3be75..de87d70dc 100644 --- a/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts +++ b/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts @@ -130,7 +130,7 @@ export class MultipleSelectEditor implements Editor { this.defaultValue = item[this.columnDef.field].map((i: any) => i.toString()); this.$editorElm.find('option').each((i: number, $e: any) => { - if (this.defaultValue === $e.value) { + if (this.defaultValue.indexOf($e.value) !== -1) { $e.selected = true; } else { $e.selected = false; diff --git a/aurelia-slickgrid/src/examples/slickgrid/example3.ts b/aurelia-slickgrid/src/examples/slickgrid/example3.ts index 5972674b4..15bf7f989 100644 --- a/aurelia-slickgrid/src/examples/slickgrid/example3.ts +++ b/aurelia-slickgrid/src/examples/slickgrid/example3.ts @@ -159,7 +159,7 @@ export class Example3 { type: FieldType.string, editor: Editors.multipleSelect, params: { - collection: Array.from(Array(10).keys()).map(k => ({ value: `Task ${k}`, label: `Task ${k}` })), + collection: Array.from(Array(12).keys()).map(k => ({ value: `Task ${k}`, label: `Task ${k}` })), collectionSortBy: { property: 'label', sortDesc: true @@ -213,7 +213,7 @@ export class Example3 { start: new Date(randomYear, randomMonth, randomDay), finish: new Date(randomYear, (randomMonth + 1), randomDay), effortDriven: (i % 5 === 0), - prerequisites: (i % 5 === 0) && i > 0 ? [`Task ${i}`, `Task ${i - 1}`] : [] + prerequisites: (i % 2 === 0) && i !== 0 && i < 12 ? [`Task ${i}`, `Task ${i - 1}`] : [] }; } this.dataset = mockedDataset; From cea580e1175158ce37a2a99b47085d0449b60300 Mon Sep 17 00:00:00 2001 From: Jeremy Zagorski Date: Mon, 14 May 2018 10:14:16 -0400 Subject: [PATCH 2/4] refactor(examples): add sortBy in filter examples in 4, 12 --- aurelia-slickgrid/src/examples/slickgrid/example12.ts | 3 ++- aurelia-slickgrid/src/examples/slickgrid/example4.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/aurelia-slickgrid/src/examples/slickgrid/example12.ts b/aurelia-slickgrid/src/examples/slickgrid/example12.ts index 2ba043e7b..9b95216c8 100644 --- a/aurelia-slickgrid/src/examples/slickgrid/example12.ts +++ b/aurelia-slickgrid/src/examples/slickgrid/example12.ts @@ -79,7 +79,8 @@ export class Example12 { filter: { collection: [{ value: '', label: '' }, { value: 'TRUE', labelKey: 'TRUE' }, { value: 'FALSE', labelKey: 'FALSE' }], collectionSortBy: { - property: 'labelKey' // will sort by translated value since "enableTranslateLabel" is true + property: 'labelKey', // will sort by translated value since "enableTranslateLabel" is true + sortDesc: true }, type: FilterType.singleSelect, enableTranslateLabel: true, diff --git a/aurelia-slickgrid/src/examples/slickgrid/example4.ts b/aurelia-slickgrid/src/examples/slickgrid/example4.ts index 202621a0d..b917c0db1 100644 --- a/aurelia-slickgrid/src/examples/slickgrid/example4.ts +++ b/aurelia-slickgrid/src/examples/slickgrid/example4.ts @@ -81,6 +81,11 @@ export class Example4 { filterable: true, filter: { collection: multiSelectFilterArray, + collectionSortBy: { + property: 'value', + sortDesc: true, + fieldType: FieldType.number + }, type: FilterType.multipleSelect, searchTerms: [1, 33, 50], // default selection // we could add certain option(s) to the "multiple-select" plugin @@ -124,6 +129,7 @@ export class Example4 { ]; this.gridOptions = { + params: {}, autoResize: { containerId: 'demo-container', sidePadding: 15 From 1919bfdba8b315bebdc8ba404e4cd08e54524806 Mon Sep 17 00:00:00 2001 From: Jeremy Zagorski Date: Mon, 14 May 2018 13:47:04 -0400 Subject: [PATCH 3/4] refactor: remove gridOptions.params check before filter/sort this was not used, but we should check for columnDef.filter or columnDef.params, whichever is being used --- .../src/aurelia-slickgrid/editors/multipleSelectEditor.ts | 2 +- .../src/aurelia-slickgrid/editors/singleSelectEditor.ts | 2 +- .../src/aurelia-slickgrid/filters/multipleSelectFilter.ts | 2 +- .../src/aurelia-slickgrid/filters/singleSelectFilter.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts b/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts index de87d70dc..aa37d3fbc 100644 --- a/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts +++ b/aurelia-slickgrid/src/aurelia-slickgrid/editors/multipleSelectEditor.ts @@ -106,7 +106,7 @@ export class MultipleSelectEditor implements Editor { } // user might want to sort the collection - if (this.gridOptions && this.gridOptions.params && this.columnDef.params.collectionSortBy) { + if (this.columnDef.params && this.columnDef.params.collectionSortBy) { const sortBy = this.columnDef.params.collectionSortBy; newCollection = this.collectionService.sortCollection(newCollection, sortBy, this.enableTranslateLabel); } diff --git a/aurelia-slickgrid/src/aurelia-slickgrid/editors/singleSelectEditor.ts b/aurelia-slickgrid/src/aurelia-slickgrid/editors/singleSelectEditor.ts index 927de4df2..bed47e619 100644 --- a/aurelia-slickgrid/src/aurelia-slickgrid/editors/singleSelectEditor.ts +++ b/aurelia-slickgrid/src/aurelia-slickgrid/editors/singleSelectEditor.ts @@ -98,7 +98,7 @@ export class SingleSelectEditor implements Editor { } // user might want to sort the collection - if (this.gridOptions.params && this.columnDef.params.collectionSortBy) { + if (this.columnDef.params && this.columnDef.params.collectionSortBy) { const sortBy = this.columnDef.params.collectionSortBy; newCollection = this.collectionService.sortCollection(newCollection, sortBy, this.enableTranslateLabel); } diff --git a/aurelia-slickgrid/src/aurelia-slickgrid/filters/multipleSelectFilter.ts b/aurelia-slickgrid/src/aurelia-slickgrid/filters/multipleSelectFilter.ts index f7ba25e89..babebcce4 100644 --- a/aurelia-slickgrid/src/aurelia-slickgrid/filters/multipleSelectFilter.ts +++ b/aurelia-slickgrid/src/aurelia-slickgrid/filters/multipleSelectFilter.ts @@ -92,7 +92,7 @@ export class MultipleSelectFilter implements Filter { } // user might want to sort the collection - if (this.gridOptions.params && this.columnDef.filter.collectionSortBy) { + if (this.columnDef.filter && this.columnDef.filter.collectionSortBy) { const sortBy = this.columnDef.filter.collectionSortBy; newCollection = this.collectionService.sortCollection(newCollection, sortBy, this.enableTranslateLabel); } diff --git a/aurelia-slickgrid/src/aurelia-slickgrid/filters/singleSelectFilter.ts b/aurelia-slickgrid/src/aurelia-slickgrid/filters/singleSelectFilter.ts index 453bd3538..88d66a907 100644 --- a/aurelia-slickgrid/src/aurelia-slickgrid/filters/singleSelectFilter.ts +++ b/aurelia-slickgrid/src/aurelia-slickgrid/filters/singleSelectFilter.ts @@ -84,7 +84,7 @@ export class SingleSelectFilter implements Filter { } // user might want to sort the collection - if (this.gridOptions.params && this.columnDef.filter.collectionSortBy) { + if (this.columnDef.filter && this.columnDef.filter.collectionSortBy) { const sortBy = this.columnDef.filter.collectionSortBy; newCollection = this.collectionService.sortCollection(newCollection, sortBy, this.enableTranslateLabel); } From b0c981574c6a5a2401d560d1e573e4e9128137d4 Mon Sep 17 00:00:00 2001 From: Jeremy Zagorski Date: Tue, 15 May 2018 12:26:14 -0400 Subject: [PATCH 4/4] refactor(examples): remove empty gridOptions.params property was added to show example with sorting/filtering before service logic was changed to now check gridOptions.params --- aurelia-slickgrid/src/examples/slickgrid/example4.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/aurelia-slickgrid/src/examples/slickgrid/example4.ts b/aurelia-slickgrid/src/examples/slickgrid/example4.ts index b917c0db1..4473e46f0 100644 --- a/aurelia-slickgrid/src/examples/slickgrid/example4.ts +++ b/aurelia-slickgrid/src/examples/slickgrid/example4.ts @@ -129,7 +129,6 @@ export class Example4 { ]; this.gridOptions = { - params: {}, autoResize: { containerId: 'demo-container', sidePadding: 15