@vgip/meta-ui 1.4.2 → 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
  }
@@ -792,15 +794,14 @@ const metaNormalizer = (meta, integration, resourceType) => {
792
794
  if (resourceType === 'CandidateNote' || resourceType === 'ContactNote') {
793
795
  metaV3.layout.editable = false;
794
796
  }
795
- }
796
- else if (integrationCode === 'CLIO') {
797
- if (resourceType === 'PhoneCommunication') {
798
- for (const f of metaV3.layout.sections[0].fields) {
799
- if (f.name === 'time_entries') {
800
- f.hidden = 'update';
801
- }
802
- }
803
- }
797
+ // } else if (integrationCode === 'CLIO') {
798
+ // if (resourceType === 'PhoneCommunication') {
799
+ // for (const f of metaV3.layout.sections[0].fields) {
800
+ // if (f.name === 'time_entries') {
801
+ // f.visible = 'CREATE';
802
+ // }
803
+ // }
804
+ // }
804
805
  }
805
806
  return sortObj(metaV3);
806
807
  };
@@ -979,15 +980,20 @@ class FieldAbstract {
979
980
  this.parentChangeSubject.subscribe((value) => {
980
981
  if (value && value.hasOwnProperty(par.split('.')[0])) {
981
982
  setHiddenByPropertyConfig(par);
983
+ if (this.meta.$hidden) {
984
+ delete this.parent[this.meta.name];
985
+ }
982
986
  }
983
987
  });
984
988
  }
985
989
  }
986
- else if (this.meta.hidden === 'create') {
987
- this.meta.$hidden = !this.isPersistedParent;
988
- }
989
- else if (this.meta.hidden === 'update') {
990
- this.meta.$hidden = this.isPersistedParent;
990
+ else if (typeof (this.meta.hidden) === 'string') {
991
+ if (this.meta.hidden.toUpperCase() === 'CREATE') {
992
+ this.meta.$hidden = !this.isPersistedParent;
993
+ }
994
+ else if (this.meta.hidden.toUpperCase() === 'UPDATE') {
995
+ this.meta.$hidden = this.isPersistedParent;
996
+ }
991
997
  }
992
998
  else {
993
999
  this.meta.$hidden = !!this.meta.hidden;
@@ -1023,11 +1029,13 @@ class FieldAbstract {
1023
1029
  });
1024
1030
  }
1025
1031
  }
1026
- else if (this.meta.visible === 'create') {
1027
- this.meta.$invisible = this.isPersistedParent;
1028
- }
1029
- else if (this.meta.visible === 'update') {
1030
- this.meta.$invisible = !this.isPersistedParent;
1032
+ else if (typeof (this.meta.visible) === 'string') {
1033
+ if (this.meta.visible.toUpperCase() === 'CREATE') {
1034
+ this.meta.$invisible = this.isPersistedParent;
1035
+ }
1036
+ else if (this.meta.visible.toUpperCase() === 'UPDATE') {
1037
+ this.meta.$invisible = !this.isPersistedParent;
1038
+ }
1031
1039
  }
1032
1040
  }
1033
1041
  if (this.theme !== 'inherit') {
@@ -3684,11 +3692,11 @@ class FieldReference extends FieldAbstract {
3684
3692
  }
3685
3693
  }
3686
3694
  }
