@micropermit/client-angular 0.1.8 → 0.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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('@micropermit/client-angular', ['exports', '@angular/core', '@angular/common/http', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
4
- (global = global || self, factory((global.micropermit = global.micropermit || {}, global.micropermit['client-angular'] = {}), global.ng.core, global.ng.common.http, global.rxjs, global.rxjs.operators, global.ng.common));
5
- }(this, (function (exports, core, http, rxjs, operators, common) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/forms')) :
3
+ typeof define === 'function' && define.amd ? define('@micropermit/client-angular', ['exports', '@angular/core', '@angular/common/http', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/forms'], factory) :
4
+ (global = global || self, factory((global.micropermit = global.micropermit || {}, global.micropermit['client-angular'] = {}), global.ng.core, global.ng.common.http, global.rxjs, global.rxjs.operators, global.ng.common, global.ng.forms));
5
+ }(this, (function (exports, core, http, rxjs, operators, common, forms) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2438,6 +2438,152 @@
2438
2438
  CallState[CallState.SUCCESS] = 'SUCCESS';
2439
2439
  CallState[CallState.ERROR] = 'ERROR';
2440
2440
 
2441
+ /**
2442
+ * @fileoverview added by tsickle
2443
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2444
+ */
2445
+ var MicroLinkValidateDirective = /** @class */ (function () {
2446
+ function MicroLinkValidateDirective() {
2447
+ this.UNSET = "";
2448
+ this.microLinkValidateField = null;
2449
+ this.microLinkValidateValue = this.UNSET;
2450
+ this.microLinkValidateDebounce = 500;
2451
+ }
2452
+ /**
2453
+ * @param {?} control
2454
+ * @return {?}
2455
+ */
2456
+ MicroLinkValidateDirective.prototype.validate = /**
2457
+ * @param {?} control
2458
+ * @return {?}
2459
+ */
2460
+ function (control) {
2461
+ var _this = this;
2462
+ return rxjs.timer(this.microLinkValidateDebounce).pipe(operators.switchMap((/**
2463
+ * @return {?}
2464
+ */
2465
+ function () {
2466
+ /** @type {?} */
2467
+ var validateValue = _this.microLinkValidateValue;
2468
+ if (validateValue === _this.UNSET) {
2469
+ validateValue = control.value;
2470
+ }
2471
+ /** @type {?} */
2472
+ var obj = {};
2473
+ if (_this.microLinkValidateField) {
2474
+ obj[_this.microLinkValidateField] = validateValue;
2475
+ }
2476
+ else {
2477
+ obj = validateValue;
2478
+ }
2479
+ return _this.microLinkValidate.callWithObs(obj, null).pipe(operators.map((/**
2480
+ * @param {?} validationRes
2481
+ * @return {?}
2482
+ */
2483
+ function (validationRes) {
2484
+ /** @type {?} */
2485
+ var hasErrors = false;
2486
+ if (_this.microLinkValidateField) {
2487
+ if (validationRes[_this.microLinkValidateField] != null) {
2488
+ hasErrors = true;
2489
+ }
2490
+ }
2491
+ else {
2492
+ for (var key in validationRes) {
2493
+ if (validationRes[key] != null) {
2494
+ hasErrors = true;
2495
+ }
2496
+ }
2497
+ }
2498
+ if (hasErrors) {
2499
+ _this.result = validationRes;
2500
+ return {
2501
+ validateMicroLink: _this.result
2502
+ };
2503
+ }
2504
+ else {
2505
+ _this.result = null;
2506
+ return null;
2507
+ }
2508
+ })));
2509
+ })));
2510
+ };
2511
+ /**
2512
+ * @param {?} control
2513
+ * @return {?}
2514
+ */
2515
+ MicroLinkValidateDirective.prototype.getControlName = /**
2516
+ * @param {?} control
2517
+ * @return {?}
2518
+ */
2519
+ function (control) {
2520
+ /** @type {?} */
2521
+ var controlName = null;
2522
+ /** @type {?} */
2523
+ var parent = control.parent;
2524
+ // only such parent, which is FormGroup, has a dictionary
2525
+ // with control-names as a key and a form-control as a value
2526
+ if (parent instanceof forms.FormGroup) {
2527
+ // now we will iterate those keys (i.e. names of controls)
2528
+ Object.keys(parent.controls).forEach((/**
2529
+ * @param {?} name
2530
+ * @return {?}
2531
+ */
2532
+ function (name) {
2533
+ // and compare the passed control and
2534
+ // a child control of a parent - with provided name (we iterate them all)
2535
+ if (control === parent.controls[name]) {
2536
+ // both are same: control passed to Validator
2537
+ // and this child - are the same references
2538
+ controlName = name;
2539
+ }
2540
+ }));
2541
+ }
2542
+ // we either found a name or simply return null
2543
+ return controlName;
2544
+ };
2545
+ MicroLinkValidateDirective.decorators = [
2546
+ { type: core.Directive, args: [{
2547
+ selector: '[microLinkValidate]',
2548
+ providers: [
2549
+ {
2550
+ provide: forms.NG_ASYNC_VALIDATORS,
2551
+ useExisting: core.forwardRef((/**
2552
+ * @return {?}
2553
+ */
2554
+ function () { return MicroLinkValidateDirective; })),
2555
+ multi: true
2556
+ }
2557
+ ],
2558
+ exportAs: 'microValidator'
2559
+ },] }
2560
+ ];
2561
+ MicroLinkValidateDirective.propDecorators = {
2562
+ microLinkValidate: [{ type: core.Input }],
2563
+ microLinkValidateField: [{ type: core.Input }],
2564
+ microLinkValidateValue: [{ type: core.Input }],
2565
+ microLinkValidateDebounce: [{ type: core.Input }]
2566
+ };
2567
+ return MicroLinkValidateDirective;
2568
+ }());
2569
+ if (false) {
2570
+ /**
2571
+ * @type {?}
2572
+ * @private
2573
+ */
2574
+ MicroLinkValidateDirective.prototype.UNSET;
2575
+ /** @type {?} */
2576
+ MicroLinkValidateDirective.prototype.microLinkValidate;
2577
+ /** @type {?} */
2578
+ MicroLinkValidateDirective.prototype.microLinkValidateField;
2579
+ /** @type {?} */
2580
+ MicroLinkValidateDirective.prototype.microLinkValidateValue;
2581
+ /** @type {?} */
2582
+ MicroLinkValidateDirective.prototype.microLinkValidateDebounce;
2583
+ /** @type {?} */
2584
+ MicroLinkValidateDirective.prototype.result;
2585
+ }
2586
+
2441
2587
  /**
2442
2588
  * @fileoverview added by tsickle
2443
2589
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2473,14 +2619,16 @@
2473
2619
  LinkFieldDirective,
2474
2620
  CallLinkDirective,
2475
2621
  MicroClientLoadingIndicatorComponent,
2476
- MicroClientErrorIndicatorComponent
2622
+ MicroClientErrorIndicatorComponent,
2623
+ MicroLinkValidateDirective
2477
2624
  ],
2478
2625
  exports: [
2479
2626
  LinkFieldPipe,
2480
2627
  LinkFieldDirective,
2481
2628
  CallLinkDirective,
2482
2629
  MicroClientErrorIndicatorComponent,
2483
- MicroClientLoadingIndicatorComponent
2630
+ MicroClientLoadingIndicatorComponent,
2631
+ MicroLinkValidateDirective
2484
2632
  ]
2485
2633
  },] }
2486
2634
  ];
@@ -2708,7 +2856,7 @@
2708
2856
  function () {
2709
2857
  /** @type {?} */
2710
2858
  var lastRow = this.lastRow();
2711
- if (lastRow) {
2859
+ if (lastRow && lastRow.__meta) {
2712
2860
  this.loadedCompletely = lastRow.__meta.nextPage == null;
2713
2861
  }
2714
2862
  else {
@@ -2935,6 +3083,7 @@
2935
3083
  exports.MicroClientLoadingIndicatorComponent = MicroClientLoadingIndicatorComponent;
2936
3084
  exports.MicroClientModule = MicroClientModule;
2937
3085
  exports.MicroError = MicroError;
3086
+ exports.MicroLinkValidateDirective = MicroLinkValidateDirective;
2938
3087
  exports.MicroObject = MicroObject;
2939
3088
  exports.MicroObjectMetadata = MicroObjectMetadata;
2940
3089
  exports.MockLinkField = MockLinkField;