2025-04-14 - Frontend LinkPath structure for tableOutput

From Izara Wiki
Jump to navigation Jump to search

Service - Search Results

Overview

Structure frontend TableConfig and Output prepare for shared library that creates complexFilter and requestProperties

Example params in tableConfig

let paramFromTableOutput = {

	// .. other properties same as params sent to backend
	// requiredDataFields not needed in tableConfig as referenced in elements and sortFields
	// header/footer filterDataField elements reference valueUserTag

	"elements": {
		// shared types
		"elementId12":{
			"elementType": "freetext",
			"value": "aa"
		}

		// headerFooter types
		"elementId1":{
			"elementType": "valueUserTag",
			"valueUserTag": "userTag_9",
			"inputType": "text" // || "select" || "checkbox" || "radio" ,
		},
		"elementId2":{
			"elementType": "valueUserTag",
			"inputType": "select",
			"options": [
	         {
               optionText:"option1",
               valueUserTag:{ 
                 userTag_1:"valueA", //value not ref valueUserTag
                 userTag_2:"valueB" 
              },
	         {
               optionText:"option2",
               valueUserTag:{ 
                 userTag_9:"valueC" 

              },
			],
		},
        "elementId21":{
			"elementType": "valueUserTag",
			"inputType": "checkbox",
			"onSetting:{
               optionText:"on",
               valueUserTag:{ 
                 userTag_1:"valueA", //value not ref valueUserTag
                 userTag_2:"valueB" 

              },
             },
             "offSetting":{
               optionText:"off",
               valueUserTag:{ 
                 userTag_9:"valueC" 

              },
             },
		   
           
		},
		"elementId3":{
			"elementType": "sort",
			"display": "downArrow", // || upArrow
			"requiredDataLinkStepObjectId": "userTag_LinkStepObjectC",
			"dataType": "number", // "number" | "string"
			"sortOrder": "ascending" // "ascending"|"descending" (default ascending)
		},
		"elementId4":{
			"elementType": "numberOfRows",
			"inputType": "text" // || "select" || "checkbox" || "radio" ,
		},
		"elementId5":{
			"elementType":"numberOfRows",
			"inputType": "select",
			"options": [
	         {
               optionText:"page5",
               value:5
             },
	       	 {
               optionText:"page7",
               value:7
             },
			],
		},
		"elementId6":{
			"elementType": "submit",
			"display": "submit", // any text to be shown
			"sendRequest": ["sort", "numberOfRows", "filter"] 
		},
		"elementId7":{
			"elementType": "reset",
			"display": "reset rows", // any text to be shown
			"sendRequest": ["sort", "numberOfRows", "filter"] 
		},
		"elementId9":{
			"elementType": "totalDatafield",
			"requiredDataLinkStepObjectId": "link1",
			"showIfNotAllRowsLoaded": true // || false
		},
		"elementId11":{
			// will need to link to per record check box
			"elementType": "bulkAction",
			"action": "on" // on | off | switch
			"bulkActionUserTag": "tagA", // have normalized list of bulkActionTags, with list of "bulkAction" and "bulkActionCheckBox" elements linked to it
		},
		"elementId8":{
			"elementType": "pageNumbers",
			"linksAfter": [
				{
					"action": "jumpNumberOfPages",
					"jumpPages": 7,
					"string": ".."
				},
				{
					"action": "jumpNumberOfPages",
					"jumpPages": 1,
					"string": ">"
				},
				{
					"action": "goToLastPage",
					"hideWhenLastPageShown": true,
					"string": ">>"
				}
			],
			"linksBefore": [
				{
					"action": "goToFirstPage",
					"hideWhenFirstPageShown": true,
					"string": "<<"
				},
				{
					"action": "jumpNumberOfPages",
					"jumpPages": 1,
					"string": "<"
				},
				{
					"action": "jumpNumberOfPages",
					"jumpPages": 7,
					"string": ".."
				}
			],
			"showPagesAfter": 3,
			"showPagesBefore": 3
		},
		
		// records types    
		"elementId5":{
			"elementType": "requiredDataLinkStepObject", // in record
			"requiredDataLinkStepObjectId": "link1",
		},
		"elementIdxx":{
			"elementType": "bulkActionCheckBox",
			"bulkActionUserTag": "tagA",
		},
	},
	
	valueUserTags: {
		// values are shared between requestProperties and filter values. This set can be iterated to overwrite values using userTag to identify
		userTag_1:{
			defaultValue: "xx",
		},
		userTag_2:{
			defaultValue: "xx",
		},
		userTag_3:{
			defaultValue: "xx",
		},
		userTag_4:{
			defaultValue: "xx",
		},
		userTag_5:{
			defaultValue: "xx",
		},
		userTag_6:{
			valueSource: "complexFilterCombination",
            complexFilterCombinationId: "hash_complexFilterCombinationA",
		},
		userTag_7:{
			valueSource: "perParentCombination",
            perParentCombinationId: "hash_perParentCombinationA",
		},
        userTag_8: {
            valueSource: 'perParentIdentifier',
            perParentIdentifierFieldname: 'sellOfferId'
        },,
		userTag_9:{
			defaultValue: "xx",
		},
		userTag_10:{
			defaultValue: "xx",
		},
		userTag_11:{
			defaultValue: "xx",
		},
	},

	bulkActionUserTags: {
		tagA:{
			bulkActions: [
                "elementId11",
                // ...
            ],
            bulkActionCheckBoxes: [
                "elementIdxx",
                // ...
            ],
		},
        // ...
	},

}

Example params sent to backend

let paramFromTableOutput = {
  objType: { //* main objType
    serviceTag: "ProductManager",
    objectType: "Product"
  },
  initialLogicalElementId: "uuid_openBracket_1",
  logicalElements: {
    uuid_openBracket_1: {
      logicalElementType: "openBracket",
      previousLogicalElementId: null,
      nextLogicalElementId: "uuid_logical_1",
    },
    uuid_logical_1: {
      logicalElementType: "logical",
      previousLogicalElementId: "uuid_openBracket_1",
      nextLogicalElementId: "uuid_operation_1",

      objType: {
        serviceTag: "ProductManager",
        objectType: "product"
      },
      partitionKeyValueUserTags: {
        productId: "valueUserTag_1",
      },
      // sortKeyValueUserTags: {
      //    productId: "valueB",
      // },
      // comparison: "equals",
      // conditionalFieldValues: [
      //  {
      //    fieldName: "language",
      //   includeValueUserTags: ["th"],
      //    // excludeValueUserTags: ["xx","sdd"]
      //  }
      // ]
    },
    uuid_operation_1: {
      logicalElementType: "operation",
      previousLogicalElementId: "uuid_logical_1",
      nextLogicalElementId: "uuid_childComplexFilter_1",
      operation: "OR"
    },
    uuid_childComplexFilter_1: {
      logicalElementType: "childComplexFilter",
      previousLogicalElementId: "uuid_operation_1",
      nextLogicalElementId: "uuid_closeBracket_1",

      objType: {
        serviceTag: "ProductManager",
        objectType: "product"
      },
      pathLinkType: {
        relType: {
          serviceTag: "SellOfferManager",
          relationshipTag: "hasSellOffer",
        },
        objType: {
          serviceTag: "SellOfferManager",
          objectType: "sellOffer",
        },
        direction: "to",
      },
      childLogicalElementId: "uuid_logical_2",
    },
    uuid_logical_2: {
      logicalElementType: "logical",
      previousLogicalElementId: "uuid_childComplexFilter_1",
      nextLogicalElementId: null,

      objType: {
        serviceTag: "SellOfferManager",
        objectType: "sellOffer",
      },
      partitionKeyValueUserTags: {
        sellOfferId: "valueUserTag_2",
      },
      // sortKeyValueUserTags: {
      //    productId: "valueB",
      // },
      // comparison: "equals",
      // conditionalFieldValues: [
      //  {
      //    fieldName: "language",
      //   includeValueUserTags: ["th"],
      //    // excludeValueUserTags: ["xx","sdd"]
      //  }
      // ]
    },
    uuid_closeBracket_1: {
      logicalElementType: "closeBracket",
      previousLogicalElementId: "uuid_childComplexFilter_1",
      nextLogicalElementId: "uuid_operation_2",
    },
    uuid_operation_2: {
      logicalElementType: "operation",
      previousLogicalElementId: "uuid_closeBracket_1",
      nextLogicalElementId: "uuid_translateIds_1",
      operation: "AND"
    },
    uuid_translateIds_1: {
      logicalElementType: "translateIds",
      previousLogicalElementId: "uuid_operation_2",
      nextLogicalElementId: "uuid_operation_3",
      objType: {
        objectType: "product",
        serviceTag: "ProductManager",
      },
      pathLinkType: {
        objType: {
          objectType: "sellOffer",
          serviceTag: "SellOfferManager",
        },
        relType: {
          relationshipTag: "hasSellOffer",
          serviceTag: "SellOfferManager"
        },
        direction: "to"
      },
      requestProperties: {
        tag_xxxx: "valueUserTag_5"
      },
      childIdentifiers: [
        {
          sellOfferId: "valueUserTag_3"
        },
        {
          sellOfferId: "valueUserTag_4"
        },
      ]
    },
    uuid_operation_3: {
      logicalElementType: "operation",
      previousLogicalElementId: "uuid_translateIds_1",
      nextLogicalElementId: "uuid_traversal_1",
      operation: "AND"
    },
    uuid_traversal_1: {
      logicalElementType: "traversal",
      previousLogicalElementId: "uuid_operation_3",
      nextLogicalElementId: null,

      objType: {
        objectType: "product",
        serviceTag: "ProductManager",
      },
      traversalSteps: [
        "hash_traversal_1",
        "hash_traversal_2",
        "hash_traversal_3",
      ]
    }
  },
  traversalSteps: {
    hash_traversal_1: {
      pathLinkType: {
        objType: {
          serviceTag: "SellOfferManager",
          objectType: "sellOffer"
        },
        relType: {
          serviceTag: "SellOfferManager",
          relationshipTag: "hasSellOffer"
        },
        direction: "to"
      },

      //* setting of traversal step
      fieldValueUserTags: [
        {
          productId: "valueUserTag_6"
        },
      ],  //optional, if this step is not last step
      relationshipProperties: {
        // timestamp: 1231456 //or will ref value???? ====> not sure?
        timestamp: "valueUserTag_7"
      },
      hopsPassObjType: true, //optional //* สามารถ hops ได้ทุก step ยกเว้น step สุดท้าย = traversal_5
      hopsStart: 1, //optional default: 1
      hopsEnd: 10, //optional
    },
    hash_traversal_2: {
      pathLinkType: {
        objType: {
          serviceTag: "SellOfferPlan",
          objectType: "sellOfferPlan"
        },
        relType: {
          serviceTag: "SellOfferManager",
          relationshipTag: "usesSellOfferPlan"
        },
        direction: "to"
      },
      fieldValueUserTags: [
        {
          sellOfferId: "valueUserTag_8"
        },
      ],//optional
      //* traversal before last traversal cannot set hopsPassObjType = true
      hopsEnd: 10, //optional
    },
    hash_traversal_3: {
      fieldValueUserTags: [
        {
          sellOfferPlanId: "valueUserTag_9"
        },
        {
          currencyId: "valueUserTag_10"
        },
        {
          sellOfferPlanId: "valueUserTag_11"
        }
      ]
    },
    hash_traversal_combinationComplexFilter_1: {
      pathLinkType: {
        objType: {
          serviceTag: "Locations",
          objectType: "localtionLink"
        },
        relType: {
          serviceTag: "Locations",
          relationshipTag: "hasLocationLink"
        },
        direction: "to"
      },
      //* setting of traversal step
      hopsPassObjType: true, //optional //* สามารถ hops ได้ทุก step ยกเว้น step สุดท้าย = traversal_5
      hopsStart: 1, //optional default: 1
      hopsEnd: 10, //optional

    },
    hash_traversal_combinationComplexFilter_2: {
      pathLinkType: {
        objType: {
          serviceTag: "Locations",
          objectType: "locationNode"
        },
        relType: {
          serviceTag: "Locations",
          relationshipTag: "isLocationNode"
        },
        direction: "to"
      },
      hopsEnd: 10, //optional
    },
    hash_traversal_combinationComplexFilter_3: {
      fieldValueUserTags: [
        {
          locationNodeId: "valueUserTag_21"
        },
        {
          locationNodeId: "valueUserTag_22"
        }
      ]
    }
  },
  requiredDataFields: [ //* linkStepObjects to create main sort result's requiredData and sortFields
    // not needed at tableConfig level because can be built from table's elements and sortFields before sending to lib that converts to backend structure
    "userTag_LinkStepObjectA", // no link, field in main objType (structure same linkPath but only one step)
    "userTag_LinkStepObjectB", // has link
  ],
  complexFilterCombinations: {
    hash_complexFilterCombinationA: {
      objType: {
        serviceTag: "Locations",
        objectType: "locationNode"
      },
      initialLogicalElementId: "hash_traversal_combinationComplexFilter",
      logicalElements: {
        //*traversal
        hash_traversal_combinationComplexFilter: {
          logicalElementType: "traversal",
          previousLogicalElementId: null,
          nextLogicalElementId: null,

          objType: {
            objectType: "locationNode",
            serviceTag: "Locations",
          },
          traversalSteps: [
            "hash_traversal_combinationComplexFilter_1",
            "hash_traversal_combinationComplexFilter_2",
            "hash_traversal_combinationComplexFilter_3",
          ]
        }
      },
    },
  },
  perParentCombinations: {
    hash_perParentCombinationA: {
      objType: {
        serviceTag: "SellOfferPlan",
        objectType: "sellOfferPlan"
      },
      initialLogicalElementId: "child_complexFilter_1",
      logicalElements: {
        child_complexFilter_1: {
          logicalElementType: "childComplexFilter",
          previousLogicalElementId: null,
          nextLogicalElementId: null,

          childLogicalElementId: "logical_sellOffer",
          objType: {
            serviceTag: "SellOfferPlan",
            objectType: "sellOfferPlan"
          },
          pathLinkType: {
            objType: {
              serviceTag: "SellOfferManager",
              objectType: "sellOffer"
            },
            relType: {
              serviceTag: "SellOfferManager",
              relationshipTag: "usesSellOfferPlan"
            },
            direction: "to"
          },
          requestProperties: {
            tag_orderQuantity: "valueUserTag_13"
          }
        },
        logical_sellOffer: {
          logicalElementType: "logical",
          previousLogicalElementId: "child_complexFilter_1",
          nextLogicalElementId: null,

          objType: {
            serviceTag: "SellOfferManager",
            objectType: "sellOffer"
          },
          partitionKeyValueUserTags: {
            sellOfferId: "valueUserTag_14",
          },
          // sortKeyValueUserTags: {
          //    productId: "valueB",
          // },
          // comparison: "equals",
          // conditionalFieldValues: [
          //  {
          //    fieldName: "language",
          //   includeValueUserTags: ["th"],
          //    // excludeValueUserTags: ["xx","sdd"]
          //  }
          // ]
        }
      }
    },
  },
  requiredDataLinkStepObjects: {
    userTag_LinkStepObjectA: { //* requiredData no linkPath
      initialObjType: { //* main objType
        serviceTag: "ProductManager",
        objectType: "Product"
      },
      linkSteps: ["hash_linkStepA_1"],
    },
    userTag_LinkStepObjectB: { // requiredDataFields for finding max orderTotal
      initialObjType: { //* main objType
        serviceTag: "ProductManager",
        objectType: "Product"
      },
      linkSteps: ["hash_linkStepB_1", "hash_linkStepB_2", "hash_linkStepB_3"],
    }
    // userTag_LinkStepObjectC
    // userTag_LinkStepObjectD
  },
  requiredDataLinkSteps: {
    hash_linkStepA_1: {
      fieldName: "xxx"
    },
    hash_linkStepB_1: {
      pathLinkType: {
        objType: {
          serviceTag: "SellOfferManager",
          objectType: "SellOffer"
        },
        relType: {
          serviceTag: "ProductManager",
          relationshipTag: "hasSellOffer"
        },
        direction: "to",
      },
      addFilterMain: true, //default: false => need to add filterMain set = true
      filterElements: { //* filter in linkPath
        objType: {
          serviceTag: "SellOfferManager",
          objectType: "SellOffer"
        },
        initialLogicalElementId: "logical_sellOffer_in_link",
        logicalElements: {
          logical_sellOffer_in_link: {
            logicalElementType: "logical",
            previousLogicalElementId: null,
            nextLogicalElementId: null,

            objType: {
              serviceTag: "SellOfferManager",
              objectType: "SellOffer"
            },
            partitionKeyValueUserTags: {
              sellOfferId: "valueUserTag_14",
            },
            // sortKeyValueUserTags: {
            //    productId: "valueUserTag_1",
            // },
            // comparison: "equals",
            conditionalFieldValues: [
              {
                fieldName: "userId",
                includeValueUserTags: ["valueUserTag_15"], //
                // excludeValueUserTags: ["xx","sdd"]
              }
            ]
          }
        }
      },

    },
    hash_linkStepB_2: {
      pathLinkType: {
        objType: {
          serviceTag: "OrderPrice",
          objectType: "OrderPrice"
        },
        relType: {
          serviceTag: "sellOfferStandard",
          relationshipTag: "hasOrderPrice"
        },
        direction: "to",
      },
      requestProperties: {
        tag_deliverTo: "valueUserTag_16",
        tag_sellOfferPlan: "valueUserTag_17",
        // tag_sellOfferPlanDeliveryMethodLink: "valueUserTag_18",
        // tag_sellOfferPlanUserPaymentMethodLink: "valueUserTag_19"
      },
      aggregate: "max",
      sortFields: [
        {
          requiredDataLinkStepObjectId: "userTag_LinkStepObjectC",
          dataType: "number",
          sortOrder: "ascending" | "descending"
        },
        {
          requiredDataLinkStepObjectId: "userTag_LinkStepObjectD",
          dataType: "string",
          sortOrder: "ascending" | "descending"
        },
        {
          requiredDataLinkStepObjectId: "userTag_LinkStepObjectD",
          dataType: "array",
          sortByValueUserTags: ["valueUserTag_1", "valueUserTag_2"],
          sortOrder: "ascending" | "descending"
        }
      ],
      comparison: "greaterThan",
      comparisonSortField: "upToValue",
      comparisonSortDataType: "string",
      comparisonValue: "valueUserTag_20",
    },
    hash_linkStepB_3: {
      fieldName: "zzz",
    }
  },
  sortFields: [
    {
      requiredDataLinkStepObjectId: "userTag_LinkStepObjectB",
      dataType: "number",
      sortOrder: "ascending" | "descending"
    },
    {
      requiredDataLinkStepObjectId: "userTag_LinkStepObjectA",
      dataType: "string",
      sortOrder: "ascending" | "descending"
    },
    {
      requiredDataLinkStepObjectId: "userTag_LinkStepObjectD",
      dataType: "array",
      sortByValueUserTags: ["valueUserTag_1", "valueUserTag_2"],
      sortOrder: "ascending" | "descending"
    }
  ],
  valueUserTags: {
    valueUserTag_1: {
      value: "1111",
    },
    valueUserTag_2: {
      value: "2222",
    },
    valueUserTag_3: {
      value: "3333",
    },
    valueUserTag_4: {
      value: "4444",
    },
    valueUserTag_5: {
      value: "5555",
    },
    valueUserTag_6: {
      value: "6666",
    },
    valueUserTag_7: {
      value: "7777",
    },
    valueUserTag_8: {
      value: "8888",
    },
    valueUserTag_9: {
      value: "9999",
    },
    valueUserTag_10: {
      value: "1010",
    },
    valueUserTag_11: {
      value: "1110",
    },
    valueUserTag_12: {
      value: "1212",
    },
    valueUserTag_13: {
      value: "1313",
    },
    valueUserTag_14: {
      valueSource: 'perParentIdentifier',
      perParentIdentifierFieldname: 'sellOfferId'
    },
    valueUserTag_15: {
      value: "praewDev"
    },
    valueUserTag_16: {
      valueSource: "complexFilterCombination",
      complexFilterCombinationId: "hash_complexFilterCombinationA",
    },
    valueUserTag_17: {
      valueSource: "perParentCombination",
      perParentCombinationId: "hash_perParentCombinationA",
    },
    valueUserTag_20: {
      value: 50
    },
    valueUserTag_21: {
      value: "2121"
    },
    valueUserTag_22: {
      value: "2221"
    }
  }
}

Future Ideas

  • requestProperties has tag_traversalType
  • searchResult (backend) in searchParams that have identifiersIds. still not have in frontend.
  • searchResult (backend) in searchParams that have searchResultGenerated. still not have in frontend (ex. variantProduct) //* will add requiredDataType in requiredDataObject, too.
  • for logicalElementsType: traversal has many fieldValueUserTags that use in traversal (backend). still not have in frontend
//* in traversal type for fields in backend idea

fields: { //* backend idea
  feildName: "value",
  status: {
    anyValue: ["ACTIVE", "PENDING"]
  },
  price: { //* not have
    comparison: "greaterThan",
    value: 100
  },
  quantity: { //* not have
    comparison: "between",
    valueBetweenStart: 10,
    valueBetweenEnd: 50
  },
}