@bennerinformatics/ember-fw-table 2.0.18 → 2.0.20

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.
Files changed (32) hide show
  1. package/addon/classes/Row.js +74 -73
  2. package/addon/classes/Table.js +147 -143
  3. package/addon/components/fw-cell-action.js +15 -14
  4. package/addon/components/fw-cell-boolean.js +12 -11
  5. package/addon/components/fw-cell-nullable.js +12 -11
  6. package/addon/components/fw-cell-permission-icon.js +12 -11
  7. package/addon/components/fw-column-sortable.js +4 -0
  8. package/addon/components/fw-column-title.js +13 -10
  9. package/addon/components/fw-delete-modal.js +61 -58
  10. package/addon/components/fw-pagination-wrapper.js +681 -470
  11. package/addon/components/fw-row-toggle-index.js +14 -10
  12. package/addon/components/fw-row-toggle.js +4 -2
  13. package/addon/components/fw-table-expanded-row.js +24 -22
  14. package/addon/components/fw-table-resort.js +13 -4
  15. package/addon/components/fw-table-sortable.js +398 -390
  16. package/addon/documentation.js +98 -0
  17. package/addon/templates/components/fw-pagination-wrapper.hbs +74 -74
  18. package/addon/templates/components/fw-table-expanded-row.hbs +23 -23
  19. package/addon/templates/components/fw-table-resort.hbs +1 -1
  20. package/addon/templates/components/fw-table-sortable.hbs +77 -76
  21. package/addon/utils/base-cells.js +40 -35
  22. package/addon/utils/export.js +76 -72
  23. package/addon/utils/formats.js +46 -42
  24. package/addon/utils/table.js +35 -31
  25. package/app/breakpoints.js +1 -1
  26. package/app/components/fw-cell-permission-icon.js +1 -1
  27. package/app/initializers/responsive.js +1 -1
  28. package/bitbucket-helpers-override.js +240 -0
  29. package/index.js +9 -9
  30. package/package.json +67 -63
  31. package/shippable.yml +28 -0
  32. package/yuidoc.json +21 -0
