Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(editor): move all Editor params into editor
- instead of using the generic "params" to pass collection and other arguments, we will use the "editor" object - doing this brings TS types and intellisense
- Loading branch information
1 parent
e9306b3
commit 0ca7bf8
Showing
19 changed files
with
372 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
aurelia-slickgrid/src/aurelia-slickgrid/filters/compoundInputFilter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
aurelia-slickgrid/src/aurelia-slickgrid/formatters/collectionEditorFormatter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { arrayToCsvFormatter } from './arrayToCsvFormatter'; | ||
import { Column, Formatter } from './../models/index'; | ||
import { findOrDefault } from '../services/index'; | ||
|
||
/** | ||
* A formatter to show the label property value of a internalColumnEditor collection | ||
*/ | ||
export const collectionEditorFormatter: Formatter = (row: number, cell: number, value: any, columnDef: Column, dataContext: any) => { | ||
if (!value || !columnDef || !columnDef.internalColumnEditor || !columnDef.internalColumnEditor.collection | ||
|| !columnDef.internalColumnEditor.collection.length) { | ||
return ''; | ||
} | ||
|
||
const { internalColumnEditor, internalColumnEditor: { collection } } = columnDef; | ||
const labelName = (internalColumnEditor.customStructure) ? internalColumnEditor.customStructure.label : 'label'; | ||
const valueName = (internalColumnEditor.customStructure) ? internalColumnEditor.customStructure.value : 'value'; | ||
|
||
if (Array.isArray(value)) { | ||
return arrayToCsvFormatter(row, | ||
cell, | ||
value.map((v: any) => findOrDefault(collection, (c: any) => c[valueName] === v)[labelName]), | ||
columnDef, | ||
dataContext); | ||
} | ||
|
||
return findOrDefault(collection, (c: any) => c[valueName] === value)[labelName] || ''; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
aurelia-slickgrid/src/aurelia-slickgrid/models/columnEditor.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { EditorType } from './editorType.enum'; | ||
import { TextEditor } from './../editors/textEditor'; | ||
import { SingleSelectEditor } from './../editors/singleSelectEditor'; | ||
import { MultipleSelectEditor } from './../editors/multipleSelectEditor'; | ||
import { LongTextEditor } from './../editors/longTextEditor'; | ||
import { IntegerEditor } from './../editors/integerEditor'; | ||
import { FloatEditor } from './../editors/floatEditor'; | ||
import { DateEditor } from './../editors/dateEditor'; | ||
import { CheckboxEditor } from './../editors/checkboxEditor'; | ||
import { | ||
CollectionFilterBy, | ||
CollectionSortBy, | ||
Editor, | ||
MultipleSelectOption | ||
} from './../models/index'; | ||
|
||
export interface ColumnEditor { | ||
/** Custom Editor */ | ||
customEditor?: any; | ||
|
||
/** Editor Type to use (input, multipleSelect, singleSelect, select, custom) */ | ||
type?: EditorType; | ||
|
||
collection?: any[]; | ||
|
||
/** We could filter some items from the collection */ | ||
collectionFilterBy?: CollectionFilterBy; | ||
|
||
/** We could sort the collection by their value, or by translated value when enableTranslateLabel is True */ | ||
collectionSortBy?: CollectionSortBy; | ||
|
||
/** Options that could be provided to the Editor, example: { container: 'body', maxHeight: 250} */ | ||
editorOptions?: MultipleSelectOption | any; | ||
|
||
/** Do we want the Editor to handle translation (localization)? */ | ||
enableTranslateLabel?: boolean; | ||
|
||
/** A custom structure can be used instead of the default label/value pair. Commonly used with Select/Multi-Select Editor */ | ||
customStructure?: { | ||
label: string; | ||
value: string; | ||
}; | ||
|
||
/** | ||
* Use "params" to pass any type of arguments to your Custom Editor (type: EditorType.custom) | ||
* or regular Editor like the EditorType.float | ||
* for example, to pass the option collection to a select Filter we can type this: | ||
* params: { decimalPlaces: 2 } | ||
*/ | ||
params?: any; | ||
} |
28 changes: 28 additions & 0 deletions
28
aurelia-slickgrid/src/aurelia-slickgrid/models/editorType.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export enum EditorType { | ||
/** Custom Editor type */ | ||
custom, | ||
|
||
/** Checkbox Editor */ | ||
checkbox, | ||
|
||
/** Date Picker Editor */ | ||
date, | ||
|
||
/** Float Editor */ | ||
float, | ||
|
||
/** Integer Editor */ | ||
integer, | ||
|
||
/** Long Text Editor */ | ||
longText, | ||
|
||
/** Multiple Select Editor */ | ||
multipleSelect, | ||
|
||
/** Single Select Editor */ | ||
singleSelect, | ||
|
||
/** Text Editor */ | ||
text, | ||
} |
Oops, something went wrong.