@colijnit/corecomponents_v12 12.2.4 → 12.2.5

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.
Files changed (24) hide show
  1. package/bundles/colijnit-corecomponents_v12.umd.js +428 -81
  2. package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
  3. package/colijnit-corecomponents_v12.d.ts +0 -2
  4. package/colijnit-corecomponents_v12.metadata.json +1 -1
  5. package/esm2015/colijnit-corecomponents_v12.js +1 -3
  6. package/esm2015/lib/components/button/button.component.js +27 -20
  7. package/esm2015/lib/components/filter-item/filter-item.component.js +10 -5
  8. package/esm2015/lib/components/input-date-picker/input-date-picker.component.js +3 -1
  9. package/esm2015/lib/components/list-of-values/list-of-values.component.js +14 -6
  10. package/esm2015/lib/directives/screen-configuration/screen-configuration.directive.js +123 -33
  11. package/esm2015/lib/directives/screen-configuration/screen-configuration.module.js +4 -6
  12. package/esm2015/lib/service/base-module-screen-config.service.js +205 -0
  13. package/esm2015/lib/service/base-module.service.js +42 -0
  14. package/esm2015/public-api.js +4 -1
  15. package/fesm2015/colijnit-corecomponents_v12.js +402 -83
  16. package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
  17. package/lib/components/button/button.component.d.ts +11 -3
  18. package/lib/directives/screen-configuration/screen-configuration.directive.d.ts +25 -9
  19. package/lib/service/base-module-screen-config.service.d.ts +47 -0
  20. package/lib/service/base-module.service.d.ts +22 -0
  21. package/package.json +5 -4
  22. package/public-api.d.ts +3 -0
  23. package/esm2015/lib/directives/screen-configuration/screen-config-component-wrapper.component.js +0 -30
  24. package/lib/directives/screen-configuration/screen-config-component-wrapper.component.d.ts +0 -11
@@ -1,8 +1,8 @@
1
1
  import { __awaiter, __decorate } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
- import { Input, Injectable, NgZone, Component, ViewEncapsulation, HostBinding, ComponentFactoryResolver, ApplicationRef, Injector, EventEmitter, Renderer2, ViewChildren, ElementRef, Output, Directive, ChangeDetectorRef, Optional, ViewChild, ViewContainerRef, HostListener, NgModule, SkipSelf, InjectionToken, Inject, ChangeDetectionStrategy, Pipe, ContentChildren, forwardRef, NO_ERRORS_SCHEMA, ContentChild } from '@angular/core';
3
+ import { Input, Injectable, NgZone, Component, ViewEncapsulation, HostBinding, ComponentFactoryResolver, ApplicationRef, Injector, EventEmitter, Renderer2, ViewChildren, ElementRef, Output, Directive, ChangeDetectorRef, Optional, ViewChild, ViewContainerRef, HostListener, NgModule, SkipSelf, InjectionToken, Inject, forwardRef, ChangeDetectionStrategy, Pipe, ContentChildren, NO_ERRORS_SCHEMA, ContentChild } from '@angular/core';
4
4
  import { NgModel, FormGroup, FormsModule } from '@angular/forms';
