@eqproject/eqp-dynamic-module 0.0.2 → 0.0.3

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.
@@ -1,6 +1,6 @@
1
1
  import { __extends, __decorate } from 'tslib';
2
2
  import { CommonModule } from '@angular/common';
3
- import { ɵɵdefineInjectable, ɵɵinject, Injectable, Input, Component, NgModule, EventEmitter, ViewChild, Output, ChangeDetectorRef, ViewChildren } from '@angular/core';
3
+ import { ɵɵdefineInjectable, ɵɵinject, Injectable, EventEmitter, Input, Output, Component, NgModule, ViewChild, ChangeDetectorRef, ViewChildren } from '@angular/core';
4
4
  import { Validators, FormControl, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
5
  import { MatCheckboxModule } from '@angular/material/checkbox';
6
6
  import { MatButtonModule } from '@angular/material/button';
@@ -383,7 +383,11 @@ var EqpDynamicModuleComponent = /** @class */ (function () {
383
383
  this.context = new Context();
384
384
  this.form = new Form();
385
385
  this.showButtons = true;
386
+ this.showTitle = true;
386
387
  this.viewMode = FormTypeEnum.LIST;
388
+ this.saveRecord = new EventEmitter();
389
+ this.deleteRecord = new EventEmitter();
390
+ this.duplicateRecord = new EventEmitter();
387
391
  this.FormTypeEnum = FormTypeEnum;
388
392
  }
389
393
  EqpDynamicModuleComponent.prototype.ngOnInit = function () {
@@ -402,16 +406,21 @@ var EqpDynamicModuleComponent = /** @class */ (function () {
402
406
  };
403
407
  EqpDynamicModuleComponent.prototype.onSaveForm = function (event) {
404
408
  //TODO: Salvare il record!
405
- if (event != null) {
406
- if (event.ID && this.values.find(function (v) { return v.ID == event.ID; })) {
407
- this.values[this.values.findIndex(function (v) { return v.ID == event.ID; })] = event;
408
- }
409
- else {
410
- this.values.push(event);
411
- }
412
- }
409
+ // if (event != null) {
410
+ // if (event.ID && this.values.find(v => v.ID == event.ID)) {
411
+ // this.values[this.values.findIndex(v => v.ID == event.ID)] = event;
412
+ // } else {
413
+ // this.values.push(event);
414
+ // }
415
+ // }
416
+ this.saveRecord.emit(event);
413
417
  this.viewMode = FormTypeEnum.LIST;
414
- console.log(event);
418
+ };
419
+ EqpDynamicModuleComponent.prototype.onDuplicateRecord = function (record) {
420
+ this.duplicateRecord.emit(record);
421
+ };
422
+ EqpDynamicModuleComponent.prototype.onDeleteRecord = function (record) {
423
+ this.deleteRecord.emit(record);
415
424
  };
416
425
  __decorate([
417
426
  Input()
@@ -425,13 +434,25 @@ var EqpDynamicModuleComponent = /** @class */ (function () {
425
434
  __decorate([
426
435
  Input()
427
436
  ], EqpDynamicModuleComponent.prototype, "showButtons", void 0);
437
+ __decorate([
438
+ Input()
439
+ ], EqpDynamicModuleComponent.prototype, "showTitle", void 0);
428
440
  __decorate([
429
441
  Input()
430
442
  ], EqpDynamicModuleComponent.prototype, "viewMode", void 0);
443
+ __decorate([
444
+ Output()
445
+ ], EqpDynamicModuleComponent.prototype, "saveRecord", void 0);
446
+ __decorate([
447
+ Output()
448
+ ], EqpDynamicModuleComponent.prototype, "deleteRecord", void 0);
449
+ __decorate([
450
+ Output()
451
+ ], EqpDynamicModuleComponent.prototype, "duplicateRecord", void 0);
431
452
  EqpDynamicModuleComponent = __decorate([
432
453
  Component({
433
454
  selector: 'eqp-dynamic-module',
434
- template: "<add-form-record *ngIf=\"viewMode == FormTypeEnum.SCALAR\" [form]=\"form\" [record]=\"selectedRecord\"\r\n [showButtons]=\"showButtons\" [onlyView]=\"onlyView\" (saveRecordEvent)=\"onSaveForm($event)\">\r\n</add-form-record>\r\n\r\n<list-form-record *ngIf=\"viewMode == FormTypeEnum.LIST\" [form]=\"form\" [values]=\"values\"\r\n (onAddViewEditRecord)=\"onAddViewEditRecord($event)\">\r\n</list-form-record>",
455
+ template: "<add-form-record *ngIf=\"viewMode == FormTypeEnum.SCALAR\" [form]=\"form\" [record]=\"selectedRecord\"\r\n [showButtons]=\"showButtons\" [onlyView]=\"onlyView\" (saveRecordEvent)=\"onSaveForm($event)\" [showTitle]=\"showTitle\">\r\n</add-form-record>\r\n\r\n<list-form-record *ngIf=\"viewMode == FormTypeEnum.LIST\" [form]=\"form\" [values]=\"values\"\r\n (onAddViewEditRecord)=\"onAddViewEditRecord($event)\" [showTitle]=\"showTitle\"\r\n (onDeleteRecord)=\"onDeleteRecord($event)\" (onDuplicateRecord)=\"onDuplicateRecord($event)\">\r\n</list-form-record>",
435
456
  styles: ["::ng-deep mat-form-field{width:100%}"]
436
457
  })
437
458
  ], EqpDynamicModuleComponent);
@@ -2332,12 +2353,22 @@ var ImageFieldTemplateComponent = /** @class */ (function () {
2332
2353
 
2333
2354
  var ListFormRecordComponent = /** @class */ (function () {
2334
2355
  function ListFormRecordComponent() {
2356
+ this.showTitle = true;
2335
2357
  this.columns = new Array();
2336
2358
  this.onAddViewEditRecord = new EventEmitter();
2359
+ this.onDeleteRecord = new EventEmitter();
2360
+ this.onDuplicateRecord = new EventEmitter();
2337
2361
  }
2338
2362
  ListFormRecordComponent.prototype.ngOnInit = function () {
2339
2363
  this.configureColumns();
2340
2364
  };
2365
+ ListFormRecordComponent.prototype.ngOnChanges = function (changes) {
2366
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
2367
+ if (changes['values'] != undefined && changes['values'].firstChange == false) {
2368
+ this.values = changes['values'].currentValue;
2369
+ this.reloadTables();
2370
+ }
2371
+ };
2341
2372
  /**
2342
2373
  * Metodo per configurare le colonne della eqp-table.
2343
2374
  */
@@ -2395,18 +2426,17 @@ var ListFormRecordComponent = /** @class */ (function () {
2395
2426
  * @param record Record da duplicare.
2396
2427
  */
2397
2428
  ListFormRecordComponent.prototype.duplicateRecord = function (record) {
2398
- var _this = this;
2399
- EqpDynamicModuleDialogService.Confirm('Duplicare il record selezionato?', function () {
2400
- var copiedRecord = JSON.parse(JSON.stringify(record));
2401
- if (!isNaN(parseInt(copiedRecord.ID))) {
2402
- copiedRecord.ID = (parseInt(copiedRecord.ID) + 1).toString();
2403
- }
2404
- else {
2405
- copiedRecord.ID = "xxxxxxxxx".replace("x", function (c) { return (Math.random() + 16 | 0).toString(16); });
2406
- }
2407
- _this.values.push(copiedRecord);
2408
- _this.reloadTables();
2409
- }, false, 'Richiesta conferma');
2429
+ // EqpDynamicModuleDialogService.Confirm('Duplicare il record selezionato?', () => {
2430
+ // var copiedRecord: Record = JSON.parse(JSON.stringify(record));
2431
+ // if (!isNaN(parseInt(copiedRecord.ID))) {
2432
+ // copiedRecord.ID = (parseInt(copiedRecord.ID) + 1).toString();
2433
+ // } else {
2434
+ // copiedRecord.ID = "xxxxxxxxx".replace("x", (c) => { return (Math.random() + 16 | 0).toString(16); });
2435
+ // }
2436
+ // this.values.push(copiedRecord);
2437
+ // this.reloadTables();
2438
+ // }, false, 'Richiesta conferma');
2439
+ this.onDuplicateRecord.emit(record);
2410
2440
  //TODO
2411
2441
  };
2412
2442
  /**
@@ -2414,11 +2444,11 @@ var ListFormRecordComponent = /** @class */ (function () {
2414
2444
  * @param record Record da eliminare selezionato sulla eqp-table.
2415
2445
  */
2416
2446
  ListFormRecordComponent.prototype.deleteRecord = function (record) {
2417
- var _this = this;
2418
- EqpDynamicModuleDialogService.Confirm('Eliminare il record selezionato?', function () {
2419
- _this.values.splice(_this.values.indexOf(record), 1);
2420
- _this.reloadTables();
2421
- }, false, 'Richiesta conferma');
2447
+ // EqpDynamicModuleDialogService.Confirm('Eliminare il record selezionato?', () => {
2448
+ // this.values.splice(this.values.indexOf(record), 1);
2449
+ // this.reloadTables();
2450
+ // }, false, 'Richiesta conferma');
2451
+ this.onDeleteRecord.emit(record);
2422
2452
  // TODO
2423
2453
  };
2424
2454
  /**
@@ -2519,6 +2549,9 @@ var ListFormRecordComponent = /** @class */ (function () {
2519
2549
  this.tableRecords.reloadDatatable();
2520
2550
  }
2521
2551
  };
2552
+ __decorate([
2553
+ Input()
2554
+ ], ListFormRecordComponent.prototype, "showTitle", void 0);
2522
2555
  __decorate([
2523
2556
  Input()
2524
2557
  ], ListFormRecordComponent.prototype, "form", void 0);
@@ -2531,10 +2564,16 @@ var ListFormRecordComponent = /** @class */ (function () {
2531
2564
  __decorate([
2532
2565
  Output()
2533
2566
  ], ListFormRecordComponent.prototype, "onAddViewEditRecord", void 0);
2567
+ __decorate([
2568
+ Output()
2569
+ ], ListFormRecordComponent.prototype, "onDeleteRecord", void 0);
2570
+ __decorate([
2571
+ Output()
2572
+ ], ListFormRecordComponent.prototype, "onDuplicateRecord", void 0);
2534
2573
  ListFormRecordComponent = __decorate([
2535
2574
  Component({
2536
2575
  selector: 'list-form-record',
2537
- template: "<div class=\"row eqp-dynamic-module-title\">\r\n <div class=\"col-md-6\">\r\n <h4><b>Elenco {{form.Name}}</b></h4>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\" (click)=\"onAddViewEditRecord.emit(null)\">\r\n <mat-icon>add</mat-icon>\r\n <span style=\"margin-left: 10px;\">Aggiungi</span>\r\n </button>\r\n </div>\r\n</div>\r\n\r\n\r\n<eqp-table #tableRecords [data]=\"values\" [columns]=\"columns\"></eqp-table>",
2576
+ template: "<div class=\"row eqp-dynamic-module-title\">\r\n <div class=\"col-md-6\">\r\n <h4 *ngIf=\"showTitle\"><b>Elenco {{form.Name}}</b></h4>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\" (click)=\"onAddViewEditRecord.emit(null)\">\r\n <mat-icon>add</mat-icon>\r\n <span style=\"margin-left: 10px;\">Aggiungi</span>\r\n </button>\r\n </div>\r\n</div>\r\n\r\n\r\n<eqp-table #tableRecords [data]=\"values\" [columns]=\"columns\"></eqp-table>",
2538
2577
  styles: ["::ng-deep .error-color{color:var(--danger)}::ng-deep .success-color{color:var(--success)}"]
2539
2578
  })
2540
2579
  ], ListFormRecordComponent);
@@ -2551,6 +2590,7 @@ var AddFormRecordComponent = /** @class */ (function () {
2551
2590
  function AddFormRecordComponent(cdr, utilityService) {
2552
2591
  this.cdr = cdr;
2553
2592
  this.utilityService = utilityService;
2593
+ this.showTitle = true;
2554
2594
  this.showButtons = true;
2555
2595
  this.form = new Form();
2556
2596
  this.fieldGroups = {};
@@ -2641,6 +2681,9 @@ var AddFormRecordComponent = /** @class */ (function () {
2641
2681
  { type: ChangeDetectorRef },
2642
2682
  { type: UtilityHelperService }
2643
2683
  ]; };
2684
+ __decorate([
2685
+ Input()
2686
+ ], AddFormRecordComponent.prototype, "showTitle", void 0);
2644
2687
  __decorate([
2645
2688
  Input()
2646
2689
  ], AddFormRecordComponent.prototype, "showButtons", void 0);
@@ -2662,7 +2705,7 @@ var AddFormRecordComponent = /** @class */ (function () {
2662
2705
  AddFormRecordComponent = __decorate([
2663
2706
  Component({
2664
2707
  selector: 'add-form-record',
2665
- template: "<div class=\"row eqp-dynamic-module-title\">\n <div class=\"col-md-12 text-center\">\n <h4><b>{{form.Name}}</b></h4>\n </div>\n</div>\n\n<form [formGroup]=\"formForm\">\n\n <!-- VISUALIZZAZIONE SEMPLICE -->\n <ng-container *ngIf=\"form.FormScalarType == FormScalarTypeEnum.Semplice\" [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: form.Fields }\">\n </ng-container>\n\n <!-- VISUALIZZAZIONE A STEPPER -->\n <mat-horizontal-stepper linear *ngIf=\"form.FormScalarType == FormScalarTypeEnum['A step']\">\n <mat-step *ngFor=\"let group of form.FormFieldsGroups\">\n <ng-template matStepLabel>\n {{group.Name}}\n </ng-template>\n\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </mat-step>\n </mat-horizontal-stepper>\n\n <!-- VISUALIZZAZIONE A TAB -->\n <mat-tab-group *ngIf=\"form.FormScalarType == FormScalarTypeEnum['In tab']\">\n <mat-tab *ngFor=\"let group of form.FormFieldsGroups\" [label]=\"group.Name\">\n <div class=\"mt-3\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </div>\n </mat-tab>\n </mat-tab-group>\n\n <!-- VISUALIZZAZIONE AD ACCORDION -->\n <mat-accordion multi *ngIf=\"form.FormScalarType == FormScalarTypeEnum['In accordion']\">\n <mat-expansion-panel *ngFor=\"let group of form.FormFieldsGroups\">\n <mat-expansion-panel-header>\n <mat-panel-title>\n {{group.Name}}\n </mat-panel-title>\n </mat-expansion-panel-header>\n\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </mat-expansion-panel>\n </mat-accordion>\n</form>\n\n<div class=\"row mt-2\" *ngIf=\"showButtons\">\n <div class=\"col-sm-12 text-right\">\n <button class=\"mr-2\" mat-raised-button (click)=\"saveOrExitForm(true)\" type=\"button\">\n Annulla\n </button>\n <button class=\"mr-2\" mat-raised-button color=\"primary\" (click)=\"saveOrExitForm(false)\"\n [disabled]=\"formForm.invalid || formForm.disabled\" type=\"button\">\n Salva\n </button>\n </div>\n</div>\n\n<!-- TEMPLATE PER LA VISUALIZZAZIONE DEI CAMPI DELLA FORM -->\n<ng-template #fieldTemplates let-fields='fields'>\n <div class=\"row\">\n <div class=\"mt-2\" *ngFor=\"let field of fields\" [ngClass]=\"utilityService.getFieldSyleClass(field)\">\n <dynamic-module-field #fieldTemplate [field]=\"field\" [form]=\"form\" [record]=\"record\" (recordChange)=\"onRecordChange()\"></dynamic-module-field>\n </div>\n </div>\n</ng-template>",
2708
+ template: "<div class=\"row eqp-dynamic-module-title\" *ngIf=\"showTitle\">\n <div class=\"col-md-12\">\n <h4><b>{{form.Name}}</b></h4>\n </div>\n</div>\n\n<form [formGroup]=\"formForm\">\n\n <!-- VISUALIZZAZIONE SEMPLICE -->\n <ng-container *ngIf=\"form.FormScalarType == FormScalarTypeEnum.Semplice\" [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: form.Fields }\">\n </ng-container>\n\n <!-- VISUALIZZAZIONE A STEPPER -->\n <mat-horizontal-stepper linear *ngIf=\"form.FormScalarType == FormScalarTypeEnum['A step']\">\n <mat-step *ngFor=\"let group of form.FormFieldsGroups\">\n <ng-template matStepLabel>\n {{group.Name}}\n </ng-template>\n\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </mat-step>\n </mat-horizontal-stepper>\n\n <!-- VISUALIZZAZIONE A TAB -->\n <mat-tab-group *ngIf=\"form.FormScalarType == FormScalarTypeEnum['In tab']\">\n <mat-tab *ngFor=\"let group of form.FormFieldsGroups\" [label]=\"group.Name\">\n <div class=\"mt-3\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </div>\n </mat-tab>\n </mat-tab-group>\n\n <!-- VISUALIZZAZIONE AD ACCORDION -->\n <mat-accordion multi *ngIf=\"form.FormScalarType == FormScalarTypeEnum['In accordion']\">\n <mat-expansion-panel *ngFor=\"let group of form.FormFieldsGroups\">\n <mat-expansion-panel-header>\n <mat-panel-title>\n {{group.Name}}\n </mat-panel-title>\n </mat-expansion-panel-header>\n\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </mat-expansion-panel>\n </mat-accordion>\n</form>\n\n<div class=\"row mt-2\" *ngIf=\"showButtons\">\n <div class=\"col-sm-12 text-right\">\n <button class=\"mr-2\" mat-raised-button (click)=\"saveOrExitForm(true)\" type=\"button\">\n Annulla\n </button>\n <button class=\"mr-2\" mat-raised-button color=\"primary\" (click)=\"saveOrExitForm(false)\"\n [disabled]=\"formForm.invalid || formForm.disabled\" type=\"button\">\n Salva\n </button>\n </div>\n</div>\n\n<!-- TEMPLATE PER LA VISUALIZZAZIONE DEI CAMPI DELLA FORM -->\n<ng-template #fieldTemplates let-fields='fields'>\n <div class=\"row\">\n <div class=\"mt-2\" *ngFor=\"let field of fields\" [ngClass]=\"utilityService.getFieldSyleClass(field)\">\n <dynamic-module-field #fieldTemplate [field]=\"field\" [form]=\"form\" [record]=\"record\"\n (recordChange)=\"onRecordChange()\"></dynamic-module-field>\n </div>\n </div>\n</ng-template>",
2666
2709
  styles: [""]
2667
2710
  })
2668
2711
  ], AddFormRecordComponent);