diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 90d5d4dd3..291bff613 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -2,6 +2,7 @@
diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 353cbb050..0498bc2e9 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -3,6 +3,7 @@ import Component from '../../lib/component'; import {buildFilter} from 'vn-loopback/util/filter'; import './style.scss'; import angular from 'angular'; +import {camelToKebab} from '../../lib/string'; export default class SmartTable extends Component { constructor($element, $, $transclude) { @@ -199,13 +200,37 @@ export default class SmartTable extends Component { const field = column.getAttribute('field'); const cell = document.createElement('td'); if (field) { - const input = this.$compile(` - column.field == field); + + if (options && options.autocomplete) { + let props = ``; + + const autocomplete = options.autocomplete; + for (const prop in autocomplete) + props += `${camelToKebab(prop)}="${autocomplete[prop]}"\n`; + + input = this.$compile(` + `)(this.$); + } else { + input = this.$compile(` + `)(this.$); + } cell.appendChild(input[0]); } searchRow.appendChild(cell); @@ -214,10 +239,14 @@ export default class SmartTable extends Component { tbody.prepend(searchRow); } - searchByColumn($event, scope, field) { + searchWithEvent($event, field) { if ($event.key != 'Enter') return; - const searchCriteria = scope.searchProps[field]; + this.searchByColumn(field); + } + + searchByColumn(field) { + const searchCriteria = this.$.searchProps[field]; const emptySearch = searchCriteria == '' || null; const filters = this.filterSanitizer(field); @@ -226,7 +255,7 @@ export default class SmartTable extends Component { this.model.userFilter = filters.userFilter; if (!emptySearch) - this.addFilter(field, scope.searchProps[field]); + this.addFilter(field, this.$.searchProps[field]); else this.model.refresh(); } @@ -344,6 +373,7 @@ ngModule.vnComponent('smartTable', { viewConfigId: '@?', autoSave: ' @@ -20,7 +21,6 @@ ng-click="$ctrl.test()" vn-tooltip="Info"> -