@unnilouis.org/vs-chipdropdown 9.0.3 → 9.0.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.
@@ -296,11 +296,18 @@
296
296
  this.has_previous = false;
297
297
  this.chipSelectedId = [];
298
298
  this.chipSelectedObj = [];
299
+ this.Outputdata = [];
300
+ this.formkeyarr = [];
299
301
  }
300
302
  VsChipddCmpComponent.prototype.ngOnInit = function () {
301
- this.DropdownForm = this.fb.group({
302
- value: ''
303
- });
303
+ // if (this.formGroup) {
304
+ // this.DropdownForm = this.formGroup;
305
+ // } else {
306
+ // this.DropdownForm = this.fb.group({
307
+ // value: '',
308
+ // });
309
+ // }
310
+ // this.dupngonit();
304
311
  // if (this.InputFields?.defaultvalue) {
305
312
  // this.DropdownForm.get("value").patchValue(this.InputFields?.defaultvalue)
306
313
  // this.chipSelectedObj = this.InputFields?.defaultvalue
@@ -323,39 +330,79 @@
323
330
  // this.getdropdown('')
324
331
  // }
325
332
  };
326
- VsChipddCmpComponent.prototype.dupngonit = function () {
333
+ VsChipddCmpComponent.prototype.looop = function () {
327
334
  var e_1, _a;
328
- var _b, _c, _d, _e, _f, _g, _h;
329
- this.DropdownForm = this.fb.group({
330
- value: ''
331
- });
332
- if ((_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.defaultvalue) {
333
- this.DropdownForm.get("value").patchValue((_c = this.InputFields) === null || _c === void 0 ? void 0 : _c.defaultvalue);
334
- this.chipSelectedObj = (_d = this.InputFields) === null || _d === void 0 ? void 0 : _d.defaultvalue;
335
- if (this.chipSelectedObj.length > 0) {
336
- try {
337
- for (var _j = __values(this.chipSelectedObj), _k = _j.next(); !_k.done; _k = _j.next()) {
338
- var foundemp = _k.value;
339
- if ((_e = this.InputFields) === null || _e === void 0 ? void 0 : _e.Outputkey) {
340
- this.chipSelectedId.push(foundemp[(_f = this.InputFields) === null || _f === void 0 ? void 0 : _f.Outputkey]);
341
- }
342
- else {
343
- this.chipSelectedId.push(foundemp.id);
344
- }
335
+ var _b, _c, _d, _e;
336
+ try {
337
+ for (var _f = __values(this.chipSelectedObj), _g = _f.next(); !_g.done; _g = _f.next()) {
338
+ var foundemp = _g.value;
339
+ if (!(foundemp instanceof Number)) {
340
+ if ((_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.Outputkey) {
341
+ this.chipSelectedId.push(foundemp[(_c = this.InputFields) === null || _c === void 0 ? void 0 : _c.Outputkey]);
345
342
  }
346
- }
347
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
348
- finally {
349
- try {
350
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
343
+ if ((_d = this.InputFields) === null || _d === void 0 ? void 0 : _d.formkey) {
344
+ this.formkeyarr.push(foundemp[(_e = this.InputFields) === null || _e === void 0 ? void 0 : _e.formkey]);
345
+ }
346
+ else {
347
+ this.chipSelectedId.push(foundemp.id);
351
348
  }
352
- finally { if (e_1) throw e_1.error; }
353
349
  }
350
+ }
351
+ }
352
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
353
+ finally {
354
+ try {
355
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
356
+ }
357
+ finally { if (e_1) throw e_1.error; }
358
+ }
359
+ };
360
+ VsChipddCmpComponent.prototype.dupngonit = function () {
361
+ var _a, _b, _c, _d, _e, _f;
362
+ if (this.formGroup) {
363
+ this.DropdownForm = this.formGroup;
364
+ if (!this.DropdownForm.contains((_a = this.InputFields) === null || _a === void 0 ? void 0 : _a.formcontrolname)) {
365
+ this.DropdownForm.addControl(this.dynamciformcontrolparent(), new forms.FormControl({ value: [], disabled: (_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.disabled }));
366
+ }
367
+ }
368
+ else {
369
+ this.DropdownForm = this.fb.group({
370
+ chipvalue: [],
371
+ });
372
+ }
373
+ console.log('this.DropdownForm', this.DropdownForm.value);
374
+ // this.chipSelectedObj =
375
+ // this.DropdownForm.get(this.dynamciformcontrolparent()).value &&
376
+ // this.DropdownForm.get(this.dynamciformcontrolparent()).value.length !== 0
377
+ // ? this.DropdownForm.get(this.dynamciformcontrolparent()).value
378
+ // : [];
379
+ // console.log('this.chipSelectedObj', this.chipSelectedObj);
380
+ if ((_c = this.InputFields) === null || _c === void 0 ? void 0 : _c.defaultvalue) {
381
+ // this.DropdownForm.get(this.dynamciformcontrolparent()).patchValue(
382
+ // this.InputFields?.formkey
383
+ // ? this.InputFields?.defaultvalue[this.InputFields?.formkey]
384
+ // : this.InputFields?.defaultvalue
385
+ // );
386
+ // this.DropdownForm.get(this.dynamciformcontrolparent()).patchValue(this.InputFields?.defaultvalue);
387
+ this.chipSelectedObj = (_d = this.InputFields) === null || _d === void 0 ? void 0 : _d.defaultvalue;
388
+ this.chipSelectedId = [];
389
+ this.formkeyarr = [];
390
+ if (this.chipSelectedObj.length > 0) {
391
+ this.looop();
354
392
  this.selected();
355
393
  }
356
394
  }
357
- if ((_g = this.InputFields) === null || _g === void 0 ? void 0 : _g.fronentdata) {
358
- this.Dropdowndata = (_h = this.InputFields) === null || _h === void 0 ? void 0 : _h.data;
395
+ if (this.DropdownForm.get(this.dynamciformcontrolparent()).value &&
396
+ this.DropdownForm.get(this.dynamciformcontrolparent()).value.length !== 0) {
397
+ this.chipSelectedObj = this.DropdownForm.get(this.dynamciformcontrolparent()).value;
398
+ console.log('test', this.chipSelectedObj = this.DropdownForm.get(this.dynamciformcontrolparent()).value);
399
+ this.chipSelectedId = [];
400
+ this.formkeyarr = [];
401
+ this.looop();
402
+ this.selected();
403
+ }
404
+ if ((_e = this.InputFields) === null || _e === void 0 ? void 0 : _e.fronentdata) {
405
+ this.Dropdowndata = (_f = this.InputFields) === null || _f === void 0 ? void 0 : _f.data;
359
406
  }
360
407
  // else {
361
408
  // this.getdropdown('')
@@ -363,16 +410,17 @@
363
410
  };
364
411
  VsChipddCmpComponent.prototype.ngOnChanges = function (changes) {
365
412
  if (changes.InputFields && changes.InputFields.currentValue) {
366
- console.log("Summary Log Changes");
413
+ console.log('Summary Log Changes');
367
414
  this.currentpage = 1;
368
415
  this.dupngonit();
369
416
  }
370
417
  if (changes.ResetForm && changes.ResetForm.currentValue) {
371
- console.log("hitted");
372
- this.DropdownForm.reset();
418
+ console.log('hitted');
419
+ // this.DropdownForm.reset();
373
420
  this.currentpage = 1;
374
421
  this.dupngonit();
375
422
  this.chipSelectedId = [];
423
+ this.formkeyarr = [];
376
424
  this.chipSelectedObj = [];
377
425
  this.dataEvent.emit([]);
378
426
  }
@@ -401,12 +449,13 @@
401
449
  var params = _this.searchparams(value);
402
450
  _this.currentpage = _this.currentpage + 1;
403
451
  if (_this.currentpage > 1) {
404
- _this.service.GetApi(_this.InputFields.url + "?page=" + _this.currentpage, params)
452
+ _this.service
453
+ .GetApi(_this.InputFields.url + '?page=' + _this.currentpage, params)
405
454
  .subscribe(function (results) {
406
- var datas = results["data"];
407
- var datapagination = results["pagination"];
455
+ var datas = results['data'];
456
+ var datapagination = results['pagination'];
408
457
  _this.Dropdowndata = _this.Dropdowndata.concat(datas);
409
- console.log("this.Dropdowndata", _this.Dropdowndata);
458
+ console.log('this.Dropdowndata', _this.Dropdowndata);
410
459
  if (_this.Dropdowndata.length >= 0) {
411
460
  _this.has_next = datapagination.has_next;
412
461
  _this.has_previous = datapagination.has_previous;
@@ -425,30 +474,39 @@
425
474
  var _this = this;
426
475
  var _a;
427
476
  if (!((_a = this.InputFields) === null || _a === void 0 ? void 0 : _a.fronentdata)) {
428
- this.DropdownForm.get("value").valueChanges.pipe(operators.debounceTime(100), operators.distinctUntilChanged(), operators.tap(function () {
477
+ this.DropdownForm.get('value')
478
+ .valueChanges.pipe(operators.debounceTime(100), operators.distinctUntilChanged(), operators.tap(function () {
429
479
  _this.DrodownLoading = true;
430
- console.log("inside tap");
480
+ console.log('inside tap');
431
481
  }), operators.switchMap(function (value) {
432
482
  var params = _this.searchparams(value);
433
483
  _this.currentpage = 1;
434
- return _this.service.GetApi(_this.InputFields.url + "?page=" + _this.currentpage, params).pipe(operators.finalize(function () {
484
+ return _this.service
485
+ .GetApi(_this.InputFields.url + '?page=' + _this.currentpage, params)
486
+ .pipe(operators.finalize(function () {
435
487
  _this.DrodownLoading = false;
436
488
  }));
437
- })).subscribe(function (results) {
438
- var datas = results["data"];
489
+ }))
490
+ .subscribe(function (results) {
491
+ var datas = results['data'];
439
492
  _this.Dropdowndata = datas;
440
493
  });
441
494
  }
442
495
  };
443
496
  VsChipddCmpComponent.prototype.getdropdown = function (value) {
444
497
  var _this = this;
498
+ this.currentpage = 1;
445
499
  if (this.InputFields.url) {
446
500
  var params = this.searchparams(value);
447
- this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params)
501
+ this.service
502
+ .GetApi(this.InputFields.url + '?page=' + this.currentpage, params)
448
503
  .subscribe(function (results) {
449
- var datas = results["data"];
450
- var datapagination = results["pagination"];
504
+ var datas = results['data'];
505
+ var datapagination = results['pagination'];
451
506
  _this.Dropdowndata = datas;
507
+ setTimeout(function () {
508
+ _this.trigger.openPanel();
509
+ }, 0);
452
510
  if (_this.Dropdowndata.length >= 0) {
453
511
  _this.has_next = datapagination.has_next;
454
512
  _this.has_previous = datapagination.has_previous;
@@ -457,29 +515,50 @@
457
515
  });
458
516
  }
459
517
  };
518
+ VsChipddCmpComponent.prototype.dynamciformcontrolparent = function () {
519
+ var _a, _b;
520
+ return ((_a = this.InputFields) === null || _a === void 0 ? void 0 : _a.formcontrolname) && this.formGroup
521
+ ? (_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.formcontrolname : 'chipvalue';
522
+ };
460
523
  VsChipddCmpComponent.prototype.selected = function () {
461
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
462
- // let data = this.DropdownForm.value.value
463
- if ((_a = this.InputFields) === null || _a === void 0 ? void 0 : _a.wholedata) {
464
- this.dataEvent.emit(this.chipSelectedObj);
465
- if (((_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.formgroup) && ((_c = this.InputFields) === null || _c === void 0 ? void 0 : _c.formcontrolname)) {
466
- (_d = this.InputFields) === null || _d === void 0 ? void 0 : _d.formgroup.get((_e = this.InputFields) === null || _e === void 0 ? void 0 : _e.formcontrolname).patchValue(this.chipSelectedObj);
467
- }
524
+ var _a, _b;
525
+ this.Outputdata = this.chipSelectedObj;
526
+ if ((_a = this.InputFields) === null || _a === void 0 ? void 0 : _a.Outputkey) {
527
+ this.Outputdata = this.chipSelectedId;
468
528
  }
469
- else {
470
- if ((_f = this.InputFields) === null || _f === void 0 ? void 0 : _f.Outputkey) {
471
- this.dataEvent.emit(this.chipSelectedId);
472
- if (((_g = this.InputFields) === null || _g === void 0 ? void 0 : _g.formgroup) && ((_h = this.InputFields) === null || _h === void 0 ? void 0 : _h.formcontrolname)) {
473
- (_j = this.InputFields) === null || _j === void 0 ? void 0 : _j.formgroup.get((_k = this.InputFields) === null || _k === void 0 ? void 0 : _k.formcontrolname).patchValue(this.chipSelectedId);
474
- }
475
- }
476
- else {
477
- this.dataEvent.emit(this.chipSelectedObj);
478
- if (((_l = this.InputFields) === null || _l === void 0 ? void 0 : _l.formgroup) && ((_m = this.InputFields) === null || _m === void 0 ? void 0 : _m.formcontrolname)) {
479
- (_o = this.InputFields) === null || _o === void 0 ? void 0 : _o.formgroup.get((_p = this.InputFields) === null || _p === void 0 ? void 0 : _p.formcontrolname).patchValue(this.chipSelectedObj);
480
- }
481
- }
529
+ if (this.formGroup && ((_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.formcontrolname)) {
530
+ this.DropdownForm.get(this.dynamciformcontrolparent()).patchValue(this.formkeyarr);
482
531
  }
532
+ console.log(this.formkeyarr);
533
+ console.log('this.DropdownForm.get', this.DropdownForm.value);
534
+ this.dataEvent.emit(this.Outputdata);
535
+ // let data = this.DropdownForm.value.value
536
+ // if (this.InputFields?.wholedata) {
537
+ // this.dataEvent.emit(this.chipSelectedObj);
538
+ // if (this.InputFields?.formgroup && this.InputFields?.formcontrolname) {
539
+ // this.InputFields?.formgroup
540
+ // .get(this.InputFields?.formcontrolname)
541
+ // .patchValue(this.chipSelectedObj);
542
+ // }
543
+ // }
544
+ // else {
545
+ // if (this.InputFields?.Outputkey) {
546
+ // this.dataEvent.emit(this.chipSelectedId);
547
+ // if (this.InputFields?.formgroup && this.InputFields?.formcontrolname) {
548
+ // this.InputFields?.formgroup
549
+ // .get(this.InputFields?.formcontrolname)
550
+ // .patchValue(this.chipSelectedId);
551
+ // }
552
+ // }
553
+ // else {
554
+ // this.dataEvent.emit(this.chipSelectedObj);
555
+ // if (this.InputFields?.formgroup && this.InputFields?.formcontrolname) {
556
+ // this.InputFields?.formgroup
557
+ // .get(this.InputFields?.formcontrolname)
558
+ // .patchValue(this.chipSelectedObj);
559
+ // }
560
+ // }
561
+ // }
483
562
  };
484
563
  VsChipddCmpComponent.prototype.searchparams = function (value) {
485
564
  var params = '';
@@ -487,7 +566,9 @@
487
566
  params = this.InputFields.params;
488
567
  }
489
568
  var inpValue = value;
490
- inpValue ? params += '&' + this.InputFields.searchkey + '=' + inpValue : '';
569
+ inpValue
570
+ ? (params += '&' + this.InputFields.searchkey + '=' + inpValue)
571
+ : '';
491
572
  return params;
492
573
  };
493
574
  VsChipddCmpComponent.prototype.removechip = function (obj) {
@@ -497,19 +578,21 @@
497
578
  console.log(this.chipSelectedObj);
498
579
  this.chipSelectedId.splice(index, 1);
499
580
  console.log(this.chipSelectedId);
581
+ this.formkeyarr.splice(index, 1);
582
+ console.log('this.formkeyarr', this.formkeyarr);
500
583
  this.DropInput.nativeElement.value = '';
501
584
  this.selected();
502
585
  }
503
586
  };
504
- VsChipddCmpComponent.prototype.venSelected = function (event) {
587
+ VsChipddCmpComponent.prototype.venSelected = function (data) {
505
588
  this.DropInput.nativeElement.value = '';
506
- console.log('event.option.value', event.option.value);
507
- this.selectvenByName(event.option.value[this.comparekey(event.option.value)]);
589
+ console.log('event.option.value', data);
590
+ this.selectvenByName(data[this.comparekey(data)]);
508
591
  console.log('chipSelectedvenid', this.chipSelectedObj);
509
592
  };
510
593
  VsChipddCmpComponent.prototype.selectvenByName = function (ven) {
511
594
  var _this = this;
512
- var _a, _b;
595
+ var _a, _b, _c, _d;
513
596
  var foundemp1 = this.chipSelectedObj.filter(function (e) { return e[_this.comparekey(e)] == ven; });
514
597
  if (foundemp1.length) {
515
598
  return;
@@ -520,9 +603,14 @@
520
603
  if ((_a = this.InputFields) === null || _a === void 0 ? void 0 : _a.Outputkey) {
521
604
  this.chipSelectedId.push(foundemp[0][(_b = this.InputFields) === null || _b === void 0 ? void 0 : _b.Outputkey]);
522
605
  }
606
+ if ((_c = this.InputFields) === null || _c === void 0 ? void 0 : _c.formkey) {
607
+ this.formkeyarr.push(foundemp[0][(_d = this.InputFields) === null || _d === void 0 ? void 0 : _d.formkey]);
608
+ }
523
609
  else {
524
610
  this.chipSelectedId.push(foundemp[0].id);
525
611
  }
612
+ console.log('formkeyarr12', this.formkeyarr);
613
+ this.selected();
526
614
  }
527
615
  };
528
616
  VsChipddCmpComponent.prototype.comparekey = function (e) {
@@ -532,7 +620,7 @@
532
620
  }
533
621
  else {
534
622
  if (e === null || e === void 0 ? void 0 : e.id) {
535
- return "id";
623
+ return 'id';
536
624
  }
537
625
  else {
538
626
  return this.InputFields.displaykey;
@@ -552,6 +640,12 @@
552
640
  __decorate([
553
641
  core.Input()
554
642
  ], VsChipddCmpComponent.prototype, "Backendapi", void 0);
643
+ __decorate([
644
+ core.ViewChild('autoCompleteInput', {
645
+ static: false,
646
+ read: autocomplete.MatAutocompleteTrigger,
647
+ })
648
+ ], VsChipddCmpComponent.prototype, "trigger", void 0);
555
649
  __decorate([
556
650
  core.ViewChild(autocomplete.MatAutocompleteTrigger)
557
651
  ], VsChipddCmpComponent.prototype, "autocompleteTrigger", void 0);
@@ -564,10 +658,13 @@
564
658
  __decorate([
565
659
  core.ViewChild('DropInput')
566
660
  ], VsChipddCmpComponent.prototype, "DropInput", void 0);
661
+ __decorate([
662
+ core.Input()
663
+ ], VsChipddCmpComponent.prototype, "formGroup", void 0);
567
664
  VsChipddCmpComponent = __decorate([
568
665
  core.Component({
569
666
  selector: 'lib-vs-chipdd-cmp',
570
- template: "<div (click)=\"!this.InputFields?.fronentdata ? this.getdropdown(''):'' \">\r\n <form [formGroup]=\"DropdownForm\">\r\n <mat-form-field class=\"mat-chipScroll\"\r\n appearance=\"outline\">\r\n <mat-label>{{InputFields?.label | translate}}</mat-label>\r\n <mat-chip-list multiple #chipListvendor class=\"chip-container\">\r\n <mat-chip *ngFor=\"let obj of chipSelectedObj\" [removable]=\"true\" (removed)=\"removechip(obj)\" class=\"mat-chipEx\">\r\n {{ obj[InputFields?.displaykey] }}\r\n <mat-icon matChipRemove>cancel</mat-icon>\r\n </mat-chip>\r\n <input #DropInput [matAutocomplete]=\"scrolll\" class=\"matformfieldinputstyle\"\r\n (keydown)=\"dropdownsearch()\" [matChipInputFor]=\"chipListvendor\" [matChipInputSeparatorKeyCodes]=\"\r\n separatorsKeysCodes\r\n \" [matChipInputAddOnBlur]=\"true\" formControlName=\"value\" />\r\n </mat-chip-list>\r\n <mat-autocomplete #scrolll=\"matAutocomplete\" (optionSelected)=\"venSelected($event)\"\r\n (opened)=\"autocompleteAppScroll()\">\r\n <ng-container>\r\n <mat-option *ngFor=\"let dropvalues of Dropdowndata\" [value]=\"dropvalues\" (click)=\"selected()\">\r\n {{dropvalues[InputFields?.displaykey]}}\r\n </mat-option>\r\n </ng-container>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </form>\r\n</div>\r\n",
667
+ template: "<div>\r\n <form [formGroup]=\"DropdownForm\">\r\n <mat-form-field\r\n class=\"mat-chipScroll\"\r\n appearance=\"outline\"\r\n (click)=\"!this.InputFields?.fronentdata ? this.getdropdown('') : ''\"\r\n >\r\n <mat-label>{{ InputFields?.label | translate }}</mat-label>\r\n <mat-chip-list multiple #chipListvendor class=\"chip-container\">\r\n <mat-chip\r\n *ngFor=\"let obj of chipSelectedObj\"\r\n [removable]=\"true\"\r\n (removed)=\"removechip(obj)\"\r\n class=\"mat-chipEx\"\r\n >\r\n {{ obj[InputFields?.displaykey] }}\r\n <mat-icon matChipRemove>cancel</mat-icon>\r\n </mat-chip>\r\n <input\r\n #DropInput\r\n [matAutocomplete]=\"scrolll\"\r\n class=\"matformfieldinputstyle\"\r\n (keydown)=\"dropdownsearch()\"\r\n [matChipInputFor]=\"chipListvendor\"\r\n [matChipInputSeparatorKeyCodes]=\"separatorsKeysCodes\"\r\n [matChipInputAddOnBlur]=\"true\"\r\n #autoCompleteInput=\"matAutocompleteTrigger\"\r\n [formControlName]=\"\r\n this.dynamciformcontrolparent()\r\n \"\r\n />\r\n </mat-chip-list>\r\n <mat-autocomplete\r\n #scrolll=\"matAutocomplete\"\r\n (opened)=\"autocompleteAppScroll()\"\r\n >\r\n <ng-container>\r\n <mat-option\r\n *ngFor=\"let dropvalues of Dropdowndata\"\r\n [value]=\"\r\n this.InputFields?.formkey\r\n ? dropvalues[this.InputFields?.formkey]\r\n : dropvalues\r\n \"\r\n (onSelectionChange)=\"venSelected(dropvalues)\"\r\n >\r\n {{ dropvalues[InputFields?.displaykey] }}\r\n </mat-option>\r\n </ng-container>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </form>\r\n</div>\r\n<!-- (click)=\"selected()\"\r\n -->\r\n<!-- (optionSelected)=\"venSelected($event)\"\r\n -->\r\n",
571
668
  styles: [".mat-chipScroll{width:420px!important}.mat-chipEx{text-align:left}.chip-container::-webkit-scrollbar{width:6px;height:6px}.chip-container::-webkit-scrollbar-track{background:0 0}.chip-container::-webkit-scrollbar-thumb{border-radius:20px;background:#c3c3c3}.chip-container::-webkit-scrollbar-thumb:hover{background:#a6a6a6}.mat-chipScroll .mat-chip-list-wrapper{height:80px;overflow-y:scroll}mat-form-field{width:250px;font-family:var(--base-font-family)}"]
572
669
  })
573
670
  ], VsChipddCmpComponent);