@planeasyinc/le-angular 0.0.24 → 0.0.25

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.
@@ -447,12 +447,22 @@ const info = {
447
447
  ],
448
448
  };
449
449
 
450
+ const download$1 = {
451
+ name: 'download',
452
+ viewBox: '0 -960 960 960',
453
+ content: [
454
+ 'M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z',
455
+ ],
456
+ };
457
+ // <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"/></svg>
458
+
450
459
  const ICONS_MAP = {
451
460
  chevron: chevron,
452
461
  'arrow-down': arrowDown,
453
462
  sort: sort,
454
463
  close: close,
455
- info: info
464
+ info: info,
465
+ download: download$1,
456
466
  };
457
467
 
458
468
  class LeIconComponent {
@@ -653,10 +663,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImpo
653
663
  ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<cdk-tree [dataSource]=\"source()\" [treeControl]=\"treeControl\">\n <!-- Tree node template for leaf nodes -->\n <cdk-nested-tree-node *cdkTreeNodeDef=\"let node\" class=\"le-tree-node\">\n <div class=\"le-tree-row\">\n <b>{{node.label | uppercase}}</b>: &nbsp;&nbsp;&nbsp; {{node.value}}\n </div>\n </cdk-nested-tree-node>\n\n <!-- Tree node template for expandable nodes -->\n <cdk-nested-tree-node *cdkTreeNodeDef=\"let node; when: hasChild\" class=\"le-tree-node\">\n\n <a class=\"le-tree-row\" [class.le-tree-row--expanded]=\"treeControl.isExpanded(node)\" [attr.aria-label]=\"'Toggle ' + node.label\" cdkTreeNodeToggle>\n <b>{{node.label | uppercase}}</b>:\n\n <le-icon class=\"le-tree-chevron\" name=\"chevron\"></le-icon>\n </a>\n\n <div [class.le-tree-invisible]=\"!treeControl.isExpanded(node)\">\n <ng-container cdkTreeNodeOutlet></ng-container>\n </div>\n </cdk-nested-tree-node>\n</cdk-tree>\n" }]
654
664
  }] });
655
665
 
656
- class StringTemplate {
666
+ class BaseTemplate {
657
667
  data = input.required();
658
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: StringTemplate, deps: [], target: i0.ɵɵFactoryTarget.Component });
659
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.21", type: StringTemplate, isStandalone: true, selector: "ng-component", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `<span class="le-table-template le-template-string">{{ data() ?? '–' }}</span>`, isInline: true });
668
+ attribute = input.required();
669
+ metadata = input.required();
670
+ clicked = output();
671
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: BaseTemplate, deps: [], target: i0.ɵɵFactoryTarget.Directive });
672
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.21", type: BaseTemplate, isStandalone: true, inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, attribute: { classPropertyName: "attribute", publicName: "attribute", isSignal: true, isRequired: true, transformFunction: null }, metadata: { classPropertyName: "metadata", publicName: "metadata", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { clicked: "clicked" }, ngImport: i0 });
673
+ }
674
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: BaseTemplate, decorators: [{
675
+ type: Directive
676
+ }] });
677
+
678
+ class StringTemplate extends BaseTemplate {
679
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: StringTemplate, deps: null, target: i0.ɵɵFactoryTarget.Component });
680
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.21", type: StringTemplate, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `<span class="le-table-template le-template-string">{{ data() ?? '–' }}</span>`, isInline: true });
660
681
  }
661
682
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: StringTemplate, decorators: [{
662
683
  type: Component,
@@ -665,11 +686,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImpo
665
686
  }]
666
687
  }] });
667
688
 