3687
- if (this.meta.search) {
3688
- const searchParams = this.meta.search.params;
3695
+ if (this.meta.auto && this.meta.auto.search) {
3696
+ const searchParams = this.meta.auto.search.params;
3689
3697
  if (searchParams) {
3690
3698
  for (const par of Object.keys(searchParams)) {
3691
- const props = searchParams[par].split('#');
3699
+ const props = searchParams[par].split('.');
3692
3700
  const field = props[0];
3693
3701
  const prop = props[1];
3694
3702
  let parValue = this.parent[field];
@@ -3699,7 +3707,7 @@ class FieldReference extends FieldAbstract {
3699
3707
  if (parValue) {
3700
3708
  const params = {};
3701
3709
  params[par] = parValue;
3702
- this.searchSuggestions(params);
3710
+ this.searchAutoSuggestions(params);
3703
3711
  }
3704
3712
  }
3705
3713
  this.parentChangeSubject.subscribe((value) => {
@@ -3710,7 +3718,7 @@ class FieldReference extends FieldAbstract {
3710
3718
  }
3711
3719
  const params = {};
3712
3720
  params[par] = value[field];
3713
- this.searchSuggestions(params);
3721
+ this.searchAutoSuggestions(params);
3714
3722
  }
3715
3723
  }
3716
3724
  });
@@ -3757,7 +3765,7 @@ class FieldReference extends FieldAbstract {
3757
3765
  delete this.searchResults;
3758
3766
  return;
3759
3767
  }
3760
- const showSearchresults = (results) => {
3768
+ const showSearchResults = (results) => {
3761
3769
  this.searching = false;
3762
3770
  delete this.searchError;
3763
3771
  delete this.activeSuggestionIndex;
@@ -3783,11 +3791,21 @@ class FieldReference extends FieldAbstract {
3783
3791
  if (this.meta.search.url) {
3784
3792
  searchUrl = this.meta.search.url.replace(/\${\s*([\w\.]+)\s*}/g, (match, key) => {
3785
3793
  if (searchParams.hasOwnProperty(key)) {
3786
- const val = searchParams[key];
3787
- delete searchParams[key];
3788
- 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
+ }
3789
3807
  }
3790
- return '';
3808
+ return 'undefined';
3791
3809
  });
3792
3810
  }
3793
3811
  for (const p of Object.keys(searchParams)) {
@@ -3796,7 +3814,7 @@ class FieldReference extends FieldAbstract {
3796
3814
  searchUrl += `${searchUrl.indexOf('?') === -1 ? '?' : '&'}q=${encodeURIComponent(this.searchText)}`;
3797
3815
  this.searching = true;
3798
3816
  this.resourceService.getByPath(searchUrl).subscribe((results) => {
3799
- showSearchresults(results);
3817
+ showSearchResults(results);
3800
3818
  }, (error) => {
3801
3819
  delete this.searching;
3802
3820
  this.searchResults = [];
@@ -3814,7 +3832,7 @@ class FieldReference extends FieldAbstract {
3814
3832
  });
3815
3833
  }
3816
3834
  this.vr.searchIntegration(this.searchText, this.searchResourceType.name || this.searchResourceTypesScope).subscribe((results) => {
3817
- showSearchresults(results);
3835
+ showSearchResults(results);
3818
3836
  }, (error) => {
3819
3837
  this.searching = false;
3820
3838
  this.searchResults = [];
@@ -4133,11 +4151,12 @@ class FieldReference extends FieldAbstract {
4133
4151
  return this.metaReference.creatable;
4134
4152
  }
4135
4153
  }
4136
- searchSuggestions(params) {
4154
+ searchAutoSuggestions(params) {
4155
+ console.log('searchAutoSuggestions', params);
4137
4156
  let searchUrl = `/suggestions/${this.meta.name}/search`;
4138
- if (this.meta.search) {
4139
- if (this.meta.search.url) {
4140
- 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) => {
4141
4160
  if (params.hasOwnProperty(key)) {
4142
4161
  const val = params[key];
4143
4162
  delete params[key];
@@ -4155,8 +4174,8 @@ class FieldReference extends FieldAbstract {
4155
4174
  if (result) {
4156
4175
  let suggestions;
4157
4176
  suggestions = result;
4158
- if (this.meta.search.extract) {
4159
- suggestions = result[this.meta.search.extract];
4177
+ if (this.meta.auto.search.extract) {
4178
+ suggestions = result[this.meta.auto.search.extract];
4160
4179
  }
4161
4180
  if (suggestions instanceof Array !== true) {
4162
4181
  suggestions = [suggestions];