voom-presenters 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/Gemfile.lock +5 -5
  4. data/app/demo/components/date_fields.pom +2 -2
  5. data/app/demo/components/datetime_fields.pom +6 -5
  6. data/app/demo/components/headers.pom +5 -0
  7. data/app/demo/components/lists.pom +11 -0
  8. data/app/demo/components/time_fields.pom +2 -2
  9. data/app/demo/events/actions/dialogs/trigger.pom +2 -2
  10. data/app/demo/events/actions/toggle_visiblity.pom +4 -4
  11. data/app/demo/shared/context_list.pom +1 -1
  12. data/component-status.yml +11 -11
  13. data/lib/voom/presenters/dsl/components/button.rb +2 -2
  14. data/lib/voom/presenters/dsl/components/checkbox.rb +2 -1
  15. data/lib/voom/presenters/dsl/components/datetime_base.rb +2 -1
  16. data/lib/voom/presenters/dsl/components/event.rb +25 -6
  17. data/lib/voom/presenters/dsl/components/expansion_panel.rb +3 -0
  18. data/lib/voom/presenters/dsl/components/header.rb +23 -0
  19. data/lib/voom/presenters/dsl/components/icon_toggle.rb +2 -2
  20. data/lib/voom/presenters/dsl/components/list.rb +18 -4
  21. data/lib/voom/presenters/dsl/components/lists/action.rb +1 -1
  22. data/lib/voom/presenters/dsl/components/lists/header.rb +19 -0
  23. data/lib/voom/presenters/dsl/components/lists/line.rb +15 -5
  24. data/lib/voom/presenters/dsl/components/menu.rb +2 -1
  25. data/lib/voom/presenters/dsl/components/mixins/typography.rb +0 -1
  26. data/lib/voom/presenters/dsl/components/toggle_base.rb +2 -2
  27. data/lib/voom/presenters/version.rb +1 -1
  28. data/lib/voom/presenters/web_client/app.rb +23 -5
  29. data/public/bundle.css +266 -153
  30. data/public/bundle.js +148 -41
  31. data/scripts/bump.sh +3 -0
  32. data/scripts/deploy-demo.sh +2 -0
  33. data/scripts/release.sh +4 -0
  34. data/views/mdc/assets/js/components/datetime.js +9 -5
  35. data/views/mdc/assets/js/components/events.js +6 -7
  36. data/views/mdc/assets/js/components/events/clears.js +26 -0
  37. data/views/mdc/assets/js/components/events/toggle_visibility.js +26 -0
  38. data/views/mdc/assets/js/components/forms.js +8 -0
  39. data/views/mdc/assets/js/components/lists.js +84 -1
  40. data/views/mdc/assets/js/components/text-fields.js +8 -0
  41. data/views/mdc/assets/scss/components/datetime.scss +5 -0
  42. data/views/mdc/assets/scss/components/list.scss +11 -0
  43. data/views/mdc/assets/scss/theme.scss +49 -2
  44. data/views/mdc/body/drawer.erb +2 -2
  45. data/views/mdc/body/header.erb +6 -0
  46. data/views/mdc/components/checkbox.erb +4 -1
  47. data/views/mdc/components/datetime.erb +2 -2
  48. data/views/mdc/components/expansion_panel.erb +1 -1
  49. data/views/mdc/components/list.erb +2 -1
  50. data/views/mdc/components/list/checkbox.erb +1 -1
  51. data/views/mdc/components/list/header.erb +35 -0
  52. data/views/mdc/components/list/line.erb +2 -1
  53. data/views/mdc/components/menu.erb +1 -1
  54. metadata +9 -4
  55. data/views/mdc/assets/js/components/events/selects.js +0 -28
  56. data/views/mdc/assets/js/components/events/toggle_visiblity.js +0 -19
data/public/bundle.js CHANGED
@@ -1437,6 +1437,14 @@ class VTextField extends Object(__WEBPACK_IMPORTED_MODULE_2__mixins_event_handle
1437
1437
  }
1438
1438
  return null;
1439
1439
  }
1440
+
1441
+ clear() {
1442
+ this.setValue('');
1443
+ }
1444
+
1445
+ setValue(value) {
1446
+ this.input.value = value;
1447
+ }
1440
1448
  }
1441
1449
  /* harmony export (immutable) */ __webpack_exports__["a"] = VTextField;
1442
1450
 