5
- import { Subject, merge, fromEvent } from 'rxjs';
5
+ import { Subject, merge, fromEvent, BehaviorSubject } from 'rxjs';
6
6
  import { DomSanitizer, HammerGestureConfig, HammerModule, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
7
7
  import { trigger, state, style, transition, animate, query, animateChild } from '@angular/animations';
8
8
  import { CommonModule } from '@angular/common';
@@ -16,6 +16,9 @@ import { OverlayConfig, Overlay } from '@angular/cdk/overlay';
16
16
  import { ComponentPortal } from '@angular/cdk/portal';
17
17
  import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
18
18
  import { ScrollingModule } from '@angular/cdk/scrolling';
19
+ import { ArrayUtils as ArrayUtils$1 } from '@colijnit/ioneconnector/build/utils/array-utils';
20
+ import { DEFAULT_GET_OBJECT_CONFIGURATION_PARAMS } from '@colijnit/ioneconnector/build/model/default-get-object-configurations-params';
21
+ import { ObjectConfiguration } from '@colijnit/ioneconnector/build/model/object-configuration';
19
22
 
20
23
  // @returns true iff given value equals null or equals undefined
21
24
  function isNill(value) {
@@ -3259,6 +3262,9 @@ EventUtils._passiveSupported = undefined;
3259
3262
  EventUtils._passiveCapture = undefined;
3260
3263
  EventUtils._passiveBubble = undefined;
3261
3264
 
3265
+ // Enables "DI for interfaces" (see ConfigNameDirective injected .hostComponent).
3266
+ const SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME = new InjectionToken("ScreenConfigAdapterComponent");
3267
+
3262
3268
  class ButtonComponent {
3263
3269
  constructor(_elementRef) {
3264
3270
  this._elementRef = _elementRef;
@@ -3275,7 +3281,7 @@ class ButtonComponent {
3275
3281
  return !!this.iconData;
3276
3282
  }
3277
3283
  onHostClick(event) {
3278
- if (this.disabled) {
3284
+ if (this.readonly || this.disabled) {
3279
3285
  this.clickedWhileDisabled.emit(event);
3280
3286
  EventUtils.KillEvent(event);
3281
3287
  }
@@ -3296,16 +3302,21 @@ class ButtonComponent {
3296
3302
  }
3297
3303
  ButtonComponent.decorators = [
3298
3304
  { type: Component, args: [{
3299
- selector: "co-button",
3305
+ selector: 'co-button',
3300
3306
  template: `
3301
- <co-icon *ngIf="!!iconData" [iconData]="iconData"></co-icon>
3302
- <span *ngIf="!!label" class="label">{{ label }}</span>
3303
- <co-icon *ngIf="!!iconDataRight" [iconData]="iconDataRight"></co-icon>
3304
- <div class="rippler" md-ripple [mdRippleDisabled]="disabled"></div>
3305
- `,
3307
+ <co-icon *ngIf="!!iconData" [iconData]="iconData"></co-icon>
3308
+ <span *ngIf="!!label" class="label">{{ label }}</span>
3309
+ <co-icon *ngIf="!!iconDataRight" [iconData]="iconDataRight"></co-icon>
3310
+ <div class="rippler" md-ripple [mdRippleDisabled]="disabled"></div>
3311
+ `,
3306
3312
  host: {
3307
- tabindex: "0"
3313
+ tabindex: '0'
3308
3314
  },
3315
+ providers: [{
3316
+ provide: SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME,
3317
+ useExisting: forwardRef(() => ButtonComponent)
3318
+ }
3319
+ ],
3309
3320
  changeDetection: ChangeDetectionStrategy.OnPush,
3310
3321
  encapsulation: ViewEncapsulation.None
3311
3322
  },] }
@@ -3314,19 +3325,20 @@ ButtonComponent.ctorParameters = () => [
3314
3325
  { type: ElementRef }
3315
3326
  ];
3316
3327
  ButtonComponent.propDecorators = {
3317
- label: [{ type: HostBinding, args: ["class.has-label",] }, { type: Input }],
3318
- iconData: [{ type: HostBinding, args: ["class.has-left-icon",] }, { type: Input }],
3319
- iconDataRight: [{ type: HostBinding, args: ["class.has-right-icon",] }, { type: Input }],
3328
+ label: [{ type: HostBinding, args: ['class.has-label',] }, { type: Input }],
3329
+ iconData: [{ type: HostBinding, args: ['class.has-left-icon',] }, { type: Input }],
3330
+ iconDataRight: [{ type: HostBinding, args: ['class.has-right-icon',] }, { type: Input }],
3320
3331
  isToggleButton: [{ type: Input }],
3321
- isToggled: [{ type: Input }, { type: HostBinding, args: ["class.toggled",] }],
3322
- hidden: [{ type: Input }, { type: HostBinding, args: ["class.co-hidden",] }],
3323
- disabled: [{ type: Input }, { type: HostBinding, args: ["class.disabled",] }],
3324
- showClass: [{ type: HostBinding, args: ["class.co-button",] }],
3332
+ isToggled: [{ type: Input }, { type: HostBinding, args: ['class.toggled',] }],
3333
+ hidden: [{ type: Input }, { type: HostBinding, args: ['class.co-hidden',] }],
3334
+ disabled: [{ type: Input }, { type: HostBinding, args: ['class.disabled',] }],
3335
+ showClass: [{ type: HostBinding, args: ['class.co-button',] }],
3325
3336
  onClick: [{ type: Output }],
3326
3337
  clickedWhileDisabled: [{ type: Output }],
3327
3338
  isToggledChange: [{ type: Output }],
3328
- hasIcon: [{ type: HostBinding, args: ["class.has-icon",] }],
3329
- onHostClick: [{ type: HostListener, args: ["click", ["$event"],] }]
3339
+ hasIcon: [{ type: HostBinding, args: ['class.has-icon',] }],
3340
+ onHostClick: [{ type: HostListener, args: ['click', ['$event'],] }],
3341
+ readonly: [{ type: HostBinding, args: ["class.read-only",] }]
3330
3342
  };
3331
3343
 
3332
3344
  class ButtonModule {
@@ -5195,9 +5207,6 @@ BaseModule.decorators = [
5195
5207
  },] }
5196
5208
  ];
5197
5209
 
5198
- // Enables "DI for interfaces" (see ConfigNameDirective injected .hostComponent).
5199
- const SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME = new InjectionToken("ScreenConfigAdapterComponent");
5200
-
5201
5210
  class InputCheckboxComponent extends BaseInputComponent {
5202
5211
  constructor(formComponent, iconCacheService, changeDetector, overlayService, componentFactoryResolver, formUserChangeListener, ngZoneWrapper, elementRef) {
5203
5212
  super(changeDetector, componentFactoryResolver, overlayService, formUserChangeListener, ngZoneWrapper, elementRef);
@@ -5403,6 +5412,8 @@ InputDatePickerComponent.decorators = [
5403
5412
  selector: 'co-input-date',
5404
5413
  template: `
5405
5414
  <co-input-text (clickOutside)="toggleCalendar(false)" overlayParent #parentForOverlay="overlayParent"
5415
+ [hidden]="hidden"
5416
+ [readonly]="readonly"
5406
5417
  [(model)]="modelAsString"
5407
5418
  [rightIcon]="rightIcon"
5408
5419
  [leftIcon]="leftIcon"
@@ -10616,8 +10627,11 @@ class ListOfValuesComponent extends BaseInputComponent {
10616
10627
  if (this._lovPopupComponentRef) {
10617
10628
  this._lovPopupComponentRef.instance.searchTerm = model;
10618
10629
  }
10619
- if (!this.selectedModel && model) {
10620
- this.openPopup();
10630
+ else {
10631
+ if (!this.selectedModel && model) {
10632
+ this.openPopup();
10633
+ this._lovPopupComponentRef.instance.searchTerm = model;
10634
+ }
10621
10635
  }
10622
10636
  this.selectedModel = model;
10623
10637
  }
@@ -10736,7 +10750,7 @@ class ListOfValuesComponent extends BaseInputComponent {
10736
10750
  this.selectedModel = this.model[this.displayField];
10737
10751
  }
10738
10752
  else {
10739
- this.selectedModel = "";
10753
+ this.selectedModel = '';
10740
10754
  }
10741
10755
  }
10742
10756
  }
@@ -10779,7 +10793,11 @@ ListOfValuesComponent.decorators = [
10779
10793
  </co-input-text>
10780
10794
  `,
10781
10795
  providers: [
10782
- OverlayService
10796
+ OverlayService,
10797
+ {
10798
+ provide: SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME,
10799
+ useExisting: forwardRef(() => ListOfValuesComponent)
10800
+ }
10783
10801
  ],
10784
10802
  encapsulation: ViewEncapsulation.None
10785
10803
  },] }
@@ -11323,6 +11341,8 @@ class FilterItemComponent {
11323
11341
  this.sliderMax = !!this.sliderMax ? this.sliderMax : this.sliderDefaultMax;
11324
11342
  let trueLowerBound = Math.min(this.sliderMin, this.sliderMax);
11325
11343
  let trueUpperBound = Math.max(this.sliderMin, this.sliderMax);
11344
+ this.sliderMin = trueLowerBound;
11345
+ this.sliderMax = trueUpperBound;
11326
11346
  this._model = `${trueLowerBound} - ${trueUpperBound}`;
11327
11347
  }
11328
11348
  _createModelForCheckboxToText() {
@@ -11564,7 +11584,7 @@ FilterItemComponent.decorators = [
11564
11584
  [excludePlusMinus]="true"
11565
11585
  [label]="'FROM' | localize"
11566
11586
  [(model)]="sliderMin"
11567
- (modelChange)="handleModelChange($event)"
11587
+ (focusout)="handleModelChange(sliderMin)"
11568
11588
  ></co-input-text>
11569
11589
  <co-input-text
11570
11590
  class="slider-to"
@@ -11574,19 +11594,22 @@ FilterItemComponent.decorators = [
11574
11594
  [excludePlusMinus]="true"
11575
11595
  [label]="'TO' | localize"
11576
11596
  [(model)]="sliderMax"
11577
- (modelChange)="handleModelChange($event)"
11597
+ (focusout)="handleModelChange(sliderMax)"
11578
11598
  ></co-input-text>
11579
11599
  </div>
11580
11600
  <div class="co-filter-item-checkbox-content" *ngIf="mode === modes.Checkbox ">
11581
11601
  <co-input-checkbox
11582
11602
  [(model)]="model"
11583
- (modelChange)="handleModelChange($event)"></co-input-checkbox>
11603
+ (modelChange)="handleModelChange($event)"
11604
+ [label]="placeholder">
11605
+ </co-input-checkbox>
11584
11606
  </div>
11585
11607
  <div class="co-filter-item-checkbox-content"
11586
11608
  *ngIf="mode === modes.CheckboxToText || mode === modes.CheckboxToSimpleText || mode === modes.CheckboxToBinary">
11587
11609
  <co-input-checkbox
11588
11610
  [(model)]="checkBoxToTextModel"
11589
- (modelChange)="handleModelChange($event)"></co-input-checkbox>
11611
+ (modelChange)="handleModelChange($event)"
11612
+ [label]="placeholder"></co-input-checkbox>
11590
11613
  </div>
11591
11614
  <div class="co-filter-item-textfield-content" *ngIf="mode === modes.TextField">
11592
11615
  <co-input-text
@@ -11985,94 +12008,391 @@ CheckmarkOverlayModule.decorators = [
11985
12008
  },] }
11986
12009
  ];
11987
12010
 
11988
- class ScreenConfigComponentWrapper {
11989
- constructor(_elementRef) {
11990
- this._elementRef = _elementRef;
11991
- this._visibleOnViewInit = true;
12011
+ class BaseModuleScreenConfigService {
12012
+ constructor() {
12013
+ // emits the params of the loaded config, each time when a new config was loaded
12014
+ this.configSet = new BehaviorSubject([]);
12015
+ this._configObjects = [];
12016
+ // key: configName, value: the ObjectConfiguration with that configName. For faster ObjectConfiguration lookups, given a configName string (vs. array).
12017
+ this._objectConfigsMap = new Map();
11992
12018
  }
11993
- setWrapperContent(element, visibleOnViewInit) {
11994
- this._contentNativeElement = element;
11995
- this._visibleOnViewInit = visibleOnViewInit;
12019
+ get configObjects() {
12020
+ return this._configObjects;
11996
12021
  }
11997
- ngAfterViewInit() {
11998
- if (this.screenConfigComponentWrapper) {
11999
- this.screenConfigComponentWrapper.nativeElement.appendChild(this._contentNativeElement);
12000
- this.hidden = !this._visibleOnViewInit;
12022
+ // POST: this.configObjects are loaded. Returns the loaded config objects.
12023
+ loadConfig(params = DEFAULT_GET_OBJECT_CONFIGURATION_PARAMS, insertRights) {
12024
+ return __awaiter(this, void 0, void 0, function* () {
12025
+ const configObjects = yield this.loadConfigForModule(params, insertRights);
12026
+ this._configObjects = configObjects;
12027
+ if (configObjects && Array.isArray(configObjects)) {
12028
+ this._buildScreenConfigMap();
12029
+ this.configSet.next(params);
12030
+ }
12031
+ return this._configObjects;
12032
+ });
12033
+ }
12034
+ lazyLoadConfig() {
12035
+ return __awaiter(this, void 0, void 0, function* () {
12036
+ if (!this.configObjects.length) {
12037
+ yield this.loadConfig();
12038
+ }
12039
+ });
12040
+ }
12041
+ isActiveFieldValidationObject(configObject) {
12042
+ if (configObject) {
12043
+ return configObject.isActiveFieldValidationObject() && !this.isDataNameHiddenByAnyOfItsParentRubrics(configObject.dataName);
12044
+ }
12045
+ }
12046
+ isBoValid(bo) {
12047
+ if (this.controlValidityByBoMap && !ArrayUtils$1.IsEmptyArray(this.controlValidityByBoMap)) {
12048
+ const mapEntry = this.controlValidityByBoMap.find(value => value.bo === bo && value.valid === false);
12049
+ if (mapEntry) {
12050
+ return mapEntry.valid;
12051
+ }
12052
+ }
12053
+ return true;
12054
+ }
12055
+ getObjectConfigurationFor(configName) {
12056
+ const configuration = this._objectConfigsMap.get(configName);
12057
+ // If configuration not found by configname, try by data name
12058
+ if (!!this._objectConfigsMap.size && !configuration && configName) {
12059
+ const configNameByDataName = this._getConfigNameByDataName(configName);
12060
+ if (this._objectConfigsMap.get(configNameByDataName)) {
12061
+ return this._objectConfigsMap.get(configNameByDataName);
12062
+ } /*else if (!environment.production) {
12063
+ console.warn("No configuration object was found by the name of: ", configName, " or dataname ", configNameByDataName);
12064
+ }*/
12065
+ }
12066
+ return configuration;
12067
+ }
12068
+ setObjectConfigurationFor(configName, configObject) {
12069
+ this._objectConfigsMap.set(configName, configObject);
12070
+ }
12071
+ // Whether the user may read the component that's associated with given config object (visibility).
12072
+ mayRead(configName) {
12073
+ const objectConfig = this._objectConfigsMap.get(configName);
12074
+ return objectConfig ? objectConfig.mayRead() : false;
12075
+ }
12076
+ isReadonly(configName) {
12077
+ return !this.mayWrite(configName);
12078
+ }
12079
+ // Whether the user may write onto the component that's associated with given config object.
12080
+ mayWrite(configName) {
12081
+ const objectConfig = this._objectConfigsMap.get(configName);
12082
+ return objectConfig ? objectConfig.mayWrite() : false;
12083
+ }
12084
+ // Whether the component associated with given config object should, from the start, be visible to the user.
12085
+ immediatelyVisible(configName) {
12086
+ const objectConfig = this._objectConfigsMap.get(configName);
12087
+ return objectConfig ? objectConfig.immediatelyVisible() : false;
12088
+ }
12089
+ // Whether the component associated with given config object should, from the start, be visible to the user.
12090
+ immediatelyHidden(configName) {
12091
+ const objectConfig = this._objectConfigsMap.get(configName);
12092
+ return objectConfig ? objectConfig.immediatelyHidden() : false;
12093
+ }
12094
+ noRights(configName) {
12095
+ const objectConfig = this._objectConfigsMap.get(configName);
12096
+ return objectConfig ? objectConfig.noRights() : false;
12097
+ }
12098
+ isHidden(configName) {
12099
+ return !this.immediatelyVisible(configName);
12100
+ }
12101
+ isRequired(configName) {
12102
+ const objectConfig = this._objectConfigsMap.get(configName);
12103
+ return objectConfig ? !objectConfig.nullable : false;
12104
+ }
12105
+ getDefaultValue(configName) {
12106
+ const objectConfig = this._objectConfigsMap.get(configName);
12107
+ return objectConfig ? objectConfig.getDefaultValue() : undefined;
12108
+ }
12109
+ getDefaultStringValue(configName) {
12110
+ const objectConfig = this._objectConfigsMap.get(configName);
12111
+ return objectConfig ? objectConfig.getDefaultStringValue() : undefined;
12112
+ }
12113
+ getDefaultNumberValue(configName) {
12114
+ const objectConfig = this._objectConfigsMap.get(configName);
12115
+ return objectConfig ? objectConfig.getDefaultNumberValue() : undefined;
12116
+ }
12117
+ getMaxLength(configName) {
12118
+ const objectConfig = this._objectConfigsMap.get(configName);
12119
+ return objectConfig ? objectConfig.maxLength : undefined;
12120
+ }
12121
+ getDecimals(configName) {
12122
+ const objectConfig = this._objectConfigsMap.get(configName);
12123
+ return objectConfig ? objectConfig.scale : undefined;
12124
+ }
12125
+ hasConfigObjects() {
12126
+ return this._configObjects && this._configObjects.length > 0 && this._objectConfigsMap.size > 0;
12127
+ }
12128
+ isKind(configName, kind) {
12129
+ const objectConfig = this._objectConfigsMap.get(configName);
12130
+ return objectConfig ? objectConfig.isKind(kind) : false;
12131
+ }
12132
+ isDataNameHiddenByItselfOrAnyOfItsParentRubrics(dataName) {
12133
+ const isHiddenItself = ArrayUtils$1.ContainsAnElementFoundBy(this._configObjects, ((item) => {
12134
+ return item.dataName === dataName && item.isHidden();
12135
+ }));
12136
+ if (isHiddenItself) {
12137
+ return true;
12138
+ }
12139
+ else {
12140
+ return this.isDataNameHiddenByAnyOfItsParentRubrics(dataName);
12141
+ }
12142
+ }
12143
+ isDataNameHiddenByAnyOfItsParentRubrics(dataName) {
12144
+ // if (this._hardCodedConfigStructure) {
12145
+ // const parentConfigNames: string[] = this._hardCodedConfigStructure.getParentConfigNamesOfFieldConfigName(this._getConfigNameByDataName(dataName));
12146
+ // if (parentConfigNames) {
12147
+ // for (let i: number = 0, len: number = parentConfigNames.length; i < len; i++) {
12148
+ // const parentConfigObj: ObjectConfiguration = this.getObjectConfigurationFor(parentConfigNames[i]);
12149
+ // if (parentConfigObj && parentConfigObj.isHidden()) {
12150
+ // return true;
12151
+ // }
12152
+ // }
12153
+ // }
12154
+ // return false;
12155
+ // }
12156
+ return false;
12157
+ }
12158
+ // return the first found config name for given data name
12159
+ _getConfigNameByDataName(dataName) {
12160
+ const itsConfigObject = this._getConfigObjectByDataName(dataName);
12161
+ if (itsConfigObject) {
12162
+ return itsConfigObject.configName;
12163
+ }
12164
+ }
12165
+ // return the first found config object with given data name
12166
+ _getConfigObjectByDataName(dataName) {
12167
+ return ArrayUtils$1.Find(this._configObjects, (cfgObj) => {
12168
+ return cfgObj.dataName === dataName;
12169
+ });
12170
+ }
12171
+ // PRE: this.configObjects is loaded. POST: this._objectConfigsMap contains the latest map of configName -> to -> ObjectConfiguration for a live screen module.
12172
+ _buildScreenConfigMap() {
12173
+ this._objectConfigsMap.clear();
12174
+ this.configObjects.forEach(item => this._objectConfigsMap.set(item.configName, item));
12175
+ }
12176
+ setScreenConfigurationObjectsReadOnly(value) {
12177
+ this.configObjects.forEach((object) => {
12178
+ const copy = Object.assign(new ObjectConfiguration(), object);
12179
+ copy.variableReadOnly = value;
12180
+ this.setObjectConfigurationFor(object.configName, copy);
12181
+ });
12182
+ }
12183
+ setScreenConfigurationObjectsRedErrorBackground(errorValidation, setAllFalse = false) {
12184
+ if (setAllFalse) {
12185
+ this.configObjects.forEach((object) => {
12186
+ const copy = Object.assign(new ObjectConfiguration(), object);
12187
+ copy.redErrorBackground = false;
12188
+ this.setObjectConfigurationFor(object.configName, copy);
12189
+ });
12190
+ }
12191
+ else if (errorValidation) {
12192
+ const errorMessages = errorValidation.getAllErrorMessagesOfMyValidationFields();
12193
+ for (let i = 0, len = errorMessages.length; i < len; i++) {
12194
+ const errorMsg = errorMessages[i];
12195
+ const configObject = this.configObjects.find(object => object.configName === errorMsg.fieldId);
12196
+ if (configObject) {
12197
+ const copy = Object.assign(new ObjectConfiguration(), configObject);
12198
+ copy.redErrorBackground = false;
12199
+ this.setObjectConfigurationFor(configObject.configName, copy);
12200
+ }
12201
+ }
12001
12202
  }
12002
12203
  }
12003
12204
  }
12004
- ScreenConfigComponentWrapper.decorators = [
12005
- { type: Component, args: [{
12006
- selector: "screen-config-component-wrapper",
12007
- template: `<div *ngIf="!hidden" #screenConfigComponentWrapper></div>`
12008
- },] }
12009
- ];
12010
- ScreenConfigComponentWrapper.ctorParameters = () => [
12011
- { type: ElementRef }
12205
+ BaseModuleScreenConfigService.decorators = [
12206
+ { type: Injectable }
12207
+ ];
12208
+
12209
+ /**
12210
+ * Base class for top-level services of CRUD-style iOne modules (the Relation, Article and Transaction modules).
12211
+ * What sets these modules apart, is the concept of a relatively bulky, 'single businessobject' being manipulated throughout all the tabs.
12212
+ *
12213
+ * Many other (smaller?) iOne modules work with multiple LISTS of different business object types instead.
12214
+ */
12215
+ class BaseModuleService {
12216
+ constructor(screenConfigService) {
12217
+ this.screenConfigService = screenConfigService;
12218
+ this.readonlyChange = new Subject();
12219
+ // Emits this each time a new error validation was received. (there will be zero error tooltips on the screen after this fires)
12220
+ this.errorValidationReceived = new Subject();
12221
+ // Emits once after succesful BO update (i.e. there were no errors)
12222
+ this.successfulUpdate = new Subject();
12223
+ this._readonly = true;
12224
+ this._subscriptions = [];
12225
+ this._subscriptions.push(this.errorValidationReceived.subscribe((errorValidation) => this.screenConfigService.setScreenConfigurationObjectsRedErrorBackground(errorValidation)), this.successfulUpdate.subscribe(() => this.screenConfigService.setScreenConfigurationObjectsRedErrorBackground(null, true)), this.readonlyChange.subscribe((readOnly) => this.screenConfigService.setScreenConfigurationObjectsReadOnly(readOnly)));
12226
+ }
12227
+ // Whether the module is in readonly modus or not. Input fields etc. will be readonly throughout the module.
12228
+ get readonly() {
12229
+ return this._readonly;
12230
+ }
12231
+ set readonly(readonly) {
12232
+ if (this._readonly !== readonly) {
12233
+ this._readonly = readonly;
12234
+ this.readonlyChange.next(this._readonly);
12235
+ }
12236
+ }
12237
+ ngOnDestroy() {
12238
+ this._subscriptions.forEach((subscription) => subscription.unsubscribe());
12239
+ }
12240
+ }
12241
+ BaseModuleService.decorators = [
12242
+ { type: Injectable }
12012
12243
  ];
12013
- ScreenConfigComponentWrapper.propDecorators = {
12014
- screenConfigComponentWrapper: [{ type: ViewChild, args: ['screenConfigComponentWrapper',] }]
12015
- };
12244
+ BaseModuleService.ctorParameters = () => [
12245
+ { type: BaseModuleScreenConfigService }
12246
+ ];
12016
12247
 
12017
12248
  // Directive to represents the marker of "screen config name ID's" of components within a module.
12018
12249
  // Manipulates visibility, readonly and other dynamic states of an input element according to its db-fetched screen configuration object.
12019
12250
  class ScreenConfigurationDirective {
12020
- constructor(hostComponent, _viewContainerRef, _componentFactoryResolver) {
12251
+ constructor(hostComponent, _element,
12252
+ // we must always have a config service to fetch config objects with
12253
+ _configService, _renderer,
12254
+ // to make host readonly when MODULE switches to readonly:
12255
+ _moduleService) {
12021
12256
  this.hostComponent = hostComponent;
12022
- this._viewContainerRef = _viewContainerRef;
12023
- this._componentFactoryResolver = _componentFactoryResolver;
12257
+ this._element = _element;
12258
+ this._configService = _configService;
12259
+ this._renderer = _renderer;
12260
+ this._moduleService = _moduleService;
12261
+ this.screenConfigNativeElement = false;
12024
12262
  this.noModuleService = false;
12263
+ // feature toggle for devs so you can see the whole screen with all inputs etc by temporarily turning off the hiding effects of this directive on its host
12264
+ this._isTurnedOff = false;
12265
+ this._subs = [];
12266
+ this._subs.push(this._configService.configSet.subscribe((configObjects) => {
12267
+ if (configObjects && configObjects.length > 0) {
12268
+ this._updateHost();
12269
+ }
12270
+ }));
12271
+ if (this._moduleService && !this.noModuleService) {
12272
+ this._subs.push(this._moduleService.readonlyChange.subscribe((moduleInReadonlyState) => {
12273
+ if (this.hostComponent) {
12274
+ this.hostComponent.readonly = this.hostComponent.forceReadonly || moduleInReadonlyState;
12275
+ }
12276
+ }), this._moduleService.errorValidationReceived.subscribe((validationResult) => {
12277
+ this._setErrorRedBackgroundAfterScrCfgValidate(validationResult);
12278
+ }), this._moduleService.successfulUpdate.subscribe(() => {
12279
+ if (this.hostComponent) {
12280
+ this.hostComponent.redErrorBackground = false;
12281
+ }
12282
+ }));
12283
+ }
12025
12284
  }
12026
- set screenConfigurationObject(screenConfigurationObject) {
12027
- if (screenConfigurationObject) {
12028
- this._screenConfigurationObject = screenConfigurationObject;
12029
- this._initWrapperComponent();
12285
+ set screenConfigurationObject(value) {
12286
+ if (value) {
12287
+ this._screenConfigurationObject = value;
12030
12288
  this._updateHost();
12031
12289
  }
12032
12290
  }
12033
12291
  get screenConfigurationObject() {
12034
12292
  return this._screenConfigurationObject;
12035
12293
  }
12294
+ ngOnInit() {
12295
+ this._updateHost();
12296
+ // this._updateHeaderStateOnHostComponent(true);
12297
+ // show initial error message if any
12298
+ if (!this.noModuleService) {
12299
+ // this._setErrorRedBackgroundAfterScrCfgValidate(this._moduleService.lastError);
12300
+ }
12301
+ }
12036
12302
  ngOnDestroy() {
12303
+ this._subs.forEach(sub => sub.unsubscribe());
12304
+ if (this._isHeader) {
12305
+ // this._doubleClickHeaders.handleCollapseableDestroy(this.screenConfigurationObject);
12306
+ }
12307
+ this._element = undefined;
12037
12308
  this.hostComponent = undefined;
12038
- this._wrapperComponentInstance = undefined;
12039
12309
  }
12040
- _initWrapperComponent() {
12041
- if (!this._wrapperComponentInstance) {
12042
- const componentFactory = this._componentFactoryResolver.resolveComponentFactory(ScreenConfigComponentWrapper);
12043
- const componentRef = this._viewContainerRef.createComponent(componentFactory);
12044
- const visibleOnViewInit = !!this.screenConfigurationObject ? this.screenConfigurationObject.immediatelyVisible() : false;
12045
- this._wrapperComponentInstance = componentRef.instance;
12046
- this._wrapperComponentInstance.setWrapperContent(this._viewContainerRef.element.nativeElement, visibleOnViewInit);
12310
+ // Sets host component visibility, required, readonly etc. if specified in backend screen config OR module readonly status.
12311
+ _updateHost() {
12312
+ if (this._mayUpdateHost() || this.screenConfigNativeElement) {
12313
+ if (!this.screenConfigNativeElement) {
12314
+ this.hostComponent.objectConfigName = this.screenConfigurationObject;
12315
+ }
12316
+ const myCfgObj = this._configService.getObjectConfigurationFor(this.screenConfigurationObject);
12317
+ if (myCfgObj) {
12318
+ this._setHostVisible(myCfgObj.immediatelyVisible());
12319
+ // if (this.hostComponent instanceof GridColumnComponent) {
12320
+ // this.hostComponent.rights = myCfgObj.rights;
12321
+ // }
12322
+ if (!this.screenConfigNativeElement) {
12323
+ this.hostComponent.required = myCfgObj.isRequired();
12324
+ this.hostComponent.readonly = this.hostComponent.forceReadonly || this._moduleInReadonlyMode() || myCfgObj.isReadonly();
12325
+ this.hostComponent.decimals = myCfgObj.scale;
12326
+ this.hostComponent.maxLength = myCfgObj.maxLength;
12327
+ }
12328
+ }
12329
+ else {
12330
+ this._setHostVisible(false);
12331
+ if (!this.screenConfigNativeElement) {
12332
+ this.hostComponent.readonly = this._moduleInReadonlyMode();
12333
+ }
12334
+ }
12047
12335
  }
12048
12336
  }
12049
- _updateHost() {
12050
- if (!!this.hostComponent && !!this._screenConfigurationObject) {
12051
- this.hostComponent.objectConfigName = this.screenConfigurationObject.configName;
12052
- if (this.screenConfigurationObject) {
12053
- this.hostComponent.required = this.screenConfigurationObject.isRequired();
12054
- // readonly based on forced boolean, based on rights value or based on variable value affected by module read only state
12055
- this.hostComponent.readonly = this.hostComponent.forceReadonly || this.screenConfigurationObject.isReadonly() || this.screenConfigurationObject.variableReadOnly;
12056
- this.hostComponent.decimals = this.screenConfigurationObject.scale;
12057
- this.hostComponent.maxLength = this.screenConfigurationObject.maxLength;
12337
+ /**
12338
+ * Spawn error message tooltip onto our host comp, if any error was meant for the host (found by screenConfigurationObject);
12339
+ * @param errorValidation A top-level full validation result, either from the backend or from some client-side validation error.
12340
+ */
12341
+ _setErrorRedBackgroundAfterScrCfgValidate(errorValidation) {
12342
+ if (this.hostComponent && errorValidation) {
12343
+ const errorMessages = errorValidation.getAllErrorMessagesOfMyValidationFields();
12344
+ for (let i = 0, len = errorMessages.length; i < len; i++) {
12345
+ const errorMsg = errorMessages[i];
12346
+ const configName = this.dataName ? this.dataName : this.screenConfigurationObject;
12347
+ if (errorMsg.fieldId === configName && this._element /*&& this._properHost(errorMsg.boId)*/) {
12348
+ this.hostComponent.redErrorBackground = true;
12349
+ }
12350
+ }
12351
+ }
12352
+ }
12353
+ _moduleInReadonlyMode() {
12354
+ return !this.noModuleService ? (this._moduleService ? this._moduleService.readonly : false) : false;
12355
+ }
12356
+ _mayUpdateHost() {
12357
+ return !!this.hostComponent && !this._isTurnedOff && !!this.screenConfigurationObject;
12358
+ }
12359
+ _setHostVisible(visible) {
12360
+ if (!this.screenConfigNativeElement) {
12361
+ this.hostComponent.hidden = !visible;
12362
+ }
12363
+ else {
12364
+ if (this._element && this._element.nativeElement) {
12365
+ if (!visible) {
12366
+ this._renderer.addClass(this._element.nativeElement, 'hidden');
12367
+ }
12368
+ else {
12369
+ this._renderer.removeClass(this._element.nativeElement, 'hidden');
12370
+ }
12058
12371
  }
12059
12372
  }
12060
12373
  }
12061
12374
  }
12062
12375
  ScreenConfigurationDirective.decorators = [
12063
12376
  { type: Directive, args: [{
12064
- selector: "[screenConfigurationObject]"
12377
+ selector: '[screenConfigurationObject]'
12065
12378
  },] }
12066
12379
  ];
12067
12380
  ScreenConfigurationDirective.ctorParameters = () => [
12068
12381
  { type: undefined, decorators: [{ type: Inject, args: [SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME,] }] },
12069
- { type: ViewContainerRef },
12070
- { type: ComponentFactoryResolver }
12382
+ { type: ElementRef },
12383
+ { type: BaseModuleScreenConfigService },
12384
+ { type: Renderer2 },
12385
+ { type: BaseModuleService }
12071
12386
  ];
12072
12387
  ScreenConfigurationDirective.propDecorators = {
12073
- screenConfigurationObject: [{ type: Input }],
12388
+ screenConfigurationObject: [{ type: Input, args: ['screenConfigurationObject',] }],
12389
+ dataName: [{ type: Input }],
12390
+ screenConfigNativeElement: [{ type: Input }],
12074
12391
  noModuleService: [{ type: Input }]
12075
12392
  };
12393
+ __decorate([
12394
+ InputBoolean()
12395
+ ], ScreenConfigurationDirective.prototype, "screenConfigNativeElement", void 0);
12076
12396
  __decorate([
12077
12397
  InputBoolean()
12078
12398
  ], ScreenConfigurationDirective.prototype, "noModuleService", void 0);
@@ -12085,8 +12405,7 @@ ScreenConfigurationModule.decorators = [
12085
12405
  CommonModule
12086
12406
  ],
12087
12407
  declarations: [
12088
- ScreenConfigurationDirective,
12089
- ScreenConfigComponentWrapper
12408
+ ScreenConfigurationDirective
12090
12409
  ],
12091
12410
  exports: [
12092
12411
  ScreenConfigurationDirective,
@@ -12144,5 +12463,5 @@ ColorSequenceService.decorators = [
12144
12463
  * Generated bundle index. Do not edit.
12145
12464
  */
12146
12465
 
12147
- export { ArticleTileComponent, ArticleTileModule, BaseInputComponent, BaseInputDatePickerDirective, ButtonComponent, ButtonModule, CalendarComponent, CalendarModule, CardComponent, CardModule, Carousel3dComponent, Carousel3dModule, CarouselComponent, CarouselHammerConfig, CarouselModule, CheckmarkOverlayModule, ClickoutsideModule, CoDialogComponent, CoDialogModule, CoDialogWizardComponent, CoDialogWizardModule, CoDirection, CoOrientation, CollapsibleComponent, CollapsibleModule, ColorSequenceService, ColumnAlign, ContentViewMode, CoreComponentsIcon, CoreComponentsTranslationModule, CoreComponentsTranslationService, DoubleCalendarComponent, DoubleCalendarModule, FilterItemComponent, FilterItemMode, FilterItemModule, FilterItemViewmodel, FilterPipe, FilterPipeModule, FilterViewmodel, FormComponent, FormInputUserModelChangeListenerService, FormMasterService, FormModule, GridToolbarButtonComponent, GridToolbarButtonModule, GridToolbarComponent, GridToolbarModule, IconCacheService, IconCollapseHandleComponent, IconCollapseHandleModule, IconComponent, IconModule, ImageComponent, ImageModule, InputCheckboxComponent, InputCheckboxModule, InputDatePickerComponent, InputDatePickerModule, InputDateRangePickerComponent, InputDateRangePickerModule, InputNumberPickerComponent, InputNumberPickerModule, InputRadioButtonComponent, InputRadioButtonModule, InputSearchComponent, InputSearchModule, InputTextComponent, InputTextModule, InputTextareaComponent, InputTextareaModule, LevelIndicatorComponent, LevelIndicatorModule, ListOfValuesComponent, ListOfValuesModule, ListOfValuesPopupComponent, NgZoneWrapperService, ObserveVisibilityModule, OrientationOfDirection, OverlayModule, OverlayService, PaginationBarComponent, PaginationBarModule, PaginationComponent, PaginationModule, PopupButtonsComponent, PopupMessageDisplayComponent, PopupModule, PopupWindowShellComponent, PriceDisplayPipe, PriceDisplayPipeModule, PromptService, ResponsiveTextComponent, ResponsiveTextModule, SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME, ScreenConfigurationModule, SimpleGridColumnDirective, SimpleGridComponent, SimpleGridModule, TextInputPopupComponent, TileComponent, TileModule, TooltipDirectiveModule, ViewModeButtonsComponent, ViewModeButtonsModule, emailValidator, equalValidator, getValidatePasswordErrorString, maxStringLengthValidator, passwordValidator, precisionScaleValidator, requiredValidator, showHideDialog, InputBoolean as ɵa, RippleModule as ɵb, PaginationService as ɵba, PaginatePipe as ɵbb, SimpleGridCellComponent as ɵbc, ListOfValuesMultiselectPopupComponent as ɵbd, PrependPipeModule as ɵbe, PrependPipe as ɵbf, TooltipModule as ɵbg, TooltipComponent as ɵbh, TooltipDirective as ɵbi, CheckmarkOverlayComponent as ɵbj, ScreenConfigurationDirective as ɵbk, ScreenConfigComponentWrapper as ɵbl, MD_RIPPLE_GLOBAL_OPTIONS as ɵc, CoRippleDirective as ɵd, CoViewportRulerService as ɵe, CoScrollDispatcherService as ɵf, CoScrollableDirective as ɵg, StopClickModule as ɵh, StopClickDirective as ɵi, BaseModule as ɵj, AppendPipeModule as ɵk, AppendPipe as ɵl, ValidationErrorModule as ɵm, OverlayDirective as ɵn, OverlayParentDirective as ɵo, LocalizePipe as ɵp, DictionaryService as ɵq, ValidationErrorComponent as ɵr, CommitButtonsModule as ɵs, CommitButtonsComponent as ɵt, ClickOutsideDirective as ɵu, ClickOutsideMasterService as ɵv, CalendarTemplateComponent as ɵw, PopupShowerService as ɵx, BaseSimpleGridComponent as ɵy, ObserveVisibilityDirective as ɵz };
12466
+ export { ArticleTileComponent, ArticleTileModule, BaseInputComponent, BaseInputDatePickerDirective, BaseModuleScreenConfigService, BaseModuleService, ButtonComponent, ButtonModule, CalendarComponent, CalendarModule, CardComponent, CardModule, Carousel3dComponent, Carousel3dModule, CarouselComponent, CarouselHammerConfig, CarouselModule, CheckmarkOverlayModule, ClickoutsideModule, CoDialogComponent, CoDialogModule, CoDialogWizardComponent, CoDialogWizardModule, CoDirection, CoOrientation, CollapsibleComponent, CollapsibleModule, ColorSequenceService, ColumnAlign, ContentViewMode, CoreComponentsIcon, CoreComponentsTranslationModule, CoreComponentsTranslationService, DoubleCalendarComponent, DoubleCalendarModule, FilterItemComponent, FilterItemMode, FilterItemModule, FilterItemViewmodel, FilterPipe, FilterPipeModule, FilterViewmodel, FormComponent, FormInputUserModelChangeListenerService, FormMasterService, FormModule, GridToolbarButtonComponent, GridToolbarButtonModule, GridToolbarComponent, GridToolbarModule, IconCacheService, IconCollapseHandleComponent, IconCollapseHandleModule, IconComponent, IconModule, ImageComponent, ImageModule, InputCheckboxComponent, InputCheckboxModule, InputDatePickerComponent, InputDatePickerModule, InputDateRangePickerComponent, InputDateRangePickerModule, InputNumberPickerComponent, InputNumberPickerModule, InputRadioButtonComponent, InputRadioButtonModule, InputSearchComponent, InputSearchModule, InputTextComponent, InputTextModule, InputTextareaComponent, InputTextareaModule, LevelIndicatorComponent, LevelIndicatorModule, ListOfValuesComponent, ListOfValuesModule, ListOfValuesPopupComponent, NgZoneWrapperService, ObserveVisibilityModule, OrientationOfDirection, OverlayModule, OverlayService, PaginationBarComponent, PaginationBarModule, PaginationComponent, PaginationModule, PopupButtonsComponent, PopupMessageDisplayComponent, PopupModule, PopupWindowShellComponent, PriceDisplayPipe, PriceDisplayPipeModule, PromptService, ResponsiveTextComponent, ResponsiveTextModule, SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME, ScreenConfigurationDirective, ScreenConfigurationModule, SimpleGridColumnDirective, SimpleGridComponent, SimpleGridModule, TextInputPopupComponent, TileComponent, TileModule, TooltipDirectiveModule, ViewModeButtonsComponent, ViewModeButtonsModule, emailValidator, equalValidator, getValidatePasswordErrorString, maxStringLengthValidator, passwordValidator, precisionScaleValidator, requiredValidator, showHideDialog, InputBoolean as ɵa, RippleModule as ɵb, PaginationService as ɵba, PaginatePipe as ɵbb, SimpleGridCellComponent as ɵbc, ListOfValuesMultiselectPopupComponent as ɵbd, PrependPipeModule as ɵbe, PrependPipe as ɵbf, TooltipModule as ɵbg, TooltipComponent as ɵbh, TooltipDirective as ɵbi, CheckmarkOverlayComponent as ɵbj, MD_RIPPLE_GLOBAL_OPTIONS as ɵc, CoRippleDirective as ɵd, CoViewportRulerService as ɵe, CoScrollDispatcherService as ɵf, CoScrollableDirective as ɵg, StopClickModule as ɵh, StopClickDirective as ɵi, BaseModule as ɵj, AppendPipeModule as ɵk, AppendPipe as ɵl, ValidationErrorModule as ɵm, OverlayDirective as ɵn, OverlayParentDirective as ɵo, LocalizePipe as ɵp, DictionaryService as ɵq, ValidationErrorComponent as ɵr, CommitButtonsModule as ɵs, CommitButtonsComponent as ɵt, ClickOutsideDirective as ɵu, ClickOutsideMasterService as ɵv, CalendarTemplateComponent as ɵw, PopupShowerService as ɵx, BaseSimpleGridComponent as ɵy, ObserveVisibilityDirective as ɵz };
12148
12467
  //# sourceMappingURL=colijnit-corecomponents_v12.js.map