@bennerinformatics/ember-fw-table 2.0.21 → 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.
Files changed (106) hide show
  1. package/README.md +6 -0
  2. package/addon/classes/Row.js +19 -13
  3. package/addon/classes/Table.js +18 -13
  4. package/addon/components/fw-cell-action.js +9 -5
  5. package/addon/components/fw-cell-boolean.js +4 -3
  6. package/addon/components/fw-cell-nullable.js +5 -2
  7. package/addon/components/fw-cell-permission-icon.js +19 -3
  8. package/addon/components/fw-column-sortable.js +12 -4
  9. package/addon/components/fw-column-title.js +12 -4
  10. package/addon/components/fw-delete-modal.js +30 -11
  11. package/addon/components/fw-expandable-row.js +5 -0
  12. package/addon/components/fw-pagination-wrapper.js +81 -162
  13. package/addon/components/fw-row-toggle-index.js +4 -4
  14. package/addon/components/fw-row-toggle.js +12 -5
  15. package/addon/components/fw-table-expanded-row.js +5 -6
  16. package/addon/components/fw-table-expanded-rows.js +8 -4
  17. package/addon/components/fw-table-resort.js +29 -16
  18. package/addon/components/fw-table-sortable.js +40 -24
  19. package/addon/documentation.js +26 -61
  20. package/addon/templates/components/fw-delete-modal.hbs +1 -1
  21. package/addon/utils/base-cells.js +40 -5
  22. package/addon/utils/export.js +3 -1
  23. package/addon/utils/formats.js +54 -7
  24. package/addon/utils/table.js +2 -1
  25. package/index.js +2 -1
  26. package/package.json +5 -7
  27. package/yuidoc-ember-theme/LICENSE +21 -0
  28. package/yuidoc-ember-theme/README.md +88 -0
  29. package/yuidoc-ember-theme/assets/css/custom.css +82 -0
  30. package/yuidoc-ember-theme/assets/css/external-small.png +0 -0
  31. package/yuidoc-ember-theme/assets/css/main.css +793 -0
  32. package/yuidoc-ember-theme/assets/css/theme.css +547 -0
  33. package/yuidoc-ember-theme/assets/icons/android-icon-144x144.png +0 -0
  34. package/yuidoc-ember-theme/assets/icons/android-icon-192x192.png +0 -0
  35. package/yuidoc-ember-theme/assets/icons/android-icon-36x36.png +0 -0
  36. package/yuidoc-ember-theme/assets/icons/android-icon-48x48.png +0 -0
  37. package/yuidoc-ember-theme/assets/icons/android-icon-72x72.png +0 -0
  38. package/yuidoc-ember-theme/assets/icons/android-icon-96x96.png +0 -0
  39. package/yuidoc-ember-theme/assets/icons/apple-icon-114x114.png +0 -0
  40. package/yuidoc-ember-theme/assets/icons/apple-icon-120x120.png +0 -0
  41. package/yuidoc-ember-theme/assets/icons/apple-icon-144x144.png +0 -0
  42. package/yuidoc-ember-theme/assets/icons/apple-icon-152x152.png +0 -0
  43. package/yuidoc-ember-theme/assets/icons/apple-icon-180x180.png +0 -0
  44. package/yuidoc-ember-theme/assets/icons/apple-icon-57x57.png +0 -0
  45. package/yuidoc-ember-theme/assets/icons/apple-icon-60x60.png +0 -0
  46. package/yuidoc-ember-theme/assets/icons/apple-icon-72x72.png +0 -0
  47. package/yuidoc-ember-theme/assets/icons/apple-icon-76x76.png +0 -0
  48. package/yuidoc-ember-theme/assets/icons/apple-icon-precomposed.png +0 -0
  49. package/yuidoc-ember-theme/assets/icons/apple-icon.png +0 -0
  50. package/yuidoc-ember-theme/assets/icons/browserconfig.xml +2 -0
  51. package/yuidoc-ember-theme/assets/icons/favicon-16x16.png +0 -0
  52. package/yuidoc-ember-theme/assets/icons/favicon-32x32.png +0 -0
  53. package/yuidoc-ember-theme/assets/icons/favicon-96x96.png +0 -0
  54. package/yuidoc-ember-theme/assets/icons/favicon.ico +0 -0
  55. package/yuidoc-ember-theme/assets/icons/manifest.json +41 -0
  56. package/yuidoc-ember-theme/assets/icons/ms-icon-144x144.png +0 -0
  57. package/yuidoc-ember-theme/assets/icons/ms-icon-150x150.png +0 -0
  58. package/yuidoc-ember-theme/assets/icons/ms-icon-310x310.png +0 -0
  59. package/yuidoc-ember-theme/assets/icons/ms-icon-70x70.png +0 -0
  60. package/yuidoc-ember-theme/assets/img/ember-logo.png +0 -0
  61. package/yuidoc-ember-theme/assets/img/fw-logo.png +0 -0
  62. package/yuidoc-ember-theme/assets/img/spinner.gif +0 -0
  63. package/yuidoc-ember-theme/assets/index.html +10 -0
  64. package/yuidoc-ember-theme/assets/js/yuidoc-bootstrap.js +274 -0
  65. package/yuidoc-ember-theme/assets/vendor/bootstrap/css/bootstrap.css +6760 -0
  66. package/yuidoc-ember-theme/assets/vendor/bootstrap/css/bootstrap.min.css +6 -0
  67. package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  68. package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
  69. package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  70. package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  71. package/yuidoc-ember-theme/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  72. package/yuidoc-ember-theme/assets/vendor/bootstrap/img/glyphicons-halflings-white.png +0 -0
  73. package/yuidoc-ember-theme/assets/vendor/bootstrap/img/glyphicons-halflings.png +0 -0
  74. package/yuidoc-ember-theme/assets/vendor/bootstrap/js/bootstrap.js +2363 -0
  75. package/yuidoc-ember-theme/assets/vendor/bootstrap/js/bootstrap.min.js +7 -0
  76. package/yuidoc-ember-theme/assets/vendor/font-awesome/css/font-awesome.css +2199 -0
  77. package/yuidoc-ember-theme/assets/vendor/font-awesome/css/font-awesome.min.css +4 -0
  78. package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/FontAwesome.otf +0 -0
  79. package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  80. package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.svg +685 -0
  81. package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  82. package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  83. package/yuidoc-ember-theme/assets/vendor/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  84. package/yuidoc-ember-theme/assets/vendor/github-slugger/slugger.js +59 -0
  85. package/yuidoc-ember-theme/assets/vendor/jquery/jquery.min.js +6 -0
  86. package/yuidoc-ember-theme/assets/vendor/jquery-ui/jquery-ui.min.js +6 -0
  87. package/yuidoc-ember-theme/assets/vendor/prettify/prettify-min.css +1 -0
  88. package/yuidoc-ember-theme/assets/vendor/prettify/prettify-min.js +1 -0
  89. package/yuidoc-ember-theme/helpers/helpers.js +236 -0
  90. package/yuidoc-ember-theme/layouts/main.handlebars +111 -0
  91. package/yuidoc-ember-theme/layouts/xhr.handlebars +7 -0
  92. package/yuidoc-ember-theme/package.json +15 -0
  93. package/yuidoc-ember-theme/partials/attrs.handlebars +144 -0
  94. package/yuidoc-ember-theme/partials/classes.handlebars +229 -0
  95. package/yuidoc-ember-theme/partials/events.handlebars +140 -0
  96. package/yuidoc-ember-theme/partials/files.handlebars +9 -0
  97. package/yuidoc-ember-theme/partials/index.handlebars +25 -0
  98. package/yuidoc-ember-theme/partials/method.handlebars +193 -0
  99. package/yuidoc-ember-theme/partials/module.handlebars +108 -0
  100. package/yuidoc-ember-theme/partials/options.handlebars +22 -0
  101. package/yuidoc-ember-theme/partials/props.handlebars +122 -0
  102. package/yuidoc-ember-theme/partials/sidebar.handlebars +77 -0
  103. package/yuidoc-ember-theme/theme.json +4 -0
  104. package/yuidoc-ember-theme/yarn.lock +4 -0
  105. package/yuidoc.json +4 -2
  106. /package/{bitbucket-helpers-override.js → yuidoc-ember-theme/helpers/bitbucket-helpers-override.js} +0 -0
