@magic-xpa/angular 4.900.0-dev490.13 → 4.900.0-dev490.132

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';
@@ -270,8 +270,8 @@ class EngineMagicService {
270
270
  GetControlPictureMask(taskId, controlName) {
271
271
  return this.magicBridge.GetControlPictureMask(taskId, controlName);
272
272
  }
273
- GetFormattedValue(taskId, controlName, value) {
274
- return this.magicBridge.GetFormattedValue(taskId, controlName, value);
273
+ GetFormattedValue(taskId, controlName, value, rowId) {
274
+ return this.magicBridge.GetFormattedValue(taskId, controlName, value, rowId);
275
275
  }
276
276
  ValidateControlValue(taskId, controlName, value) {
277
277
  return this.magicBridge.ValidateControlValue(taskId, controlName, value);
@@ -1752,8 +1752,8 @@ class TaskMagicService {
1752
1752
  guiRowId = '0';
1753
1753
  return this.Records.list.length > +guiRowId ? this.Records.list[guiRowId].values[controlId] : '';
1754
1754
  }
1755
- getFormattedValue(controlName, val) {
1756
- return this.magic.GetFormattedValue(this.taskId, controlName, val);
1755
+ getFormattedValue(controlName, val, rowId) {
1756
+ return this.magic.GetFormattedValue(this.taskId, controlName, val, rowId);
1757
1757
  }
1758
1758
  setValue(controlId, guiRowId, value) {
1759
1759
  return this.Records.list[guiRowId].setValue(controlId, value);
@@ -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
  }
@@ -2439,7 +2439,7 @@ class AccessorMagicService {
2439
2439
  }
2440
2440
  getFormattedValue(controlId, rowId) {
2441
2441
  let val = this.task.getValue(controlId, rowId);
2442
- val = this.task.getFormattedValue(controlId, val);
2442
+ val = this.task.getFormattedValue(controlId, val, rowId);
2443
2443
  return val;
2444
2444
  }
2445
2445
  getPicture(controlId, rowId) {
@@ -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;
@@ -3271,26 +3293,18 @@ class MgformatMagicDirective {
3271
3293
  if (attr == StorageAttribute.ALPHA || attr == StorageAttribute.UNICODE) {
3272
3294
  if (control.validator == null)
3273
3295
  control.setValidators(Validators.maxLength(pic.getMaskLength()));
3274
- else
3275
- control.setValidators([control.validator, Validators.maxLength(pic.getMaskLength())]);
3296
+ else {
3297
+ control.setValidators(Validators.maxLength(pic.getMaskLength()));
3298
+ if (isUndefined(this.magicDir.rowId))
3299
+ this.magicDir.rowId = '0';
3300
+ control.setValidators([control.validator, this._task.customValidator(this.magicDir.rowId, this.magicDir.id)]);
3301
+ }
3302
+ control.updateValueAndValidity();
3276
3303
  }
3277
3304
  }
3278
3305
  }
3279
3306
  }
3280
3307
  }
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
3308
  formatDate(pic) {
3295
3309
  let mgDateFormatter = new MgDateFormatter();
3296
3310
  this._task.mgInputDateFormat = mgDateFormatter.ConvertMgDateFormatToAngular(pic.getMask());
@@ -3439,7 +3453,7 @@ class MgformatMagicDirective {
3439
3453
  }
3440
3454
  MgformatMagicDirective.ɵfac = function MgformatMagicDirective_Factory(t) { return new (t || MgformatMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(TaskMagicService)); };
3441
3455
  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); });
3456
+ 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
3457
  } } });
3444
3458
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MgformatMagicDirective, [{
3445
3459
  type: Directive,
@@ -3449,6 +3463,9 @@ MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirec
3449
3463
  }], function () { return [{ type: MagicDirective }, { type: TaskMagicService }]; }, { onFocusEvent: [{
3450
3464
  type: HostListener,
3451
3465
  args: ['focus', ['$event']]
3466
+ }], onInputEvent: [{
3467
+ type: HostListener,
3468
+ args: ['input', ['$event']]
3452
3469
  }], onChangeEvent: [{
3453
3470
  type: HostListener,
3454
3471
  args: ['change', ['$event']]