@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 { __decorate, __metadata } from 'tslib';
@@ -1961,7 +1961,7 @@ class TaskMagicService {
1961
1961
  return val;
1962
1962
  }
1963
1963
  case StorageAttribute.NUMERIC:
1964
- return (val === null) ? 0 : val;
1964
+ return val;
1965
1965
  default:
1966
1966
  return val;
1967
1967
  }
@@ -2778,16 +2778,16 @@ class MagicDirective {
2778
2778
  this.eventHandlers = {};
2779
2779
  this.eventsOnlyVal = false;
2780
2780
  this.htmlElement = this.element.nativeElement;
2781
- if (!(typeof magicRow === 'undefined' || magicRow === null))
2781
+ if (!(typeof magicRow === "undefined" || magicRow === null))
2782
2782
  this.rowId = magicRow.rowId;
2783
2783
  }
2784
2784
  set magic(val) {
2785
2785
  this.id = val;
2786
- this.selector = 'magic';
2786
+ this.selector = "magic";
2787
2787
  }
2788
2788
  ;
2789
2789
  set eventsOnly(val) {
2790
- console.log('eventsOnly');
2790
+ console.log("eventsOnly");
2791
2791
  this.eventsOnlyVal = true;
2792
2792
  }
2793
2793
  ;
@@ -2795,11 +2795,11 @@ class MagicDirective {
2795
2795
  return this._task;
2796
2796
  }
