@bennerinformatics/ember-fw-table 2.0.20 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/addon/classes/Row.js +80 -74
- package/addon/classes/Table.js +152 -147
- package/addon/components/fw-cell-action.js +19 -15
- package/addon/components/fw-cell-boolean.js +13 -12
- package/addon/components/fw-cell-nullable.js +15 -12
- package/addon/components/fw-cell-permission-icon.js +28 -12
- package/addon/components/fw-column-sortable.js +12 -4
- package/addon/components/fw-column-title.js +21 -13
- package/addon/components/fw-delete-modal.js +80 -61
- package/addon/components/fw-expandable-row.js +5 -0
- package/addon/components/fw-pagination-wrapper.js +600 -681
- package/addon/components/fw-row-toggle-index.js +14 -14
- package/addon/components/fw-row-toggle.js +12 -5
- package/addon/components/fw-table-expanded-row.js +23 -24
- package/addon/components/fw-table-expanded-rows.js +8 -4
- package/addon/components/fw-table-resort.js +31 -18
- package/addon/components/fw-table-sortable.js +414 -398
- package/addon/documentation.js +63 -98
- package/addon/templates/components/fw-delete-modal.hbs +2 -7
- package/addon/templates/components/fw-pagination-wrapper.hbs +45 -74
- package/addon/templates/components/fw-table-expanded-row.hbs +23 -23
- package/addon/templates/components/fw-table-expanded-rows.hbs +1 -1
- package/addon/templates/components/fw-table-resort.hbs +4 -4
- package/addon/templates/components/fw-table-sortable.hbs +54 -77
- package/addon/utils/base-cells.js +75 -40
- package/addon/utils/export.js +78 -76
- package/addon/utils/formats.js +93 -46
- package/addon/utils/table.js +36 -35
- package/app/breakpoints.js +1 -1
- package/app/components/fw-cell-permission-icon.js +1 -1
- package/app/initializers/responsive.js +1 -1
- package/codemods.log +16 -0
- package/index.js +10 -9
- package/package.json +65 -67
- package/yuidoc-ember-theme/LICENSE +21 -0
- package/yuidoc-ember-theme/README.md +88 -0
- package/yuidoc-ember-theme/assets/css/custom.css +82 -0
- package/yuidoc-ember-theme/assets/css/external-small.png +0 -0
- package/yuidoc-ember-theme/assets/css/main.css +793 -0
- package/yuidoc-ember-theme/assets/css/theme.css +547 -0
- package/yuidoc-ember-theme/assets/icons/android-icon-144x144.png +0 -0
- package/yuidoc-ember-theme/assets/icons/android-icon-192x192.png +0 -0
- package/yuidoc-ember-theme/assets/icons/android-icon-36x36.png +0 -0
- package/yuidoc-ember-theme/assets/icons/android-icon-48x48.png +0 -0
- package/yuidoc-ember-theme/assets/icons/android-icon-72x72.png +0 -0
- package/yuidoc-ember-theme/assets/icons/android-icon-96x96.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-114x114.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-120x120.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-144x144.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-152x152.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-180x180.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-57x57.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-60x60.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-72x72.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-76x76.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon-precomposed.png +0 -0
- package/yuidoc-ember-theme/assets/icons/apple-icon.png +0 -0
- package/yuidoc-ember-theme/assets/icons/browserconfig.xml +2 -0
- package/yuidoc-ember-theme/assets/icons/favicon-16x16.png +0 -0
- package/yuidoc-ember-theme/assets/icons/favicon-32x32.png +0 -0
- package/yuidoc-ember-theme/assets/icons/favicon-96x96.png +0 -0
- package/yuidoc-ember-theme/assets/icons/favicon.ico +0 -0
- package/yuidoc-ember-theme/assets/icons/manifest.json +41 -0
- package/yuidoc-ember-theme/assets/icons/ms-icon-144x144.png +0 -0
- package/yuidoc-ember-theme/assets/icons/ms-icon-150x150.png +0 -0
- package/yuidoc-ember-theme/assets/icons/ms-icon-310x310.png +0 -0
- package/yuidoc-ember-theme/assets/icons/ms-icon-70x70.png +0 -0
- package/yuidoc-ember-theme/assets/img/ember-logo.png +0 -0
- package/yuidoc-ember-theme/assets/img/fw-logo.png +0 -0
- package/yuidoc-ember-theme/assets/img/spinner.gif +0 -0
- package/yuidoc-ember-theme/assets/index.html +10 -0
- package/yuidoc-ember-theme/assets/js/yuidoc-bootstrap.js +274 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/css/bootstrap.css +6760 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/css/bootstrap.min.css +6 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/img/glyphicons-halflings-white.png +0 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/img/glyphicons-halflings.png +0 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/js/bootstrap.js +2363 -0
- package/yuidoc-ember-theme/assets/vendor/bootstrap/js/bootstrap.min.js +7 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/css/font-awesome.css +2199 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/css/font-awesome.min.css +4 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/FontAwesome.otf +0 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.svg +685 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/yuidoc-ember-theme/assets/vendor/github-slugger/slugger.js +59 -0
- package/yuidoc-ember-theme/assets/vendor/jquery/jquery.min.js +6 -0
- package/yuidoc-ember-theme/assets/vendor/jquery-ui/jquery-ui.min.js +6 -0
- package/yuidoc-ember-theme/assets/vendor/prettify/prettify-min.css +1 -0
- package/yuidoc-ember-theme/assets/vendor/prettify/prettify-min.js +1 -0
- package/{bitbucket-helpers-override.js → yuidoc-ember-theme/helpers/bitbucket-helpers-override.js} +240 -240
- package/yuidoc-ember-theme/helpers/helpers.js +236 -0
- package/yuidoc-ember-theme/layouts/main.handlebars +111 -0
- package/yuidoc-ember-theme/layouts/xhr.handlebars +7 -0
- package/yuidoc-ember-theme/package.json +15 -0
- package/yuidoc-ember-theme/partials/attrs.handlebars +144 -0
- package/yuidoc-ember-theme/partials/classes.handlebars +229 -0
- package/yuidoc-ember-theme/partials/events.handlebars +140 -0
- package/yuidoc-ember-theme/partials/files.handlebars +9 -0
- package/yuidoc-ember-theme/partials/index.handlebars +25 -0
- package/yuidoc-ember-theme/partials/method.handlebars +193 -0
- package/yuidoc-ember-theme/partials/module.handlebars +108 -0
- package/yuidoc-ember-theme/partials/options.handlebars +22 -0
- package/yuidoc-ember-theme/partials/props.handlebars +122 -0
- package/yuidoc-ember-theme/partials/sidebar.handlebars +77 -0
- package/yuidoc-ember-theme/theme.json +4 -0
- package/yuidoc-ember-theme/yarn.lock +4 -0
- package/yuidoc.json +23 -21
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# ember-fw-table
|
|
2
2
|
|
|
3
|
+
We have a couple of documentation websites, which may help in using this package:
|
|
4
|
+
|
|
5
|
+
[Ember FW Table Docs](https://linformatics.bitbucket.io/docs/addons/client/ember-fw-table) give a more robust guide to some of the important features of the package.
|
|
6
|
+
|
|
7
|
+
[Ember FW Table API Docs](https://linformatics.bitbucket.io/docs/addons/client-api/ember-fw-table) are api documentation for each of our components, which are generated from code comments.
|
|
8
|
+
|
|
3
9
|
This README outlines the details of collaborating on this Ember addon.
|
|
4
10
|
|
|
5
11
|
## Installation
|
package/addon/classes/Row.js
CHANGED
|
@@ -1,74 +1,80 @@
|
|
|
1
|
-
import {computed, defineProperty, observer} from '@ember/object';
|
|
2
|
-
import {alias} from '@ember/object/computed';
|
|
3
|
-
import LightRow from 'ember-light-table/classes/Row';
|
|
4
|
-
import {showExpanded} from '../utils/table';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Function to create the canExpand computed property
|
|
8
|
-
* @param {array} keys Array of keys to watch
|
|
9
|
-
* @return {computed} Computed property
|
|
10
|
-
*/
|
|
11
|
-
function canExpand(keys) {
|
|
12
|
-
return computed('table.{alwaysExpand,hasExpandedColumns}', ...keys, function() {
|
|
13
|
-
// start with some short exits
|
|
14
|
-
// no expanded columns is false
|
|
15
|
-
if (!this.
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
// if it has an expanded column that always shows, automatically true
|
|
19
|
-
if (this.
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// try and find any column that has something
|
|
24
|
-
return this.
|
|
25
|
-
return showExpanded(this.
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Personal copy of Ember Light Table row to support the can expand property
|
|
32
|
-
* @type {EmberObject}
|
|
33
|
-
* @extends EmberLightTable/Row
|
|
34
|
-
* @class Row
|
|
35
|
-
*/
|
|
36
|
-
export default class Row extends LightRow.extend({
|
|
37
|
-
/**
|
|
38
|
-
* Parent table instance
|
|
39
|
-
* @property table
|
|
40
|
-
* @type {Table}
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the row is currently allowed to expand
|
|
45
|
-
* @type {boolean}
|
|
46
|
-
*/
|
|
47
|
-
canExpand: alias('table.hasExpandedColumns'),
|
|
48
|
-
|
|
49
|
-
/** Disables expanded state if canExpand is false */
|
|
50
|
-
expanded: computed('canExpand', '_expanded', {
|
|
51
|
-
get() {
|
|
52
|
-
return this.
|
|
53
|
-
},
|
|
54
|
-
set(_, value) {
|
|
55
|
-
value &= this.
|
|
56
|
-
this.set('_expanded', value);
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Observer to update canExpand if the expanded keys ever changes
|
|
63
|
-
*/
|
|
64
|
-
// eslint-disable-next-line ember/no-observers
|
|
65
|
-
updateColumns: observer('table.expandedKeys', function() {
|
|
66
|
-
defineProperty(this, 'canExpand', canExpand(this.
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
defineProperty(this, 'canExpand', canExpand(table.get('expandedKeys')));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
import {computed, defineProperty, observer} from '@ember/object';
|
|
2
|
+
import {alias} from '@ember/object/computed';
|
|
3
|
+
import LightRow from 'ember-light-table/classes/Row';
|
|
4
|
+
import {showExpanded} from '../utils/table';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Function to create the canExpand computed property
|
|
8
|
+
* @param {array} keys Array of keys to watch
|
|
9
|
+
* @return {computed} Computed property
|
|
10
|
+
*/
|
|
11
|
+
function canExpand(keys) {
|
|
12
|
+
return computed('table.{alwaysExpand,hasExpandedColumns,expandedColumns}', ...keys, function() {
|
|
13
|
+
// start with some short exits
|
|
14
|
+
// no expanded columns is false
|
|
15
|
+
if (!this.table.hasExpandedColumns) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
// if it has an expanded column that always shows, automatically true
|
|
19
|
+
if (this.table.alwaysExpand) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// try and find any column that has something
|
|
24
|
+
return this.table.expandedColumns.any((column) => {
|
|
25
|
+
return showExpanded(this.table, this, column);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Personal copy of Ember Light Table row to support the can expand property
|
|
32
|
+
* @type {EmberObject}
|
|
33
|
+
* @extends EmberLightTable/Row
|
|
34
|
+
* @class Row
|
|
35
|
+
*/
|
|
36
|
+
export default class Row extends LightRow.extend({
|
|
37
|
+
/**
|
|
38
|
+
* Parent table instance
|
|
39
|
+
* @property table
|
|
40
|
+
* @type {Table}
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the row is currently allowed to expand
|
|
45
|
+
* @type {boolean}
|
|
46
|
+
*/
|
|
47
|
+
canExpand: alias('table.hasExpandedColumns'),
|
|
48
|
+
|
|
49
|
+
/** Disables expanded state if canExpand is false */
|
|
50
|
+
expanded: computed('canExpand', '_expanded', {
|
|
51
|
+
get() {
|
|
52
|
+
return this.canExpand && this.get('_expanded');
|
|
53
|
+
},
|
|
54
|
+
set(_, value) {
|
|
55
|
+
value &= this.canExpand;
|
|
56
|
+
this.set('_expanded', value);
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Observer to update canExpand if the expanded keys ever changes
|
|
63
|
+
*/
|
|
64
|
+
// eslint-disable-next-line ember/no-observers
|
|
65
|
+
updateColumns: observer('table.expandedKeys', function() {
|
|
66
|
+
defineProperty(this, 'canExpand', canExpand(this.table.expandedKeys));
|
|
67
|
+
}),
|
|
68
|
+
|
|
69
|
+
init({content, table}) {
|
|
70
|
+
this._super(...arguments);
|
|
71
|
+
this.table = table;
|
|
72
|
+
defineProperty(this, 'canExpand', canExpand(table.get('expandedKeys')));
|
|
73
|
+
}
|
|
74
|
+
}) {
|
|
75
|
+
// constructor({content, table}) {
|
|
76
|
+
// super(content);
|
|
77
|
+
// this.table = table;
|
|
78
|
+
// defineProperty(this, 'canExpand', canExpand(table.get('expandedKeys')));
|
|
79
|
+
// }
|
|
80
|
+
}
|
package/addon/classes/Table.js
CHANGED
|
@@ -1,147 +1,152 @@
|
|
|
1
|
-
import LightTable from 'ember-light-table/classes/Table';
|
|
2
|
-
import Row from './Row';
|
|
3
|
-
import {A as emberArray} from '@ember/array';
|
|
4
|
-
import {computed} from '@ember/object';
|
|
5
|
-
import {filter} from '@ember/object/computed';
|
|
6
|
-
import {isEmpty, isNone} from '@ember/utils';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Create a collection of Row objects with the given collection
|
|
10
|
-
* @method createRows
|
|
11
|
-
* @static
|
|
12
|
-
* @param {Array} rows Passed in rows
|
|
13
|
-
* @param {Table} table Table instance
|
|
14
|
-
* @return {Array} Array of table rows
|
|
15
|
-
*/
|
|
16
|
-
function createRows(rows = [], table) {
|
|
17
|
-
return rows.map((r) =>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Personal copy of the table class with some additional computed properties
|
|
22
|
-
*
|
|
23
|
-
* @class Table
|
|
24
|
-
* @extends EmberLightTable/Table
|
|
25
|
-
*/
|
|
26
|
-
/*
|
|
27
|
-
* TODO: needs to implement some additional row methods as right now only setRows is wrapped
|
|
28
|
-
*/
|
|
29
|
-
export class Table extends LightTable.extend({
|
|
30
|
-
/**
|
|
31
|
-
* Table columns without export only columns
|
|
32
|
-
* @property tableColumns
|
|
33
|
-
* @type {Ember.Array}
|
|
34
|
-
*/
|
|
35
|
-
tableColumns: filter('columns.@each.exportOnly', function(column) {
|
|
36
|
-
return !column.get('exportOnly');
|
|
37
|
-
}),
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @property visibleColumnGroups
|
|
41
|
-
* @type {Ember.Array}
|
|
42
|
-
*/
|
|
43
|
-
visibleColumnGroups: computed('tableColumns.[]', 'tableColumns.@each.{isHidden,isVisibleGroupColumn}', function() {
|
|
44
|
-
return this.
|
|
45
|
-
return c.get('isVisibleGroupColumn') || (!c.get('isGroupColumn') && !c.get('isHidden'));
|
|
46
|
-
});
|
|
47
|
-
}).readOnly(),
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @property visibleSubColumns
|
|
51
|
-
* @type {Ember.Array}
|
|
52
|
-
*/
|
|
53
|
-
visibleSubColumns: computed('tableColumns.@each.visibleSubColumns', function() {
|
|
54
|
-
return emberArray([].concat(...this.
|
|
55
|
-
}).readOnly(),
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @property allColumns
|
|
59
|
-
* @type {Ember.Array}
|
|
60
|
-
*/
|
|
61
|
-
allColumns: computed('tableColumns.@each.subColumns', function() {
|
|
62
|
-
return this.
|
|
63
|
-
arr.pushObjects(c.get('isGroupColumn') ? c.get('subColumns') : [c]);
|
|
64
|
-
return arr;
|
|
65
|
-
}, emberArray([]));
|
|
66
|
-
}).readOnly(),
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* List of all columns that can show in expanded view, it will be filtered again later
|
|
70
|
-
*
|
|
71
|
-
* @private
|
|
72
|
-
* @property expandedColumns
|
|
73
|
-
* @type {Array}
|
|
74
|
-
*/
|
|
75
|
-
expandedColumns: filter('allColumns.@each.{isHidden,showExpanded,cellComponent}', function(column) {
|
|
76
|
-
// if the column is not hidden, skip it
|
|
77
|
-
if (!column.get('isHidden')) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
// if hidden, ask the column if we should show it
|
|
81
|
-
let showExpanded = column.get('showExpanded');
|
|
82
|
-
if (!isNone(showExpanded)) {
|
|
83
|
-
return showExpanded;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// by default, show if the value path is empty and its not a row toggle
|
|
87
|
-
return column.get('cellComponent') !== 'fw-row-toggle';
|
|
88
|
-
}).readOnly(),
|
|
89
|
-
|
|
90
|
-
alwaysExpand: computed('expandedColumns.@each.canExpand', function() {
|
|
91
|
-
return this.
|
|
92
|
-
}),
|
|
93
|
-
|
|
94
|
-
expandedKeys: computed('expandedColumns.[]', function() {
|
|
95
|
-
let keys = [];
|
|
96
|
-
this.
|
|
97
|
-
// check if we have a specific expansion property
|
|
98
|
-
let showExpanded = column.get('showExpanded');
|
|
99
|
-
if (typeof showExpanded === 'string') {
|
|
100
|
-
keys.pushObject(showExpanded);
|
|
101
|
-
} else {
|
|
102
|
-
// otherwise, try the value path
|
|
103
|
-
if (column.get('valuePath')) {
|
|
104
|
-
keys.pushObject(column.get('valuePath'));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return keys;
|
|
110
|
-
}),
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Returns true if the table currently contains hidden columns
|
|
114
|
-
*
|
|
115
|
-
* @private
|
|
116
|
-
* @property hasHiddenColumns
|
|
117
|
-
* @type {Boolean}
|
|
118
|
-
*/
|
|
119
|
-
hasExpandedColumns: computed('expandedColumns', function() {
|
|
120
|
-
return !isEmpty(this.
|
|
121
|
-
}),
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Replace all the row's content with content of the argument. If argument is an empty array rows will be cleared.
|
|
125
|
-
* @method setRows
|
|
126
|
-
* @param {Array} rows
|
|
127
|
-
* @return {Array} rows
|
|
128
|
-
*/
|
|
129
|
-
setRows(rows = []) {
|
|
130
|
-
return this.
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.setRows(rows);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
1
|
+
import LightTable from 'ember-light-table/classes/Table';
|
|
2
|
+
import Row from './Row';
|
|
3
|
+
import {A as emberArray} from '@ember/array';
|
|
4
|
+
import {computed} from '@ember/object';
|
|
5
|
+
import {filter} from '@ember/object/computed';
|
|
6
|
+
import {isEmpty, isNone} from '@ember/utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a collection of Row objects with the given collection
|
|
10
|
+
* @method createRows
|
|
11
|
+
* @static
|
|
12
|
+
* @param {Array} rows Passed in rows
|
|
13
|
+
* @param {Table} table Table instance
|
|
14
|
+
* @return {Array} Array of table rows
|
|
15
|
+
*/
|
|
16
|
+
function createRows(rows = [], table) {
|
|
17
|
+
return rows.map((r) => Row.create({content: r, table}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Personal copy of the table class with some additional computed properties
|
|
22
|
+
*
|
|
23
|
+
* @class Table
|
|
24
|
+
* @extends EmberLightTable/Table
|
|
25
|
+
*/
|
|
26
|
+
/*
|
|
27
|
+
* TODO: needs to implement some additional row methods as right now only setRows is wrapped
|
|
28
|
+
*/
|
|
29
|
+
export class Table extends LightTable.extend({
|
|
30
|
+
/**
|
|
31
|
+
* Table columns without export only columns
|
|
32
|
+
* @property tableColumns
|
|
33
|
+
* @type {Ember.Array}
|
|
34
|
+
*/
|
|
35
|
+
tableColumns: filter('columns.@each.exportOnly', function(column) {
|
|
36
|
+
return !column.get('exportOnly');
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @property visibleColumnGroups
|
|
41
|
+
* @type {Ember.Array}
|
|
42
|
+
*/
|
|
43
|
+
visibleColumnGroups: computed('tableColumns.[]', 'tableColumns.@each.{isHidden,isVisibleGroupColumn}', function() {
|
|
44
|
+
return this.tableColumns.filter((c) => {
|
|
45
|
+
return c.get('isVisibleGroupColumn') || (!c.get('isGroupColumn') && !c.get('isHidden'));
|
|
46
|
+
});
|
|
47
|
+
}).readOnly(),
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @property visibleSubColumns
|
|
51
|
+
* @type {Ember.Array}
|
|
52
|
+
*/
|
|
53
|
+
visibleSubColumns: computed('tableColumns.@each.visibleSubColumns', function() {
|
|
54
|
+
return emberArray([].concat(...this.tableColumns.getEach('visibleSubColumns')));
|
|
55
|
+
}).readOnly(),
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @property allColumns
|
|
59
|
+
* @type {Ember.Array}
|
|
60
|
+
*/
|
|
61
|
+
allColumns: computed('tableColumns.@each.subColumns', function() {
|
|
62
|
+
return this.tableColumns.reduce((arr, c) => {
|
|
63
|
+
arr.pushObjects(c.get('isGroupColumn') ? c.get('subColumns') : [c]);
|
|
64
|
+
return arr;
|
|
65
|
+
}, emberArray([]));
|
|
66
|
+
}).readOnly(),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* List of all columns that can show in expanded view, it will be filtered again later
|
|
70
|
+
*
|
|
71
|
+
* @private
|
|
72
|
+
* @property expandedColumns
|
|
73
|
+
* @type {Array}
|
|
74
|
+
*/
|
|
75
|
+
expandedColumns: filter('allColumns.@each.{isHidden,showExpanded,cellComponent}', function(column) {
|
|
76
|
+
// if the column is not hidden, skip it
|
|
77
|
+
if (!column.get('isHidden')) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
// if hidden, ask the column if we should show it
|
|
81
|
+
let showExpanded = column.get('showExpanded');
|
|
82
|
+
if (!isNone(showExpanded)) {
|
|
83
|
+
return showExpanded;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// by default, show if the value path is empty and its not a row toggle
|
|
87
|
+
return column.get('cellComponent') !== 'fw-row-toggle';
|
|
88
|
+
}).readOnly(),
|
|
89
|
+
|
|
90
|
+
alwaysExpand: computed('expandedColumns.@each.canExpand', function() {
|
|
91
|
+
return this.expandedColumns.any((column) => column.get('showExpanded') === true);
|
|
92
|
+
}),
|
|
93
|
+
|
|
94
|
+
expandedKeys: computed('expandedColumns.[]', function() {
|
|
95
|
+
let keys = [];
|
|
96
|
+
this.expandedColumns.forEach((column) => {
|
|
97
|
+
// check if we have a specific expansion property
|
|
98
|
+
let showExpanded = column.get('showExpanded');
|
|
99
|
+
if (typeof showExpanded === 'string') {
|
|
100
|
+
keys.pushObject(showExpanded);
|
|
101
|
+
} else {
|
|
102
|
+
// otherwise, try the value path
|
|
103
|
+
if (column.get('valuePath')) {
|
|
104
|
+
keys.pushObject(column.get('valuePath'));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return keys;
|
|
110
|
+
}),
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns true if the table currently contains hidden columns
|
|
114
|
+
*
|
|
115
|
+
* @private
|
|
116
|
+
* @property hasHiddenColumns
|
|
117
|
+
* @type {Boolean}
|
|
118
|
+
*/
|
|
119
|
+
hasExpandedColumns: computed('expandedColumns', function() {
|
|
120
|
+
return !isEmpty(this.expandedColumns);
|
|
121
|
+
}),
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Replace all the row's content with content of the argument. If argument is an empty array rows will be cleared.
|
|
125
|
+
* @method setRows
|
|
126
|
+
* @param {Array} rows
|
|
127
|
+
* @return {Array} rows
|
|
128
|
+
*/
|
|
129
|
+
setRows(rows = []) {
|
|
130
|
+
return this.rows.setObjects(createRows(rows, this));
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
init({columns, rows}) {
|
|
134
|
+
this._super(...arguments);
|
|
135
|
+
this.setRows(rows);
|
|
136
|
+
}
|
|
137
|
+
}) {
|
|
138
|
+
// constructor({columns, rows}) {
|
|
139
|
+
// super(columns, []);
|
|
140
|
+
// this.setRows(rows);
|
|
141
|
+
// }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Creates an instance of the table class, mimicking the new Table constructor of the parent
|
|
146
|
+
* @param {Array} columns Table columns
|
|
147
|
+
* @param {Array} rows Table rows
|
|
148
|
+
* @return {Table} Table class to use in ember-light-table
|
|
149
|
+
*/
|
|
150
|
+
export default function newTable(columns, rows) {
|
|
151
|
+
return Table.create({columns, rows});
|
|
152
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import Component from '@ember/component';
|
|
2
|
-
import layout from '../templates/components/fw-cell-action';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This cell contains buttons to edit and delete a model, which can have actions passed in
|
|
6
|
-
* The edit action is expected to be passed in as tableActions.edit
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import Component from '@ember/component';
|
|
2
|
+
import layout from '../templates/components/fw-cell-action';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This cell contains buttons to edit and delete a model, which can have actions passed in.
|
|
6
|
+
* The edit action is expected to be passed in as `tableActions.edit`, while delete as `tableActions.delete`.
|
|
7
|
+
* This component will only give you two actions, so if you need a more complicated component than edit and delete,
|
|
8
|
+
* you will need to create your own cell component.
|
|
9
|
+
* Setting the variable `small` in the column will cause the buttons to display smaller.
|
|
10
|
+
*
|
|
11
|
+
* The easiest way to add this cell is through the base cell in utils, for more information, [click here](../classes/BaseCells.html). In most cases, it is best
|
|
12
|
+
* to use the util rather than this cell component directly.
|
|
13
|
+
* @public
|
|
14
|
+
* @class FwCellAction
|
|
15
|
+
* @module CellComponents
|
|
16
|
+
*/
|
|
17
|
+
export default Component.extend({
|
|
18
|
+
layout
|
|
19
|
+
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import Component from '@ember/component';
|
|
2
|
-
import layout from '../templates/components/fw-cell-boolean';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Displays a cell containing a boolean as either "Yes" or "No"
|
|
6
|
-
* @public
|
|
7
|
-
* @deprecated
|
|
8
|
-
* @class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import Component from '@ember/component';
|
|
2
|
+
import layout from '../templates/components/fw-cell-boolean';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Displays a cell containing a boolean as either "Yes" or "No".
|
|
6
|
+
* @public
|
|
7
|
+
* @deprecated You should use the [`formatBoolean` in the Format Util](../classes/BaseCells.html) instead.
|
|
8
|
+
* @class FwCellBoolean
|
|
9
|
+
* @module CellComponents
|
|
10
|
+
*/
|
|
11
|
+
export default Component.extend({
|
|
12
|
+
layout
|
|
13
|
+
});
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import Component from '@ember/component';
|
|
2
|
-
import layout from '../templates/components/fw-cell-nullable';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates a table cell that displays a default value if null.
|
|
6
|
-
* That value defaults to "None", but can be changed by setting the nullText property in a column
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import Component from '@ember/component';
|
|
2
|
+
import layout from '../templates/components/fw-cell-nullable';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a table cell that displays a default value if null.
|
|
6
|
+
* That value defaults to "None", but can be changed by setting the `nullText` property in a column.
|
|
7
|
+
* @deprecated You should use the [`formatNullable` in the Format Util](../classes/BaseCells.html) instead.
|
|
8
|
+
* @public
|
|
9
|
+
* @class FwCellNullable
|
|
10
|
+
* @module CellComponents
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export default Component.extend({
|
|
14
|
+
layout
|
|
15
|
+
});
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import Component from '@ember/component';
|
|
2
|
-
import layout from '../templates/components/fw-cell-permission-icon';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import Component from '@ember/component';
|
|
2
|
+
import layout from '../templates/components/fw-cell-permission-icon';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This component displays the permission icon for the table on the Permissions page. It should be used in the following way:
|
|
6
|
+
* ```js
|
|
7
|
+
* columns: [{
|
|
8
|
+
* label: 'Admin',
|
|
9
|
+
* valuePath: 'admin',
|
|
10
|
+
* cellComponent: 'fw-cell-permission-icon',
|
|
11
|
+
* align: 'center',
|
|
12
|
+
* width: '80px'
|
|
13
|
+
* }]
|
|
14
|
+
* ```
|
|
15
|
+
* This component will take the value, and display the proper Fontawesome icon based on its value. The value should be one of the following three numbers:
|
|
16
|
+
*
|
|
17
|
+
* - 0 means that that role does not have access to that feature, and it will display a red X.
|
|
18
|
+
* - 1 means that that feature is controlled by access control, not by Group Control, and it will display a lock icon in the primary color of the app
|
|
19
|
+
* - 2 means that that role has access to that feature, and will display a green check mark.
|
|
20
|
+
* - If the value is anything else, the cell will just be empty
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @class FwCellPermissionIcon
|
|
24
|
+
* @module CellComponents
|
|
25
|
+
*/
|
|
26
|
+
export default Component.extend({
|
|
27
|
+
layout
|
|
28
|
+
});
|
|
@@ -3,11 +3,19 @@ import {computed} from '@ember/object';
|
|
|
3
3
|
import layout from '../templates/components/fw-column-sortable';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Displays a column title which can show a sorting icon
|
|
6
|
+
* Displays a column title which can show a sorting icon if a network request is still active. This can be used for your columns when using the [FwPaginationWrapper](../classes/FwPaginationWrapper.html),
|
|
7
|
+
* so that sorting works properly. It should be set as the columns component (not the cellComponent), like so:
|
|
8
|
+
* ```js
|
|
9
|
+
* columns: [{
|
|
10
|
+
* label: 'Name',
|
|
11
|
+
* valuePath: 'name',
|
|
12
|
+
* component: 'fw-column-sortable'
|
|
13
|
+
* }...]
|
|
14
|
+
* ```
|
|
15
|
+
* If you do this, when you are sorting the table within the paginated wrapper, it will display a spinning icon letting the user know that the sort is loading.
|
|
7
16
|
* @public
|
|
8
|
-
* @class
|
|
9
|
-
* @module
|
|
10
|
-
* @submodule Internal
|
|
17
|
+
* @class FwColumnSortable
|
|
18
|
+
* @module ColumnComponents
|
|
11
19
|
*/
|
|
12
20
|
export default Component.extend({
|
|
13
21
|
layout,
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import Sortable from './fw-column-sortable';
|
|
2
|
-
import layout from '../templates/components/fw-column-title';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
import Sortable from './fw-column-sortable';
|
|
2
|
+
import layout from '../templates/components/fw-column-title';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This column component extends [`fw-column-sortable` component](../classes/FwColumnSortable.html), so it will display a sort-icon, but it also display a column title
|
|
6
|
+
* which will truncate with an ellipsis if too long. This can be used for your columns when using the [FwPaginationWrapper](../classes/FwPaginationWrapper.html),
|
|
7
|
+
* so that sorting works properly. It should be set as the columns component (not the cellComponent), like so:
|
|
8
|
+
* ```js
|
|
9
|
+
* columns: [{
|
|
10
|
+
* label: 'Name',
|
|
11
|
+
* valuePath: 'name',
|
|
12
|
+
* component: 'fw-column-title'
|
|
13
|
+
* }...]
|
|
14
|
+
* ```
|
|
15
|
+
* @public
|
|
16
|
+
* @class FwColumnTitle
|
|
17
|
+
* @module ColumnComponents
|
|
18
|
+
*/
|
|
19
|
+
export default Sortable.extend({
|
|
20
|
+
layout
|
|
21
|
+
});
|