668
- class ReferenceTemplate {
669
- data = input.required();
670
- attribute = input.required();
671
- metadata = input.required();
672
- clicked = output();
689
+ class ReferenceTemplate extends BaseTemplate {
673
690
  reference = computed(() => {
674
691
  const ref = this.data()?.ref;
675
692
  return {
@@ -680,7 +697,10 @@ class ReferenceTemplate {
680
697
  onClick(event) {
681
698
  event.preventDefault();
682
699
  event.stopImmediatePropagation();
683
- this.clicked.emit(this.data());
700
+ this.clicked.emit({
701
+ type: 'reference',
702
+ data: this.data(),
703
+ });
684
704
  }
685
705
  generateText(ref) {
686
706
  if (ref) {
@@ -695,8 +715,8 @@ class ReferenceTemplate {
695
715
  return ref?.address ? `${href}?address=${ref.address}` : href;
696
716
  }
697
717
  }
698
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: ReferenceTemplate, deps: [], target: i0.ɵɵFactoryTarget.Component });
699
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: ReferenceTemplate, isStandalone: true, selector: "ng-component", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, attribute: { classPropertyName: "attribute", publicName: "attribute", isSignal: true, isRequired: true, transformFunction: null }, metadata: { classPropertyName: "metadata", publicName: "metadata", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { clicked: "clicked" }, ngImport: i0, template: `
718
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: ReferenceTemplate, deps: null, target: i0.ɵɵFactoryTarget.Component });
719
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: ReferenceTemplate, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
700
720
  <span class="le-table-template le-template-reference">
701
721
  @if (reference(); as reference) {
702
722
  @if (reference.href) {
@@ -737,10 +757,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImpo
737
757
  }]
738
758
  }] });
739
759
 
740
- class JSONTemplate {
741
- data = input.required();
742
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: JSONTemplate, deps: [], target: i0.ɵɵFactoryTarget.Component });
743
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.21", type: JSONTemplate, isStandalone: true, selector: "ng-component", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `<pre class="le-table-template le-template-json">{{
760
+ class JSONTemplate extends BaseTemplate {
761
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: JSONTemplate, deps: null, target: i0.ɵɵFactoryTarget.Component });
762
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.21", type: JSONTemplate, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `<pre class="le-table-template le-template-json">{{
744
763
  data() ? (data() | json) : '–'
745
764
  }}</pre>`, isInline: true, dependencies: [{ kind: "pipe", type: JsonPipe, name: "json" }] });
746
765
  }
@@ -754,15 +773,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImpo
754
773
  }]
755
774
  }] });
756
775
 
776
+ class FileTemplate extends BaseTemplate {
777
+ onClick(event) {
778
+ event.preventDefault();
779
+ event.stopImmediatePropagation();
780
+ this.clicked.emit({
781
+ type: 'file',
782
+ data: this.data(),
783
+ });
784
+ }
785
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: FileTemplate, deps: null, target: i0.ɵɵFactoryTarget.Component });
786
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: FileTemplate, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
787
+ <span class="le-table-template le-template-file">
788
+ @if (data()) {
789
+ <a [attr.aria-label]="'Download'" (click)="onClick($event)">
790
+ <le-icon size="16" class="le-icon-download" name="download"></le-icon>
791
+ Download
792
+ </a>
793
+ } @else {
794
+ No file attached
795
+ }
796
+ </span>
797
+ `, isInline: true, dependencies: [{ kind: "component", type: LeIconComponent, selector: "le-icon", inputs: ["name", "size"] }] });
798
+ }
799
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: FileTemplate, decorators: [{
800
+ type: Component,
801
+ args: [{
802
+ standalone: true,
803
+ imports: [LeIconComponent],
804
+ template: `
805
+ <span class="le-table-template le-template-file">
806
+ @if (data()) {
807
+ <a [attr.aria-label]="'Download'" (click)="onClick($event)">
808
+ <le-icon size="16" class="le-icon-download" name="download"></le-icon>
809
+ Download
810
+ </a>
811
+ } @else {
812
+ No file attached
813
+ }
814
+ </span>
815
+ `,
816
+ }]
817
+ }] });
818
+
757
819
  const TABLE_SELL_TEMPLATE_NAMES = {
758
820
  StringTemplate: 'StringTemplate',
759
821
  ReferenceTemplate: 'ReferenceTemplate',
760
822
  JsonTemplate: 'JsonTemplate',
823
+ FileTemplate: 'FileTemplate',
761
824
  };
