mmhglobal-dynamicform 2.6.2 → 2.6.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.
@@ -11768,11 +11768,11 @@ class ZudfComponent extends ContainerFieldBase {
11768
11768
  * @param group The ZGroup object to which the field elements will be added.
11769
11769
  * @param jsonString The JSON string representing the field elements.
11770
11770
  */
11771
- renderFieldElementByJsonString(group, jsonString) {
11771
+ renderFieldElementByJsonString(group, jsonString, fieldElementName = '') {
11772
11772
  // Parse the JSON string into an array of field elements.
11773
11773
  const fieldElementMasterCodeJsonArray = JSON.parse(jsonString);
11774
11774
  // Render the field elements.
11775
- this.renderFieldElement(fieldElementMasterCodeJsonArray);
11775
+ this.renderFieldElement(fieldElementMasterCodeJsonArray, fieldElementName);
11776
11776
  }
11777
11777
  //#region Display model
11778
11778
  /**
@@ -11865,7 +11865,7 @@ class ZudfComponent extends ContainerFieldBase {
11865
11865
  * Renders field elements as form controls in a new form group.
11866
11866
  * @param {any} fieldElements - The field elements to be rendered.
11867
11867
  */
11868
- renderFieldElement(fieldElements) {
11868
+ renderFieldElement(fieldElements, fieldElementName = '') {
11869
11869
  this.clearZModel();
11870
11870
  if (fieldElements) {
11871
11871
  this.loadedFieldsSequence = {};
@@ -11908,6 +11908,12 @@ class ZudfComponent extends ContainerFieldBase {
11908
11908
  }
11909
11909
  });
11910
11910
  }
11911
+ // need to call back field element "<field name>_loaded"
11912
+ if (fieldElementName != '') {
11913
+ if (this.group[fieldElementName + '_loaded']) {
11914
+ this.group[fieldElementName + '_loaded'](this.group);
11915
+ }
11916
+ }
11911
11917
  // To consider: Trigger the "onchange" event or perform any other necessary actions here
11912
11918
  });
11913
11919
  }