@@ -4,26 +4,35 @@ import {alias, filter, filterBy, sort} from '@ember/object/computed';
4
4
  import layout from '../templates/components/fw-table-resort';
5
5
 
6
6
  /**
7
- * This table contains logic to resort a "table" of models
7
+ * This table contains client-side logic to resort a "table" of models. This resort table will not call the actual serverside "save" function, so you will need to persist the changes to the database yourself,
8
+ * but it will do everything else for you (ie all you should have to do is call save, and the reorder will work). A basic usage example is the following:
9
+ *
8
10
  * ```handlebars
9
11
  * <FwTableResort @items={{items}} @titleKey='name' @sortKey='sorted' />
10
12
  * ```
11
13
  *
12
14
  * 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
15
  * ```handlebars
14
- * <FwTableResort @sortKey='sorted' as |item expanded|>
16
+ * <FwTableResort @items={{items}} @sortKey='sorted' as |item expanded|>
15
17
  * {{input item.name}}
16
18
  * </FwTableResort>
17
19
  * ```
18
- *
19
- * @class FW-Table-Resort
20
+ * Currently the only way to have a display title different from the default sort is to use the block format manually (set the `titleKey` to the desired default sort, and then manually display
21
+ * the other desired property).
22
+ * @class FwTableResort
20
23
  * @public
24
+ * @module Components
21
25
  */