2797
2797
  regEvents() {
2798
- this.eventHandlers['focusin'] = this.OnFocus.bind(this);
2798
+ this.eventHandlers["focusin"] = this.OnFocus.bind(this);
2799
2799
  Object.keys(this.eventHandlers).forEach((key) => {
2800
2800
  this.focusUnlistener = this.renderer.listen(this.htmlElement, key, this.eventHandlers[key]);
2801
2801
  });
2802
- let events = ['click', 'mousedown', 'dblclick'];
2802
+ let events = ["click", "mousedown", "dblclick"];
2803
2803
  events.forEach(event => {
2804
2804
  this.renderer.listen(this.htmlElement, event, (e) => {
2805
2805
  let fromButton = false;
@@ -2810,15 +2810,15 @@ class MagicDirective {
2810
2810
  e.cancelBubble = true;
2811
2811
  });
2812
2812
  });
2813
- this.renderer.listen(this.htmlElement, 'change', (e) => {
2814
- let guiEvent = getGuiEventObj('selectionchanged', this.id, +this.rowId);
2813
+ this.renderer.listen(this.htmlElement, "change", (e) => {
2814
+ let guiEvent = getGuiEventObj("selectionchanged", this.id, +this.rowId);
2815
2815
  if ((event.target).selectedIndex !== undefined) {
2816
2816
  guiEvent.Value = (event.target).selectedIndex.toString();
2817
2817
  e.cancelBubble = true;
2818
2818
  this.task.insertEvent(guiEvent);
2819
2819
  }
2820
2820
  });
2821
- fromEvent(this.htmlElement, 'input').pipe(map((event) => {
2821
+ fromEvent(this.htmlElement, "input").pipe(map((event) => {
2822
2822
  return event.target.value;
2823
2823
  }), debounceTime(200)).subscribe((x) => {
2824
2824
  if (this.task.getProperty(this.id, HtmlProperties.BindingLevel, this.rowId) === BindingLevel.Character) {
@@ -2827,8 +2827,8 @@ class MagicDirective {
2827
2827
  this.task.mgAccessorService.setValueToControl(this.id, x, true);
2828
2828
  }
2829
2829
  });
2830
- this.renderer.listen(this.htmlElement, 'keydown', (e) => {
2831
- let guiEvent = getGuiEventObj('keydown', this.id, +this.rowId);
2830
+ this.renderer.listen(this.htmlElement, "keydown", (e) => {
2831
+ let guiEvent = getGuiEventObj("keydown", this.id, +this.rowId);
2832
2832
  guiEvent.modifiers = Modifiers.MODIFIER_NONE;
2833
2833
  if (e.altKey && e.keyCode !== GuiConstants.KEY_ALT)
2834
2834
  guiEvent.modifiers = Modifiers.MODIFIER_ALT;
@@ -2854,7 +2854,7 @@ class MagicDirective {
2854
2854
  });
2855
2855
  }
2856
2856
  OnFocus() {
2857
- this.task.insertEvent(getGuiEventObj('focus', this.id, +this.rowId));
2857
+ this.task.insertEvent(getGuiEventObj("focus", this.id, +this.rowId));
2858
2858
  event.cancelBubble = true;
2859
2859
  }
2860
2860
  IsSameElement(command) {
@@ -2874,7 +2874,7 @@ class MagicDirective {
2874
2874
  .subscribe(a => {
2875
2875
  let command = a;
2876
2876
  if (isNullOrUndefined(this.rowId))
2877
- this.rowId = '0';
2877
+ this.rowId = "0";
2878
2878
  try {
2879
2879
  if (!this.eventsOnlyVal)
2880
2880
  this.handleCommand(command);
@@ -2902,7 +2902,7 @@ class MagicDirective {
2902
2902
  this.focusUnlistener();
2903
2903
  if (!(command.obj.ConnectedControl && this.htmlElement instanceof HTMLButtonElement))
2904
2904
  this.htmlElement.focus();
2905
- this.focusUnlistener = this.renderer.listen(this.htmlElement, 'focusin', this.eventHandlers['focusin']);
2905
+ this.focusUnlistener = this.renderer.listen(this.htmlElement, "focusin", this.eventHandlers["focusin"]);
2906
2906
  break;
2907
2907
  }
2908
2908
  }
@@ -2912,13 +2912,13 @@ class MagicDirective {
2912
2912
  let methodName = command._str;
2913
2913
  let args = command.arguments;
2914
2914
  let magicComponent = (this.vcRef._hostLView).find(v => v instanceof TaskBaseMagicComponent);
2915
- let resultString = '';
2915
+ let resultString = "";
2916
2916
  try {
2917
2917
  if (!isNullOrUndefined(magicComponent[methodName])) {
2918
2918
  resultString = magicComponent[methodName].apply(magicComponent, args);
2919
2919
  }
2920
2920
  else
2921
- console.error('Instance method ' + methodName + ' does not exists');
2921
+ console.error("Instance method " + methodName + " does not exists");
2922
2922
  }
2923
2923
  catch (e) {
2924
2924
  console.error(e.message);
@@ -2930,10 +2930,13 @@ class MagicDirective {
2930
2930
  handleSetProperty(command) {
2931
2931
  switch (command.Operation) {
2932
2932
  case HtmlProperties.ReadOnly:
2933
- if (command.obj1 != true)
2934
- this.renderer.removeAttribute(this.htmlElement, command.Operation);
2935
- else
2936
- this.renderer.setAttribute(this.htmlElement, command.Operation, command.str);
2933
+ {
2934
+ if (command.obj.Type == MgControlType.CTRL_TYPE_TEXT)
2935
+ if (command.obj1 != true)
2936
+ this.renderer.removeAttribute(this.htmlElement, command.Operation);
2937
+ else
2938
+ this.renderer.setAttribute(this.htmlElement, command.Operation, command.str);
2939
+ }
2937
2940
  break;
2938
2941
  }
2939
2942
  }
@@ -2948,16 +2951,16 @@ MagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MagicDirective, selectors:
2948
2951
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MagicDirective, [{
2949
2952
  type: Directive,
2950
2953
  args: [{
2951
- selector: '[magic]'
2954
+ selector: "[magic]"
2952
2955
  }]
2953
2956
  }], function () { return [{ type: TaskMagicService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: RowMagicDirective, decorators: [{
2954
2957
  type: Optional
2955
2958
  }] }]; }, { magic: [{
2956
2959
  type: Input,
2957
- args: ['magic']
2960
+ args: ["magic"]
2958
2961
  }], eventsOnly: [{
2959
2962
  type: Input,
2960
- args: ['eventsOnly']
2963
+ args: ["eventsOnly"]
2961
2964
  }], rowId: [{
2962
2965
  type: Input
2963
2966
  }] }); })();
@@ -3255,6 +3258,25 @@ class MgformatMagicDirective {
3255
3258
  }
3256
3259
  }
3257
3260
  onFocusEvent($event) {
3261
+ this.calculatePattern();
3262
+ }
3263
+ onInputEvent($event) {
3264
+ this.calculatePattern();
3265
+ }
3266
+ onChangeEvent($event) {
3267
+ let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
3268
+ let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
3269
+ switch (attr) {
3270
+ case StorageAttribute.ALPHA:
3271
+ case StorageAttribute.UNICODE:
3272
+ this.formatAlphaUnicode(control);
3273
+ break;
3274
+ case StorageAttribute.BOOLEAN:
3275
+ this.formatBoolean(control);
3276
+ break;
3277
+ }
3278
+ }
3279
+ calculatePattern() {
3258
3280
  let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
3259
3281
  if (control != null) {
3260
3282
  let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
@@ -3269,28 +3291,13 @@ class MgformatMagicDirective {
3269
3291
  }
3270
3292
  else {
3271
3293
  if (attr == StorageAttribute.ALPHA || attr == StorageAttribute.UNICODE) {
3272
- if (control.validator == null)
3273
- control.setValidators(Validators.maxLength(pic.getMaskLength()));
3274
- else
3275
- control.setValidators([control.validator, Validators.maxLength(pic.getMaskLength())]);
3294
+ control.setValidators(Validators.maxLength(pic.getMaskLength()));
3295
+ control.updateValueAndValidity();
3276
3296
  }
3277
3297
  }
3278
3298
  }
3279
3299
  }
3280
3300
  }
3281
- onChangeEvent($event) {
3282
- let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
3283
- let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
3284
- switch (attr) {
3285
- case StorageAttribute.ALPHA:
3286
- case StorageAttribute.UNICODE:
3287
- this.formatAlphaUnicode(control);
3288
- break;
3289
- case StorageAttribute.BOOLEAN:
3290
- this.formatBoolean(control);
3291
- break;
3292
- }
3293
- }
3294
3301
  formatDate(pic) {
3295
3302
  let mgDateFormatter = new MgDateFormatter();
3296
3303
  this._task.mgInputDateFormat = mgDateFormatter.ConvertMgDateFormatToAngular(pic.getMask());
@@ -3439,7 +3446,7 @@ class MgformatMagicDirective {
3439
3446
  }
3440
3447
  MgformatMagicDirective.ɵfac = function MgformatMagicDirective_Factory(t) { return new (t || MgformatMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(TaskMagicService)); };
3441
3448
  MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirective, selectors: [["", "mgFormat", ""]], hostBindings: function MgformatMagicDirective_HostBindings(rf, ctx) { if (rf & 1) {
3442
- i0.ɵɵlistener("focus", function MgformatMagicDirective_focus_HostBindingHandler($event) { return ctx.onFocusEvent($event); })("change", function MgformatMagicDirective_change_HostBindingHandler($event) { return ctx.onChangeEvent($event); });
3449
+ 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); });
3443
3450
  } } });
3444
3451
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MgformatMagicDirective, [{
3445
3452
  type: Directive,
@@ -3449,6 +3456,9 @@ MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirec
3449
3456
  }], function () { return [{ type: MagicDirective }, { type: TaskMagicService }]; }, { onFocusEvent: [{
3450
3457
  type: HostListener,
3451
3458
  args: ['focus', ['$event']]
3459
+ }], onInputEvent: [{
3460
+ type: HostListener,
3461
+ args: ['input', ['$event']]
3452
3462
  }], onChangeEvent: [{
3453
3463
  type: HostListener,
3454
3464
  args: ['change', ['$event']]