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.
@@ -11786,11 +11786,11 @@ class ZudfComponent extends ContainerFieldBase {
11786
11786
  * @param group The ZGroup object to which the field elements will be added.
11787
11787
  * @param jsonString The JSON string representing the field elements.
11788
11788
  */
11789
- renderFieldElementByJsonString(group, jsonString) {
11789
+ renderFieldElementByJsonString(group, jsonString, fieldElementName = '') {
11790
11790
  // Parse the JSON string into an array of field elements.
11791
11791
  const fieldElementMasterCodeJsonArray = JSON.parse(jsonString);
11792
11792
  // Render the field elements.
11793
- this.renderFieldElement(fieldElementMasterCodeJsonArray);
11793
+ this.renderFieldElement(fieldElementMasterCodeJsonArray, fieldElementName);
11794
11794
  }
11795
11795
  //#region Display model
11796
11796
  /**
@@ -11884,7 +11884,7 @@ class ZudfComponent extends ContainerFieldBase {
11884
11884
  * Renders field elements as form controls in a new form group.
11885
11885
  * @param {any} fieldElements - The field elements to be rendered.
11886
11886
  */
11887
- renderFieldElement(fieldElements) {
11887
+ renderFieldElement(fieldElements, fieldElementName = '') {
11888
11888
  this.clearZModel();
11889
11889
  if (fieldElements) {
11890
11890
  this.loadedFieldsSequence = {};
@@ -11928,6 +11928,12 @@ class ZudfComponent extends ContainerFieldBase {
11928
11928
  }
11929
11929
  });
11930
11930
  }
11931
+ // need to call back field element "<field name>_loaded"
11932
+ if (fieldElementName != '') {
11933
+ if (this.group[fieldElementName + '_loaded']) {
11934
+ this.group[fieldElementName + '_loaded'](this.group);
11935
+ }
11936
+ }
11931
11937
  // To consider: Trigger the "onchange" event or perform any other necessary actions here
11932
11938
  });
11933
11939
  }
