@energycap/components 0.26.3 → 0.26.4-ECAP-11517-disable-selectable-table-rows.20211115-1649

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.
@@ -402,6 +402,28 @@ ResizableTableDirective.propDecorators = {
402
402
  resizableColumns: [{ type: Input }]
403
403
  };
404
404
 
405
+ class ResizableColumnComponent {
406
+ constructor(el) {
407
+ this.el = el;
408
+ this.onResize = new EventEmitter();
409
+ }
410
+ emitWidth(width) {
411
+ this.onResize.emit(width);
412
+ }
413
+ }
414
+ ResizableColumnComponent.decorators = [
415
+ { type: Component, args: [{
416
+ selector: 'th.is-resizable',
417
+ template: "<div class=\"content-wrapper\">\r\n <div class=\"content\">\r\n <ng-content></ng-content>\r\n </div>\r\n</div>\r\n<div class=\"handle\"></div>\r\n"
418
+ },] }
419
+ ];
420
+ ResizableColumnComponent.ctorParameters = () => [
421
+ { type: ElementRef }
422
+ ];
423
+ ResizableColumnComponent.propDecorators = {
424
+ onResize: [{ type: Output }]
425
+ };
426
+
405
427
  class TableMasterRowComponent {
406
428
  constructor(renderer, el) {
407
429
  this.renderer = renderer;
@@ -572,6 +594,7 @@ class TableSelectableRowComponent {
572
594
  constructor() {
573
595
  /**The ID root to use for the checkbox and table cell */
574
596
  this.id = '';
597
+ this._enabled = true;
575
598
  /*Required for all rows. The row index this component represents, to allow it to know how to handle shift+clicks.
576
599
  Defaults to -1 which will cause the directive to behave as a header row*/
577
600
  this.rowIndex = -1;
@@ -590,6 +613,9 @@ class TableSelectableRowComponent {
590
613
  /**Sends an event when the component is destroyed so that it can unsubscribe from any observables */
591
614
  this.destroyed = new Subject();
592
615
  }
616
+ /** Disables the selection functionality when false */
617
+ set enabled(value) { this._enabled = value !== false; }
618
+ get enabled() { return this._enabled; }
593
619
  /**Validate and populate the context as the table is dynamically built. Because the context is shared between the
594
620
  * header and each of the rows, changes to it can be used to determine what is happening and hook up the correct
595
621
  * subscriptions for selectAll. The user can provide an existing formArray for the rows and form control for the header,
@@ -619,6 +645,9 @@ class TableSelectableRowComponent {
619
645
  this.formControl = this.context.rowCheckboxes.at(this.rowIndex);
620
646
  this.checkboxAttributeID = `${this.id}_row${this.rowIndex}_ecCheckbox`;
621
647
  }
648
+ if (changes.enabled && !this.enabled) {
649
+ this.formControl.setValue(false);
650
+ }
622
651
  }
623
652
  /** Tell the header checkbox to refresh the selectAll subscription because a row was removed*/
624
653
  ngOnDestroy() {
@@ -637,7 +666,7 @@ class TableSelectableRowComponent {
637
666
  */
638
667
  rowClicked(event) {
639
668
  var _a, _b, _c;
640
- if (!this.isHeader) {
669
+ if (!this.isHeader && this.enabled) {
641
670
  let targetEl = event === null || event === void 0 ? void 0 : event.target;
642
671
  let isCheckboxClick = (_c = (_b = (_a = targetEl === null || targetEl === void 0 ? void 0 : targetEl.classList) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === null || _c === void 0 ? void 0 : _c.includes('row-checkbox');
643
672
  //normally clicking on a row checks only that row and unchecks everything else.
@@ -711,12 +740,13 @@ class TableSelectableRowComponent {
711
740
  TableSelectableRowComponent.decorators = [
712
741
  { type: Component, args: [{
713
742
  selector: '[ecTableSelectableRow]',
714
- template: "<!-- any elements of the existing table row that must go before the row selection checkbox can be marked with a class of before-checkbox -->\r\n<ng-content select=\".before-checkbox\"></ng-content>\r\n<th *ngIf=\"isHeader\"\r\n class=\"checkbox\"\r\n [ecTableLockedColumn]=\"lockedColOptions\">\r\n <ec-checkbox id=\"{{id}}_selectAll\"\r\n class=\"m-0\"\r\n *ngIf=\"context?.selectAllCheckbox\"\r\n [formModel]=\"context?.selectAllCheckbox\"\r\n [dependentCheckboxesGroup]=\"dependentCheckboxesReference\">\r\n </ec-checkbox>\r\n</th>\r\n<td *ngIf=\"!isHeader && formControl\" \r\n class=\"checkbox\"\r\n [ecTableLockedColumn]=\"lockedColOptions\">\r\n <ec-checkbox id=\"{{id}}_row{{rowIndex}}_checkbox\"\r\n [attr.id]=\"checkboxAttributeID\"\r\n class=\"m-0 row-checkbox\"\r\n [formModel]=\"formControl\">\r\n </ec-checkbox>\r\n</td>\r\n<!-- The rest of the table row -->\r\n<ng-content></ng-content>\r\n",
715
- styles: [":host:not(.is-header){cursor:pointer}:host .checkbox{padding-left:1px;padding-right:1px;width:1.125rem}:host .checkbox:first-child{padding-left:.5rem;width:1.5625rem}td.checkbox ec-checkbox ::ng-deep *{pointer-events:none}"]
743
+ template: "<!-- any elements of the existing table row that must go before the row selection checkbox can be marked with a class of before-checkbox -->\r\n<ng-content select=\".before-checkbox\"></ng-content>\r\n<ng-container *ngIf=\"enabled\">\r\n <th *ngIf=\"isHeader\"\r\n class=\"checkbox\"\r\n [ecTableLockedColumn]=\"lockedColOptions\">\r\n <ec-checkbox id=\"{{id}}_selectAll\"\r\n class=\"m-0\"\r\n *ngIf=\"context?.selectAllCheckbox\"\r\n [formModel]=\"context?.selectAllCheckbox\"\r\n [dependentCheckboxesGroup]=\"dependentCheckboxesReference\">\r\n </ec-checkbox>\r\n </th>\r\n <td *ngIf=\"!isHeader && formControl\"\r\n class=\"checkbox\"\r\n [ecTableLockedColumn]=\"lockedColOptions\">\r\n <ec-checkbox id=\"{{id}}_row{{rowIndex}}_checkbox\"\r\n [attr.id]=\"checkboxAttributeID\"\r\n class=\"m-0 row-checkbox\"\r\n [formModel]=\"formControl\">\r\n </ec-checkbox>\r\n </td>\r\n</ng-container>\r\n<!-- The rest of the table row -->\r\n<ng-content></ng-content>",
744
+ styles: [":host.is-enabled:not(.is-header){cursor:pointer}:host .checkbox{padding-left:1px;padding-right:1px;width:1.125rem}:host .checkbox:first-child{padding-left:.5rem;width:1.5625rem}td.checkbox ec-checkbox ::ng-deep *{pointer-events:none}"]
716
745
  },] }
717
746
  ];
718
747
  TableSelectableRowComponent.propDecorators = {
719
748
  id: [{ type: HostBinding, args: ['attr.id',] }, { type: Input }],
749
+ enabled: [{ type: HostBinding, args: ['class.is-enabled',] }, { type: Input, args: ['ecTableSelectableRow',] }],
720
750
  context: [{ type: Input, args: ['selectionContext',] }],
721
751
  rowIndex: [{ type: Input }],
722
752
  lockedColOptions: [{ type: Input }],
@@ -725,28 +755,6 @@ TableSelectableRowComponent.propDecorators = {
725
755
  rowClicked: [{ type: HostListener, args: ['click', ['$event'],] }]
726
756
  };
727
757
 
728
- class ResizableColumnComponent {
729
- constructor(el) {
730
- this.el = el;
731
- this.onResize = new EventEmitter();
732
- }
733
- emitWidth(width) {
734
- this.onResize.emit(width);
735
- }
736
- }
737
- ResizableColumnComponent.decorators = [
738
- { type: Component, args: [{
739
- selector: 'th.is-resizable',
740
- template: "<div class=\"content-wrapper\">\r\n <div class=\"content\">\r\n <ng-content></ng-content>\r\n </div>\r\n</div>\r\n<div class=\"handle\"></div>\r\n"
741
- },] }
742
- ];
743
- ResizableColumnComponent.ctorParameters = () => [
744
- { type: ElementRef }
745
- ];
746
- ResizableColumnComponent.propDecorators = {
747
- onResize: [{ type: Output }]
748
- };
749
-
750
758
  class TableComponent {
751
759
  constructor(renderer, el) {
752
760
  this.renderer = renderer;
@@ -821,11 +829,6 @@ class TableComponent {
821
829
  }
822
830
  }
823
831
  }
824
- ngOnInit() {
825
- if (this.selectionContext) {
826
- this.selectable = true;
827
- }
828
- }
829
832
  ngAfterContentInit() {
830
833
  this.hasMasterDetailRows = !!this.masterRows.length;
831
834
  this.masterRows.changes.pipe(takeUntil(this.destroyed)).subscribe(() => {
@@ -945,7 +948,7 @@ TableComponent.propDecorators = {
945
948
  sortable: [{ type: HostBinding, args: ['class.is-sortable',] }, { type: Input }],
946
949
  selectionContext: [{ type: Input }],
947
950
  selectionToolbarTemplate: [{ type: Input }],
948
- selectable: [{ type: HostBinding, args: ['class.is-selectable',] }],
951
+ selectable: [{ type: HostBinding, args: ['class.is-selectable',] }, { type: Input }],
949
952
  isForm: [{ type: HostBinding, args: ['class.is-form-table',] }, { type: Input }],
950
953
  sort: [{ type: Input }],
951
954
  sortChange: [{ type: Output }],
@@ -5518,8 +5521,7 @@ class SearchableTableComponent {
5518
5521
  this.sortable = false;
5519
5522
  this.autofocus = false;
5520
5523
  /**Set to a space-separated set of strings that should be added to the ec-table class attribute
5521
- * this allows finer control over styling, including the ability to turn on selectable highlights
5522
- * by including is-selectable
5524
+ * this allows finer control over styling.
5523
5525
  */
5524
5526
  this.tableClasses = '';
5525
5527
  /** Emits when table sort has changed */
@@ -5594,6 +5596,8 @@ class SearchableTableComponent {
5594
5596
  this.searchboxReadonly = false;
5595
5597
  /** Optional text to add to the results count in the table footer. This text will be added after the count and objectType. */
5596
5598
  this.additionalCountText = '';
5599
+ /** Enables table row selection and row highlighting styles when true */
5600
+ this.selectable = false;
5597
5601
  /**
5598
5602
  * Text displayed in the footer.
5599
5603
  * Sometimes `noDataMessage`, sometimes `noSearchResultsMessage`
@@ -5735,7 +5739,7 @@ class SearchableTableComponent {
5735
5739
  SearchableTableComponent.decorators = [
5736
5740
  { type: Component, args: [{
5737
5741
  selector: 'ec-searchable-table',
5738
- template: "<header *ngIf=\"!hideHeader\"\r\n class=\"d-flex flex-shrink align-items-center mb-3\">\r\n <ec-textbox id=\"{{id}}_searchbox\"\r\n *ngIf=\"!hideSearchControl\"\r\n class=\"mb-0 flex-grow mr-2\"\r\n [autofocus]=\"autofocus\"\r\n [formModel]=\"searchModel\"\r\n [tabindex]=\"searchboxTabIndex\"\r\n [placeholder]=\"searchboxPlaceholder\"\r\n [readonly]=\"searchboxReadonly\"></ec-textbox>\r\n <div class=\"flex-grow\">\r\n <ng-content select=\".searchable-table-controls\"></ng-content>\r\n </div>\r\n</header>\r\n<section id=\"{{id}}_card\"\r\n class=\"card m-0 d-flex flex-column bg-content\"\r\n [class.is-translucent]=\"status.status !== 'error'\"\r\n ecOverlay\r\n [status]=\"status.status\"\r\n [message]=\"status.message\"\r\n [displayAsMask]=\"true\">\r\n <ng-content select=\".card-header\"></ng-content>\r\n <ec-table id=\"{{id}}_table\"\r\n class=\"flex-shrink-max {{tableClasses}}\"\r\n [class.is-fixed]=\"tableLayoutFixed\"\r\n [sortable]=\"sortable\"\r\n [sort]=\"sort\"\r\n (sortChange)=\"onSortChange($event)\"\r\n [resizable]=\"resizable\"\r\n [scrollable]=\"true\"\r\n [selectionContext]=\"selectionContext\"\r\n [selectionToolbarTemplate]=\"selectionToolbarTemplate\"\r\n [resizableColumns]=\"resizableColumns\">\r\n <ng-content></ng-content>\r\n </ec-table>\r\n\r\n <!-- pagination footer visible if table is page-able and there are more than one page of results -->\r\n <footer *ngIf=\"!hideFooter && pageable && searchResults.totalItemsBeforePaging! > pageSize!\" class=\"d-flex flex-shrink align-items-center border-top\">\r\n <ec-table-pagination id=\"{{id}}_pager\"\r\n class=\"font-color-primary\"\r\n [totalItems]=\"searchResults.totalItemsBeforePaging\"\r\n [pageSize]=\"pageSize\"\r\n [maxTabs]=\"maxTabs\"\r\n [pageNumber]=\"pageInfo?.pageNumber\"\r\n (pageChanged)=\"onPageChange($event)\">\r\n </ec-table-pagination>\r\n <div id=\"resultsCount\"\r\n *ngIf=\"searchResults?.items?.length\"\r\n class=\"ml-auto mr-2 font-color-hint text-truncate\" \r\n title=\"{{resultsCount}} {{additionalCountText}}\">{{resultsCount}} {{additionalCountText}}</div>\r\n </footer>\r\n\r\n <!-- default footer: visible if hideFooter is false and table is not page-able or there are only one page of results (always shows if there is a caption to indicate no results) -->\r\n <footer *ngIf=\"(!hideFooter && (!pageable || searchResults.totalItemsBeforePaging! <= pageSize!)) || tableCaption\"\r\n class=\"p-2 d-flex\"\r\n [class.has-results]=\"searchResults?.items?.length\">\r\n <ng-content *ngIf=\"!tableCaption\"\r\n select=\".searchable-table-footer\"></ng-content>\r\n <div id=\"tableCaption\"\r\n *ngIf=\"tableCaption\"\r\n [innerHTML]=\"tableCaption\"></div>\r\n <div id=\"resultsCount\"\r\n *ngIf=\"searchResults?.items?.length\"\r\n class=\"ml-auto text-truncate\"\r\n title=\"{{resultsCount}} {{additionalCountText}}\">{{resultsCount}} {{additionalCountText}}</div>\r\n </footer>\r\n</section>",
5742
+ template: "<header *ngIf=\"!hideHeader\"\r\n class=\"d-flex flex-shrink align-items-center mb-3\">\r\n <ec-textbox id=\"{{id}}_searchbox\"\r\n *ngIf=\"!hideSearchControl\"\r\n class=\"mb-0 flex-grow mr-2\"\r\n [autofocus]=\"autofocus\"\r\n [formModel]=\"searchModel\"\r\n [tabindex]=\"searchboxTabIndex\"\r\n [placeholder]=\"searchboxPlaceholder\"\r\n [readonly]=\"searchboxReadonly\"></ec-textbox>\r\n <div class=\"flex-grow\">\r\n <ng-content select=\".searchable-table-controls\"></ng-content>\r\n </div>\r\n</header>\r\n<section id=\"{{id}}_card\"\r\n class=\"card m-0 d-flex flex-column bg-content\"\r\n [class.is-translucent]=\"status.status !== 'error'\"\r\n ecOverlay\r\n [status]=\"status.status\"\r\n [message]=\"status.message\"\r\n [displayAsMask]=\"true\">\r\n <ng-content select=\".card-header\"></ng-content>\r\n <ec-table id=\"{{id}}_table\"\r\n class=\"flex-shrink-max {{tableClasses}}\"\r\n [class.is-fixed]=\"tableLayoutFixed\"\r\n [sortable]=\"sortable\"\r\n [sort]=\"sort\"\r\n (sortChange)=\"onSortChange($event)\"\r\n [resizable]=\"resizable\"\r\n [scrollable]=\"true\"\r\n [selectable]=\"selectable\"\r\n [selectionContext]=\"selectionContext\"\r\n [selectionToolbarTemplate]=\"selectionToolbarTemplate\"\r\n [resizableColumns]=\"resizableColumns\">\r\n <ng-content></ng-content>\r\n </ec-table>\r\n\r\n <!-- pagination footer visible if table is page-able and there are more than one page of results -->\r\n <footer *ngIf=\"!hideFooter && pageable && searchResults.totalItemsBeforePaging! > pageSize!\" class=\"d-flex flex-shrink align-items-center border-top\">\r\n <ec-table-pagination id=\"{{id}}_pager\"\r\n class=\"font-color-primary\"\r\n [totalItems]=\"searchResults.totalItemsBeforePaging\"\r\n [pageSize]=\"pageSize\"\r\n [maxTabs]=\"maxTabs\"\r\n [pageNumber]=\"pageInfo?.pageNumber\"\r\n (pageChanged)=\"onPageChange($event)\">\r\n </ec-table-pagination>\r\n <div id=\"resultsCount\"\r\n *ngIf=\"searchResults?.items?.length\"\r\n class=\"ml-auto mr-2 font-color-hint text-truncate\" \r\n title=\"{{resultsCount}} {{additionalCountText}}\">{{resultsCount}} {{additionalCountText}}</div>\r\n </footer>\r\n\r\n <!-- default footer: visible if hideFooter is false and table is not page-able or there are only one page of results (always shows if there is a caption to indicate no results) -->\r\n <footer *ngIf=\"(!hideFooter && (!pageable || searchResults.totalItemsBeforePaging! <= pageSize!)) || tableCaption\"\r\n class=\"p-2 d-flex\"\r\n [class.has-results]=\"searchResults?.items?.length\">\r\n <ng-content *ngIf=\"!tableCaption\"\r\n select=\".searchable-table-footer\"></ng-content>\r\n <div id=\"tableCaption\"\r\n *ngIf=\"tableCaption\"\r\n [innerHTML]=\"tableCaption\"></div>\r\n <div id=\"resultsCount\"\r\n *ngIf=\"searchResults?.items?.length\"\r\n class=\"ml-auto text-truncate\"\r\n title=\"{{resultsCount}} {{additionalCountText}}\">{{resultsCount}} {{additionalCountText}}</div>\r\n </footer>\r\n</section>",
5739
5743
  styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:flex;flex:1 1;flex-direction:column;min-height:0}footer{font-size:.75rem;line-height:1rem}footer.has-results{border-top:1px solid rgba(26,26,35,.18);color:rgba(26,26,35,.38);text-align:right}"]
5740
5744
  },] }
5741
5745
  ];
@@ -5776,7 +5780,8 @@ SearchableTableComponent.propDecorators = {
5776
5780
  selectionContext: [{ type: Input }],
5777
5781
  selectionToolbarTemplate: [{ type: Input }],
5778
5782
  resizableColumns: [{ type: ContentChildren, args: [ResizableColumnComponent, { descendants: true },] }],
5779
- additionalCountText: [{ type: Input }]
5783
+ additionalCountText: [{ type: Input }],
5784
+ selectable: [{ type: Input }]
5780
5785
  };
5781
5786
 
5782
5787
  /**
@@ -6989,7 +6994,7 @@ class ToastComponent {
6989
6994
  ToastComponent.decorators = [
6990
6995
  { type: Component, args: [{
6991
6996
  selector: 'ec-toast',
6992
- template: "<ec-banner id=\"{{toastItem?.id}}_banner\"\r\n [type]=\"toastItem?.type\"\r\n bannerStyle=\"toast\"\r\n [customIcon]=\"toastItem?.icon\"\r\n [showCloseBtn]=\"toastItem?.dismissible\"\r\n [autoHideOnClose]=\"false\"\r\n (closed)=\"closeClicked()\">\r\n <div class=\"d-flex\">\r\n <p id=\"{{toastItem?.id}}_message\"\r\n class=\"mb-0\">{{toastItem?.message}}</p>\r\n <a id=\"{{toastItem?.id}}_action\"\r\n *ngIf=\"toastItem?.action && toastItem?.actionLabel\"\r\n class=\"text-link ml-2\"\r\n (click)=\"toastItem!.action!()\">{{toastItem?.actionLabel | translate}}</a>\r\n </div>\r\n</ec-banner>",
6997
+ template: "<ec-banner id=\"{{toastItem?.id}}_banner\"\r\n [type]=\"toastItem?.type\"\r\n bannerStyle=\"toast\"\r\n [customIcon]=\"toastItem?.icon\"\r\n [showCloseBtn]=\"toastItem?.dismissible\"\r\n [autoHideOnClose]=\"false\"\r\n (closed)=\"closeClicked()\">\r\n <div class=\"d-flex\">\r\n <div id=\"{{toastItem?.id}}_message\"\r\n [innerHTML]=\"toastItem?.message | translate\"></div>\r\n <a id=\"{{toastItem?.id}}_action\"\r\n *ngIf=\"toastItem?.action && toastItem?.actionLabel\"\r\n class=\"text-link ml-2\"\r\n (click)=\"toastItem!.action!()\">{{toastItem?.actionLabel | translate}}</a>\r\n </div>\r\n</ec-banner>",
6993
6998
  styles: [":host{bottom:0;display:block;left:50%;position:fixed;transform:translate(-50%,150%);transition:transform var(--toast-animation-duration,.25s);transition-timing-function:ease-in;z-index:70}:host.is-open{transform:translate(-50%,calc(var(--toast-bottom, 0rem)*-1 - 1.5rem));transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}"]
6994
6999
  },] }
6995
7000
  ];