@bnsights/bbsf-controls 1.0.56 → 1.0.58

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.
@@ -17,7 +17,7 @@ import { DatePipe, CommonModule } from '@angular/common';
17
17
  import { SearchCountryField, NgxIntlTelInputModule } from 'ngx-intl-tel-input';
18
18
  import { UtilityService, ControlValidationService, BBSFTranslateService, RequestOptionsModel, RequestHandlerService, environment as environment$1, BBSFUtilitiesModule } from '@bnsights/bbsf-utilities';
19
19
  import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
20
- import { Subject, Observable, noop as noop$1, of, Subscription } from 'rxjs';
20
+ import { Subject, Observable, noop as noop$1, of, EMPTY, Subscription } from 'rxjs';
21
21
  import { OwlDateTimeIntl, DateTimeAdapter, OwlDateTimeModule, OwlNativeDateTimeModule, OWL_DATE_TIME_LOCALE } from 'ng-pick-datetime';
22
22
  import { FileUploader, FileLikeObject, FileUploadModule } from 'ng2-file-upload';
23
23
  import { __decorate, __awaiter } from 'tslib';
@@ -4071,6 +4071,10 @@ class TagsInputComponent {
4071
4071
  }
4072
4072
  }
4073
4073
  }
4074
+ ngOnDestroy() {
4075
+ if (this.changeValueSubscription)
4076
+ this.changeValueSubscription.unsubscribe();
4077
+ }
4074
4078
  ngOnInit() {
4075
4079
  this.controlValidationService.isCreatedBefor = false;
4076
4080
  this.options.DatasourceItemText = this.options.DatasourceItemText.toLowerCase();
@@ -4115,6 +4119,17 @@ class TagsInputComponent {
4115
4119
  this.group.markAllAsTouched();
4116
4120
  this.markAllAsTouched = true;
4117
4121
  });
4122
+ //Check for changing in value
4123
+ this.changeValueSubscription = this.TagsFormControl.valueChanges.subscribe(c => {
4124
+ var _a;
4125
+ this.tags = this.TagsFormControl.value;
4126
+ this.SelectedId = (_a = this.tags) === null || _a === void 0 ? void 0 : _a.filter(item => item.id).map(item => item.id);
4127
+ if (this.tags == null) {
4128
+ this.SearchKey.selected = "";
4129
+ this.tags = [];
4130
+ this.TagsFormControl.setValue([]);
4131
+ }
4132
+ });
4118
4133
  }