@@ -12063,16 +12069,15 @@ class ZudfComponent extends ContainerFieldBase {
12063
12069
  if (Array.isArray(patchedModelData[model])) {
12064
12070
  const gridValue = `${model}${this.prefixValueOption}`;
12065
12071
  const gridDataSource = `${model}${this.prefixDataSourceName}`;
12066
- // Check is it kcard, sometime can be dropdown.
12067
- const component = ZComponentHelper.getComponentByValue(this.group, model);
12068
- if (component?.data?.Type === 'kcard') {
12069
- // Update the data source for the grid
12070
- group[gridDataSource] = patchedModelData[model];
12071
- // Update the grid value
12072
- if (group[gridValue]) {
12073
- group[gridValue].setData(group[gridDataSource]);
12074
- }
12072
+ //const component = ZComponentHelper.getComponentByValue(this.group, model);
12073
+ //if (component?.data?.Type === 'kcard' || component?.data?.Type === 'zgrid') {
12074
+ // Update the data source for the grid
12075
+ group[gridDataSource] = patchedModelData[model];
12076
+ // Update the grid value
12077
+ if (group[gridValue]) {
12078
+ group[gridValue].setData(group[gridDataSource]);
12075
12079
  }
12080
+ //}
12076
12081
  }
12077
12082
  }
12078
12083
  // Update the form group model
@@ -12744,8 +12749,11 @@ class SfquerybuilderComponent {
12744
12749
  this.inOperators = ['in', 'notin'];
12745
12750
  this.dropdownOperators = [
12746
12751
  this.equalOperator,
12752
+ this.notequalOperator,
12747
12753
  this.inOperator,
12748
- this.notinOperator
12754
+ this.notinOperator,
12755
+ this.isnullOperator,
12756
+ this.isnotnullOperator
12749
12757
  ];
12750
12758
  this.stringOperators = [
12751
12759
  this.equalOperator,
@@ -12764,7 +12772,9 @@ class SfquerybuilderComponent {
12764
12772
  this.greaterthanOperator,
12765
12773
  this.greaterthanorequalOperator,
12766
12774
  this.lessthanOperator,
12767
- this.lessthanorequalOperator
12775
+ this.lessthanorequalOperator,
12776
+ this.isnullOperator,
12777
+ this.isnotnullOperator
12768
12778
  ];
12769
12779
  this.dateOperators = [
12770
12780
  this.equalOperator,
@@ -12772,16 +12782,26 @@ class SfquerybuilderComponent {
12772
12782
  this.greaterthanOperator,
12773
12783
  this.greaterthanorequalOperator,
12774
12784
  this.lessthanOperator,
12775
- this.lessthanorequalOperator
12785
+ this.lessthanorequalOperator,
12786
+ this.isnullOperator,
12787
+ this.isnotnullOperator
12788
+ ];
12789
+ this.booleanOperators = [
12790
+ this.equalOperator,
12791
+ this.notequalOperator,
12792
+ this.isnullOperator,
12793
+ this.isnotnullOperator
12776
12794
  ];
12777
12795
  this.selectionComponentList = [];
12778
12796
  }
12779
12797
  ngOnInit() {
12780
12798
  ZComponentHelper.setComponentProperties(this);
12781
12799
  ZComponentHelper.registerComponent(this);
12782
- of(true).pipe(switchMap$1(cont => {
12800
+ of(true).pipe(switchMap$1(_ => {
12783
12801
  return this.beforeLoadField(this.data);
12784
- }), switchMap$1(cont2 => {
12802
+ }), tap$1(data => {
12803
+ this.data = data;
12804
+ }), switchMap$1(_ => {
12785
12805
  return this.loadQueryBuilder();
12786
12806
  })).subscribe(() => {
12787
12807
  // Where to update operator syntax
@@ -12803,67 +12823,78 @@ class SfquerybuilderComponent {
12803
12823
  }
12804
12824
  this.fields = this.fieldService.getFormFieldCode(this.data.Value, "FormField", null, null);
12805
12825
  try {
12826
+ let isGrouped = true;
12806
12827
  return this.fields.pipe(tap$1((data) => {
12828
+ // if [isGrouped = true] include grouping name as prefix
12829
+ if (data.length > 1) {
12830
+ isGrouped = false;
12831
+ }
12807
12832
  data.forEach(async (field) => {
12808
- //sf //todo: later change to base on other attribute single or multi select for field element
12809
- if (field.Type == 'category' || field.Type == 'multiselect') {
12810
- this.sdFilter.push({
12811
- field: field.Value,
12812
- label: field.Name,
12813
- type: 'string',
12814
- operators: this.dropdownOperators,
12815
- template: await this.generateColumnSelection(field),
12816
- });
12817
- }
12818
- else if (field.Type === 'string') {
12819
- this.sdFilter.push({
12820
- field: field.Value,
12821
- label: field.Name,
12822
- operators: this.stringOperators,
12823
- type: 'string'
12824
- });
12825
- }
12826
- else if (field.Type === 'date') {
12827
- this.sdFilter.push({
12828
- field: field.Value,
12829
- label: field.Name,
12830
- operators: this.dateOperators,
12831
- type: 'date'
12832
- });
12833
- }
12834
- else if (field.Type === 'number') {
12835
- this.sdFilter.push({
12836
- field: field.Value,
12837
- label: field.Name,
12838
- operators: this.integerOperators,
12839
- type: 'number'
12840
- });
12841
- }
12842
- else if (field.Value === 'boolean') {
12843
- this.sdFilter.push({
12844
- field: field.Value,
12845
- label: field.Name,
12846
- type: 'boolean',
12847
- template: await this.generateColumnCheckbox(field.Name, false)
12848
- });
12849
- }
12850
- else {
12851
- this.sdFilter.push({
12852
- field: field.Value,
12853
- label: field.Name,
12854
- type: 'string',
12855
- operators: this.stringOperators,
12856
- });
12857
- }
12833
+ this.renderComponentType(field, isGrouped);
12858
12834
  }); //end foreach
12859
12835
  this.issfLoaded = true;
12860
12836
  }));
12837
+ return of(true);
12861
12838
  }
12862
12839
  catch (error) {
12863
12840
  console.error("error: ", error);
12864
12841
  return of(false);
12865
12842
  }
12866
12843
  }
12844
+ async renderComponentType(field, isGrouped, fieldTitle) {
12845
+ let componentLabel = field.SubType ? field.Label : field.Label ?? field.Name;
12846
+ componentLabel = !isGrouped && !ZComponentHelper.isNullUndefinedEmpty(fieldTitle) ? "[" + fieldTitle + "] " + field.Label : !ZComponentHelper.isNullUndefinedEmpty(field.Label) ? field.Label : field.Name;
12847
+ let componentField = !ZComponentHelper.isNullUndefinedEmpty(fieldTitle) ? fieldTitle + "_" + field.Value : field.Value;
12848
+ if (field.Type === 'category' || field.Type === 'multiselect' || field.Type === 'zuiselectmultiple') {
12849
+ this.sdFilter.push({
12850
+ field: componentField,
12851
+ label: componentLabel,
12852
+ type: 'string',
12853
+ operators: this.dropdownOperators,
12854
+ template: await this.generateColumnSelection(field),
12855
+ });
12856
+ }
12857
+ else if (field.Type === 'date') {
12858
+ this.sdFilter.push({
12859
+ field: componentField,
12860
+ label: componentLabel,
12861
+ operators: this.dateOperators,
12862
+ type: 'date'
12863
+ });
12864
+ }
12865
+ else if (field.Type === 'number') {
12866
+ this.sdFilter.push({
12867
+ field: componentField,
12868
+ label: componentLabel,
12869
+ operators: this.integerOperators,
12870
+ type: 'number'
12871
+ });
12872
+ }
12873
+ else if (field.Value === 'boolean') {
12874
+ this.sdFilter.push({
12875
+ field: componentField,
12876
+ label: componentLabel,
12877
+ type: 'boolean',
12878
+ operators: this.booleanOperators,
12879
+ template: await this.generateColumnCheckbox(field.Name, false)
12880
+ });
12881
+ }
12882
+ else if (field.Type === 'kcard') {
12883
+ if (field.Value.length > 0) {
12884
+ field.Value.forEach(async (item) => {
12885
+ this.renderComponentType(item, isGrouped, field.Title);
12886
+ });
12887
+ }
12888
+ }
12889
+ else {
12890
+ this.sdFilter.push({
12891
+ field: componentField,
12892
+ label: componentLabel,
12893
+ operators: this.stringOperators,
12894
+ type: 'string'
12895
+ });
12896
+ }
12897
+ }
12867
12898
  //#region checkbox
12868
12899
  generateColumnCheckbox(label, value) {
12869
12900
  return {
@@ -12895,7 +12926,8 @@ class SfquerybuilderComponent {
12895
12926
  if (this.data['Filters']) {
12896
12927
  this.filters = ZComponentHelper.getGroupEvalValue.call(this, this.data['Filters'], this.group);
12897
12928
  }
12898
- return createElement('input', { attrs: { 'type': 'text', 'style': 'display: none' } }); //createElement('input', { attrs: { 'type': 'text' } });
12929
+ //return createElement('input', { attrs: { 'type': 'text', 'style': 'display: none' } });
12930
+ return createElement('input', { attrs: { 'type': 'text' } });
12899
12931
  },
12900
12932
  // Destroy the custom component
12901
12933
  destroy: (args) => {
@@ -12933,49 +12965,102 @@ class SfquerybuilderComponent {
12933
12965
  const selectionComponent = this.generateSelectionComponent(args, optionList);
12934
12966
  selectionComponent.appendTo('#' + args.elements.id);
12935
12967
  }
12968
+ // manual dropdown or zudf manual dropdown
12969
+ else if (fieldElementData['SelectOptions'] && Array.isArray(fieldElementData['SelectOptions'])) {
12970
+ // convert to property name used in the component rendering
12971
+ const optionList = [];
12972
+ fieldElementData['SelectOptions'].forEach((item) => {
12973
+ optionList.push({
12974
+ text: item['text'],
12975
+ value: item['value']
12976
+ });
12977
+ });
12978
+ const selectionComponent = this.generateSelectionComponent(args, optionList);
12979
+ selectionComponent.appendTo('#' + args.elements.id);
12980
+ }
12981
+ // zudf ResourceURL / Common Master dropdown
12936
12982
  else {
12937
12983
  const selectOptions = fieldElementData['SelectOptions'];
12938
12984
  const selectOptionsResourceURL = selectOptions['ResourceURL'];
12939
- const prefixResourceURLChecking = selectOptionsResourceURL + '_' + args.elements.id;
12940
- if (!this.loadedDropdownOptions.includes(prefixResourceURLChecking)) {
12941
- this.loadedDropdownOptions.push(prefixResourceURLChecking);
12942
- if (this.filters) {
12943
- selectOptions['Filters'] = this.filters;
12985
+ // ResourceURL dropdown
12986
+ if (selectOptionsResourceURL) {
12987
+ const prefixResourceURLChecking = selectOptionsResourceURL + '_' + args.elements.id;
12988
+ if (!this.loadedDropdownOptions.includes(prefixResourceURLChecking)) {
12989
+ this.loadedDropdownOptions.push(prefixResourceURLChecking);
12990
+ if (this.filters) {
12991
+ selectOptions['Filters'] = this.filters;
12992
+ }
12993
+ const param = Object.assign({}, DefaultPageSettingParams);
12994
+ param.pageSize = selectOptions['PageSize'];
12995
+ param.columns = selectOptions['Columns'];
12996
+ param.filters += selectOptions['Filters'];
12997
+ param.sortColumnName = selectOptions['SortColumnName'];
12998
+ param.sortOrder = selectOptions['SortOrder'];
12999
+ // Need delay 400ms if not 3rd segment (value) will not be rendered.
13000
+ this.webApiService.httpPost$(this.resourceApiService.getPageUrl(selectOptionsResourceURL), param).pipe(delay(400), map((resp) => {
13001
+ const optionList = [];
13002
+ resp.dataSet.forEach((item) => {
13003
+ optionList.push({
13004
+ text: item[selectOptions['Name']],
13005
+ value: item[selectOptions['Value']]
13006
+ });
13007
+ });
13008
+ const selectionComponent = this.generateSelectionComponent(args, optionList);
13009
+ selectionComponent.appendTo('#' + args.elements.id);
13010
+ //const xxx = document.getElementById(args.elements.id);
13011
+ ////xxx.appendChild(inputElement);
13012
+ //xxx.style.display = 'block';
13013
+ //#region used for updateSelectionOption
13014
+ const existingIndex = this.selectionComponentList.findIndex((item) => item.componentId === args.elements.id);
13015
+ if (existingIndex !== -1) {
13016
+ // Object with the same componentId exists, replace resourceUrl
13017
+ this.selectionComponentList[existingIndex].resourceUrl = selectOptionsResourceURL;
13018
+ }
13019
+ else {
13020
+ // Object with componentId doesn't exist, push a new object
13021
+ this.selectionComponentList.push({
13022
+ resourceUrl: selectOptionsResourceURL,
13023
+ componentId: args.elements.id
13024
+ });
13025
+ }
13026
+ //#endregion
13027
+ })).subscribe();
12944
13028
  }
12945
- const param = Object.assign({}, DefaultPageSettingParams);
12946
- param.pageSize = selectOptions['PageSize'];
12947
- param.columns = selectOptions['Columns'];
12948
- param.filters += selectOptions['Filters'];
12949
- param.sortColumnName = selectOptions['SortColumnName'];
12950
- param.sortOrder = selectOptions['SortOrder'];
12951
- this.webApiService.httpPost$(this.resourceApiService.getPageUrl(selectOptionsResourceURL), param).pipe(delay(300), map((resp) => {
13029
+ }
13030
+ // zudf Common Master dropdown
13031
+ else if (fieldElementData.zudfDataSourceType && fieldElementData.zudfDataSourceType === "resource") {
13032
+ // extract zudf_dropdown from session storage
13033
+ const zudf_dropdown = sessionStorage.getItem("zudf_dropdown") ? JSON.parse(sessionStorage.getItem("zudf_dropdown")) : null;
13034
+ if (zudf_dropdown) {
12952
13035
  const optionList = [];
12953
- resp.dataSet.forEach((item) => {
12954
- optionList.push({
12955
- text: item[selectOptions['Name']],
12956
- value: item[selectOptions['Value']]
12957
- });
13036
+ zudf_dropdown.forEach(res => {
13037
+ const name = res.text.split("Options")[0];
13038
+ if (fieldElementData.Label === name) {
13039
+ res.value.forEach(val => {
13040
+ optionList.push({
13041
+ text: val['Name'],
13042
+ value: val['Id']
13043
+ });
13044
+ });
13045
+ }
12958
13046
  });
12959
13047
  const selectionComponent = this.generateSelectionComponent(args, optionList);
12960
13048
  selectionComponent.appendTo('#' + args.elements.id);
12961
- const xxx = document.getElementById(args.elements.id);
12962
- //xxx.appendChild(inputElement);
12963
- xxx.style.display = 'block';
12964
- //#region used for updateSelectionOption
12965
- const existingIndex = this.selectionComponentList.findIndex((item) => item.componentId === args.elements.id);
12966
- if (existingIndex !== -1) {
12967
- // Object with the same componentId exists, replace resourceUrl
12968
- this.selectionComponentList[existingIndex].resourceUrl = selectOptionsResourceURL;
12969
- }
12970
- else {
12971
- // Object with componentId doesn't exist, push a new object
12972
- this.selectionComponentList.push({
12973
- resourceUrl: selectOptionsResourceURL,
12974
- componentId: args.elements.id
12975
- });
12976
- }
12977
- //#endregion
12978
- })).subscribe();
13049
+ }
13050
+ }
13051
+ // User List dropdown
13052
+ else if (fieldElementData.zudfDataSourceType && fieldElementData.zudfDataSourceType === "user") {
13053
+ const optionList = [];
13054
+ const userList = JSON.parse(sessionStorage?.getItem("userList") ?? 'null');
13055
+ //const arrayTest = userList.map(({ SelectionName, Id }) => ({ text: SelectionName, value: Id }));
13056
+ userList.forEach((item) => {
13057
+ optionList.push({
13058
+ text: item['SelectionName'],
13059
+ value: item['Id']
13060
+ });
13061
+ });
13062
+ const selectionComponent = this.generateSelectionComponent(args, optionList);
13063
+ selectionComponent.appendTo('#' + args.elements.id);
12979
13064
  }
12980
13065
  }
12981
13066
  } //end write
@@ -13077,10 +13162,10 @@ class SfquerybuilderComponent {
13077
13162
  const callFunc = eval('this.' + beforeLoadField);
13078
13163
  if (typeof callFunc === "function") {
13079
13164
  const newFunc = callFunc.bind(this);
13080
- return newFunc(event, this);
13165
+ return newFunc(event, this, fieldElementData);
13081
13166
  }
13082
13167
  }
13083
- return of(true);
13168
+ return of(fieldElementData);
13084
13169
  }
13085
13170
  }
13086
13171
  SfquerybuilderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: SfquerybuilderComponent, deps: [{ token: i2.FieldService }, { token: i2.ResourceApiService }, { token: i2.WebApiService }], target: i0.ɵɵFactoryTarget.Component });