762
825
  const TABLE_CELL_TEMPLATES = {
763
826
  StringTemplate: StringTemplate,
764
827
  ReferenceTemplate: ReferenceTemplate,
765
828
  JsonTemplate: JSONTemplate,
829
+ FileTemplate: FileTemplate,
766
830
  };
767
831
 
768
832
  class TableViewCellDirective {
@@ -789,18 +853,16 @@ class TableViewCellDirective {
789
853
  }
790
854
  this.componentRef = this.vcr.createComponent(component);
791
855
  this.componentRef?.setInput('data', data);
792
- if (type === 'ReferenceTemplate') {
793
- if (column) {
794
- this.componentRef?.setInput('attribute', column);
795
- }
796
- if (metadata) {
797
- this.componentRef?.setInput('metadata', metadata);
798
- }
799
- const sub = (this.componentRef?.instance).clicked.subscribe(data => {
800
- this.clicked.emit(data);
801
- });
802
- this.componentRef?.onDestroy(() => sub.unsubscribe());
856
+ if (column) {
857
+ this.componentRef?.setInput('attribute', column);
858
+ }
859
+ if (metadata) {
860
+ this.componentRef?.setInput('metadata', metadata);
803
861
  }
862
+ const sub = (this.componentRef?.instance).clicked.subscribe(data => {
863
+ this.clicked.emit(data);
864
+ });
865
+ this.componentRef?.onDestroy(() => sub.unsubscribe());
804
866
  });
805
867
  });
806
868
  }
@@ -1224,6 +1286,15 @@ const buildQueryString = (params) => {
1224
1286
  return query.filter((item) => !!item).join('&');
1225
1287
  };
1226
1288
 
1289
+ const download = (url) => {
1290
+ const a = document.createElement('a');
1291
+ a.style.display = 'none';
1292
+ a.href = url;
1293
+ document.body.appendChild(a);
1294
+ a.click();
1295
+ window.URL.revokeObjectURL(url);
1296
+ };
1297
+
1227
1298
  class TableViewComponent {
1228
1299
  apiService = inject(LEApiService);
1229
1300
  dataService = inject(LEDataService);
@@ -1359,16 +1430,42 @@ class TableViewComponent {
1359
1430
  });
1360
1431
  }
1361
1432
  onCellClicked(data) {
1362
- const path = `${data.ref.resource}%23${data.ref.class_name}%3A${data.ref.class_version}%3A${data.ref.object_id}%3A${data.ref.object_version}`;
1433
+ if (data.type === 'reference') {
1434
+ this.processReferenceClick(data.data);
1435
+ }
1436
+ else if (data.type === 'file') {
1437
+ this.processFileClick(data.data);
1438
+ }
1439
+ }
1440
+ processReferenceClick(data) {
1441
+ const address = this.getAddressFromRef(data.ref);
1363
1442
  this.setView({
1364
- id: path,
1443
+ id: address,
1365
1444
  type: 'form',
1366
1445
  controlSource: {
1367
1446
  kind: 'object',
1368
- entity: path,
1447
+ entity: address,
1369
1448
  },
1370
1449
  });
1371
1450
  }
1451
+ processFileClick(data) {
1452
+ console.log('processFileClick', data);
1453
+ const ref = data.ref || data;
1454
+ if (ref && 'resource' in ref) {
1455
+ const address = this.getAddressFromRef(ref);
1456
+ this.apiService.getObjectByAddress(address, {}).subscribe({
1457
+ next: (res) => {
1458
+ download(res.rows[0].data);
1459
+ },
1460
+ });
1461
+ }
1462
+ else if (typeof ref === 'string') {
1463
+ download(ref);
1464
+ }
1465
+ }
1466
+ getAddressFromRef(ref) {
1467
+ return `${ref.resource}%23${ref.class_name}%3A${ref.class_version}%3A${ref.object_id}%3A${ref.object_version}`;
1468
+ }
1372
1469
  processRowClickAction(action, row) {
1373
1470
  const { type, node } = action;
1374
1471
  const clone = JSON.parse(JSON.stringify(node));