4119
4134
  ngAfterViewInit() {
4120
4135
  if (this.options.AttributeList != null) {
@@ -4140,6 +4155,9 @@ class TagsInputComponent {
4140
4155
  this.controlUtility.CopyInputMessage(inputElement);
4141
4156
  }
4142
4157
  searchFunctionFactory(Text) {
4158
+ //If no text then return empty observable
4159
+ if (!Text)
4160
+ return EMPTY;
4143
4161
  let Url = `${this.options.ActionURL}?${this.options.QueryParamName}=${encodeURIComponent(Text)}&${this.options.SelectedItemsParamName}=${this.SelectedId}`;
4144
4162
  if (this.options.ExtraFilters)
4145
4163
  Url = Url + `&${this.options.ExtraFilters}`;
@@ -4150,17 +4168,9 @@ class TagsInputComponent {
4150
4168
  return Model;
4151
4169
  }
4152
4170
  AddTag(event, key) {
4153
- if (this.IsNoMatch == true && this.options.AllowNewSelection == false && key.selected) {
4154
- this.TagsFormControl.setErrors({ "errorMassage": this.options.NoResultText });
4155
- this.TagsFormControl.markAsTouched();
4156
- this.TagsFormControl.invalid;
4157
- }
4158
- else if (this.IsNoMatch == false && this.options.AllowNewSelection == false) {
4159
- this.TagsFormControl.clearValidators();
4160
- this.TagsFormControl.updateValueAndValidity();
4161
- this.TagsFormControl.valid;
4162
- }
4163
- else if (this.IsNoMatch == true && event == "Enter" && this.options.AllowNewSelection && key.selected) {
4171
+ var _a, _b;
4172
+ //Check if input is enter press
4173
+ if (this.IsNoMatch == true && event.key == "Enter" && this.options.AllowNewSelection && key.selected) {
4164
4174
  if (!(this.tags.length >= this.options.MaxNumberTags)) {
4165
4175
  this.tags.push({ name: key.selected });
4166
4176
  this.group.get(this.options.Name).setValue(this.tags);
@@ -4174,6 +4184,26 @@ class TagsInputComponent {
4174
4184
  this.tags.pop();
4175
4185
  }
4176
4186
  }
4187
+ //Check if input is charachter
4188
+ else if (String.fromCharCode(event.keyCode).match(/(\w|\s)/g)) {
4189
+ if (this.IsNoMatch == true && this.options.AllowNewSelection == false && key.selected) {
4190
+ this.TagsFormControl.setErrors({ "errorMassage": this.options.NoResultText });
4191
+ this.TagsFormControl.markAsTouched();
4192
+ }
4193
+ else if (this.IsNoMatch == false && this.options.AllowNewSelection == false) {
4194
+ this.TagsFormControl.clearValidators();
4195
+ this.TagsFormControl.updateValueAndValidity();
4196
+ }
4197
+ }
4198
+ //Remove unmatched error incase of deleting search value
4199
+ else if (event.key === "Backspace" && ((_a = key.selected) === null || _a === void 0 ? void 0 : _a.length) <= 1 && this.TagsFormControl.hasError('errorMassage')) {
4200
+ this.TagsFormControl.setErrors({ "errorMassage": null });
4201
+ this.TagsFormControl.updateValueAndValidity();
4202
+ if (((_b = this.SelectedId) === null || _b === void 0 ? void 0 : _b.length) == 0 && this.options.IsRequired) {
4203
+ this.TagsFormControl.setErrors({ required: "" });
4204
+ this.TagsFormControl.markAsTouched();
4205
+ }
4206
+ }
4177
4207
  }
4178
4208
  onTagsChanged(result) {
4179
4209
  //console.log(this.tags)
@@ -4206,7 +4236,7 @@ TagsInputComponent.decorators = [
4206
4236
  { type: Component, args: [{
4207
4237
  // tslint:disable-next-line: component-selector
4208
4238
  selector: 'BBSF-TagsInput',
4209
- template: "<div class=\"b-control b-tags-input\">\r\n <div class=\"form-group validate is-invalid\" [formGroup]=\"group\">\r\n <div class=\"form-group row\" [formGroup]=\"TagsFormGroup\">\r\n\r\n <label class=\"b-label col-form-label col-sm-12 \" [ngClass]=\"(options.ViewType==1)?'col-md-12':'col-md-3'\"\r\n [hidden]=\"options.HideLabel\">\r\n {{options.LabelValue}}\r\n <span *ngIf=\"(options.ShowAsterisk&&options.IsRequired)||(options.IsRequired)\" class=\"text-danger Required-text\"\r\n aria-required=\"true\">*</span>\r\n </label>\r\n\r\n <div class=\"col-sm-12\" [ngClass]=\"(options.ViewType==1)?'':'col-md-9'\">\r\n <b-tags-input id=\"typeahead-http\" type=\"text\" class=\"form-control bnsights-control {{options.ExtraClasses}}\"\r\n dir=\"{{options.ForceDirection==2?'rtl':''}}\" [disabled]=\"options.IsDisabled\" aria-describedby=\"email-error\"\r\n aria-invalid=\"true\" formControlName=\"tags\"\r\n [class.is-invalid]=\"TagsFormControl.invalid && TagsFormControl.touched\" placeholder=\"{{options.Placeholder}}\"\r\n id=\"{{options.Name}}\" (onTagsChanged)=\"onTagsChanged($event)\" [(ngModel)]=\"tags\"\r\n removeLastOnBackspace=\"{{options.RemoveLastOnBackspace}}\" (onNoOptionsMatch)=\"onNoOptionsMatch($event)\"\r\n [options]=\"searchFunctionFactory(SearchKey.selected)\" #SearchKey\r\n scrollableOptions=\"{{options.ScrollableOptions}}\" scrollableOptionsInView=\"{{options.MaxSearchResultsCount}}\"\r\n (keypress)=\"AddTag($event.key,SearchKey)\" [ViewMode]=\"options.TagInputMode\"\r\n maxTags=\"{{options.MaxNumberTags}}\" minLengthBeforeOptions=\"{{options.MinSearchLength}}\"\r\n [showDescription]=\"options.ShowDescription\" [defaultImageURL]=\"options.DefaultImgUrl\" name=\"tags\">\r\n </b-tags-input>\r\n\r\n <div class=\"text-danger Required-text\" *ngIf=\"(TagsFormControl.invalid && TagsFormControl.touched)\">\r\n {{getErrorValidation(TagsFormControl.errors|keyvalue)}}\r\n </div>\r\n\r\n\r\n <div class=\"d-flex justify-content-between align-items-center\">\r\n <div class=\"control-desc text-dark\">{{options.LabelDescription}}</div>\r\n </div>\r\n\r\n <div *ngIf=\"(group.valid&&group.dirty&&group.touched )||(group.untouched&&group.invalid&&group.dirty) \">\r\n {{resetError()}}</div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n",
4239
+ template: "<div class=\"b-control b-tags-input\">\r\n <div class=\"form-group validate is-invalid\" [formGroup]=\"group\">\r\n <div class=\"form-group row\" [formGroup]=\"TagsFormGroup\">\r\n\r\n <label class=\"b-label col-form-label col-sm-12 \" [ngClass]=\"(options.ViewType==1)?'col-md-12':'col-md-3'\"\r\n [hidden]=\"options.HideLabel\">\r\n {{options.LabelValue}}\r\n <span *ngIf=\"(options.ShowAsterisk&&options.IsRequired)||(options.IsRequired)\" class=\"text-danger Required-text\"\r\n aria-required=\"true\">*</span>\r\n </label>\r\n\r\n <div class=\"col-sm-12\" [ngClass]=\"(options.ViewType==1)?'':'col-md-9'\">\r\n <b-tags-input id=\"typeahead-http\" type=\"text\" class=\"form-control bnsights-control {{options.ExtraClasses}}\"\r\n dir=\"{{options.ForceDirection==2?'rtl':''}}\" [disabled]=\"options.IsDisabled\" aria-describedby=\"email-error\"\r\n aria-invalid=\"true\" formControlName=\"tags\"\r\n [class.is-invalid]=\"TagsFormControl.invalid && TagsFormControl.touched\" placeholder=\"{{options.Placeholder}}\"\r\n id=\"{{options.Name}}\" (onTagsChanged)=\"onTagsChanged($event)\" [(ngModel)]=\"tags\" \r\n removeLastOnBackspace=\"{{options.RemoveLastOnBackspace}}\" (onNoOptionsMatch)=\"onNoOptionsMatch($event)\"\r\n [options]=\"searchFunctionFactory(SearchKey.selected)\" #SearchKey\r\n scrollableOptions=\"{{options.ScrollableOptions}}\" scrollableOptionsInView=\"{{options.MaxSearchResultsCount}}\"\r\n (keydown)=\"AddTag($event,SearchKey)\" [ViewMode]=\"options.TagInputMode\"\r\n maxTags=\"{{options.MaxNumberTags}}\" minLengthBeforeOptions=\"{{options.MinSearchLength}}\"\r\n [showDescription]=\"options.ShowDescription\" [defaultImageURL]=\"options.DefaultImgUrl\" name=\"tags\">\r\n </b-tags-input>\r\n\r\n <div class=\"text-danger Required-text\" *ngIf=\"(TagsFormControl.invalid && TagsFormControl.touched)\">\r\n {{getErrorValidation(TagsFormControl.errors|keyvalue)}}\r\n </div>\r\n\r\n\r\n <div class=\"d-flex justify-content-between align-items-center\">\r\n <div class=\"control-desc text-dark\">{{options.LabelDescription}}</div>\r\n </div>\r\n\r\n <div *ngIf=\"(group.valid&&group.dirty&&group.touched )||(group.untouched&&group.invalid&&group.dirty) \">\r\n {{resetError()}}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n",
4210
4240
  styles: [".example-form{min-width:150px;max-width:500px;width:100%}.example-full-width{width:100%}.flip_V{transform:scaleY(-1)}\n"]
4211
4241
  },] }
4212
4242
  ];
@@ -4223,7 +4253,8 @@ TagsInputComponent.ctorParameters = () => [
4223
4253
  TagsInputComponent.propDecorators = {
4224
4254
  group: [{ type: Input }],
4225
4255
  options: [{ type: Input }],
4226
- OnChange: [{ type: Output }]
4256
+ OnChange: [{ type: Output }],
4257
+ SearchKey: [{ type: ViewChild, args: ['SearchKey', { static: false },] }]
4227
4258
  };
4228
4259
 
4229
4260
  class PagingDTO {
@@ -6857,7 +6888,7 @@ class RepeaterTableComponent {
6857
6888
  if (this.options.RepeaterValue.length > 0) {
6858
6889
  this.originalItems = this.options.RepeaterValue;
6859
6890
  for (let index = 0; index < this.options.RepeaterValue.length; index++) {
6860
- this.items.push(index + 1);
6891
+ this.items.push(index);
6861
6892
  }
6862
6893
  }
6863
6894
  else
@@ -6930,13 +6961,16 @@ class RepeaterTableComponent {
6930
6961
  this.items = this.items.filter((res) => res != this.items[Index]);
6931
6962
  }
6932
6963
  addItem() {
6933
- this.items.push(this.items[this.items.length - 1] + 1);
6964
+ if (this.items.length == 0)
6965
+ this.items.push(this.items.length);
6966
+ else
6967
+ this.items.push(this.items[this.items.length - 1] + 1);
6934
6968
  }
6935
6969
  }
6936
6970
  RepeaterTableComponent.decorators = [
6937
6971
  { type: Component, args: [{
6938
6972
  selector: 'BBSF-repeater-table',
6939
- template: "<div class=\"b-control b-repeater-table\">\r\n <table class=\"{{options.RepeaterTableExtraClasses}}\">\r\n <thead>\r\n <tr class=\"{{options.RepeaterTableRowExtraClasses}}\">\r\n <th *ngFor=\"let item of options.RepeaterStructure\" class=\"min-w-150px\">{{item.HeaderTitle}}</th>\r\n <th>{{utilityService.getResourceValue(options.ActionLabelKey)}}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let item of items ; index as i\">\r\n <td *ngFor=\"let RepeaterField of options.RepeaterStructure ; index as r\">\r\n <repeater-field-builder [RepeaterField]=\"RepeaterField\" [itemNumber]=\"i\"\r\n [itemsValue]=\"originalItems\" [controlNumber]=\"r\" [group]=\"repeaterGroup\">\r\n </repeater-field-builder>\r\n </td>\r\n <td class=\"d-flex align-items-center\">\r\n <button class=\"{{options.DeleteButtonExtraClasses}}\" type=\"button\" (click)=\"deleteItem(i)\"\r\n [disabled]=\"(items.length ==options.MinRequiredItems&&options.IsRequired) ||(originalItems.length-1>=i)\">\r\n <span [innerHTML]=\"options.DeleteButtonText\"></span></button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n <tfoot>\r\n <tr>\r\n <td colspan=\"4\">\r\n <div class=\"row\">\r\n <div class=\"col-md-12 d-grid gap-2\"> \r\n <button class=\"{{options.AddButtonExtraClasses}}\" type=\"button\" (click)=\"addItem()\"><span\r\n [innerHTML]=\"options.AddButtonText\"></span></button>\r\n </div>\r\n </div>\r\n </td>\r\n </tr>\r\n </tfoot>\r\n </table>\r\n</div>"
6973
+ template: "<div class=\"b-control b-repeater-table\">\r\n <table class=\"{{options.RepeaterTableExtraClasses}}\">\r\n <thead>\r\n <tr class=\"{{options.RepeaterTableRowExtraClasses}}\">\r\n <th *ngFor=\"let item of options.RepeaterStructure\" class=\"min-w-150px\">{{item.HeaderTitle}}</th>\r\n <th>{{utilityService.getResourceValue(options.ActionLabelKey)}}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let item of items ; index as i\">\r\n <td *ngFor=\"let RepeaterField of options.RepeaterStructure ; index as r\">\r\n <repeater-field-builder [RepeaterField]=\"RepeaterField\" [itemNumber]=\"i\"\r\n [itemsValue]=\"originalItems\" [controlNumber]=\"r\" [group]=\"repeaterGroup\">\r\n </repeater-field-builder>\r\n </td>\r\n <td class=\"d-flex align-items-center\">\r\n <button class=\"{{options.DeleteButtonExtraClasses}}\" type=\"button\" (click)=\"deleteItem(i)\"\r\n [disabled]=\"(items.length ==options.MinRequiredItems&&options.IsRequired)\">\r\n <span [innerHTML]=\"options.DeleteButtonText\"></span></button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n <!-- ||(originalItems.length-1>=i -->\r\n <tfoot>\r\n <tr>\r\n <td colspan=\"4\">\r\n <div class=\"row\">\r\n <div class=\"col-md-12 d-grid gap-2\"> \r\n <button class=\"{{options.AddButtonExtraClasses}}\" type=\"button\" (click)=\"addItem()\"><span\r\n [innerHTML]=\"options.AddButtonText\"></span></button>\r\n </div>\r\n </div>\r\n </td>\r\n </tr>\r\n </tfoot>\r\n </table>\r\n</div>"
6940
6974
  },] }
6941
6975
  ];
6942
6976
  RepeaterTableComponent.ctorParameters = () => [
@@ -7191,7 +7225,8 @@ class BTagsInputComponent {
7191
7225
  }
7192
7226
  }
7193
7227
  removeLastTag(tagInput) {
7194
- if (!this.removeLastOnBackspace || !this.tags.length) {
7228
+ var _a;
7229
+ if (!this.removeLastOnBackspace || !((_a = this.tags) === null || _a === void 0 ? void 0 : _a.length)) {
7195
7230
  return;
7196
7231
  }
7197
7232
  if (tagInput.value === '') {
@@ -7208,6 +7243,8 @@ class BTagsInputComponent {
7208
7243
  tagInput.value = '';
7209
7244
  }
7210
7245
  addPredefinedTag(tag) {
7246
+ if (this.tags == null)
7247
+ this.tags = [];
7211
7248
  if (!this.maximumOfTagsReached()) {
7212
7249
  this.tags.push(tag);
7213
7250
  this.tagsChanged('add', tag);