Skip to content

Commit

Permalink
refactor(component): Remove autocomplete functionality
Browse files Browse the repository at this point in the history
This hasn't been working for a while and can easily be implemented
by the code using ng2-handsontable.
(see https://docs.handsontable.com/demo-autocomplete.html)
  • Loading branch information
rene-leanix committed Apr 9, 2018
1 parent b1fb869 commit 300499e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
6 changes: 1 addition & 5 deletions demo/src/components/handsontable/basic-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export class BasicDemoComponent {
},
{
data: 'product.description',
source: 'product.options',
optionField: 'description',
type: 'autocomplete',
strict: false,
visibleRows: 4
renderer: 'text'
},
{
data: 'price',
Expand Down
36 changes: 0 additions & 36 deletions src/handsontable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ export class HotTableComponent implements OnInit, OnDestroy, OnChanges {
this.inst = new Handsontable(this.view, options);
});

this.parseAutoComplete(options);

if (this.pagedData) {
this.data = [];
this.pagedDataSubscription = this.pagedData.subscribe((newPagedData: any) => {
Expand All @@ -212,7 +210,6 @@ export class HotTableComponent implements OnInit, OnDestroy, OnChanges {
this.inst.loadData(this.data);
this.inst.updateSettings(options, false);
});
this.parseAutoComplete(options);
});
}
}
Expand Down Expand Up @@ -245,39 +242,6 @@ export class HotTableComponent implements OnInit, OnDestroy, OnChanges {
this.markAsChanged(properties);
}

private parseAutoComplete(options: any) {
const columns = this.columns || options.columns;
const dataSet = options.data;

if (columns) {
columns.forEach((column: any) => {
if (typeof column.source === 'string') {
const relatedField: string = column.source;
column.source = (_query: any, process: any) => {
const row: number = this.ngZone.runOutsideAngular(() =>
this.inst.getSelected()[0][0]
);
const data: any = dataSet[row];

if (!data) {
return;
}

const fieldParts: string[] = relatedField.split('.');
let o: any = data;
for (const part of fieldParts) {
o = o[part];
}

process(o.map((item: any) => {
return !column.optionField ? item : item[column.optionField];
}));
};
}
});
}
}

private checkInputs(): boolean {
const dataCount = Number(!!this.pagedData) + Number(!!this.data) +
Number(!!(this.options && this.options.data));
Expand Down

0 comments on commit 300499e

Please sign in to comment.