@bennerinformatics/ember-fw-table 2.0.17 → 2.0.19

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 (33) 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 +1 -0
  7. package/addon/components/fw-column-sortable.js +5 -1
  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 +231 -20
  11. package/addon/components/fw-row-toggle-index.js +14 -10
  12. package/addon/components/fw-row-toggle.js +5 -3
  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 +3 -4
  16. package/addon/documentation.js +98 -0
  17. package/addon/templates/components/fw-cell-action.hbs +2 -2
  18. package/addon/templates/components/fw-cell-permission-icon.hbs +9 -9
  19. package/addon/templates/components/fw-delete-modal.hbs +12 -12
  20. package/addon/templates/components/fw-pagination-wrapper.hbs +2 -2
  21. package/addon/templates/components/fw-table-resort.hbs +4 -4
  22. package/addon/templates/components/fw-table-sortable.hbs +76 -76
  23. package/addon/utils/base-cells.js +40 -35
  24. package/addon/utils/export.js +76 -72
  25. package/addon/utils/formats.js +46 -42
  26. package/addon/utils/table.js +35 -31
  27. package/app/breakpoints.js +1 -0
  28. package/app/initializers/responsive.js +1 -0
  29. package/bitbucket-helpers-override.js +240 -0
  30. package/index.js +10 -9
  31. package/package.json +7 -3
  32. package/shippable.yml +28 -0
  33. package/yuidoc.json +21 -0
@@ -1,22 +1,24 @@
1
- import Component from '@ember/component';
2
- import {computed} from '@ember/object';
3
- import layout from '../templates/components/fw-table-expanded-row';
4
-
5
- /**
6
- * This component is used internally as the logic behind the rows displayed inside rows
7
- * It is not included in the exports as it is not intended to be called directly
8
- * @protected
9
- */
10
- export default Component.extend({
11
- layout,
12
-
13
- value: computed('rawValue', function() {
14
- let rawValue = this.get('rawValue');
15
- let format = this.get('column.format');
16
-
17
- if (format && typeof format === 'function') {
18
- return format.call(this, rawValue);
19
- }
20
- return rawValue;
21
- })
22
- });
1
+ import Component from '@ember/component';
2
+ import {computed} from '@ember/object';
3
+ import layout from '../templates/components/fw-table-expanded-row';
4
+
5
+ /**
6
+ * This component is used internally as the logic behind the rows displayed inside rows
7
+ * It is not included in the exports as it is not intended to be called directly
8
+ * @protected
9
+ * @module Components
10
+ * @submodule Internal
11
+ */
12
+ export default Component.extend({
13
+ layout,
14
+
15
+ value: computed('rawValue', function() {
16
+ let rawValue = this.get('rawValue');
17
+ let format = this.get('column.format');
18
+
19
+ if (format && typeof format === 'function') {
20
+ return format.call(this, rawValue);
21
+ }
22
+ return rawValue;
23
+ })
24
+ });
@@ -5,19 +5,18 @@ import layout from '../templates/components/fw-table-resort';
5
5
 
6
6
  /**
7
7
  * This table contains logic to resort a "table" of models
8
- * * ```handlebars
8
+ * ```handlebars
9
9
  * {{fw-table-resort items titleKey='name' sortKey='sorted'}}
10
10
  * ```
11
11
  *
12
12
  * If used in a block format instead, it is possible to fully define the title area, such as to replace it with input fields, which also adds a cheveron to expand if desired
13
- * * ```handlebars
13
+ * ```handlebars
14
14
  * {{#fw-table-resort sortKey='sorted' as |item expanded|}}
15
15
  * {{input item.name}}
16
16
  * {{/fw-table-resort}}
17
17
  * ```
18
18
  *
19
- * @class TableResort
20
- * @module ember-fw-table
19
+ * @class FW-Table-Resort
21
20
  * @public
22
21
  */