@@ -12075,7 +12081,6 @@ class ZudfComponent extends ContainerFieldBase {
12075
12081
  * @returns {void}
12076
12082
  */
12077
12083
  setFormFieldzModel(group = this.group, modelData) {
12078
- var _a;
12079
12084
  // Add the component prefix to the model data property names
12080
12085
  const patchedModelData = this.addZModelPropertyPrefix(modelData);
12081
12086
  // Update the zModel values of the form group
@@ -12085,16 +12090,15 @@ class ZudfComponent extends ContainerFieldBase {
12085
12090
  if (Array.isArray(patchedModelData[model])) {
12086
12091
  const gridValue = `${model}${this.prefixValueOption}`;
12087
12092
  const gridDataSource = `${model}${this.prefixDataSourceName}`;
12088
- // Check is it kcard, sometime can be dropdown.
12089
- const component = ZComponentHelper.getComponentByValue(this.group, model);
12090
- if (((_a = component === null || component === void 0 ? void 0 : component.data) === null || _a === void 0 ? void 0 : _a.Type) === 'kcard') {
12091
- // Update the data source for the grid
12092
- group[gridDataSource] = patchedModelData[model];
12093
- // Update the grid value
12094
- if (group[gridValue]) {
12095
- group[gridValue].setData(group[gridDataSource]);
12096
- }
12093
+ //const component = ZComponentHelper.getComponentByValue(this.group, model);
12094
+ //if (component?.data?.Type === 'kcard' || component?.data?.Type === 'zgrid') {
12095
+ // Update the data source for the grid
12096
+ group[gridDataSource] = patchedModelData[model];
12097
+ // Update the grid value
12098
+ if (group[gridValue]) {
12099
+ group[gridValue].setData(group[gridDataSource]);
12097
12100
  }
12101
+ //}
12098
12102
  }
12099
12103
  }
12100
12104
  // Update the form group model
@@ -12766,8 +12770,11 @@ class SfquerybuilderComponent {
12766
12770
  this.inOperators = ['in', 'notin'];
12767
12771
  this.dropdownOperators = [
12768
12772
  this.equalOperator,
12773
+ this.notequalOperator,
12769
12774
  this.inOperator,
12770
- this.notinOperator
12775
+ this.notinOperator,
12776
+ this.isnullOperator,
12777
+ this.isnotnullOperator
12771
12778
  ];
12772
12779
  this.stringOperators = [
12773
12780
  this.equalOperator,
@@ -12786,7 +12793,9 @@ class SfquerybuilderComponent {
12786
12793
  this.greaterthanOperator,
12787
12794
  this.greaterthanorequalOperator,
12788
12795
  this.lessthanOperator,
12789
- this.lessthanorequalOperator
12796
+ this.lessthanorequalOperator,
12797
+ this.isnullOperator,
12798
+ this.isnotnullOperator
12790
12799
  ];
12791
12800
  this.dateOperators = [
12792
12801
  this.equalOperator,
@@ -12794,16 +12803,26 @@ class SfquerybuilderComponent {
12794
12803
  this.greaterthanOperator,
12795
12804
  this.greaterthanorequalOperator,
12796
12805
  this.lessthanOperator,
12797
- this.lessthanorequalOperator
12806
+ this.lessthanorequalOperator,
12807
+ this.isnullOperator,
12808
+ this.isnotnullOperator
12809
+ ];
12810
+ this.booleanOperators = [
12811
+ this.equalOperator,
12812
+ this.notequalOperator,
12813
+ this.isnullOperator,
12814
+ this.isnotnullOperator
12798
12815
  ];
12799
12816
  this.selectionComponentList = [];
12800
12817
  }
12801
12818
  ngOnInit() {
12802
12819
  ZComponentHelper.setComponentProperties(this);
12803
12820
  ZComponentHelper.registerComponent(this);
12804
- of(true).pipe(switchMap$1(cont => {
12821
+ of(true).pipe(switchMap$1(_ => {
12805
12822
  return this.beforeLoadField(this.data);
12806
- }), switchMap$1(cont2 => {
12823
+ }), tap$1(data => {
12824
+ this.data = data;
12825
+ }), switchMap$1(_ => {
12807
12826
  return this.loadQueryBuilder();
12808
12827
  })).subscribe(() => {
12809
12828
  // Where to update operator syntax
@@ -12825,67 +12844,81 @@ class SfquerybuilderComponent {
12825
12844
  }
12826
12845
  this.fields = this.fieldService.getFormFieldCode(this.data.Value, "FormField", null, null);
12827
12846
  try {
12847
+ let isGrouped = true;
12828
12848
  return this.fields.pipe(tap$1((data) => {
12849
+ // if [isGrouped = true] include grouping name as prefix
12850
+ if (data.length > 1) {
12851
+ isGrouped = false;
12852
+ }
12829
12853
  data.forEach((field) => __awaiter(this, void 0, void 0, function* () {
12830
- //sf //todo: later change to base on other attribute single or multi select for field element
12831
- if (field.Type == 'category' || field.Type == 'multiselect') {
12832
- this.sdFilter.push({
12833
- field: field.Value,
12834
- label: field.Name,
12835
- type: 'string',
12836
- operators: this.dropdownOperators,
12837
- template: yield this.generateColumnSelection(field),
12838
- });
12839
- }
12840
- else if (field.Type === 'string') {
12841
- this.sdFilter.push({
12842
- field: field.Value,
12843
- label: field.Name,
12844
- operators: this.stringOperators,
12845
- type: 'string'
12846
- });
12847
- }
12848
- else if (field.Type === 'date') {
12849
- this.sdFilter.push({
12850
- field: field.Value,
12851
- label: field.Name,
12852
- operators: this.dateOperators,
12853
- type: 'date'
12854
- });
12855
- }
12856
- else if (field.Type === 'number') {
12857
- this.sdFilter.push({
12858
- field: field.Value,
12859
- label: field.Name,
12860
- operators: this.integerOperators,
12861
- type: 'number'
12862
- });
12863
- }
12864
- else if (field.Value === 'boolean') {
12865
- this.sdFilter.push({
12866
- field: field.Value,
12867
- label: field.Name,
12868
- type: 'boolean',
12869
- template: yield this.generateColumnCheckbox(field.Name, false)
12870
- });
12871
- }
12872
- else {
12873
- this.sdFilter.push({
12874
- field: field.Value,
12875
- label: field.Name,
12876
- type: 'string',
12877
- operators: this.stringOperators,
12878
- });
12879
- }
12854
+ this.renderComponentType(field, isGrouped);
12880
12855
  })); //end foreach
12881
12856
  this.issfLoaded = true;
12882
12857
  }));
12858
+ return of(true);
12883
12859
  }
12884
12860
  catch (error) {
12885
12861
  console.error("error: ", error);
12886
12862
  return of(false);
12887
12863
  }
12888
12864
  }
12865
+ renderComponentType(field, isGrouped, fieldTitle) {
12866
+ var _a;
12867
+ return __awaiter(this, void 0, void 0, function* () {
12868
+ let componentLabel = field.SubType ? field.Label : (_a = field.Label) !== null && _a !== void 0 ? _a : field.Name;
12869
+ componentLabel = !isGrouped && !ZComponentHelper.isNullUndefinedEmpty(fieldTitle) ? "[" + fieldTitle + "] " + field.Label : !ZComponentHelper.isNullUndefinedEmpty(field.Label) ? field.Label : field.Name;
12870
+ let componentField = !ZComponentHelper.isNullUndefinedEmpty(fieldTitle) ? fieldTitle + "_" + field.Value : field.Value;
12871
+ if (field.Type === 'category' || field.Type === 'multiselect' || field.Type === 'zuiselectmultiple') {
12872
+ this.sdFilter.push({
12873
+ field: componentField,
12874
+ label: componentLabel,
12875
+ type: 'string',
12876
+ operators: this.dropdownOperators,
12877
+ template: yield this.generateColumnSelection(field),
12878
+ });
12879
+ }
12880
+ else if (field.Type === 'date') {
12881
+ this.sdFilter.push({
12882
+ field: componentField,
12883
+ label: componentLabel,
12884
+ operators: this.dateOperators,
12885
+ type: 'date'
12886
+ });
12887
+ }
12888
+ else if (field.Type === 'number') {
12889
+ this.sdFilter.push({
12890
+ field: componentField,
12891
+ label: componentLabel,
12892
+ operators: this.integerOperators,
12893
+ type: 'number'
12894
+ });
12895
+ }
12896
+ else if (field.Value === 'boolean') {
12897
+ this.sdFilter.push({
12898
+ field: componentField,
12899
+ label: componentLabel,
12900
+ type: 'boolean',
12901
+ operators: this.booleanOperators,
12902
+ template: yield this.generateColumnCheckbox(field.Name, false)
12903
+ });
12904
+ }
12905
+ else if (field.Type === 'kcard') {
12906
+ if (field.Value.length > 0) {
12907
+ field.Value.forEach((item) => __awaiter(this, void 0, void 0, function* () {
12908
+ this.renderComponentType(item, isGrouped, field.Title);
12909
+ }));
12910
+ }
12911
+ }
12912
+ else {
12913
+ this.sdFilter.push({
12914
+ field: componentField,
12915
+ label: componentLabel,
12916
+ operators: this.stringOperators,
12917
+ type: 'string'
12918
+ });
12919
+ }
12920
+ });
12921
+ }
12889
12922
  //#region checkbox
12890
12923
  generateColumnCheckbox(label, value) {
12891
12924
  return {
@@ -12917,7 +12950,8 @@ class SfquerybuilderComponent {
12917
12950
  if (this.data['Filters']) {
12918
12951
  this.filters = ZComponentHelper.getGroupEvalValue.call(this, this.data['Filters'], this.group);
12919
12952
  }
12920
- return createElement('input', { attrs: { 'type': 'text', 'style': 'display: none' } }); //createElement('input', { attrs: { 'type': 'text' } });
12953
+ //return createElement('input', { attrs: { 'type': 'text', 'style': 'display: none' } });
12954
+ return createElement('input', { attrs: { 'type': 'text' } });
12921
12955
  },
12922
12956
  // Destroy the custom component
12923
12957
  destroy: (args) => {
@@ -12942,6 +12976,7 @@ class SfquerybuilderComponent {
12942
12976
  },
12943
12977
  // Wire events for the custom component.
12944
12978
  write: (args) => {
12979
+ var _a;
12945
12980
  //origin
12946
12981
  if (fieldElementData['ValueOptions']) {
12947
12982
  // convert to property name used in the component rendering
@@ -12955,49 +12990,102 @@ class SfquerybuilderComponent {
12955
12990
  const selectionComponent = this.generateSelectionComponent(args, optionList);
12956
12991
  selectionComponent.appendTo('#' + args.elements.id);
12957
12992
  }
12993
+ // manual dropdown or zudf manual dropdown
12994
+ else if (fieldElementData['SelectOptions'] && Array.isArray(fieldElementData['SelectOptions'])) {
12995
+ // convert to property name used in the component rendering
12996
+ const optionList = [];
12997
+ fieldElementData['SelectOptions'].forEach((item) => {
12998
+ optionList.push({
12999
+ text: item['text'],
13000
+ value: item['value']
13001
+ });
13002
+ });
13003
+ const selectionComponent = this.generateSelectionComponent(args, optionList);
13004
+ selectionComponent.appendTo('#' + args.elements.id);
13005
+ }
13006
+ // zudf ResourceURL / Common Master dropdown
12958
13007
  else {
12959
13008
  const selectOptions = fieldElementData['SelectOptions'];
12960
13009
  const selectOptionsResourceURL = selectOptions['ResourceURL'];
12961
- const prefixResourceURLChecking = selectOptionsResourceURL + '_' + args.elements.id;
12962
- if (!this.loadedDropdownOptions.includes(prefixResourceURLChecking)) {
12963
- this.loadedDropdownOptions.push(prefixResourceURLChecking);
12964
- if (this.filters) {
12965
- selectOptions['Filters'] = this.filters;
13010
+ // ResourceURL dropdown
13011
+ if (selectOptionsResourceURL) {
13012
+ const prefixResourceURLChecking = selectOptionsResourceURL + '_' + args.elements.id;
13013
+ if (!this.loadedDropdownOptions.includes(prefixResourceURLChecking)) {
13014
+ this.loadedDropdownOptions.push(prefixResourceURLChecking);
13015
+ if (this.filters) {
13016
+ selectOptions['Filters'] = this.filters;
13017
+ }
13018
+ const param = Object.assign({}, DefaultPageSettingParams);
13019
+ param.pageSize = selectOptions['PageSize'];
13020
+ param.columns = selectOptions['Columns'];
13021
+ param.filters += selectOptions['Filters'];
13022
+ param.sortColumnName = selectOptions['SortColumnName'];
13023
+ param.sortOrder = selectOptions['SortOrder'];
13024
+ // Need delay 400ms if not 3rd segment (value) will not be rendered.
13025
+ this.webApiService.httpPost$(this.resourceApiService.getPageUrl(selectOptionsResourceURL), param).pipe(delay(400), map((resp) => {
13026
+ const optionList = [];
13027
+ resp.dataSet.forEach((item) => {
13028
+ optionList.push({
13029
+ text: item[selectOptions['Name']],
13030
+ value: item[selectOptions['Value']]
13031
+ });
13032
+ });
13033
+ const selectionComponent = this.generateSelectionComponent(args, optionList);
13034
+ selectionComponent.appendTo('#' + args.elements.id);
13035
+ //const xxx = document.getElementById(args.elements.id);
13036
+ ////xxx.appendChild(inputElement);
13037
+ //xxx.style.display = 'block';
13038
+ //#region used for updateSelectionOption
13039
+ const existingIndex = this.selectionComponentList.findIndex((item) => item.componentId === args.elements.id);
13040
+ if (existingIndex !== -1) {
13041
+ // Object with the same componentId exists, replace resourceUrl
13042
+ this.selectionComponentList[existingIndex].resourceUrl = selectOptionsResourceURL;
13043
+ }
13044
+ else {
13045
+ // Object with componentId doesn't exist, push a new object
13046
+ this.selectionComponentList.push({
13047
+ resourceUrl: selectOptionsResourceURL,
13048
+ componentId: args.elements.id
13049
+ });
13050
+ }
13051
+ //#endregion
13052
+ })).subscribe();
12966
13053
  }
12967
- const param = Object.assign({}, DefaultPageSettingParams);
12968
- param.pageSize = selectOptions['PageSize'];
12969
- param.columns = selectOptions['Columns'];
12970
- param.filters += selectOptions['Filters'];
12971
- param.sortColumnName = selectOptions['SortColumnName'];
12972
- param.sortOrder = selectOptions['SortOrder'];
12973
- this.webApiService.httpPost$(this.resourceApiService.getPageUrl(selectOptionsResourceURL), param).pipe(delay(300), map((resp) => {
13054
+ }
13055
+ // zudf Common Master dropdown
13056
+ else if (fieldElementData.zudfDataSourceType && fieldElementData.zudfDataSourceType === "resource") {
13057
+ // extract zudf_dropdown from session storage
13058
+ const zudf_dropdown = sessionStorage.getItem("zudf_dropdown") ? JSON.parse(sessionStorage.getItem("zudf_dropdown")) : null;
13059
+ if (zudf_dropdown) {
12974
13060
  const optionList = [];
12975
- resp.dataSet.forEach((item) => {
12976
- optionList.push({
12977
- text: item[selectOptions['Name']],
12978
- value: item[selectOptions['Value']]
12979
- });
13061
+ zudf_dropdown.forEach(res => {
13062
+ const name = res.text.split("Options")[0];
13063
+ if (fieldElementData.Label === name) {
13064
+ res.value.forEach(val => {
13065
+ optionList.push({
13066
+ text: val['Name'],
13067
+ value: val['Id']
13068
+ });
13069
+ });
13070
+ }
12980
13071
  });
12981
13072
  const selectionComponent = this.generateSelectionComponent(args, optionList);
12982
13073
  selectionComponent.appendTo('#' + args.elements.id);
12983
- const xxx = document.getElementById(args.elements.id);
12984
- //xxx.appendChild(inputElement);
12985
- xxx.style.display = 'block';
12986
- //#region used for updateSelectionOption
12987
- const existingIndex = this.selectionComponentList.findIndex((item) => item.componentId === args.elements.id);
12988
- if (existingIndex !== -1) {
12989
- // Object with the same componentId exists, replace resourceUrl
12990
- this.selectionComponentList[existingIndex].resourceUrl = selectOptionsResourceURL;
12991
- }
12992
- else {
12993
- // Object with componentId doesn't exist, push a new object
12994
- this.selectionComponentList.push({
12995
- resourceUrl: selectOptionsResourceURL,
12996
- componentId: args.elements.id
12997
- });
12998
- }
12999
- //#endregion
13000
- })).subscribe();
13074
+ }
13075
+ }
13076
+ // User List dropdown
13077
+ else if (fieldElementData.zudfDataSourceType && fieldElementData.zudfDataSourceType === "user") {
13078
+ const optionList = [];
13079
+ const userList = JSON.parse((_a = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem("userList")) !== null && _a !== void 0 ? _a : 'null');
13080
+ //const arrayTest = userList.map(({ SelectionName, Id }) => ({ text: SelectionName, value: Id }));
13081
+ userList.forEach((item) => {
13082
+ optionList.push({
13083
+ text: item['SelectionName'],
13084
+ value: item['Id']
13085
+ });
13086
+ });
13087
+ const selectionComponent = this.generateSelectionComponent(args, optionList);
13088
+ selectionComponent.appendTo('#' + args.elements.id);
13001
13089
  }
13002
13090
  }
13003
13091
  } //end write
@@ -13099,10 +13187,10 @@ class SfquerybuilderComponent {
13099
13187
  const callFunc = eval('this.' + beforeLoadField);
13100
13188
  if (typeof callFunc === "function") {
13101
13189
  const newFunc = callFunc.bind(this);
13102
- return newFunc(event, this);
13190
+ return newFunc(event, this, fieldElementData);
13103
13191
  }
13104
13192
  }
13105
- return of(true);
13193
+ return of(fieldElementData);
13106
13194
  }
13107
13195
  }
13108
13196
  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 });