Skip to content

Commit

Permalink
fix(merge): fix some merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Mar 30, 2018
2 parents c86911c + 554576c commit d2172df
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 55 deletions.
14 changes: 0 additions & 14 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ major.minor.patch
* **Operating System:**
OSX 10.x|Linux (distro)|Windows [7|8|8.1|10]

* **Node Version:**
8.x.x
<!--
Minimum supported Node version is latest Node 4.x LTS
run `node -v`
-->

* **NPM Version:**
3.8.9
<!--
Minimum supported NPM version is 3.x
run `npm -v`
-->

* **Bundler used (WebPack/RequireJS/SystemJS**
JSPM 0.16.32 | webpack 2.1.0-beta.17
<!--
Expand Down
18 changes: 15 additions & 3 deletions aurelia-slickgrid/src/aurelia-slickgrid/aurelia-slickgrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'slickgrid/plugins/slick.headermenu';
import 'slickgrid/plugins/slick.rowmovemanager';
import 'slickgrid/plugins/slick.rowselectionmodel';

import { bindable, bindingMode, inject } from 'aurelia-framework';
import { Container, Factory, bindable, bindingMode, inject } from 'aurelia-framework';
import { EventAggregator, Subscription } from 'aurelia-event-aggregator';
import { I18N } from 'aurelia-i18n';
import { GlobalGridOptions } from './global-grid-options';
Expand Down Expand Up @@ -56,7 +56,7 @@ const aureliaEventPrefix = 'asg';
const eventPrefix = 'sg';

// Aurelia doesn't support well TypeScript @autoinject in a Plugin so we'll do it the old fashion way
@inject(ControlAndPluginService, ExportService, Element, EventAggregator, FilterService, GraphqlService, GridEventService, GridExtraService, GridStateService, I18N, ResizerService, SortService)
@inject(ControlAndPluginService, ExportService, Element, EventAggregator, FilterService, GraphqlService, GridEventService, GridExtraService, GridStateService, I18N, ResizerService, SortService, Container)
export class AureliaSlickgridCustomElement {
private _dataset: any[];
private _eventHandler: any = new Slick.EventHandler();
Expand Down Expand Up @@ -91,7 +91,8 @@ export class AureliaSlickgridCustomElement {
private gridStateService: GridStateService,
private i18n: I18N,
private resizer: ResizerService,
private sortService: SortService) { }
private sortService: SortService,
private container: Container) { }

attached() {
this.elm.dispatchEvent(new CustomEvent(`${eventPrefix}-on-before-grid-create`, {
Expand Down Expand Up @@ -189,6 +190,17 @@ export class AureliaSlickgridCustomElement {
height: `${binding.gridHeight}px`,
width: `${binding.gridWidth}px`
};

// Wrap each editor class in the Factory resolver so consumers of this library can use
// dependency injection. Aurelia will resolve all dependencies when we pass the container
// and allow slickgrid to pass its arguments to the editors constructor last
// when slickgrid creates the editor
// https://github.com/aurelia/dependency-injection/blob/master/src/resolvers.js
for (const c of this.columnDefinitions) {
if (c.editor) {
c.editor = Factory.of(c.editor).get(this.container);
}
}
}

datasetChanged(newValue: any[], oldValue: any[]) {
Expand Down
15 changes: 4 additions & 11 deletions aurelia-slickgrid/src/aurelia-slickgrid/editors/dateEditor.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { mapFlatpickrDateFormatWithFieldType } from './../services/utilities';
import { Column, Editor, FieldType, GridOption } from './../models/index';
import { I18N } from 'aurelia-i18n';
import { inject } from 'aurelia-framework';
import * as flatpickr from 'flatpickr';
import * as $ from 'jquery';

/*
* An example of a date picker editor using Flatpickr
* https://chmln.github.io/flatpickr
*/
@inject(I18N)
export class DateEditor implements Editor {
$input: any;
flatInstance: any;
defaultDate: string;

constructor(private args: any) {
constructor(private i18n: I18N, private args: any) {
this.init();
}

Expand All @@ -22,7 +24,7 @@ export class DateEditor implements Editor {
this.defaultDate = this.args.item[this.args.column.field] || null;
const inputFormat = mapFlatpickrDateFormatWithFieldType(this.args.column.type || FieldType.dateIso);
const outputFormat = mapFlatpickrDateFormatWithFieldType(this.args.column.outputType || FieldType.dateUtc);
let currentLocale = this.getCurrentLocale(this.args.column, gridOptions);
let currentLocale = this.i18n.getLocale() || 'en';
if (currentLocale.length > 2) {
currentLocale = currentLocale.substring(0, 2);
}
Expand All @@ -45,15 +47,6 @@ export class DateEditor implements Editor {
this.show();
}

getCurrentLocale(columnDef: Column, gridOptions: GridOption) {
const params = gridOptions.params || columnDef.params || {};
if (params.i18n && params.i18n instanceof I18N) {
return params.i18n.getLocale();
}

return 'en';
}

loadFlatpickrLocale(locale: string) {
// change locale if needed, Flatpickr reference: https://chmln.github.io/flatpickr/localization/
if (locale !== 'en') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { inject } from 'aurelia-framework';
import { I18N } from 'aurelia-i18n';
import { arraysEqual } from '../services/index';
import {
Expand All @@ -15,6 +16,7 @@ const SELECT_ELEMENT_HEIGHT = 26;
/**
* Slickgrid editor class for multiple select lists
*/
@inject(I18N)
export class MultipleSelectEditor implements Editor {
/** The JQuery DOM element */
$editorElm: any;
Expand All @@ -40,13 +42,9 @@ export class MultipleSelectEditor implements Editor {
/** The property name for labels in the collection */
labelName: string;

/** The i18n aurelia library */
private _i18n: I18N;

constructor(private args: any) {
constructor(private i18n: I18N, private args: any) {
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 All @@ -60,11 +58,9 @@ export class MultipleSelectEditor implements Editor {
onOpen: () => this.autoAdjustDropPosition(this.$editorElm, this.editorElmOptions),
};

if (this._i18n) {
this.defaultOptions.countSelected = this._i18n.tr('X_OF_Y_SELECTED');
this.defaultOptions.allSelected = this._i18n.tr('ALL_SELECTED');
this.defaultOptions.selectAllText = this._i18n.tr('SELECT_ALL');
}
this.defaultOptions.countSelected = this.i18n.tr('X_OF_Y_SELECTED');
this.defaultOptions.allSelected = this.i18n.tr('ALL_SELECTED');
this.defaultOptions.selectAllText = this.i18n.tr('SELECT_ALL');

this.init();
}
Expand Down Expand Up @@ -195,7 +191,7 @@ export class MultipleSelectEditor implements Editor {
}
const labelKey = (option.labelKey || option[this.labelName]) as string;

const textLabel = ((option.labelKey || isEnabledTranslate) && this._i18n && typeof this._i18n.tr === 'function') ? this._i18n.tr(labelKey || ' ') : labelKey;
const textLabel = (option.labelKey || isEnabledTranslate) ? this.i18n.tr(labelKey || ' ') : labelKey;

options += `<option value="${option[this.valueName]}">${textLabel}</option>`;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { inject } from 'aurelia-framework';
import { I18N } from 'aurelia-i18n';
import {
Editor,
Expand All @@ -15,6 +16,7 @@ const SELECT_ELEMENT_HEIGHT = 26;
/**
* Slickgrid editor class for single select lists
*/
@inject(I18N)
export class SingleSelectEditor implements Editor {
/** The JQuery DOM element */
$editorElm: any;
Expand All @@ -40,13 +42,9 @@ export class SingleSelectEditor implements Editor {
/** The property name for labels in the collection */
labelName: string;

/** The i18n aurelia library */
private _i18n: I18N;

constructor(private args: any) {
constructor(private i18n: I18N, private args: any) {
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 Expand Up @@ -185,7 +183,7 @@ export class SingleSelectEditor implements Editor {
'{ collection: [ { value: \'1\', label: \'One\' } ] } } }');
}
const labelKey = (option.labelKey || option[this.labelName]) as string;
const textLabel = ((option.labelKey || isEnabledTranslate) && this._i18n && typeof this._i18n.tr === 'function') ? this._i18n.tr(labelKey || ' ') : labelKey;
const textLabel = (option.labelKey || isEnabledTranslate) ? this.i18n.tr(labelKey || ' ') : labelKey;

options += `<option value="${option[this.valueName]}">${textLabel}</option>`;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class CompoundDateFilter implements Filter {
private buildDatePickerInput(searchTerm: SearchTerm) {
const inputFormat = mapFlatpickrDateFormatWithFieldType(this.columnDef.type || FieldType.dateIso);
const outputFormat = mapFlatpickrDateFormatWithFieldType(this.columnDef.outputType || this.columnDef.type || FieldType.dateUtc);
let currentLocale = this.getCurrentLocale(this.columnDef, this.gridOptions) || '';
let currentLocale = this.i18n.getLocale() || 'en';
if (currentLocale.length > 2) {
currentLocale = currentLocale.substring(0, 2);
}
Expand Down Expand Up @@ -211,15 +211,6 @@ export class CompoundDateFilter implements Filter {
return $filterContainerElm;
}

private getCurrentLocale(columnDef: Column, gridOptions: GridOption) {
const params = gridOptions.params || columnDef.params || {};
if (params.i18n && params.i18n instanceof I18N) {
return params.i18n.getLocale();
}

return 'en';
}

private loadFlatpickrLocale(locale: string) {
// change locale if needed, Flatpickr reference: https://chmln.github.io/flatpickr/localization/
if (locale !== 'en') {
Expand Down

0 comments on commit d2172df

Please sign in to comment.