@vgip/meta-ui 1.4.3 → 1.4.4

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.
@@ -671,13 +671,15 @@ const metaNormalizer = (meta, integration, resourceType) => {
671
671
  break;
672
672
  }
673
673
  case 'NETSUITE': {
674
- if (f.name === 'company' && !f.search) {
675
- f.search = {
676
- params: {
677
- contactId: 'contact#id'
678
- },
679
- url: '../Contact/${contactId}?expand=company',
680
- extract: 'company'
674
+ if (f.name === 'company' && !f.auto) {
675
+ f.auto = {
676
+ search: {
677
+ params: {
678
+ contactId: 'contact.id'
679
+ },
680
+ url: '../Contact/${contactId}?expand=company',
681
+ extract: 'company'
682
+ }
681
683
  };
682
684
  }
683
685
  }
@@ -3690,11 +3692,11 @@ class FieldReference extends FieldAbstract {
3690
3692
  }
3691
3693
  }
3692
3694
  }
3693
- if (this.meta.search) {
3694
- const searchParams = this.meta.search.params;
3695
+ if (this.meta.auto && this.meta.auto.search) {
3696
+ const searchParams = this.meta.auto.search.params;
3695
3697
  if (searchParams) {
3696
3698
  for (const par of Object.keys(searchParams)) {
3697
- const props = searchParams[par].split('#');
3699
+ const props = searchParams[par].split('.');
3698
3700
  const field = props[0];
3699
3701
  const prop = props[1];
3700
3702
  let parValue = this.parent[field];
@@ -3705,7 +3707,7 @@ class FieldReference extends FieldAbstract {
3705
3707
  if (parValue) {
3706
3708
  const params = {};
3707
3709
  params[par] = parValue;
3708
- this.searchSuggestions(params);
3710
+ this.searchAutoSuggestions(params);
3709
3711
  }
3710
3712
  }
3711
3713
  this.parentChangeSubject.subscribe((value) => {
@@ -3716,7 +3718,7 @@ class FieldReference extends FieldAbstract {
3716
3718
  }
3717
3719
  const params = {};
3718
3720
  params[par] = value[field];
3719
- this.searchSuggestions(params);
3721
+ this.searchAutoSuggestions(params);
3720
3722
  }
3721
3723
  }
3722
3724
  });
@@ -3763,7 +3765,7 @@ class FieldReference extends FieldAbstract {
3763
3765
  delete this.searchResults;
3764
3766
  return;
3765
3767
  }
3766
- const showSearchresults = (results) => {
3768
+ const showSearchResults = (results) => {
3767
3769
  this.searching = false;
3768
3770
  delete this.searchError;
3769
3771
  delete this.activeSuggestionIndex;
@@ -3789,11 +3791,21 @@ class FieldReference extends FieldAbstract {
3789
3791
  if (this.meta.search.url) {
3790
3792
  searchUrl = this.meta.search.url.replace(/\${\s*([\w\.]+)\s*}/g, (match, key) => {
3791
3793
  if (searchParams.hasOwnProperty(key)) {
3792
- const val = searchParams[key];
3793
- delete searchParams[key];
3794
- return val;
3794
+ const props = searchParams[key].split('.');
3795
+ const field = props[0];
3796
+ const prop = props[1];
3797
+ delete searchParams[key]; // if it is URL param, remove it as query param
3798
+ let parValue = this.parent[field];
3799
+ if (parValue) {
3800
+ if (prop) {
3801
+ parValue = parValue[prop];
3802
+ }
3803
+ if (parValue) {
3804
+ return parValue;
3805
+ }
3806
+ }
3795
3807
  }
3796
- return '';
3808
+ return 'undefined';
3797
3809
  });
3798
3810
  }
3799
3811
  for (const p of Object.keys(searchParams)) {
@@ -3802,7 +3814,7 @@ class FieldReference extends FieldAbstract {
3802
3814
  searchUrl += `${searchUrl.indexOf('?') === -1 ? '?' : '&'}q=${encodeURIComponent(this.searchText)}`;
3803
3815
  this.searching = true;
3804
3816
  this.resourceService.getByPath(searchUrl).subscribe((results) => {
3805
- showSearchresults(results);
3817
+ showSearchResults(results);
3806
3818
  }, (error) => {
3807
3819
  delete this.searching;
3808
3820
  this.searchResults = [];
@@ -3820,7 +3832,7 @@ class FieldReference extends FieldAbstract {
3820
3832
  });
3821
3833
  }
3822
3834
  this.vr.searchIntegration(this.searchText, this.searchResourceType.name || this.searchResourceTypesScope).subscribe((results) => {
3823
- showSearchresults(results);
3835
+ showSearchResults(results);
3824
3836
  }, (error) => {
3825
3837
  this.searching = false;
3826
3838
  this.searchResults = [];
@@ -4139,11 +4151,12 @@ class FieldReference extends FieldAbstract {
4139
4151
  return this.metaReference.creatable;
4140
4152
  }
4141
4153
  }
4142
- searchSuggestions(params) {
4154
+ searchAutoSuggestions(params) {
4155
+ console.log('searchAutoSuggestions', params);
4143
4156
  let searchUrl = `/suggestions/${this.meta.name}/search`;
4144
- if (this.meta.search) {
4145
- if (this.meta.search.url) {
4146
- searchUrl = this.meta.search.url.replace(/\${\s*([\w\.]+)\s*}/g, (match, key) => {
4157
+ if (this.meta.auto && this.meta.auto.search) {
4158
+ if (this.meta.auto.search.url) {
4159
+ searchUrl = this.meta.auto.search.url.replace(/\${\s*([\w\.]+)\s*}/g, (match, key) => {
4147
4160
  if (params.hasOwnProperty(key)) {
4148
4161
  const val = params[key];
4149
4162
  delete params[key];
@@ -4161,8 +4174,8 @@ class FieldReference extends FieldAbstract {
4161
4174
  if (result) {
4162
4175
  let suggestions;
4163
4176
  suggestions = result;
4164
- if (this.meta.search.extract) {
4165
- suggestions = result[this.meta.search.extract];
4177
+ if (this.meta.auto.search.extract) {
4178
+ suggestions = result[this.meta.auto.search.extract];
4166
4179
  }
4167
4180
  if (suggestions instanceof Array !== true) {
4168
4181
  suggestions = [suggestions];