23
22
  const TableResort = Component.extend({
@@ -60,6 +59,16 @@ const TableResort = Component.extend({
60
59
  */
61
60
  delete: () => {},
62
61
 
62
+ /**
63
+ * The icon that will be used for the delete button. Useful if you want the button to do something other than delete.
64
+ *
65
+ * @public
66
+ * @default fa-regular fa-trash-can
67
+ * @property deleteIcon
68
+ * @type {String}
69
+ */
70
+ deleteIcon: 'fa-regular fa-trash-can',
71
+
63
72
  /**
64
73
  * String pointer to the model's sort key, will be used to sort the items and modify the key later
65
74
  *
@@ -11,12 +11,12 @@ import RSVP from 'rsvp';
11
11
  /**
12
12
  * This table contains logic to show a table as a panel in an app. This table features sorting rows can be expanded
13
13
  * to show hidden data
14
- * * ```handlebars
14
+ * ```handlebars
15
15
  * {{fw-table-sortable data columns title='Table'}}
16
16
  * ```
17
17
  *
18
18
  * If used in a block format instead, it is possible to fully define the title area, replacing the title parameter. The export action is passed as a yield parameter to redefine the export button
19
- * * ```handlebars
19
+ * ```handlebars
20
20
  * {{#fw-table-sortable data columns as |export|}}
21
21
  * <strong class='panel-title'>Table</strong>
22
22
  * {{/fw-table-sortable}}
@@ -29,9 +29,8 @@ import RSVP from 'rsvp';
29
29
  * Alternatively, setting this to `true` or `false` will force the state regardless of a property.
30
30
  * By default will show if the property from `valuePath` is not null
31
31
  *
32
- * @class TableSortable
32
+ * @class FW-Table-Sortable
33
33
  * @extends EmberLightTable
34
- * @module ember-fw-table
35
34
  * @public
36
35
  */
37
36
  const TableSortable = Component.extend({
@@ -0,0 +1,98 @@
1
+ /* Below is the main documentation for the addon. This file is only for documentation, it doesn't actually do anything. */
2
+ /**
3
+ * The primary purpose of ember-fw-table is to make a simplified form of ember-light-table,
4
+ * and which is easier to use than its parent. Within it as well, we have added a few extra
5
+ * things that make more complicated aspects of tables also easier to incorporate (such as
6
+ * paginated tables). For more information on ember-light-table,
7
+ * [see their documentation](https://adopted-ember-addons.github.io/ember-light-table/docs).
8
+ *
9
+ * Because of the design of this addon, it is much simpler than some of Informatics other
10
+ * addons. All of the "internal" elements of this addon, which are used within the addon, but
11
+ * are not designed to be used outside, are in an "Internal" submodule.
12
+ * * [Components](Components.html)
13
+ * - [Main Components](Main.html)
14
+ * - [Internal Components](Internal.html)
15
+ * - [Cell Components](Cell.html)
16
+ * * [Utils](Utils.html)
17
+ *
18
+ * @module Introduction
19
+ * @main Introduction
20
+ */
21
+ /**
22
+ * Ember-FW-Table defines many different components that can be used throughout the Informatics apps. To understand what a component is,
23
+ * [click here](https://guides.emberjs.com/v2.18.0/components/) for Ember's own documentation on components. The main focus of this app
24
+ * is of course the main table Here contains a list
25
+ * of all of the different components that are defined by ember-fw. Ember-fw also adds the ability for more advanced components
26
+ * (which are components that require more than just a simple call to use), such as [Notifications](../classes/NotificationsService.html)
27
+ * and [Modals](Modals.html).
28
+ *
29
+ * @module Components
30
+ * @main Components
31
+ */
32
+ /**
33
+ * Since the main component that is imported with this addon is to do with the table,
34
+ * there are many components that can be explained in detail, but are really only internal to
35
+ * the addon itself, and probably shouldn't be used without a serious reason. Those listed below
36
+ * are technically able to be used by any app which import the addon, but will probably only be
37
+ * helpful documentation for the developer who develops the ember-fw-table addon.
38
+ *
39
+ * @module Components
40
+ * @submodule Internal
41
+ * @main Internal
42
+ */
43
+
44
+ /**
45
+ * There are a few other components which are added in this addon, which are built to be used within
46
+ * the app. Of course the largest of these is the fw-table-sortable, after which the addon derives
47
+ * its name, but there are also other supplemental components designed for use with the app.
48
+ *
49
+ * ***
50
+ *
51
+ * ###Classes
52
+ * * [FW-Table-Sortable](../classes/FW-Table-Sortable.html)
53
+ * * [FW-Table-Resort](../classes/FW-Table-Resort.html)
54
+ * * [FW-Pagination-Wrapper](../classes/FW-Pagination-Wrapper.html)
55
+ * * [FW-Delete-Modal](../classes/FW-Delete-Modal.html)
56
+ *
57
+ * @module Components
58
+ * @submodule Main
59
+ * @main Main
60
+ */
61
+
62
+ /**
63
+ * Some components in this addon were designed to be used with the `cellComponent` value used in the table.
64
+ * For information on how `cellComponent` works, [click here](https://adopted-ember-addons.github.io/ember-light-table/docs/classes/Column.html#property_cellComponent).
65
+ *
66
+ * For each of these cell components, you call them in the following way:
67
+ * ```js
68
+ * column: [
69
+ * {
70
+ * label: 'Actions',
71
+ * cellComponent: 'fw-cell-action'
72
+ * }
73
+ * ]
74
+ * ```
75
+ *
76
+ * ***
77
+ *
78
+ * ### Classes
79
+ * * [FW-Cell-Action](../classes/FW-Cell-Action.html)
80
+ * * [FW-Cell-Boolean](../classes/FW-Cell-Boolean.html)
81
+ * * [FW-Cell-Nullable](../classes/FW-Cell-Nullable.html)
82
+ * * [FW-Cell-Permission-Icon](../classes/FW-Cell-Permission-Icon.html)
83
+ * * [FW-Row-Toggle](../classes/FW-Row-Toggle.html)
84
+ * * [FW-Row-Toggle-Index](../classes/FW-Row-Toggle-Index.html)
85
+ *
86
+ * @module Components
87
+ * @submodule Cell
88
+ * @main Cell
89
+ */
90
+
91
+ /**
92
+ * Utils is short for Utilities, and they are essentially whatever you need them to be. It is simply a way to import a function that does a certain task.
93
+ * In ember-fw-table, we have a few utils files that have been defined, and each has a couple different functions that are semi-related to each other. So each "class"
94
+ * within the utils module actually is simply a group of related functions exported that can be used after they are imported.
95
+ *
96
+ * @module Utils
97
+ * @main Utils
98
+ */
@@ -1,12 +1,12 @@
1
1
  {{#if tableActions.edit}}
2
2
  <button class='btn btn-sm btn-primary' title='Edit' {{action tableActions.edit row.content bubbles=false}}>
3
- <i class='fas fa-pencil-alt'/>
3
+ <i class='fa-solid fa-pencil'/>
4
4
  {{unless column.small 'Edit'}}
5
5
  </button>
6
6
  {{/if}}
7
7
  {{#if tableActions.delete}}
8
8
  <button class='btn btn-sm btn-danger' title='Delete' {{action tableActions.delete row.content bubbles=false}}>
9
- <i class='far fa-trash-alt'/>
9
+ <i class='fa-regular fa-trash-can'/>
10
10
  {{unless column.small 'Delete'}}
11
11
  </button>
12
12
  {{/if}}
@@ -1,9 +1,9 @@
1
- {{#if (eq value 2)}}
2
- <span class="text-success" title="Has Permission"><i class="fas fa-check"></i></span>
3
- {{/if}}
4
- {{#if (eq value 1)}}
5
- <span class="text-primary" title="Permission Determined By Access Control"><i class="fas fa-lock"></i></span>
6
- {{/if}}
7
- {{#if (eq value 0)}}
8
- <span class="text-danger" title="Doesn't Have Permission"><i class="fas fa-times"></i></span>
9
- {{/if}}
1
+ {{#if (eq value 2)}}
2
+ <span class="text-success" title="Has Permission"><i class="fa-solid fa-check"></i></span>
3
+ {{/if}}
4
+ {{#if (eq value 1)}}
5
+ <span class="text-primary" title="Permission Determined By Access Control"><i class="fa-solid fa-lock"></i></span>
6
+ {{/if}}
7
+ {{#if (eq value 0)}}
8
+ <span class="text-danger" title="Doesn't Have Permission"><i class="fa-solid fa-xmark"></i></span>
9
+ {{/if}}
@@ -1,12 +1,12 @@
1
- {{fw-fullscreen-modal "confirm-choice"
2
- size="md"
3
- model=(hash
4
- confirmButtonText="Delete"
5
- confirmButtonStyle="danger"
6
- confirmButtonIcon="far fa-trash-alt"
7
- onconfirm=(action 'deleteModel')
8
- message=_message
9
- )
10
- close=close
11
- scrollTop=scrollTop
12
- }}
1
+ {{fw-fullscreen-modal "confirm-choice"
2
+ size="md"
3
+ model=(hash
4
+ confirmButtonText="Delete"
5
+ confirmButtonStyle="danger"
6
+ confirmButtonIcon="fa-regular fa-trash-can"
7
+ onconfirm=(action 'deleteModel')
8
+ message=_message
9
+ )
10
+ close=close
11
+ scrollTop=scrollTop
12
+ }}
@@ -10,7 +10,7 @@
10
10
  {{fw-loading-spinner}}
11
11
  {{else if pageEntries}}
12
12
  {{!-- Page numbers --}}
13
- {{#if showPages}}
13
+ {{#if (and showPages showPagesTop)}}
14
14
  <div class="text-center" style="overflow:auto">
15
15
  {{page-numbers
16
16
  content=(hash)
@@ -57,7 +57,7 @@
57
57
  {{/if}}
58
58
 
59
59
  {{!-- Second page numbers --}}
60
- {{#if showPages}}
60
+ {{#if (and showPages showPagesBottom)}}
61
61
  <div class="text-center" style="overflow:auto">
62
62
  {{page-numbers
63
63
  content=(hash)
@@ -3,17 +3,17 @@
3
3
  {{#sortable-item tagName="li" model=item group=group handle=".handle" spacing=spacing}}
4
4
  <div class="input-group">
5
5
  <span class="input-group-addon handle draggable">
6
- <i class="fas fa-ellipsis-v fa-2"></i>
6
+ <i class="fa-solid fa-ellipsis-vertical fa-2"></i>
7
7
  </span>
8
8
  {{#if hasBlock}}
9
9
  {{#if allowExpand}}
10
10
  {{#if item.unexpandable}}
11
11
  <span class="input-group-addon">
12
- <i class="fas fa-chevron-right faded"></i>
12
+ <i class="fa-solid fa-chevron-right faded"></i>
13
13
  </span>
14
14
  {{else}}
15
15
  <span class="input-group-addon clickable" {{action "toggleExpanded" item}}>
16
- <i class={{if item.expanded "fas fa-chevron-down" "fas fa-chevron-right"}}></i>
16
+ <i class={{if item.expanded "fa-solid fa-chevron-down" "fa-solid fa-chevron-right"}}></i>
17
17
  </span>
18
18
  {{/if}}
19
19
  {{/if}}
@@ -28,7 +28,7 @@
28
28
  <span class="input-group-addon">&nbsp;&nbsp;&nbsp;</span>
29
29
  {{else}}
30
30
  <span class="input-group-addon clickable" {{action "deleteItem" item}}>
31
- <i class="far fa-trash-alt fa-2"></i>
31
+ <i class={{deleteIcon}}></i>
32
32
  </span>
33
33
  {{/if}}
34
34
  {{else}}
@@ -1,76 +1,76 @@
1
- {{#if (or (and hasBlock showHeader) title canExport)}}
2
- <header class="panel-heading">
3
- {{#if (and hasBlock showHeader)}}
4
- {{yield (action 'export') true}}
5
- {{else}}
6
- <strong class="panel-title">{{or title 'Table'}}</strong>
7
- {{#if (and deleteTable deleteTablePermission)}}
8
- {{fw-promise-button
9
- class="btn btn-xs pull-right"
10
- buttonIcon='far fa-trash-alt'
11
- buttonText=deleteTitle
12
- buttonStyle='danger'
13
- promise=(action deleteTable data)
14
- type='submit'
15
- }}
16
- {{/if}}
17
- {{#if canExport}}
18
- <button class="btn btn-xs btn-primary pull-right" {{action 'export'}}>
19
- <i class="far fa-file-excel"/>
20
- {{exportTitle}}
21
- </button>
22
- {{/if}}
23
- {{/if}}
24
- <div class="clearfix"/>
25
- </header>
26
- {{/if}}
27
- <section class="panel-body table-body">
28
- {{#if (and table.isEmpty (not headerEmpty))}}
29
- {{empty}}
30
- {{else}}
31
- {{#light-table
32
- table
33
- height=fixedHeight
34
- tableClassNames=(concat "table table-striped table-bordered " tableClassNames)
35
- tableActions=tableActions
36
- responsive=responsive
37
- breakpoints=breakpoints
38
- as |t|
39
- }}
40
- {{t.head
41
- onColumnClick=(action 'sort')
42
- iconAscending='fas fa-sort-up'
43
- iconDescending='fas fa-sort-down'
44
- iconSortable='fas fa-sort'
45
- sortOnClick=false
46
- fixed=(if fixedHeight true false)
47
- }}
48
- {{#t.body
49
- canExpand=hasExpandedColumns
50
- onRowClick=(action 'expand')
51
- expandOnClick=false
52
- multiRowExpansion=false
53
- rowComponent=(component 'fw-expandable-row')
54
- canSelect=false
55
- as |body|
56
- }}
57
- {{#if table.hasExpandedColumns}}
58
- {{#body.expanded-row as |row|}}
59
- {{fw-table-expanded-rows tableActions=tableActions table=table row=row}}
60
- {{/body.expanded-row}}
61
- {{/if}}
62
-
63
- {{#if table.isEmpty}}
64
- {{#body.no-data}}
65
- {{empty}}
66
- {{/body.no-data}}
67
- {{/if}}
68
- {{/t.body}}
69
- {{/light-table}}
70
- {{/if}}
71
- </section>
72
- {{#if (and hasBlock showFooter)}}
73
- <footer class="panel-footer clearfix">
74
- {{yield (action 'export') false}}
75
- </footer>
76
- {{/if}}
1
+ {{#if (or (and hasBlock showHeader) title canExport)}}
2
+ <header class="panel-heading">
3
+ {{#if (and hasBlock showHeader)}}
4
+ {{yield (action 'export') true}}
5
+ {{else}}
6
+ <strong class="panel-title">{{or title 'Table'}}</strong>
7
+ {{#if (and deleteTable deleteTablePermission)}}
8
+ {{fw-promise-button
9
+ class="btn btn-xs pull-right"
10
+ buttonIcon='fa-regular fa-trash-can'
11
+ buttonText=deleteTitle
12
+ buttonStyle='danger'
13
+ promise=(action deleteTable data)
14
+ type='submit'
15
+ }}
16
+ {{/if}}
17
+ {{#if canExport}}
18
+ <button class="btn btn-xs btn-primary pull-right" {{action 'export'}}>
19
+ <i class="fa-regular fa-file-excel"/>
20
+ {{exportTitle}}
21
+ </button>
22
+ {{/if}}
23
+ {{/if}}
24
+ <div class="clearfix"/>
25
+ </header>
26
+ {{/if}}
27
+ <section class="panel-body table-body">
28
+ {{#if (and table.isEmpty (not headerEmpty))}}
29
+ {{empty}}
30
+ {{else}}
31
+ {{#light-table
32
+ table
33
+ height=fixedHeight
34
+ tableClassNames=(concat "table table-striped table-bordered " tableClassNames)
35
+ tableActions=tableActions
36
+ responsive=responsive
37
+ breakpoints=breakpoints
38
+ as |t|
39
+ }}
40
+ {{t.head
41
+ onColumnClick=(action 'sort')
42
+ iconAscending='fa-solid fa-sort-up'
43
+ iconDescending='fa-solid fa-sort-down'
44
+ iconSortable='fa-solid fa-sort'
45
+ sortOnClick=false
46
+ fixed=(if fixedHeight true false)
47
+ }}
48
+ {{#t.body
49
+ canExpand=hasExpandedColumns
50
+ onRowClick=(action 'expand')
51
+ expandOnClick=false
52
+ multiRowExpansion=false
53
+ rowComponent=(component 'fw-expandable-row')
54
+ canSelect=false
55
+ as |body|
56
+ }}
57
+ {{#if table.hasExpandedColumns}}
58
+ {{#body.expanded-row as |row|}}
59
+ {{fw-table-expanded-rows tableActions=tableActions table=table row=row}}
60
+ {{/body.expanded-row}}
61
+ {{/if}}
62
+
63
+ {{#if table.isEmpty}}
64
+ {{#body.no-data}}
65
+ {{empty}}
66
+ {{/body.no-data}}
67
+ {{/if}}
68
+ {{/t.body}}
69
+ {{/light-table}}
70
+ {{/if}}
71
+ </section>
72
+ {{#if (and hasBlock showFooter)}}
73
+ <footer class="panel-footer clearfix">
74
+ {{yield (action 'export') false}}
75
+ </footer>
76
+ {{/if}}
@@ -1,35 +1,40 @@
1
- /**
2
- * Creates a generic row toggle object
3
- * @param {Object} extra Additional values to add to the row toggle. Breakpoints is the most common one
4
- * @return {Object} Object to use as a row toggle column
5
- */
6
- export function rowToggle(extra = {}) {
7
- let {valuePath} = extra;
8
- return Object.assign({
9
- label: valuePath ? '#' : '',
10
- width: valuePath ? '40px' : '35px',
11
- align: valuePath ? 'toggle' : 'center',
12
- sortable: !!valuePath,
13
- canExport: false,
14
- showExpanded: false,
15
- cellComponent: valuePath ? 'fw-row-toggle-index' : 'fw-row-toggle'
16
- }, extra);
17
- }
18
-
19
- /**
20
- * Creates a generic action cell
21
- * @param {Object} extra Additional values to add to the action buttons. Small is useful to shrink it with breakpoints
22
- * @return {Object} Object to use as an actions button column
23
- */
24
- export function actions(extra = {}) {
25
- let {small} = extra;
26
- return Object.assign({
27
- label: 'Actions',
28
- // if small is set, shrink the width
29
- width: small ? '95px' : '170px',
30
- sortable: false,
31
- canExport: false,
32
- showExpanded: false,
33
- cellComponent: 'fw-cell-action'
34
- }, extra);
35
- }
1
+ /**
2
+ * DESCRIPTION NEEDED
3
+ * @class BaseCells
4
+ * @module Utils
5
+ */
6
+ /**
7
+ * Creates a generic row toggle object
8
+ * @param {Object} extra Additional values to add to the row toggle. Breakpoints is the most common one
9
+ * @return {Object} Object to use as a row toggle column
10
+ */
11
+ export function rowToggle(extra = {}) {
12
+ let {valuePath} = extra;
13
+ return Object.assign({
14
+ label: valuePath ? '#' : '',
15
+ width: valuePath ? '40px' : '35px',
16
+ align: valuePath ? 'toggle' : 'center',
17
+ sortable: !!valuePath,
18
+ canExport: false,
19
+ showExpanded: false,
20
+ cellComponent: valuePath ? 'fw-row-toggle-index' : 'fw-row-toggle'
21
+ }, extra);
22
+ }
23
+
24
+ /**
25
+ * Creates a generic action cell
26
+ * @param {Object} extra Additional values to add to the action buttons. Small is useful to shrink it with breakpoints
27
+ * @return {Object} Object to use as an actions button column
28
+ */
29
+ export function actions(extra = {}) {
30
+ let {small} = extra;
31
+ return Object.assign({
32
+ label: 'Actions',
33
+ // if small is set, shrink the width
34
+ width: small ? '95px' : '170px',
35
+ sortable: false,
36
+ canExport: false,
37
+ showExpanded: false,
38
+ cellComponent: 'fw-cell-action'
39
+ }, extra);
40
+ }