Skip to content

Commit

Permalink
fix(editor): i18n service can also be passed as params in gridOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Mar 15, 2018
1 parent 6756de8 commit c11eff4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { arraysEqual } from '../services/index';
import {
Editor,
Column,
GridOption,
MultipleSelectOption,
SelectOption
} from './../models/index';
Expand Down Expand Up @@ -46,7 +47,9 @@ export class MultipleSelectEditor implements Editor {
private _i18n: I18N;

constructor(private args: any) {
this._i18n = this.args.column.params.i18n;
const gridOptions = this.args.grid.getOptions() as GridOption;
const params = gridOptions.params || this.args.column.params || {};
this._i18n = params.i18n;

this.defaultOptions = {
container: 'body',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { I18N } from 'aurelia-i18n';
import {
Editor,
Column,
GridOption,
MultipleSelectOption,
SelectOption
} from '../models/index';
Expand Down Expand Up @@ -46,7 +47,9 @@ export class SingleSelectEditor implements Editor {
private _i18n: I18N;

constructor(private args: any) {
this._i18n = this.args.column.params.i18n;
const gridOptions = this.args.grid.getOptions() as GridOption;
const params = gridOptions.params || this.args.column.params || {};
this._i18n = params.i18n;

this.defaultOptions = {
container: 'body',
Expand Down
15 changes: 7 additions & 8 deletions aurelia-slickgrid/src/examples/slickgrid/example3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class Example3 {
editor: Editors.singleSelect,
minWidth: 100,
params: {
formatters: [ Formatters.collection, Formatters.percentCompleteBar ],
formatters: [Formatters.collection, Formatters.percentCompleteBar],
collection: Array.from(Array(101).keys()).map(k => ({ value: k, label: k }))
}
}, {
Expand All @@ -124,10 +124,7 @@ export class Example3 {
sortable: true,
minWidth: 100,
type: FieldType.date,
editor: Editors.date,
params: {
i18n: this.i18n
}
editor: Editors.date
}, {
id: 'finish',
name: 'Finish',
Expand All @@ -153,8 +150,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}` })),
i18n: this.i18n
collection: Array.from(Array(10).keys()).map(k => ({ value: `Task ${k}`, label: `Task ${k}` }))
}
}];

Expand All @@ -170,6 +166,9 @@ export class Example3 {
editCommandHandler: (item, column, editCommand) => {
this._commandQueue.push(editCommand);
editCommand.execute();
},
params: {
i18n: this.i18n
}
};
}
Expand All @@ -196,7 +195,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 % 5 === 0) && i > 0 ? [`Task ${i}`, `Task ${i - 1}`] : []
};
}
this.dataset = mockedDataset;
Expand Down

0 comments on commit c11eff4

Please sign in to comment.