@smartsoft001/crud-shell-angular 1.1.730 → 1.1.733

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.
@@ -2384,11 +2384,11 @@
2384
2384
  },
2385
2385
  }
2386
2386
  : null,
2387
- item: this.config.edit || this.config.details
2387
+ item: !!this.config.edit || this.config.details
2388
2388
  ? {
2389
2389
  options: {
2390
2390
  routingPrefix: "/" + this.router.routerState.snapshot.url + "/",
2391
- edit: this.config.edit,
2391
+ edit: !!this.config.edit,
2392
2392
  },
2393
2393
  }
2394
2394
  : null,
@@ -2696,37 +2696,48 @@
2696
2696
  return __awaiter(this, void 0, void 0, function () {
2697
2697
  var compiledComponents;
2698
2698
  var _this = this;
2699
- return __generator(this, function (_b) {
2700
- switch (_b.label) {
2699
+ return __generator(this, function (_c) {
2700
+ switch (_c.label) {
2701
2701
  case 0:
2702
2702
  this.detailsService.init();
2703
2703
  this.styleService.init(this.elementRef);
2704
2704
  this.pageService.checkPermissions();
2705
- if (this.router.routerState.snapshot.url.endsWith("/add")) {
2706
- this.mode = "create";
2707
- }
2708
- else {
2709
- this.mode = this.config.details ? "details" : "update";
2710
- this.activeRoute.params
2711
- .pipe(this.takeUntilDestroy)
2712
- .subscribe(function (_b) {
2713
- var id = _b.id;
2714
- _this.facade.select(id);
2715
- _this.id = id;
2716
- });
2717
- this.activeRoute.queryParams
2718
- .pipe(this.takeUntilDestroy)
2719
- .subscribe(function (_b) {
2720
- var edit = _b.edit;
2721
- if (edit) {
2722
- _this.mode = "update";
2723
- }
2724
- });
2725
- }
2705
+ if (!this.router.routerState.snapshot.url.endsWith("/add")) return [3 /*break*/, 2];
2706
+ this.mode = "create";
2707
+ return [4 /*yield*/, this.generateComponents('add')];
2708
+ case 1:
2709
+ _c.sent();
2710
+ return [3 /*break*/, 5];
2711
+ case 2:
2712
+ this.mode = this.config.details ? "details" : "update";
2713
+ if (!(this.mode === 'update')) return [3 /*break*/, 4];
2714
+ return [4 /*yield*/, this.generateComponents('edit')];
2715
+ case 3:
2716
+ _c.sent();
2717
+ _c.label = 4;
2718
+ case 4:
2719
+ this.activeRoute.params
2720
+ .pipe(this.takeUntilDestroy)
2721
+ .subscribe(function (_c) {
2722
+ var id = _c.id;
2723
+ _this.facade.select(id);
2724
+ _this.id = id;
2725
+ });
2726
+ this.activeRoute.queryParams
2727
+ .pipe(this.takeUntilDestroy)
2728
+ .subscribe(function (_c) {
2729
+ var edit = _c.edit;
2730
+ if (edit) {
2731
+ _this.mode = "update";
2732
+ _this.generateComponents('edit');
2733
+ }
2734
+ });
2735
+ _c.label = 5;
2736
+ case 5:
2726
2737
  this.uniqueProvider = function (values) { return __awaiter(_this, void 0, void 0, function () {
2727
2738
  var filter, totalCount;
2728
- return __generator(this, function (_b) {
2729
- switch (_b.label) {
2739
+ return __generator(this, function (_c) {
2740
+ switch (_c.label) {
2730
2741
  case 0:
2731
2742
  filter = {
2732
2743
  query: [],
@@ -2747,12 +2758,12 @@
2747
2758
  }
2748
2759
  return [4 /*yield*/, this.service.getList(filter).toPromise()];
2749
2760
  case 1:
2750
- totalCount = (_b.sent()).totalCount;
2761
+ totalCount = (_c.sent()).totalCount;
2751
2762
  return [2 /*return*/, !totalCount];
2752
2763
  }
2753
2764
  });
2754
2765
  }); };
2755
- if (!this.config.details) return [3 /*break*/, 2];
2766
+ if (!this.config.details) return [3 /*break*/, 7];
2756
2767
  return [4 /*yield*/, this.dynamicComponentLoader.getComponentsWithFactories({
2757
2768
  components: __spreadArray(__spreadArray([], __read((this.config.details &&
2758
2769
  this.config.details["components"] &&
@@ -2764,8 +2775,8 @@
2764
2775
  ? [this.config.details["components"].bottom]
2765
2776
  : []))),
2766
2777
  })];
2767
- case 1:
2768
- compiledComponents = _b.sent();
2778
+ case 6:
2779
+ compiledComponents = _c.sent();
2769
2780
  this.detailsOptions = {
2770
2781
  type: this.config.type,
2771
2782
  item$: this.facade.selected$,
@@ -2783,8 +2794,8 @@
2783
2794
  : null,
2784
2795
  },
2785
2796
  };
2786
- _b.label = 2;
2787
- case 2:
2797
+ _c.label = 7;
2798
+ case 7:
2788
2799
  this.initPageOptions();
2789
2800
  this.facade.selected$.pipe(this.takeUntilDestroy).subscribe(function (item) {
2790
2801
  _this.item = item;
@@ -2797,6 +2808,39 @@
2797
2808
  });
2798
2809
  });
2799
2810
  };
2811
+ ItemComponent.prototype.generateComponents = function (mode) {
2812
+ var _a, _b;
2813
+ return __awaiter(this, void 0, void 0, function () {
2814
+ var compiledComponents, topComponentFactory, bottomComponentFactory;
2815
+ var _this = this;
2816
+ return __generator(this, function (_c) {
2817
+ switch (_c.label) {
2818
+ case 0: return [4 /*yield*/, this.dynamicComponentLoader.getComponentsWithFactories({
2819
+ components: __spreadArray(__spreadArray([], __read((this.config[mode] &&
2820
+ this.config[mode]["components"] &&
2821
+ this.config[mode]["components"].top
2822
+ ? [this.config[mode]["components"].top]
2823
+ : []))), __read((this.config[mode] &&
2824
+ this.config[mode]["components"] &&
2825
+ this.config[mode]["components"].bottom
2826
+ ? [this.config[mode]["components"].bottom]
2827
+ : []))),
2828
+ })];
2829
+ case 1:
2830
+ compiledComponents = _c.sent();
2831
+ topComponentFactory = (_a = compiledComponents.find(function (cc) { var _a; return cc.component === ((_a = _this.config[mode]["components"]) === null || _a === void 0 ? void 0 : _a.top); })) === null || _a === void 0 ? void 0 : _a.factory;
2832
+ bottomComponentFactory = (_b = compiledComponents.find(function (cc) { var _a; return cc.component === ((_a = _this.config[mode]["components"]) === null || _a === void 0 ? void 0 : _a.bottom); })) === null || _b === void 0 ? void 0 : _b.factory;
2833
+ if (!this.topTpl.get(0) && topComponentFactory) {
2834
+ this.topTpl.createComponent(topComponentFactory);
2835
+ }
2836
+ if (!this.bottomTpl.get(0) && bottomComponentFactory) {
2837
+ this.bottomTpl.createComponent(bottomComponentFactory);
2838
+ }
2839
+ return [2 /*return*/];
2840
+ }
2841
+ });
2842
+ });
2843
+ };
2800
2844
  ItemComponent.prototype.onPartialChange = function (val) {
2801
2845
  this.formPartialValue = val;
2802
2846
  };
@@ -2835,6 +2879,8 @@
2835
2879
  handler: function () {
2836
2880
  _this.mode = "details";
2837
2881
  _this.initPageOptions();
2882
+ _this.topTpl.clear();
2883
+ _this.bottomTpl.clear();
2838
2884
  },
2839
2885
  disabled$: new rxjs.BehaviorSubject(false),
2840
2886
  },
@@ -2867,6 +2913,7 @@
2867
2913
  text: "edit",
2868
2914
  handler: function () {
2869
2915
  _this.mode = "update";
2916
+ _this.generateComponents('edit');
2870
2917
  _this.initPageOptions();
2871
2918
  },
2872
2919
  disabled$: new rxjs.BehaviorSubject(false),
@@ -2942,7 +2989,7 @@
2942
2989
  ItemComponent.decorators = [
2943
2990
  { type: i0.Component, args: [{
2944
2991
  selector: "smart-crud-item-page",
2945
- template: "\n <smart-page [options]=\"pageOptions\">\n <div #topTpl></div>\n <smart-crud-item-standard-page *ngIf=\"template === 'default'\"\n [detailsOptions]=\"detailsOptions\"\n [mode]=\"mode\"\n [uniqueProvider]=\"uniqueProvider\"\n (onPartialChange)=\"onPartialChange($event)\"\n (onChange)=\"onChange($event)\"\n (onValidChange)=\"onValidChange($event)\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTpl\"></ng-container>\n </smart-crud-item-standard-page>\n <ng-template #contentTpl>\n <ng-content></ng-content>\n </ng-template>\n <div class=\"dynamic-content\"></div>\n </smart-page>\n "
2992
+ template: "\n <smart-page [options]=\"pageOptions\">\n <div #topTpl class=\"top-content\"></div>\n <smart-crud-item-standard-page *ngIf=\"template === 'default'\"\n [detailsOptions]=\"detailsOptions\"\n [mode]=\"mode\"\n [uniqueProvider]=\"uniqueProvider\"\n (onPartialChange)=\"onPartialChange($event)\"\n (onChange)=\"onChange($event)\"\n (onValidChange)=\"onValidChange($event)\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTpl\"></ng-container>\n </smart-crud-item-standard-page>\n <ng-template #contentTpl>\n <ng-content></ng-content>\n </ng-template>\n <div class=\"dynamic-content\"></div>\n <div #bottomTpl class=\"bottom-content\"></div>\n </smart-page>\n "
2946
2993
  },] }
2947
2994
  ];
2948
2995
  /**
@@ -2977,6 +3024,8 @@
2977
3024
  standardComponents: [{ type: i0.ViewChildren, args: [ItemStandardComponent, { read: ItemStandardComponent },] }],
2978
3025
  content: [{ type: i0.ViewChild, args: [angular$1.IonContent, { static: true },] }],
2979
3026
  contentTpl: [{ type: i0.ViewChild, args: ["contentTpl", { read: i0.TemplateRef, static: false },] }],
3027
+ topTpl: [{ type: i0.ViewChild, args: ["topTpl", { read: i0.ViewContainerRef, static: true },] }],
3028
+ bottomTpl: [{ type: i0.ViewChild, args: ["bottomTpl", { read: i0.ViewContainerRef, static: true },] }],
2980
3029
  dynamicContents: [{ type: i0.ViewChildren, args: [angular.DynamicContentDirective, { read: angular.DynamicContentDirective },] }]
2981
3030
  };
2982
3031