@@ -10046,7 +10054,11 @@ class VDateTime extends __WEBPACK_IMPORTED_MODULE_1__text_fields__["a" /* VTextF
10046
10054
  config.enableTime = true;
10047
10055
  config.noCalendar = true;
10048
10056
  }
10049
- __WEBPACK_IMPORTED_MODULE_0_flatpickr___default()(this.input, config);
10057
+ this.fp = __WEBPACK_IMPORTED_MODULE_0_flatpickr___default()(this.input, config);
10058
+ }
10059
+
10060
+ clear() {
10061
+ this.fp.clear();
10050
10062
  }
10051
10063
  }
10052
10064
  /* unused harmony export VDateTime */
@@ -13158,11 +13170,11 @@ class MDCNotchedOutline extends __WEBPACK_IMPORTED_MODULE_0__material_base_compo
13158
13170
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__events_replaces__ = __webpack_require__(74);
13159
13171
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__events_dialog__ = __webpack_require__(75);
13160
13172
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__events_errors__ = __webpack_require__(32);
13161
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__events_toggle_visiblity__ = __webpack_require__(76);
13173
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__events_toggle_visibility__ = __webpack_require__(76);
13162
13174
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__events_snackbar__ = __webpack_require__(77);
13163
13175
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__events_autocomplete__ = __webpack_require__(78);
13164
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__events_selects__ = __webpack_require__(79);
13165
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__events_navigates__ = __webpack_require__(80);
13176
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__events_navigates__ = __webpack_require__(79);
13177
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__events_clears__ = __webpack_require__(80);
13166
13178
 
13167
13179
 
13168
13180
 
@@ -13238,15 +13250,15 @@ class VEvents {
13238
13250
  case 'dialog':
13239
13251
  return new __WEBPACK_IMPORTED_MODULE_3__events_dialog__["a" /* VDialog */](options, params, event);
13240
13252
  case 'toggle_visibility':
13241
- return new __WEBPACK_IMPORTED_MODULE_5__events_toggle_visiblity__["a" /* VToggleVisiblity */](options, params, event);
13253
+ return new __WEBPACK_IMPORTED_MODULE_5__events_toggle_visibility__["a" /* VToggleVisibility */](options, params, event);
13242
13254
  case 'snackbar':
13243
13255
  return new __WEBPACK_IMPORTED_MODULE_6__events_snackbar__["a" /* VSnackbarEvent */](options, params, event);
13244
13256
  case 'autocomplete':
13245
13257
  return new __WEBPACK_IMPORTED_MODULE_7__events_autocomplete__["a" /* VAutoComplete */](options, url, params, event);
13246
- case 'selects':
13247
- return new __WEBPACK_IMPORTED_MODULE_8__events_selects__["a" /* VSelects */](options, params, event);
13248
13258
  case 'navigates':
13249
- return new __WEBPACK_IMPORTED_MODULE_9__events_navigates__["a" /* VNavigates */](options, params, event);
13259
+ return new __WEBPACK_IMPORTED_MODULE_8__events_navigates__["a" /* VNavigates */](options, params, event);
13260
+ case 'clear':
13261
+ return new __WEBPACK_IMPORTED_MODULE_9__events_clears__["a" /* VClears */](options, params, event);
13250
13262
  default:
13251
13263
  throw action_type + ' is not supported.';
13252
13264
  }
@@ -14104,7 +14116,7 @@ class VDialog {
14104
14116
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14105
14117
 
14106
14118
  "use strict";
14107
- class VToggleVisiblity {
14119
+ class VToggleVisibility {
14108
14120
  constructor(options, params, event) {
14109
14121
  this.targetId = options.target;
14110
14122
  this.params = params;
@@ -14112,18 +14124,25 @@ class VToggleVisiblity {
14112
14124
  }
14113
14125
 
14114
14126
  call(results) {
14115
- var targetId = this.targetId;
14116
- var promiseObj = new Promise(function (resolve) {
14117
- console.log("Toggling visiblity on: " + targetId);
14118
- var elem = document.getElementById(targetId);
14119
- elem.classList.toggle("v-hidden");
14120
- results.push({ action: 'toggle_visiblity', statusCode: 200 });
14127
+ let targetId = this.targetId;
14128
+ let action = this.params.action;
14129
+ let promiseObj = new Promise(function (resolve) {
14130
+ console.log("Toggling visibility on: " + targetId);
14131
+ let elem = document.getElementById(targetId);
14132
+ if (action === 'show') {
14133
+ elem.classList.remove("v-hidden");
14134
+ } else if (action === 'hide') {
14135
+ elem.classList.add("v-hidden");
14136
+ } else {
14137
+ elem.classList.toggle("v-hidden");
14138
+ }
14139
+ results.push({ action: 'toggle_visibility', statusCode: 200 });
14121
14140
  resolve(results);
14122
14141
  });
14123
14142
  return promiseObj;
14124
14143
  }
14125
14144
  }
14126
- /* harmony export (immutable) */ __webpack_exports__["a"] = VToggleVisiblity;
14145
+ /* harmony export (immutable) */ __webpack_exports__["a"] = VToggleVisibility;
14127
14146
 
14128
14147
 
14129
14148
  /***/ }),
@@ -14270,7 +14289,7 @@ class VAutoComplete extends __WEBPACK_IMPORTED_MODULE_1__base__["a" /* VBase */]
14270
14289
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14271
14290
 
14272
14291
  "use strict";
14273
- class VSelects {
14292
+ class VNavigates {
14274
14293
  constructor(options, params, event) {
14275
14294
  this.target = options.target;
14276
14295
  this.params = params;
@@ -14278,27 +14297,16 @@ class VSelects {
14278
14297
  }
14279
14298
 
14280
14299
  call(results) {
14281
- let targetFields = document.querySelectorAll('input[name="' + this.target + '"]');
14282
- let checked = this.event.target.checked;
14283
- new Promise(function (resolve) {
14284
- if (targetFields) {
14285
- if (checked) {
14286
- for (let i = 0; i < targetFields.length; i++) {
14287
- console.log(i);
14288
- targetFields[i].checked = true;
14289
- }
14290
- } else {
14291
- for (let i = 0; i < targetFields.length; i++) {
14292
- targetFields[i].checked = false;
14293
- }
14294
- }
14295
- }
14296
- results.push({ action: 'selects', statusCode: 200 });
14300
+ var promiseObj = new Promise(function (resolve) {
14301
+ console.log("Navigating back");
14302
+ results.push({ action: 'navigates', statusCode: 200 });
14303
+ history.back();
14297
14304
  resolve(results);
14298
14305
  });
14306
+ return promiseObj;
14299
14307
  }
14300
14308
  }
14301
- /* harmony export (immutable) */ __webpack_exports__["a"] = VSelects;
14309
+ /* harmony export (immutable) */ __webpack_exports__["a"] = VNavigates;
14302
14310
 
14303
14311
 
14304
14312
  /***/ }),
@@ -14306,24 +14314,32 @@ class VSelects {
14306
14314
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14307
14315
 
14308
14316
  "use strict";
14309
- class VNavigates {
14317
+ class VClears {
14310
14318
  constructor(options, params, event) {
14311
14319
  this.target = options.target;
14312
- this.params = params;
14320
+ this.ids = params.ids;
14313
14321
  this.event = event;
14314
14322
  }
14315
14323
 
14316
14324
  call(results) {
14325
+ let ids = this.ids;
14317
14326
  var promiseObj = new Promise(function (resolve) {
14318
- console.log("Navigating back");
14319
- results.push({ action: 'navigates', statusCode: 200 });
14320
- history.back();
14327
+ console.log("Clearing");
14328
+ results.push({ action: 'clears', statusCode: 200 });
14329
+ for (const id of ids) {
14330
+ let elem = document.getElementById(id);
14331
+ if (elem && elem.vComponent && elem.vComponent.clear) {
14332
+ elem.vComponent.clear();
14333
+ } else {
14334
+ console.log("Unable to clear element with id: " + id + "! Check to make sure you passed the correct id, and that the control/input can be cleared.");
14335
+ }
14336
+ }
14321
14337
  resolve(results);
14322
14338
  });
14323
14339
  return promiseObj;
14324
14340
  }
14325
14341
  }
14326
- /* harmony export (immutable) */ __webpack_exports__["a"] = VNavigates;
14342
+ /* harmony export (immutable) */ __webpack_exports__["a"] = VClears;
14327
14343
 
14328
14344
 
14329
14345
  /***/ }),
@@ -14332,9 +14348,92 @@ class VNavigates {
14332
14348
 
14333
14349
  "use strict";
14334
14350
  /* harmony export (immutable) */ __webpack_exports__["a"] = initLists;
14351
+
14352
+ function createSelectAllHandler(component, target, listElements) {
14353
+ return function () {
14354
+ for (let element of listElements) {
14355
+ element.checked = target.checked;
14356
+ }
14357
+ if (component.dataset.totalLines > listElements.length) {
14358
+ toggleSelectTotalHeader(component, listElements.length, target.checked);
14359
+ }
14360
+ };
14361
+ }
14362
+
14363
+ function createSelectTotalSetHandler(component) {
14364
+ return function (event) {
14365
+ event.preventDefault();
14366
+ if (component.dataset.totalLines > 0) {
14367
+ toggleSelectTotalInput(component, !component.querySelector('#select-total').checked);
14368
+ }
14369
+ };
14370
+ }
14371
+
14372
+ function createListItemSelectHandler(component, listElements, selectAll) {
14373
+ return function () {
14374
+ let checked = 0;
14375
+ let unchecked = 0;
14376
+ toggleSelectTotalInput(component, false); // Clear select total results whenever a list item selection is modified
14377
+ for (let element of listElements) {
14378
+ element.checked ? checked++ : unchecked++;
14379
+ }
14380
+ selectAll.indeterminate = checked && unchecked;
14381
+ selectAll.checked = checked && !unchecked;
14382
+ toggleSelectTotalHeader(component, listElements.length, Boolean(checked) && !Boolean(unchecked));
14383
+ };
14384
+ }
14385
+
14386
+ function toggleSelectTotalHeader(component, count, show = false) {
14387
+ if (component.dataset.totalLines > 0) {
14388
+ updateSelectionCount(component, count);
14389
+ if (show === false) {
14390
+ component.querySelector('#list-item-select-all-header').classList.add('hidden');
14391
+ } else {
14392
+ component.querySelector('#list-item-select-all-header').classList.remove('hidden');
14393
+ }
14394
+ }
14395
+ }
14396
+
14397
+ function toggleSelectTotalInput(component, selectTotal = false) {
14398
+ if (component.dataset.totalLines > 0) {
14399
+ component.querySelector('#select-total').checked = selectTotal;
14400
+ component.querySelector('#list-item-select-all-toggle-on').classList.add('hidden');
14401
+ component.querySelector('#list-item-select-all-toggle-off').classList.add('hidden');
14402
+ component.querySelector('#list-item-select-all-toggle-' + (selectTotal ? 'on' : 'off')).classList.remove('hidden');
14403
+ }
14404
+ }
14405
+
14406
+ function updateSelectionCount(component, count) {
14407
+ if (component.dataset.totalLines > 0) {
14408
+ component.querySelector('#page-selection-count').innerHTML = count;
14409
+ }
14410
+ }
14411
+
14335
14412
  function initLists() {
14336
14413
  console.log('\tLists');
14337
- // Put any initialization code you need here
14414
+ let components = document.querySelectorAll('.mdc-list');
14415
+ if (components) {
14416
+ for (let component of components) {
14417
+ let selectAllLineItem = component.querySelector('.v-checkbox--select-control');
14418
+ let selectableLineItems = component.querySelectorAll('.v-list-item--selectable-checkbox');
14419
+ if (selectAllLineItem && selectableLineItems) {
14420
+
14421
+ for (let element of component.querySelectorAll('.toggle-total-set')) {
14422
+ // Clone and replace element to prevent duplicate event handlers when additional records are loaded/paged
14423
+ let new_element = element.cloneNode(true);
14424
+ element.parentNode.replaceChild(new_element, element);
14425
+ new_element.addEventListener('click', createSelectTotalSetHandler(component));
14426
+ }
14427
+
14428
+ selectAllLineItem.addEventListener('change', createSelectAllHandler(component, selectAllLineItem, selectableLineItems));
14429
+
14430
+ for (let element of selectableLineItems) {
14431
+ element.addEventListener('change', createListItemSelectHandler(component, selectableLineItems, selectAllLineItem));
14432
+ }
14433
+ updateSelectionCount(component, selectableLineItems.length);
14434
+ }
14435
+ }
14436
+ }
14338
14437
  }
14339
14438
 
14340
14439
  /***/ }),
@@ -17975,6 +18074,14 @@ class VForm {
17975
18074
  }
17976
18075
  }
17977
18076
  }
18077
+
18078
+ clear() {
18079
+ for (const input of this.inputs()) {
18080
+ if (input.vComponent && input.vComponent.clear) {
18081
+ input.vComponent.clear();
18082
+ }
18083
+ }
18084
+ }
17978
18085
  }
17979
18086
  /* unused harmony export VForm */
17980
18087
 
data/scripts/bump.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ gem bump
3
+
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ git push heroku master
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ gem tag
3
+ gem release
4
+
@@ -22,13 +22,17 @@ export class VDateTime extends VTextField {
22
22
  config.altInput = true;
23
23
  let type = element.dataset.type;
24
24
 
25
- if(type==='datetime'){
25
+ if (type === 'datetime') {
26
26
  config.enableTime = true;
27
- }else if(type==='time'){
28
- config.enableTime=true;
29
- config.noCalendar=true;
27
+ } else if (type === 'time') {
28
+ config.enableTime = true;
29
+ config.noCalendar = true;
30
30
  }
31
- flatpickr(this.input, config);
31
+ this.fp = flatpickr(this.input, config);
32
+ }
33
+
34
+ clear() {
35
+ this.fp.clear();
32
36
  }
33
37
  }
34
38
 
@@ -3,12 +3,11 @@ import {VPosts} from './events/posts';
3
3
  import {VReplaces} from './events/replaces';
4
4
  import {VDialog} from './events/dialog';
5
5
  import {VErrors} from './events/errors';
6
- import {VToggleVisiblity} from './events/toggle_visiblity';
6
+ import {VToggleVisibility} from './events/toggle_visibility';
7
7
  import {VSnackbarEvent} from './events/snackbar';
8
8
  import {VAutoComplete} from './events/autocomplete';
9
- import {VSelects} from './events/selects';
10
9
  import {VNavigates} from './events/navigates';
11
-
10
+ import {VClears} from './events/clears';
12
11
 
13
12
  export class VEvents {
14
13
  //[[type, url, target, params]]
@@ -76,15 +75,15 @@ export class VEvents {
76
75
  case 'dialog':
77
76
  return new VDialog(options, params, event);
78
77
  case 'toggle_visibility':
79
- return new VToggleVisiblity(options, params, event);
78
+ return new VToggleVisibility(options, params, event);
80
79
  case 'snackbar':
81
80
  return new VSnackbarEvent(options, params, event);
82
81
  case 'autocomplete':
83
82
  return new VAutoComplete(options, url, params, event);
84
- case 'selects':
85
- return new VSelects(options, params, event);
86
83
  case 'navigates':
87
84
  return new VNavigates(options, params, event);
85
+ case 'clear':
86
+ return new VClears(options, params, event);
88
87
  default:
89
88
  throw action_type + ' is not supported.';
90
89
  }
@@ -139,7 +138,7 @@ function fireAfterLoad() {
139
138
  for (var j = 0; j < eventsData.length; j++) {
140
139
  var eventData = eventsData[j];
141
140
  var eventName = eventData[0];
142
- if(eventName==='after_init') {
141
+ if (eventName === 'after_init') {
143
142
  var event = new Event('after_init');
144
143
  // Dispatch the event.
145
144
  eventElem.dispatchEvent(event);
@@ -0,0 +1,26 @@
1
+ export class VClears {
2
+ constructor(options, params, event) {
3
+ this.target = options.target;
4
+ this.ids = params.ids;
5
+ this.event = event;
6
+ }
7
+
8
+ call(results) {
9
+ let ids = this.ids;
10
+ var promiseObj = new Promise(function (resolve) {
11
+ console.log("Clearing");
12
+ results.push({action: 'clears', statusCode: 200});
13
+ for (const id of ids){
14
+ let elem = document.getElementById(id);
15
+ if(elem && elem.vComponent && elem.vComponent.clear){
16
+ elem.vComponent.clear();
17
+ }else {
18
+ console.log("Unable to clear element with id: "+id+
19
+ "! Check to make sure you passed the correct id, and that the control/input can be cleared.");
20
+ }
21
+ }
22
+ resolve(results);
23
+ });
24
+ return promiseObj;
25
+ }
26
+ }
@@ -0,0 +1,26 @@
1
+ export class VToggleVisibility {
2
+ constructor(options, params, event) {
3
+ this.targetId = options.target;
4
+ this.params = params;
5
+ this.event = event;
6
+ }
7
+
8
+ call(results) {
9
+ let targetId = this.targetId;
10
+ let action = this.params.action;
11
+ let promiseObj = new Promise(function (resolve) {
12
+ console.log("Toggling visibility on: " + targetId);
13
+ let elem = document.getElementById(targetId);
14
+ if (action === 'show') {
15
+ elem.classList.remove("v-hidden");
16
+ } else if (action === 'hide') {
17
+ elem.classList.add("v-hidden");
18
+ } else {
19
+ elem.classList.toggle("v-hidden");
20
+ }
21
+ results.push({action:'toggle_visibility', statusCode: 200});
22
+ resolve(results);
23
+ });
24
+ return promiseObj;
25
+ }
26
+ }
@@ -54,4 +54,12 @@ export class VForm {
54
54
  }
55
55
  }
56
56
  }
57
+
58
+ clear() {
59
+ for (const input of this.inputs()) {
60
+ if (input.vComponent && input.vComponent.clear) {
61
+ input.vComponent.clear();
62
+ }
63
+ }
64
+ }
57
65
  }
@@ -1,4 +1,87 @@
1
+
2
+ function createSelectAllHandler(component, target, listElements) {
3
+ return function() {
4
+ for (let element of listElements) {
5
+ element.checked = target.checked;
6
+ }
7
+ if (component.dataset.totalLines > listElements.length) {
8
+ toggleSelectTotalHeader(component, listElements.length, target.checked);
9
+ }
10
+ }
11
+ }
12
+
13
+ function createSelectTotalSetHandler(component) {
14
+ return function(event) {
15
+ event.preventDefault();
16
+ if (component.dataset.totalLines > 0) {
17
+ toggleSelectTotalInput(component, !component.querySelector('#select-total').checked);
18
+ }
19
+ }
20
+ }
21
+
22
+ function createListItemSelectHandler(component, listElements, selectAll) {
23
+ return function() {
24
+ let checked = 0;
25
+ let unchecked = 0;
26
+ toggleSelectTotalInput(component, false); // Clear select total results whenever a list item selection is modified
27
+ for (let element of listElements) {
28
+ element.checked ? checked++ : unchecked++;
29
+ }
30
+ selectAll.indeterminate = (checked && unchecked);
31
+ selectAll.checked = (checked && !unchecked);
32
+ toggleSelectTotalHeader(component, listElements.length, (Boolean(checked) && !Boolean(unchecked)));
33
+ }
34
+ }
35
+
36
+ function toggleSelectTotalHeader(component, count, show = false) {
37
+ if (component.dataset.totalLines > 0) {
38
+ updateSelectionCount(component, count);
39
+ if (show === false) {
40
+ component.querySelector('#list-item-select-all-header').classList.add('hidden');
41
+ } else {
42
+ component.querySelector('#list-item-select-all-header').classList.remove('hidden');
43
+ }
44
+ }
45
+ }
46
+
47
+ function toggleSelectTotalInput(component, selectTotal = false) {
48
+ if (component.dataset.totalLines > 0) {
49
+ component.querySelector('#select-total').checked = selectTotal
50
+ component.querySelector('#list-item-select-all-toggle-on').classList.add('hidden');
51
+ component.querySelector('#list-item-select-all-toggle-off').classList.add('hidden');
52
+ component.querySelector('#list-item-select-all-toggle-' + (selectTotal ? 'on' : 'off')).classList.remove('hidden');
53
+ }
54
+ }
55
+
56
+ function updateSelectionCount(component, count) {
57
+ if (component.dataset.totalLines > 0) {
58
+ component.querySelector('#page-selection-count').innerHTML = count;
59
+ }
60
+ }
61
+
1
62
  export function initLists() {
2
63
  console.log('\tLists');
3
- // Put any initialization code you need here
64
+ let components = document.querySelectorAll('.mdc-list');
65
+ if (components) {
66
+ for (let component of components) {
67
+ let selectAllLineItem = component.querySelector('.v-checkbox--select-control');
68
+ let selectableLineItems = component.querySelectorAll('.v-list-item--selectable-checkbox');
69
+ if (selectAllLineItem && selectableLineItems) {
70
+
71
+ for (let element of component.querySelectorAll('.toggle-total-set')) {
72
+ // Clone and replace element to prevent duplicate event handlers when additional records are loaded/paged
73
+ let new_element = element.cloneNode(true);
74
+ element.parentNode.replaceChild(new_element, element);
75
+ new_element.addEventListener('click', createSelectTotalSetHandler(component));
76
+ }
77
+
78
+ selectAllLineItem.addEventListener('change', createSelectAllHandler(component, selectAllLineItem, selectableLineItems));
79
+
80
+ for (let element of selectableLineItems) {
81
+ element.addEventListener('change', createListItemSelectHandler(component, selectableLineItems, selectAllLineItem));
82
+ }
83
+ updateSelectionCount(component, selectableLineItems.length);
84
+ }
85
+ }
86
+ }
4
87
  }