@magic-xpa/angular 4.900.0-dev490.8 → 4.900.0-dev490.80

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.
@@ -10,7 +10,7 @@ import * as i3 from 'ng-dynamic-component';
10
10
  import { DynamicModule } from 'ng-dynamic-component';
11
11
  import { InteractiveCommandType, OverlayType, Styles, HtmlProperties, GuiConstants, CommandType, PIC, GuiEnvironment, Modifiers } from '@magic-xpa/gui';
12
12
  import { MagicBridge, getGuiEventObj, CookieService } from '@magic-xpa/engine';
13
- import { MagicProperties, Logger, StrUtil, StorageAttribute, BindingLevel, StorageAttributeType, PICInterface } from '@magic-xpa/utils';
13
+ import { MagicProperties, Logger, StrUtil, StorageAttribute, BindingLevel, StorageAttributeType, MgControlType, PICInterface } from '@magic-xpa/utils';
14
14
  import { filter, map, debounceTime } from 'rxjs/operators';
15
15
  import { Subject, fromEvent } from 'rxjs';
16
16
  import { __awaiter, __decorate, __metadata } from 'tslib';
@@ -2021,7 +2021,7 @@ class TaskMagicService {
2021
2021
  return val;
2022
2022
  }
2023
2023
  case StorageAttribute.NUMERIC:
2024
- return (val === null) ? 0 : val;
2024
+ return val;
2025
2025
  default:
2026
2026
  return val;
2027
2027
  }
@@ -2858,16 +2858,16 @@ class MagicDirective {
2858
2858
  this.eventHandlers = {};
2859
2859
  this.eventsOnlyVal = false;
2860
2860
  this.htmlElement = this.element.nativeElement;
2861
- if (!(typeof magicRow === 'undefined' || magicRow === null))
2861
+ if (!(typeof magicRow === "undefined" || magicRow === null))
2862
2862
  this.rowId = magicRow.rowId;
2863
2863
  }
2864
2864
  set magic(val) {
2865
2865
  this.id = val;
2866
- this.selector = 'magic';
2866
+ this.selector = "magic";
2867
2867
  }
2868
2868
  ;
2869
2869
  set eventsOnly(val) {
2870
- console.log('eventsOnly');
2870
+ console.log("eventsOnly");
2871
2871
  this.eventsOnlyVal = true;
2872
2872
  }
2873
2873
  ;
@@ -2875,11 +2875,11 @@ class MagicDirective {
2875
2875
  return this._task;
2876
2876
  }