22
26
  const TableResort = Component.extend({
23
27
  layout,
24
28
  tagName: 'section',
25
29
  classNames: ['panel-body', 'fw-table-resort'],
26
-
30
+ /**
31
+ * Required property. This is what you pass the array of items you wish to sort with the table.
32
+ * @public
33
+ * @property items
34
+ * @type {Boolean}
35
+ */
27
36
  /**
28
37
  * If true, show an expand button for more fields
29
38
  *
@@ -37,14 +46,16 @@ const TableResort = Component.extend({
37
46
  * Filter called to check if an item is active
38
47
  *
39
48
  * @public
49
+ * @property activeFilter
40
50
  * @type {Function}
41
51
  */
42
52
  activeFilter: null,
43
53
 
44
54
  /**
45
- * Filter called to check if an item is active
55
+ * Key used to determine if an item is active
46
56
  *
47
57
  * @public
58
+ * @property activeKey
48
59
  * @type {String}
49
60
  */
50
61
  activeKey: null,
@@ -99,13 +110,13 @@ const TableResort = Component.extend({
99
110
  * Tolerance before dragging starts
100
111
  *
101
112
  * @public
102
- * @property spacing
113
+ * @property distance
103
114
  * @type {Number}
104
115
  */
105
116
  distance: 0,
106
117
 
107
118
  /**
108
- * A list of all items which will be shown in the table
119
+ * An internal list of all items which will be shown in the table (takes into account activeKey and activeFilter)
109
120
  *
110
121
  * @private
111
122
  * @property viewableItems
@@ -133,18 +144,18 @@ const TableResort = Component.extend({
133
144
  this._super(...arguments);
134
145
 
135
146
  // determine the default sort order from the sortkey
136
- this.set('_sortOrder', [this.get('sortKey')]);
147
+ this.set('_sortOrder', [this.sortKey]);
137
148
  // if we have a fallback for default is null, add that as well
138
- if (this.get('titleKey')) {
139
- this.get('_sortOrder').pushObject(this.get('titleKey'));
149
+ if (this.titleKey) {
150
+ this._sortOrder.pushObject(this.titleKey);
140
151
  }
141
152
 
142
153
  // determine how we will filter the viewable items based on what the user gave
143
154
  // if its a key, either filter type
144
- let activeKey = this.get('activeKey');
155
+ let activeKey = this.activeKey;
145
156
  if (activeKey) {
146
157
  // have a function? use that
147
- let activeFilter = this.get('activeFilter');
158
+ let activeFilter = this.activeFilter;
148
159
  if (activeFilter) {
149
160
  defineProperty(this, 'viewableItems', filter(`items.@each.${activeKey}`, activeFilter));
150
161
  } else {
@@ -159,15 +170,17 @@ const TableResort = Component.extend({
159
170
 
160
171
  /**
161
172
  * Helper function to sort a list of passed items
173
+ * @method reorderItems
162
174
  * @param {DS.Model[]} items Model array
175
+ * @private
163
176
  */
164
177
  reorderItems(items) {
165
- let activeFilter = this.get('activeFilter');
178
+ let activeFilter = this.activeFilter;
166
179
  if (activeFilter) {
167
180
  items = items.filter(activeFilter);
168
181
  }
169
182
  items.forEach((item, index) => {
170
- item.set(this.get('sortKey'), index + 1);
183
+ item.set(this.sortKey, index + 1);
171
184
  });
172
185
  },
173
186
 
@@ -194,7 +207,7 @@ const TableResort = Component.extend({
194
207
  */
195
208
  deleteItem(item) {
196
209
  this.delete(item);
197
- this.reorderItems(this.get('sortedItems'));
210
+ this.reorderItems(this.sortedItems);
198
211
  }
199
212
  }
200
213
  });
@@ -12,12 +12,12 @@ import RSVP from 'rsvp';
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
14
  * ```handlebars
15
- * <FwTableSortable @data={{data}} @columns={{columns}} @title='Table' />
15
+ * <FwTableSortable @data={{model}} @columns={{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
19
  * ```handlebars
20
- * <FwTableSortable @data={{data}} @columns={{columns}} as |export|>
20
+ * <FwTableSortable @data={{model}} @columns={{columns}} as |export|>
21
21
  * <strong class='panel-title'>Table</strong>
22
22
  * </FwTableSortable>
23
23
  * ```
@@ -29,7 +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 FW-Table-Sortable
32
+ * @class FwTableSortable
33
+ * @module Components
33
34
  * @extends EmberLightTable
34
35
  * @public
35
36
  */
@@ -110,6 +111,7 @@ const TableSortable = Component.extend({
110
111
  * @public
111
112
  * @property headerEmpty
112
113
  * @type {Boolean}
114
+ * @default true
113
115
  */
114
116
  headerEmpty: true,
115
117
  /**
@@ -126,6 +128,7 @@ const TableSortable = Component.extend({
126
128
  * @public
127
129
  * @property responsive
128
130
  * @type {Boolean}
131
+ * @default false
129
132
  */
130
133
  responsive: false,
131
134
 
@@ -145,10 +148,13 @@ const TableSortable = Component.extend({
145
148
  * * `canExport`: if true (default), the column will be included in the export. Set to false to skip exporting the column.
146
149
  * * `exportOnly`: if true, the column will not show in the table, but will still be exported.
147
150
  *
148
- * Additionally, the value `export` is set to true in `format`'s context
151
+ * Additionally, the value `export` is set to true in `format`'s context.
152
+ *
153
+ * If this is set to a string, the string is used as the name of the export button.
149
154
  * @public
150
155
  * @property canExport
151
- * @type {Boolean}
156
+ * @type {Boolean | String}
157
+ * @default false
152
158
  */
153
159
  canExport: false,
154
160
 
@@ -158,6 +164,7 @@ const TableSortable = Component.extend({
158
164
  * @public
159
165
  * @property showHeader
160
166
  * @type {Boolean}
167
+ * @default true
161
168
  */
162
169
  showHeader: true,
163
170
 
@@ -167,6 +174,7 @@ const TableSortable = Component.extend({
167
174
  * @public
168
175
  * @property showFooter
169
176
  * @type {Boolean}
177
+ * @default true
170
178
  */
171
179
  showFooter: false,
172
180
 
@@ -187,7 +195,7 @@ const TableSortable = Component.extend({
187
195
  * @type {Array}
188
196
  */
189
197
  _defaultSort: computed('defaultSort', function() {
190
- let defaultSort = this.get('defaultSort');
198
+ let defaultSort = this.defaultSort;
191
199
  if (isNone(defaultSort)) {
192
200
  return [];
193
201
  }
@@ -214,11 +222,11 @@ const TableSortable = Component.extend({
214
222
  * @type {Array}
215
223
  */
216
224
  sortOrder: computed('_defaultSort.[]', 'sortColumn', function() {
217
- let sortColumn = this.get('sortColumn');
225
+ let sortColumn = this.sortColumn;
218
226
  if (sortColumn) {
219
- return [sortColumn].pushObjects(this.get('_defaultSort'));
227
+ return [sortColumn].pushObjects(this._defaultSort);
220
228
  }
221
- return this.get('_defaultSort');
229
+ return this._defaultSort;
222
230
  }),
223
231
 
224
232
  /**
@@ -247,7 +255,7 @@ const TableSortable = Component.extend({
247
255
  * @type {String}
248
256
  */
249
257
  exportTitle: computed('canExport', function() {
250
- let canExport = this.get('canExport');
258
+ let canExport = this.canExport;
251
259
  if (canExport === true) {
252
260
  return 'Export';
253
261
  }
@@ -255,26 +263,34 @@ const TableSortable = Component.extend({
255
263
  }),
256
264
 
257
265
  /**
258
- * Called to delete the full page of entries
266
+ * Called to delete the full page of entries. Pass in the action to be called by the button.
267
+ *
268
+ * @property deleteTable
269
+ * @type {Action}
270
+ * @default undefined
259
271
  */
260
272
  deleteTable: undefined,
261
273
 
262
274
  /**
263
- * Determines title for delete function
275
+ * Determines title for delete function. This will only be used if deleteTable action is passed in.
276
+ *
277
+ * @property deleteOverrideTitle
278
+ * @type {String}
264
279
  */
265
280
  deleteOverrideTitle: null,
266
281
 
267
282
  deleteTitle: computed('deleteTable', 'deleteOverrideTitle', function() {
268
- if (!this.get('deleteTable')) {
283
+ if (!this.deleteTable) {
269
284
  return null;
270
285
  } else {
271
- return this.get('deleteOverrideTitle') ? this.get('deleteOverrideTitle') : 'Delete All';
286
+ return this.deleteOverrideTitle ? this.deleteOverrideTitle : 'Delete All';
272
287
  }
273
288
  }),
274
289
 
275
290
  /**
276
291
  * Determines if the current user has permission to delete the table (usually has-role helper will be used to determine this)
277
- * example: deleteTablePermission=(has-role 'admin')
292
+ * example: `@deleteTablePermission={{has-role 'admin'}}`. This will only be used if `deleteTable` action is passed in.
293
+ * @property deleteTablePermissions
278
294
  * @type {Boolean}
279
295
  * @default true
280
296
  */
@@ -288,8 +304,8 @@ const TableSortable = Component.extend({
288
304
  */
289
305
  // eslint-disable-next-line ember/no-observers
290
306
  updateTableRows: observer('sortedData', function() {
291
- if (this.get('table')) {
292
- this.get('table').setRows(this.get('sortedData'));
307
+ if (this.table) {
308
+ this.table.setRows(this.sortedData);
293
309
  }
294
310
  }),
295
311
 
@@ -301,8 +317,8 @@ const TableSortable = Component.extend({
301
317
  */
302
318
  // eslint-disable-next-line ember/no-observers
303
319
  updateTableColumns: observer('columns', function() {
304
- if (this.get('table')) {
305
- this.get('table').setColumns(this.get('columns'));
320
+ if (this.table) {
321
+ this.table.setColumns(this.columns);
306
322
  }
307
323
  }),
308
324
 
@@ -315,8 +331,8 @@ const TableSortable = Component.extend({
315
331
  didReceiveAttrs() {
316
332
  this._super(...arguments);
317
333
  // first, determine our sorting
318
- let defaultSort = this.get('_defaultSort');
319
- let columns = this.get('columns') || [];
334
+ let defaultSort = this._defaultSort;
335
+ let columns = this.columns || [];
320
336
  if (!isEmpty(defaultSort)) {
321
337
  // make a map of key to ascending
322
338
  let [mainKey] = defaultSort;
@@ -330,9 +346,9 @@ const TableSortable = Component.extend({
330
346
  return key === mainKey ? Object.assign({}, column, {sorted: true, ascending}) : column;
331
347
  });
332
348
  }
333
- this.set('table', newTable(columns, this.get('sortedData')));
349
+ this.set('table', newTable(columns, this.sortedData));
334
350
 
335
- if (this.get('noPanel')) {
351
+ if (this.noPanel) {
336
352
  this.set('classNames', null);
337
353
  }
338
354
  },
@@ -386,7 +402,7 @@ const TableSortable = Component.extend({
386
402
  * Called by the export button to export the current table data to CSV
387
403
  */
388
404
  export() {
389
- exportTable(this.get('table'), this.get('title'));
405
+ exportTable(this.table, this.title);
390
406
  }
391
407
  }
392
408
  });
@@ -4,64 +4,22 @@
4
4
  * and which is easier to use than its parent. Within it as well, we have added a few extra
5
5
  * things that make more complicated aspects of tables also easier to incorporate (such as
6
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)
7
+ * [see their documentation](https://adopted-ember-addons.github.io/ember-light-table/docs). For a more
8
+ * comprehensive guide to Ember FW Table, see our [Ember FW Table](https://linformatics.bitbucket.io/docs/addons/client/ember-fw-table).
9
+ * This is just designed to be API docs to briefly describe various elements and how to use them.
17
10
  *
18
11
  * @module Introduction
19
12
  * @main Introduction
20
13
  */
21
14
  /**
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).
15
+ * Components defined by Ember FW Table.
28
16
  *
29
17
  * @module Components
30
18
  * @main Components
31
19
  */
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
20
 
44
21
  /**
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).
22
+ * Cell Components in Ember FW Table.
65
23
  *
66
24
  * For each of these cell components, you call them in the following way:
67
25
  * ```js
@@ -73,25 +31,32 @@
73
31
  * ]
74
32
  * ```
75
33
  *
76
- * ***
77
34
  *
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)
35
+ * @module CellComponents
36
+ * @main CellComponents
37
+ */
38
+
39
+ /**
40
+ * Column Components in Ember FW Table.
41
+ *
42
+ * For each of these column components, call them in the following way:
43
+ *
44
+ * ```js
45
+ * columns: [
46
+ * {
47
+ * label: 'Column',
48
+ * component: 'fw-column-title'
49
+ * }
50
+ * ]
51
+ *
52
+ * ```
85
53
  *
86
- * @module Components
87
- * @submodule Cell
88
- * @main Cell
54
+ * @module ColumnComponents
55
+ * @main ColumnComponents
89
56
  */
90
57
 
91
58
  /**
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.
59
+ * Utils defined in Ember FW Table.
95
60
  *
96
61
  * @module Utils
97
62
  * @main Utils
@@ -1,4 +1,4 @@
1
- <FwFullscreenModal @modal="confirm-choice" @size="md" @model={{hash
1
+ <FwFullscreenModal @modal="confirm-choice" @size="sm" @model={{hash
2
2
  confirmButtonText="Delete"
3
3
  confirmButtonStyle="danger"
4
4
  confirmButtonIcon="fa-regular fa-trash-can"
@@ -1,11 +1,30 @@
1
1
  /**
2
- * DESCRIPTION NEEDED
2
+ * This util is designed to create the most basic defined cells for you. While it does not cover all the cellComponents, the most commonly used (`FwRowToggle`, `FwRowToggleIndex`, and `FwCellAction`) can be imported
3
+ * rather than creating the cell object yourself. You would import them in the following way:
4
+ * ```js
5
+ * import {functionName} from '@bennerinformatics/ember-fw-table/base-cells';
6
+ * ```
7
+ * After it is imported, the functions below tell you how to implement each one.
3
8
  * @class BaseCells
4
9
  * @module Utils
5
10
  */
6
11
  /**
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
12
+ * Creates a generic row toggle object. If you pass in a `valuePath` to extra, it will format using the `FwRowToggleIndex` component (which displays a value on hover) rather than just the regular
13
+ * `FwRowToggle`. This should be the first cell defined in the columns arraw. An example use case would be the following (after importing `rowToggle` as defined above):
14
+ * ```js
15
+ * //generic rowToggle, no differences
16
+ * columns: [
17
+ * rowToggle(),
18
+ * ...
19
+ * ],
20
+ * //rowToggle when you need to pass in something to extra, such as valuePath or breakpoints
21
+ * columns: [
22
+ * rowToggle({breakpoints: ['mobile']}),
23
+ * ...
24
+ * ]
25
+ * ```
26
+ * @method rowToggle
27
+ * @param {Object} extra Additional values to add to the row toggle. Breakpoints is the most common one, but will accept any normal column inputs
9
28
  * @return {Object} Object to use as a row toggle column
10
29
  */
11
30
  export function rowToggle(extra = {}) {
@@ -22,8 +41,24 @@ export function rowToggle(extra = {}) {
22
41
  }
23
42
 
24
43
  /**
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
44
+ * Creates a generic action cell, with a delete and edit button. Passing `small` into extra, will display as only icon buttons, whereas the full text will be displayed if it is not set.
45
+ * This should always be the last cell in your columns array. An example use case would be the following (after importing as above):
46
+ * ```js
47
+ * //will render action cell with icon buttons only
48
+ * columns: [
49
+ * ...
50
+ * actions({small: true})
51
+ * ],
52
+ * //will render action cell with full text of "Edit" and "Delete"
53
+ * columns: [
54
+ * ...
55
+ * actions()
56
+ * ]
57
+ * ```
58
+ *
59
+ * **Note**: You will still need to pass in your edit and delete actions to the `tableActions` in the `FwTableSortable` component in order for this to work properly. This only renders the cell.
60
+ * @method actions
61
+ * @param {Object} extra Additional values to add to the action buttons. Small is useful to shrink it with breakpoints.
27
62
  * @return {Object} Object to use as an actions button column
28
63
  */
29
64
  export function actions(extra = {}) {
@@ -2,12 +2,13 @@ import EmberObject from '@ember/object';
2
2
  import {isEmpty, isNone} from '@ember/utils';
3
3
  import Papa from 'papaparse';
4
4
  /**
5
- * Used internally only. DESCRIPTION NEEDED
5
+ * An internal util that is used in ember-fw-table for the export functionality, both in the `FwTableSortable` and `FwPaginationWrapper`.
6
6
  * @class Export
7
7
  * @module Utils
8
8
  */
9
9
  /**
10
10
  * Creates a CSV file from a data array and a title
11
+ * @method createCSV
11
12
  * @param {Array} data Array of table cells
12
13
  * @param {Title} [name=null] Name to export
13
14
  */
@@ -29,6 +30,7 @@ export function createCSV(data, name = null) {
29
30
 
30
31
  /**
31
32
  * Exports an Ember Light Table to CSV
33
+ * @method exportTable
32
34
  * @param {Table} table Table class, just needs to include rows and columns
33
35
  * @param {String} [title='Export'] Title to use for exporting
34
36
  */
@@ -2,12 +2,25 @@
2
2
  import {htmlSafe} from '@ember/string';
3
3
  import {isNone} from '@ember/utils';
4
4
  /**
5
- * DESCRIPTION NEEDED
5
+ * These utils are designed for helping you be able to easily format a column by passing this function into the `format` attribute of the column. To use these functions, all you need to do
6
+ * is import them at the top of the Javascript file, with the following import:
7
+ * ```js
8
+ * import {functionName} from '@bennerinformatics/ember-fw-table/utils/formats';
9
+ * ```
10
+ * Then you use it in the column array to format it appropriately. Each function gives you an example of how to use it.
6
11
  * @class Format
7
12
  * @module Utils
8
13
  */
9
14
  /**
10
- * Format function which replaces the value with a basic Yes/No format for if its true or false
15
+ * Format function which replaces the value with a basic Yes/No format for if its true or false. Designed to be used in the following way with a boolean column (after importing `formatBoolean` in the way described above):
16
+ * ```js
17
+ * column: [{
18
+ * label: 'My Boolean',
19
+ * valuePath: 'myBoolean',
20
+ * format: formatBoolean
21
+ * ...
22
+ * }...],
23
+ * @method formatBoolean
11
24
  * @param {Any} value Value to test
12
25
  * @return {String} "Yes" if the value is truthy, "No" otherwise
13
26
  */
@@ -16,22 +29,56 @@ export function formatBoolean(value) {
16
29
  }
17
30
 
18
31
  /**
19
- * Generates a format function which returns the value or an italic default text
32
+ * Generates a format function which returns the value or an italic default text if the value is null. Designed to be used in the following way with a column that may have a null value (after importing `formatNullable` in the way described above):
33
+ * ```js
34
+ * column: [
35
+ * //if null, will display the default "None" in italics
36
+ * {
37
+ * label: 'Some Column',
38
+ * valuePath: 'someColumn',
39
+ * format: formatNullable
40
+ * ...
41
+ * },
42
+ * //if null, will display "No Value" instead of "None" in italics
43
+ * {
44
+ * label: 'Some Column',
45
+ * valueText: 'someColumn',
46
+ * format: formatNullable('No Value')
47
+ * }
48
+ * ...],
49
+ * @method formatNullable
20
50
  * @param {String} [nullText='None'] Text if the value is null
21
51
  * @return {Function} Function to pass into the column format
22
52
  */
23
53
  export function formatNullable(nullText = 'None') {
24
54
  return function(value) {
25
55
  if (isNone(value)) {
26
- return this.get('export') ? '' : htmlSafe(`<i>${nullText}</i>`);
56
+ return this['export'] ? '' : htmlSafe(`<i>${nullText}</i>`);
27
57
  }
28
58
  return value;
29
59
  };
30
60
  }
31
61
 
32
62
  /**
33
- * Generates a function which formats a moment based on the specified format
34
- * @param {String} format moment format
63
+ * Generates a function which formats a moment based on the specified format. Designed to be used in the following way with a column displaying a date (after importing `formatMoment` in the way described above):
64
+ * ```js
65
+ * column: [
66
+ * //will display date as 1970-01-01
67
+ * {
68
+ * label: 'Some Column',
69
+ * valuePath: 'someColumn',
70
+ * format: formatMoment('YYYY-MM-DD')
71
+ * ...
72
+ * },
73
+ * //will display date in the table as 1970-01-01, but when exporting display 01-01-1970
74
+ * {
75
+ * label: 'Some Column',
76
+ * valueText: 'someColumn',
77
+ * format: formatMoment('YYYY-MM-DD', 'MM-DD-YYYY')
78
+ * }
79
+ * ...],
80
+ * @method formatMoment
81
+ * @param {String} format moment format. For a list of valid strings, see [Moment docs](https://momentjs.com/docs/#/displaying/format/)
35
82
  * @param {String} exportFormat moment format used on exporting
36
83
  * @return {Function} Function to pass into a column which formats by a moment
37
84
  */
@@ -39,7 +86,7 @@ export function formatMoment(format, exportFormat = null) {
39
86
  return function(date) {
40
87
  if (moment.isMoment(date)) {
41
88
  // if we are exporting and have an export format, use that
42
- let useFormat = exportFormat && this.get('export') ? exportFormat : format;
89
+ let useFormat = exportFormat && this['export'] ? exportFormat : format;
43
90
  return date.format(useFormat);
44
91
  }
45
92
  };
@@ -1,11 +1,12 @@
1
1
  import {isEmpty} from '@ember/utils';
2
2
  /**
3
- * Used internal only DESCRIPTION NEEDED
3
+ * This is an internal util that is used to help with the logic for expanded rows.
4
4
  * @class TableUtil
5
5
  * @module Utils
6
6
  */
7
7
  /**
8
8
  * Checks if a row should be show in expanded view given the context
9
+ * @method showExpanded
9
10
  * @param {Table} table Table class instance
10
11
  * @param {Row} row Row class instance
11
12
  * @param {Column} column Column class instance
package/index.js CHANGED
@@ -5,5 +5,6 @@ module.exports = {
5
5
  name: '@bennerinformatics/ember-fw-table',
6
6
  included() {
7
7
  this._super.included.apply(this, arguments);
8
- }
8
+ },
9
+ isDevelopingAddon: () => true
9
10
  };