Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 7x 1x 24x 24x 24x 26x 24x 24x 24x 24x 26x 26x | import Component from '@ember/component'; import layout from '../../../../../templates/components/bootstrap/tables/body/row/-cell'; import { get, computed } from '@ember/object'; import { task, didCancel } from 'ember-concurrency'; import { isPresent } from '@ember/utils'; import { or } from '@ember/object/computed'; export default Component.extend({ layout, tagName: 'td', cellData: null, _hasCellValueKey: computed('column.cellValueKey', function() { return isPresent(this.get('column.cellValueKey')); }), _hasCellValueTask: computed('column.cellValueTask', function() { return isPresent(this.get('column.cellValueTask')); }), _hasCellValue: or('_hasCellValueKey', '_hasCellValueTask'), defaultCellDataTask: task(function * (model, column) { const modelKey = yield get(column, 'cellValueKey'); Eif(isPresent(modelKey)) { return yield get(model, modelKey); } else { return null; } }), calculateCellDataTask: task(function * (column) { if(isPresent(column)) { const rowModel = yield this.get('rowData'); const cellTask = yield get(column, 'cellValueTask'); Iif(isPresent(cellTask)) { return yield cellTask.perform(rowModel); } else { return yield this.get('defaultCellDataTask').perform(rowModel, column); } } }).restartable(), didReceiveAttrs() { this.get('calculateCellDataTask').perform(this.get('column')).then((value) => { this.set('cellData', value); }).catch((e) => { if (!didCancel(e)) { throw e; } }); }, }); |