2877
2877
  regEvents() {
2878
- this.eventHandlers['focusin'] = this.OnFocus.bind(this);
2878
+ this.eventHandlers["focusin"] = this.OnFocus.bind(this);
2879
2879
  Object.keys(this.eventHandlers).forEach((key) => {
2880
2880
  this.focusUnlistener = this.renderer.listen(this.htmlElement, key, this.eventHandlers[key]);
2881
2881
  });
2882
- let events = ['click', 'mousedown', 'dblclick'];
2882
+ let events = ["click", "mousedown", "dblclick"];
2883
2883
  events.forEach(event => {
2884
2884
  this.renderer.listen(this.htmlElement, event, (e) => {
2885
2885
  let fromButton = false;
@@ -2890,15 +2890,15 @@ class MagicDirective {
2890
2890
  e.cancelBubble = true;
2891
2891
  });
2892
2892
  });
2893
- this.renderer.listen(this.htmlElement, 'change', (e) => {
2894
- let guiEvent = getGuiEventObj('selectionchanged', this.id, +this.rowId);
2893
+ this.renderer.listen(this.htmlElement, "change", (e) => {
2894
+ let guiEvent = getGuiEventObj("selectionchanged", this.id, +this.rowId);
2895
2895
  if ((event.target).selectedIndex !== undefined) {
2896
2896
  guiEvent.Value = (event.target).selectedIndex.toString();
2897
2897
  e.cancelBubble = true;
2898
2898
  this.task.insertEvent(guiEvent);
2899
2899
  }
2900
2900
  });
2901
- fromEvent(this.htmlElement, 'input').pipe(map((event) => {
2901
+ fromEvent(this.htmlElement, "input").pipe(map((event) => {
2902
2902
  return event.target.value;
2903
2903
  }), debounceTime(200)).subscribe((x) => {
2904
2904
  if (this.task.getProperty(this.id, HtmlProperties.BindingLevel, this.rowId) === BindingLevel.Character) {
@@ -2907,8 +2907,8 @@ class MagicDirective {
2907
2907
  this.task.mgAccessorService.setValueToControl(this.id, x, true);
2908
2908
  }
2909
2909
  });
2910
- this.renderer.listen(this.htmlElement, 'keydown', (e) => {
2911
- let guiEvent = getGuiEventObj('keydown', this.id, +this.rowId);
2910
+ this.renderer.listen(this.htmlElement, "keydown", (e) => {
2911
+ let guiEvent = getGuiEventObj("keydown", this.id, +this.rowId);
2912
2912
  guiEvent.modifiers = Modifiers.MODIFIER_NONE;
2913
2913
  if (e.altKey && e.keyCode !== GuiConstants.KEY_ALT)
2914
2914
  guiEvent.modifiers = Modifiers.MODIFIER_ALT;
@@ -2934,7 +2934,7 @@ class MagicDirective {
2934
2934
  });
2935
2935
  }
2936
2936
  OnFocus() {
2937
- this.task.insertEvent(getGuiEventObj('focus', this.id, +this.rowId));
2937
+ this.task.insertEvent(getGuiEventObj("focus", this.id, +this.rowId));
2938
2938
  event.cancelBubble = true;
2939
2939
  }
2940
2940
  IsSameElement(command) {
@@ -2954,7 +2954,7 @@ class MagicDirective {
2954
2954
  .subscribe(a => {
2955
2955
  let command = a;
2956
2956
  if (isNullOrUndefined(this.rowId))
2957
- this.rowId = '0';
2957
+ this.rowId = "0";
2958
2958
  try {
2959
2959
  if (!this.eventsOnlyVal)
2960
2960
  this.handleCommand(command);
@@ -2982,7 +2982,7 @@ class MagicDirective {
2982
2982
  this.focusUnlistener();
2983
2983
  if (!(command.obj.ConnectedControl && this.htmlElement instanceof HTMLButtonElement))
2984
2984
  this.htmlElement.focus();
2985
- this.focusUnlistener = this.renderer.listen(this.htmlElement, 'focusin', this.eventHandlers['focusin']);
2985
+ this.focusUnlistener = this.renderer.listen(this.htmlElement, "focusin", this.eventHandlers["focusin"]);
2986
2986
  break;
2987
2987
  }
2988
2988
  }
@@ -2992,13 +2992,13 @@ class MagicDirective {
2992
2992
  let methodName = command._str;
2993
2993
  let args = command.arguments;
2994
2994
  let magicComponent = (this.vcRef._hostLView).find(v => v instanceof TaskBaseMagicComponent);
2995
- let resultString = '';
2995
+ let resultString = "";
2996
2996
  try {
2997
2997
  if (!isNullOrUndefined(magicComponent[methodName])) {
2998
2998
  resultString = magicComponent[methodName].apply(magicComponent, args);
2999
2999
  }
3000
3000
  else
3001
- console.error('Instance method ' + methodName + ' does not exists');
3001
+ console.error("Instance method " + methodName + " does not exists");
3002
3002
  }
3003
3003
  catch (e) {
3004
3004
  console.error(e.message);
@@ -3010,10 +3010,13 @@ class MagicDirective {
3010
3010
  handleSetProperty(command) {
3011
3011
  switch (command.Operation) {
3012
3012
  case HtmlProperties.ReadOnly:
3013
- if (command.obj1 != true)
3014
- this.renderer.removeAttribute(this.htmlElement, command.Operation);
3015
- else
3016
- this.renderer.setAttribute(this.htmlElement, command.Operation, command.str);
3013
+ {
3014
+ if (command.obj.Type == MgControlType.CTRL_TYPE_TEXT)
3015
+ if (command.obj1 != true)
3016
+ this.renderer.removeAttribute(this.htmlElement, command.Operation);
3017
+ else
3018
+ this.renderer.setAttribute(this.htmlElement, command.Operation, command.str);
3019
+ }
3017
3020
  break;
3018
3021
  }
3019
3022
  }
@@ -3029,7 +3032,7 @@ MagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MagicDirective, selectors:
3029
3032
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MagicDirective, [{
3030
3033
  type: Directive,
3031
3034
  args: [{
3032
- selector: '[magic]'
3035
+ selector: "[magic]"
3033
3036
  }]
3034
3037
  }], function () {
3035
3038
  return [{ type: TaskMagicService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: RowMagicDirective, decorators: [{
@@ -3037,10 +3040,10 @@ MagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MagicDirective, selectors:
3037
3040
  }] }];
3038
3041
  }, { magic: [{
3039
3042
  type: Input,
3040
- args: ['magic']
3043
+ args: ["magic"]
3041
3044
  }], eventsOnly: [{
3042
3045
  type: Input,
3043
- args: ['eventsOnly']
3046
+ args: ["eventsOnly"]
3044
3047
  }], rowId: [{
3045
3048
  type: Input
3046
3049
  }] });
@@ -3345,6 +3348,25 @@ class MgformatMagicDirective {
3345
3348
  }
3346
3349
  }
3347
3350
  onFocusEvent($event) {
3351
+ this.calculatePattern();
3352
+ }
3353
+ onInputEvent($event) {
3354
+ this.calculatePattern();
3355
+ }
3356
+ onChangeEvent($event) {
3357
+ let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
3358
+ let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
3359
+ switch (attr) {
3360
+ case StorageAttribute.ALPHA:
3361
+ case StorageAttribute.UNICODE:
3362
+ this.formatAlphaUnicode(control);
3363
+ break;
3364
+ case StorageAttribute.BOOLEAN:
3365
+ this.formatBoolean(control);
3366
+ break;
3367
+ }
3368
+ }
3369
+ calculatePattern() {
3348
3370
  let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
3349
3371
  if (control != null) {
3350
3372
  let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
@@ -3359,28 +3381,13 @@ class MgformatMagicDirective {
3359
3381
  }
3360
3382
  else {
3361
3383
  if (attr == StorageAttribute.ALPHA || attr == StorageAttribute.UNICODE) {
3362
- if (control.validator == null)
3363
- control.setValidators(Validators.maxLength(pic.getMaskLength()));
3364
- else
3365
- control.setValidators([control.validator, Validators.maxLength(pic.getMaskLength())]);
3384
+ control.setValidators(Validators.maxLength(pic.getMaskLength()));
3385
+ control.updateValueAndValidity();
3366
3386
  }
3367
3387
  }
3368
3388
  }
3369
3389
  }
3370
3390
  }
3371
- onChangeEvent($event) {
3372
- let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
3373
- let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
3374
- switch (attr) {
3375
- case StorageAttribute.ALPHA:
3376
- case StorageAttribute.UNICODE:
3377
- this.formatAlphaUnicode(control);
3378
- break;
3379
- case StorageAttribute.BOOLEAN:
3380
- this.formatBoolean(control);
3381
- break;
3382
- }
3383
- }
3384
3391
  formatDate(pic) {
3385
3392
  let mgDateFormatter = new MgDateFormatter();
3386
3393
  this._task.mgInputDateFormat = mgDateFormatter.ConvertMgDateFormatToAngular(pic.getMask());
@@ -3530,7 +3537,7 @@ class MgformatMagicDirective {
3530
3537
  MgformatMagicDirective.ɵfac = function MgformatMagicDirective_Factory(t) { return new (t || MgformatMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(TaskMagicService)); };
3531
3538
  MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirective, selectors: [["", "mgFormat", ""]], hostBindings: function MgformatMagicDirective_HostBindings(rf, ctx) {
3532
3539
  if (rf & 1) {
3533
- i0.ɵɵlistener("focus", function MgformatMagicDirective_focus_HostBindingHandler($event) { return ctx.onFocusEvent($event); })("change", function MgformatMagicDirective_change_HostBindingHandler($event) { return ctx.onChangeEvent($event); });
3540
+ i0.ɵɵlistener("focus", function MgformatMagicDirective_focus_HostBindingHandler($event) { return ctx.onFocusEvent($event); })("input", function MgformatMagicDirective_input_HostBindingHandler($event) { return ctx.onInputEvent($event); })("change", function MgformatMagicDirective_change_HostBindingHandler($event) { return ctx.onChangeEvent($event); });
3534
3541
  }
3535
3542
  } });
3536
3543
  (function () {
@@ -3542,6 +3549,9 @@ MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirec
3542
3549
  }], function () { return [{ type: MagicDirective }, { type: TaskMagicService }]; }, { onFocusEvent: [{
3543
3550
  type: HostListener,
3544
3551
  args: ['focus', ['$event']]
3552
+ }], onInputEvent: [{
3553
+ type: HostListener,
3554
+ args: ['input', ['$event']]
3545
3555
  }], onChangeEvent: [{
3546
3556
  type: HostListener,
3547
3557
  args: ['change', ['$event']]