@@ -1,73 +1,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}', ...keys, function() {
13
- // start with some short exits
14
- // no expanded columns is false
15
- if (!this.get('table.hasExpandedColumns')) {
16
- return false;
17
- }
18
- // if it has an expanded column that always shows, automatically true
19
- if (this.get('table.alwaysExpand')) {
20
- return true;
21
- }
22
-
23
- // try and find any column that has something
24
- return this.get('table.expandedColumns').any((column) => {
25
- return showExpanded(this.get('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
- */
35
- export default class Row extends LightRow.extend({
36
- /**
37
- * Parent table instance
38
- * @property table
39
- * @type {Table}
40
- */
41
-
42
- /**
43
- * Checks if the row is currently allowed to expand
44
- * @type {boolean}
45
- */
46
- canExpand: alias('table.hasExpandedColumns'),
47
-
48
- /** Disables expanded state if canExpand is false */
49
- expanded: computed('canExpand', '_expanded', {
50
- get() {
51
- return this.get('canExpand') && this.get('_expanded');
52
- },
53
- set(_, value) {
54
- value &= this.get('canExpand');
55
- this.set('_expanded', value);
56
- return value;
57
- }
58
- }),
59
-
60
- /**
61
- * Observer to update canExpand if the expanded keys ever changes
62
- */
63
- // eslint-disable-next-line ember/no-observers
64
- updateColumns: observer('table.expandedKeys', function() {
65
- defineProperty(this, 'canExpand', canExpand(this.get('table.expandedKeys')));
66
- })
67
- }) {
68
- constructor({content, table}) {
69
- super(content);
70
- this.set('table', table);
71
- defineProperty(this, 'canExpand', canExpand(table.get('expandedKeys')));
72
- }
73
- }
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.get('table.hasExpandedColumns')) {
16
+ return false;
17
+ }
18
+ // if it has an expanded column that always shows, automatically true
19
+ if (this.get('table.alwaysExpand')) {
20
+ return true;
21
+ }
22
+
23
+ // try and find any column that has something
24
+ return this.get('table.expandedColumns').any((column) => {
25
+ return showExpanded(this.get('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.get('canExpand') && this.get('_expanded');
53
+ },
54
+ set(_, value) {
55
+ value &= this.get('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.get('table.expandedKeys')));
67
+ })
68
+ }) {
69
+ constructor({content, table}) {
70
+ super(content);
71
+ this.set('table', table);
72
+ defineProperty(this, 'canExpand', canExpand(table.get('expandedKeys')));
73
+ }
74
+ }
@@ -1,143 +1,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) => new Row({content: r, table}));
18
- }
19
-
20
- /**
21
- * Personal copy of the table class with some additional computed properties
22
- *
23
- * TODO: needs to implement some additional row methods as right now only setRows is wrapped
24
- */
25
- export class Table extends LightTable.extend({
26
- /**
27
- * Table columns without export only columns
28
- * @property tableColumns
29
- * @type {Ember.Array}
30
- */
31
- tableColumns: filter('columns.@each.exportOnly', function(column) {
32
- return !column.get('exportOnly');
33
- }),
34
-
35
- /**
36
- * @property visibleColumnGroups
37
- * @type {Ember.Array}
38
- */
39
- visibleColumnGroups: computed('tableColumns.[]', 'tableColumns.@each.{isHidden,isVisibleGroupColumn}', function() {
40
- return this.get('tableColumns').filter((c) => {
41
- return c.get('isVisibleGroupColumn') || (!c.get('isGroupColumn') && !c.get('isHidden'));
42
- });
43
- }).readOnly(),
44
-
45
- /**
46
- * @property visibleSubColumns
47
- * @type {Ember.Array}
48
- */
49
- visibleSubColumns: computed('tableColumns.@each.visibleSubColumns', function() {
50
- return emberArray([].concat(...this.get('tableColumns').getEach('visibleSubColumns')));
51
- }).readOnly(),
52
-
53
- /**
54
- * @property allColumns
55
- * @type {Ember.Array}
56
- */
57
- allColumns: computed('tableColumns.@each.subColumns', function() {
58
- return this.get('tableColumns').reduce((arr, c) => {
59
- arr.pushObjects(c.get('isGroupColumn') ? c.get('subColumns') : [c]);
60
- return arr;
61
- }, emberArray([]));
62
- }).readOnly(),
63
-
64
- /**
65
- * List of all columns that can show in expanded view, it will be filtered again later
66
- *
67
- * @private
68
- * @property expandedColumns
69
- * @type {Array}
70
- */
71
- expandedColumns: filter('allColumns.@each.{isHidden,showExpanded,cellComponent}', function(column) {
72
- // if the column is not hidden, skip it
73
- if (!column.get('isHidden')) {
74
- return false;
75
- }
76
- // if hidden, ask the column if we should show it
77
- let showExpanded = column.get('showExpanded');
78
- if (!isNone(showExpanded)) {
79
- return showExpanded;
80
- }
81
-
82
- // by default, show if the value path is empty and its not a row toggle
83
- return column.get('cellComponent') !== 'fw-row-toggle';
84
- }).readOnly(),
85
-
86
- alwaysExpand: computed('expandedColumns.@each.canExpand', function() {
87
- return this.get('expandedColumns').any((column) => column.get('showExpanded') === true);
88
- }),
89
-
90
- expandedKeys: computed('expandedColumns.[]', function() {
91
- let keys = [];
92
- this.get('expandedColumns').forEach((column) => {
93
- // check if we have a specific expansion property
94
- let showExpanded = column.get('showExpanded');
95
- if (typeof showExpanded === 'string') {
96
- keys.pushObject(showExpanded);
97
- } else {
98
- // otherwise, try the value path
99
- if (column.get('valuePath')) {
100
- keys.pushObject(column.get('valuePath'));
101
- }
102
- }
103
- });
104
-
105
- return keys;
106
- }),
107
-
108
- /**
109
- * Returns true if the table currently contains hidden columns
110
- *
111
- * @private
112
- * @property hasHiddenColumns
113
- * @type {Boolean}
114
- */
115
- hasExpandedColumns: computed('expandedColumns', function() {
116
- return !isEmpty(this.get('expandedColumns'));
117
- }),
118
-
119
- /**
120
- * Replace all the row's content with content of the argument. If argument is an empty array rows will be cleared.
121
- * @method setRows
122
- * @param {Array} rows
123
- * @return {Array} rows
124
- */
125
- setRows(rows = []) {
126
- return this.get('rows').setObjects(createRows(rows, this));
127
- }
128
- }) {
129
- constructor({columns, rows}) {
130
- super(columns, []);
131
- this.setRows(rows);
132
- }
133
- }
134
-
135
- /**
136
- * Creates an instance of the table class, mimicking the new Table constructor of the parent
137
- * @param {Array} columns Table columns
138
- * @param {Array} rows Table rows
139
- * @return {Table} Table class to use in ember-light-table
140
- */
141
- export default function newTable(columns, rows) {
142
- return new Table({columns, rows});
143
- }
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) => new Row({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.get('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.get('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.get('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.get('expandedColumns').any((column) => column.get('showExpanded') === true);
92
+ }),
93
+
94
+ expandedKeys: computed('expandedColumns.[]', function() {
95
+ let keys = [];
96
+ this.get('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.get('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.get('rows').setObjects(createRows(rows, this));
131
+ }
132
+ }) {
133
+ constructor({columns, rows}) {
134
+ super(columns, []);
135
+ this.setRows(rows);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Creates an instance of the table class, mimicking the new Table constructor of the parent
141
+ * @param {Array} columns Table columns
142
+ * @param {Array} rows Table rows
143
+ * @return {Table} Table class to use in ember-light-table
144
+ */
145
+ export default function newTable(columns, rows) {
146
+ return new Table({columns, rows});
147
+ }
@@ -1,14 +1,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
- *
8
- * Setting the variable "small" in the column will cause the buttons to display smaller
9
- * The easiest way to add this cell is through the base cell in utils
10
- * @public
11
- */
12
- export default Component.extend({
13
- layout
14
- });
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
+ *
8
+ * Setting the variable "small" in the column will cause the buttons to display smaller
9
+ * The easiest way to add this cell is through the base cell in utils, for more information, [click here](../classes/BaseCells.html)
10
+ * @public
11
+ * @class FW-Cell-Action
12
+ */
13
+ export default Component.extend({
14
+ layout
15
+ });
@@ -1,11 +1,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 Use utils/formats.formatBoolean
8
- */
9
- export default Component.extend({
10
- layout
11
- });
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 Use utils/formats.formatBoolean
8
+ * @class FW-Cell-Boolean
9
+ */
10
+ export default Component.extend({
11
+ layout
12
+ });
@@ -1,11 +1,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
- * @public
8
- */
9
- export default Component.extend({
10
- layout
11
- });
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
+ * @public
8
+ * @class FW-Cell-Nullable
9
+ */
10
+ export default Component.extend({
11
+ layout
12
+ });
@@ -1,11 +1,12 @@
1
- import Component from '@ember/component';
2
- import layout from '../templates/components/fw-cell-permission-icon';
3
-
4
- /**
5
- * Displays a cell containing a boolean as either "Yes" or "No"
6
- * @public
7
- * @deprecated Use utils/formats.formatBoolean
8
- */
9
- export default Component.extend({
10
- layout
11
- });
1
+ import Component from '@ember/component';
2
+ import layout from '../templates/components/fw-cell-permission-icon';
3
+
4
+ /**
5
+ * Displays a cell containing a boolean as either "Yes" or "No"
6
+ * @public
7
+ * @deprecated Use utils/formats.formatBoolean
8
+ * @class FW-Cell-Permission-Icon
9
+ */
10
+ export default Component.extend({
11
+ layout
12
+ });
@@ -5,11 +5,15 @@ import layout from '../templates/components/fw-column-sortable';
5
5
  /**
6
6
  * Displays a column title which can show a sorting icon
7
7
  * @public
8
+ * @class FW-Column-Sortable
9
+ * @module Components
10
+ * @submodule Internal
8
11
  */
9
12
  export default Component.extend({
10
13
  layout,
11
14
 
12
15
  /**
16
+ * Computed property that determines the icon of the sort whether it is currently sorting, sortable, ascending, or sorted.
13
17
  * @property sortIcon
14
18
  * @type {String|null}
15
19
  * @private
@@ -1,10 +1,13 @@
1
- import Sortable from './fw-column-sortable';
2
- import layout from '../templates/components/fw-column-title';
3
-
4
- /**
5
- * Displays a column title which will truncate with an ellipsis if too long
6
- * @public
7
- */
8
- export default Sortable.extend({
9
- layout
10
- });
1
+ import Sortable from './fw-column-sortable';
2
+ import layout from '../templates/components/fw-column-title';
3
+
4
+ /**
5
+ * Displays a column title which will truncate with an ellipsis if too long
6
+ * @public
7
+ * @class FW-Column-Title
8
+ * @module Components
9
+ * @submodule Internal
10
+ */
11
+ export default Sortable.extend({
12
+ layout
13
+ });