@okf/ootils 1.21.6 → 1.23.0
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.
- package/dist/browser.d.mts +389 -1
- package/dist/browser.d.ts +389 -1
- package/dist/browser.js +999 -0
- package/dist/browser.mjs +982 -0
- package/dist/node.d.mts +403 -6
- package/dist/node.d.ts +403 -6
- package/dist/node.js +1014 -0
- package/dist/node.mjs +997 -0
- package/dist/universal.d.mts +389 -1
- package/dist/universal.d.ts +389 -1
- package/dist/universal.js +999 -0
- package/dist/universal.mjs +982 -0
- package/package.json +1 -1
package/dist/browser.mjs
CHANGED
|
@@ -813,15 +813,997 @@ var mergeAnnoDataIntoAnnotationsTags = ({
|
|
|
813
813
|
});
|
|
814
814
|
return newConsolidated;
|
|
815
815
|
};
|
|
816
|
+
|
|
817
|
+
// src/utils/parseSpecialConfigSyntax.ts
|
|
818
|
+
var parseSpecialConfigSyntax = ({
|
|
819
|
+
config,
|
|
820
|
+
// can be string or JSON
|
|
821
|
+
content,
|
|
822
|
+
returnUndefinedIfReplacementWordNotFound = false
|
|
823
|
+
}) => {
|
|
824
|
+
let filterConfigString = typeof config === "string" ? config : JSON.stringify(config);
|
|
825
|
+
filterConfigString = parseDynamicValuePaths({ filterConfigString, content });
|
|
826
|
+
if (filterConfigString === "replacement-word-not-found" && returnUndefinedIfReplacementWordNotFound) {
|
|
827
|
+
return void 0;
|
|
828
|
+
}
|
|
829
|
+
return typeof config === "string" ? filterConfigString : JSON.parse(filterConfigString);
|
|
830
|
+
};
|
|
831
|
+
var parseDynamicValuePaths = ({ filterConfigString, content }) => {
|
|
832
|
+
let valPathRegex = /\$valuePath\(.*?\)/g;
|
|
833
|
+
let valPathMatch = filterConfigString.match(valPathRegex);
|
|
834
|
+
if (!valPathMatch) return filterConfigString;
|
|
835
|
+
let toReturn = filterConfigString;
|
|
836
|
+
for (let singleMatch of valPathMatch) {
|
|
837
|
+
let actualValPath = singleMatch.replace("$valuePath(", "");
|
|
838
|
+
actualValPath = actualValPath.replace(")", "");
|
|
839
|
+
let replacementWord = getVal(content, actualValPath);
|
|
840
|
+
if (replacementWord === void 0) {
|
|
841
|
+
return "replacement-word-not-found";
|
|
842
|
+
}
|
|
843
|
+
if (Array.isArray(replacementWord)) {
|
|
844
|
+
replacementWord = '["' + replacementWord.join('", "') + '"]';
|
|
845
|
+
toReturn = toReturn.replace('"' + singleMatch + '"', replacementWord);
|
|
846
|
+
} else {
|
|
847
|
+
toReturn = toReturn.replace(singleMatch, replacementWord);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return toReturn;
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
// src/utils/routePathGenerators/getRoutePathToPublishedContent.ts
|
|
854
|
+
var getRoutePathToPublishedContent = ({
|
|
855
|
+
contentType,
|
|
856
|
+
contentId,
|
|
857
|
+
SELF_MANAGED_BASE_CONFIGS,
|
|
858
|
+
scrollIntoViewElemId
|
|
859
|
+
}) => {
|
|
860
|
+
const scrollIntoViewQueryParam = scrollIntoViewElemId ? `scrollIntoViewElemId=${scrollIntoViewElemId}` : void 0;
|
|
861
|
+
const sm_link = SELF_MANAGED_BASE_CONFIGS?.enable && SELF_MANAGED_BASE_CONFIGS?.contentPageRelated?.linkToPublishedPage + (scrollIntoViewQueryParam ? `?${scrollIntoViewQueryParam}` : "");
|
|
862
|
+
const standard_link = `/published-page/${contentType}?id=${contentId}${scrollIntoViewQueryParam ? `&${scrollIntoViewQueryParam}` : ""}`;
|
|
863
|
+
return sm_link ? parseSpecialConfigSyntax({
|
|
864
|
+
config: sm_link,
|
|
865
|
+
content: { contentType, contentId }
|
|
866
|
+
}) : standard_link;
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// src/utils/routePathGenerators/getRoutePathToEditContent.ts
|
|
870
|
+
var getRoutePathToEditContent = ({
|
|
871
|
+
contentType,
|
|
872
|
+
contentId,
|
|
873
|
+
SELF_MANAGED_BASE_CONFIGS
|
|
874
|
+
}) => {
|
|
875
|
+
const sm_link = SELF_MANAGED_BASE_CONFIGS?.contentPageRelated?.linkToEdit;
|
|
876
|
+
const standard_link = `/edit/${contentType}?id=${contentId}`;
|
|
877
|
+
return sm_link ? parseSpecialConfigSyntax({ config: sm_link, content: { contentType, contentId } }) : standard_link;
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
// src/utils/routePathGenerators/getRoutePathToModerateContent.ts
|
|
881
|
+
var getRoutePathToModerateContent = ({
|
|
882
|
+
contentType,
|
|
883
|
+
contentId,
|
|
884
|
+
SELF_MANAGED_BASE_CONFIGS
|
|
885
|
+
}) => {
|
|
886
|
+
const sm_link = SELF_MANAGED_BASE_CONFIGS?.contentPageRelated?.linkToModerate;
|
|
887
|
+
const standard_link = `/moderate/${contentType}?id=${contentId}`;
|
|
888
|
+
return sm_link ? parseSpecialConfigSyntax({ config: sm_link, content: { contentType, contentId } }) : standard_link;
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
// src/UI_CONTENT.ts
|
|
892
|
+
var UI_CONTENT = {
|
|
893
|
+
autoGenFilterConfigs: {
|
|
894
|
+
annoTagsTitle: "Annotation Tags",
|
|
895
|
+
tagsTitle: "Document Tags",
|
|
896
|
+
tagsFilterTitle: "Filters for"
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/generateFilterKey.ts
|
|
901
|
+
var generateFilterKey = ({
|
|
902
|
+
filterType,
|
|
903
|
+
scope = "doc",
|
|
904
|
+
tagType,
|
|
905
|
+
valuePath,
|
|
906
|
+
rollupPath,
|
|
907
|
+
tagTypeCollectionToRollup,
|
|
908
|
+
valuePathInRolledUpCollection,
|
|
909
|
+
relationshipValuePath,
|
|
910
|
+
rollupResourceTypes
|
|
911
|
+
} = { filterType: "" }) => {
|
|
912
|
+
if (!filterType) return void 0;
|
|
913
|
+
const normalizeSimple = (s) => typeof s === "string" ? s.trim().replace(/\s+/g, " ") : s;
|
|
914
|
+
const normalizePath = (p) => {
|
|
915
|
+
if (typeof p !== "string") return p;
|
|
916
|
+
const trimmed = p.trim();
|
|
917
|
+
return trimmed.replace(/\.+/g, ".").replace(/^\./, "").replace(/\.$/, "");
|
|
918
|
+
};
|
|
919
|
+
switch (filterType) {
|
|
920
|
+
case "tagType":
|
|
921
|
+
if (!tagType) return void 0;
|
|
922
|
+
return `tagType::${scope}::${normalizeSimple(tagType)}`;
|
|
923
|
+
case "valuePathType":
|
|
924
|
+
case "dateRangeType":
|
|
925
|
+
case "numberRangeType":
|
|
926
|
+
if (!valuePath) return void 0;
|
|
927
|
+
{
|
|
928
|
+
const vp = normalizePath(valuePath);
|
|
929
|
+
return `${filterType}::${vp}`;
|
|
930
|
+
}
|
|
931
|
+
case "nestedRollupTagType":
|
|
932
|
+
if (!Array.isArray(rollupPath) || rollupPath.length === 0) return void 0;
|
|
933
|
+
return `nestedRollupTagType::${rollupPath.join("::")}`;
|
|
934
|
+
case "rollupValuePathType":
|
|
935
|
+
if (!tagTypeCollectionToRollup || !valuePathInRolledUpCollection) return void 0;
|
|
936
|
+
return `rollupValuePathType::${normalizeSimple(tagTypeCollectionToRollup)}::${normalizePath(
|
|
937
|
+
valuePathInRolledUpCollection
|
|
938
|
+
)}`;
|
|
939
|
+
case "rollupRelationshipType": {
|
|
940
|
+
const normalizedTypes = Array.isArray(rollupResourceTypes) ? [...rollupResourceTypes].sort().join("|") : "";
|
|
941
|
+
if (!relationshipValuePath) return void 0;
|
|
942
|
+
return `rollupRelationshipType::${normalizePath(relationshipValuePath)}::${normalizedTypes}${tagType ? `::${normalizeSimple(tagType)}` : ""}`;
|
|
943
|
+
}
|
|
944
|
+
default:
|
|
945
|
+
return void 0;
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/buildFilterConfigurations.ts
|
|
950
|
+
var getTplTitle = (contentType, allTpls) => {
|
|
951
|
+
const tpl = allTpls.find((t) => t.kp_content_type === contentType);
|
|
952
|
+
return tpl?.general?.content?.title;
|
|
953
|
+
};
|
|
954
|
+
var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup = false, isAnno = false }) => {
|
|
955
|
+
const createFilterSection = ({ group, type: type2, totalTpls, isRollup: isRollup2, allTpls: allTpls2 }) => {
|
|
956
|
+
const isCommon = group.contentTypes.length === totalTpls;
|
|
957
|
+
const baseTitle = type2 === "tags" ? UI_CONTENT.autoGenFilterConfigs.tagsFilterTitle : type2 === "annoTags" ? UI_CONTENT.autoGenFilterConfigs.annoTagsTitle : "";
|
|
958
|
+
return {
|
|
959
|
+
id: `group_${group.contentTypes.join("_")}_${type2}`,
|
|
960
|
+
filterScope: type2,
|
|
961
|
+
title: isCommon ? `Common ${isRollup2 ? "Rollup " : ""}${baseTitle}` : `${isRollup2 ? "Rollup " : ""}${baseTitle}`,
|
|
962
|
+
subtitle: `${group.contentTypes.map((c) => {
|
|
963
|
+
let thisTpl = allTpls2.find((tpl) => tpl.kp_content_type === c);
|
|
964
|
+
return thisTpl?.general?.content?.title || thisTpl?.kp_content_type || "";
|
|
965
|
+
}).join(", ")}`,
|
|
966
|
+
contentTypesCount: group.contentTypes.length,
|
|
967
|
+
elements: group.elements
|
|
968
|
+
};
|
|
969
|
+
};
|
|
970
|
+
const buildFilterConfig = (element, section) => {
|
|
971
|
+
const allProfileTpls = allTpls.filter((d) => d.category === "userProfiles");
|
|
972
|
+
switch (element.filterType) {
|
|
973
|
+
case "split_valuePathType":
|
|
974
|
+
return element.block.props.subQuestionLabels.map((subQuestion) => {
|
|
975
|
+
const targetValuePath = element.block.valuePath + "." + subQuestion.value;
|
|
976
|
+
const display = element.display + " - " + subQuestion.display;
|
|
977
|
+
const filterKey = generateFilterKey({
|
|
978
|
+
filterType: "valuePathType",
|
|
979
|
+
valuePath: targetValuePath,
|
|
980
|
+
scope: section.filterScope
|
|
981
|
+
});
|
|
982
|
+
return {
|
|
983
|
+
filterId: `valuePathFilter_${element.contentType}_${targetValuePath.replaceAll(".", "_DOT_")}`,
|
|
984
|
+
display,
|
|
985
|
+
value: targetValuePath,
|
|
986
|
+
filterKey,
|
|
987
|
+
contentType: element.contentType,
|
|
988
|
+
path: element.valuePath,
|
|
989
|
+
source: {
|
|
990
|
+
filterType: "tplType",
|
|
991
|
+
contentType: element.contentType,
|
|
992
|
+
valuePath: element.valuePath,
|
|
993
|
+
scope: "tags"
|
|
994
|
+
},
|
|
995
|
+
target: {
|
|
996
|
+
filterType: "valuePathType",
|
|
997
|
+
valuePath: element.saveValueAsString ? targetValuePath : `${targetValuePath}.value`
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
});
|
|
1001
|
+
case "valuePathType": {
|
|
1002
|
+
const valuePathFilterKey = generateFilterKey({
|
|
1003
|
+
filterType: "valuePathType",
|
|
1004
|
+
valuePath: element.valuePath,
|
|
1005
|
+
scope: section.filterScope
|
|
1006
|
+
});
|
|
1007
|
+
return {
|
|
1008
|
+
filterId: `valuePathFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
1009
|
+
display: element.display,
|
|
1010
|
+
value: element.value || element.contentType || element.valuePath,
|
|
1011
|
+
filterKey: valuePathFilterKey,
|
|
1012
|
+
contentType: element.contentType,
|
|
1013
|
+
path: element.valuePath,
|
|
1014
|
+
source: {
|
|
1015
|
+
filterType: "tplType",
|
|
1016
|
+
contentType: element.contentType,
|
|
1017
|
+
valuePath: element.valuePath,
|
|
1018
|
+
scope: "tags"
|
|
1019
|
+
},
|
|
1020
|
+
target: {
|
|
1021
|
+
filterType: "valuePathType",
|
|
1022
|
+
valuePath: element.saveValueAsString ? element.valuePath : `${element.valuePath}.value`
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
case "dateRangeType": {
|
|
1027
|
+
const dateFilterKey = generateFilterKey({
|
|
1028
|
+
filterType: "dateRangeType",
|
|
1029
|
+
valuePath: element.valuePath,
|
|
1030
|
+
scope: section.filterScope
|
|
1031
|
+
});
|
|
1032
|
+
return {
|
|
1033
|
+
filterId: `dateFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
1034
|
+
display: element.display,
|
|
1035
|
+
value: element.valuePath,
|
|
1036
|
+
filterKey: dateFilterKey,
|
|
1037
|
+
contentType: element.contentType,
|
|
1038
|
+
path: element.valuePath,
|
|
1039
|
+
source: { filterType: "dateRangeType" },
|
|
1040
|
+
target: { filterType: "dateRangeType", valuePath: element.valuePath }
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
case "numberRangeType": {
|
|
1044
|
+
const numberFilterKey = generateFilterKey({
|
|
1045
|
+
filterType: "numberRangeType",
|
|
1046
|
+
valuePath: element.valuePath,
|
|
1047
|
+
scope: section.filterScope
|
|
1048
|
+
});
|
|
1049
|
+
return {
|
|
1050
|
+
filterId: `numberFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
1051
|
+
display: element.display,
|
|
1052
|
+
value: element.valuePath,
|
|
1053
|
+
filterKey: numberFilterKey,
|
|
1054
|
+
contentType: element.contentType,
|
|
1055
|
+
path: element.valuePath,
|
|
1056
|
+
source: { filterType: "numberRangeType", valuePath: element.valuePath },
|
|
1057
|
+
target: { filterType: "numberRangeType", valuePath: element.valuePath }
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
case "nestedRollupTagType": {
|
|
1061
|
+
const lastItemInPath = element.rollupPath[element.rollupPath.length - 1];
|
|
1062
|
+
const isTerminalValuePath = lastItemInPath.startsWith("main.");
|
|
1063
|
+
const getDisplay = (rollupPath) => {
|
|
1064
|
+
if (isTerminalValuePath) {
|
|
1065
|
+
return element.filterDisplay || lastItemInPath;
|
|
1066
|
+
}
|
|
1067
|
+
const lastTag = rollupPath[rollupPath.length - 1];
|
|
1068
|
+
const lastTagTpl = allTpls.find(
|
|
1069
|
+
(tpl) => tpl.kp_content_type === lastTag
|
|
1070
|
+
);
|
|
1071
|
+
return lastTagTpl?.general?.content?.title || lastTagTpl?.kp_content_type;
|
|
1072
|
+
};
|
|
1073
|
+
const getTooltip = (rollupPath) => {
|
|
1074
|
+
const displays = [...rollupPath].reverse().map((item, index) => {
|
|
1075
|
+
if (index === 0 && isTerminalValuePath) {
|
|
1076
|
+
return element.filterDisplay || item;
|
|
1077
|
+
}
|
|
1078
|
+
const tpl = allTpls.find((tpl2) => tpl2.kp_content_type === item);
|
|
1079
|
+
return tpl?.general?.content?.title || tpl?.kp_content_type;
|
|
1080
|
+
});
|
|
1081
|
+
return `Indirect filter: ${displays.join(" > ")}`;
|
|
1082
|
+
};
|
|
1083
|
+
const lastTagInPath = element.rollupPath[element.rollupPath.length - 1];
|
|
1084
|
+
const isLastTagProfile = !isTerminalValuePath && allProfileTpls.some(
|
|
1085
|
+
(tpl) => tpl.kp_content_type === lastTagInPath
|
|
1086
|
+
);
|
|
1087
|
+
const getSourceConfig = () => {
|
|
1088
|
+
if (isTerminalValuePath) {
|
|
1089
|
+
const parentTagType = element.rollupPath[element.rollupPath.length - 2];
|
|
1090
|
+
const sourceValuePath = lastItemInPath.endsWith(".value") ? lastItemInPath.slice(0, -6) : lastItemInPath;
|
|
1091
|
+
return {
|
|
1092
|
+
filterType: "tplType",
|
|
1093
|
+
contentType: parentTagType,
|
|
1094
|
+
valuePath: sourceValuePath,
|
|
1095
|
+
scope: section.filterScope
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
if (isLastTagProfile) {
|
|
1099
|
+
return {
|
|
1100
|
+
filterType: "usersType",
|
|
1101
|
+
profileTypes: [lastTagInPath],
|
|
1102
|
+
scope: section.filterScope
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
return {
|
|
1106
|
+
filterType: "tagType",
|
|
1107
|
+
tagType: lastTagInPath,
|
|
1108
|
+
scope: section.filterScope
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
return {
|
|
1112
|
+
filterId: `ROLLUP_${section.filterScope}_${element.rollupPath.join(
|
|
1113
|
+
"_"
|
|
1114
|
+
)}`,
|
|
1115
|
+
display: getDisplay(element.rollupPath),
|
|
1116
|
+
value: element.rollupPath,
|
|
1117
|
+
tooltip: getTooltip(element.rollupPath),
|
|
1118
|
+
filterKey: generateFilterKey({
|
|
1119
|
+
filterType: "nestedRollupTagType",
|
|
1120
|
+
rollupPath: element.rollupPath,
|
|
1121
|
+
scope: section.filterScope
|
|
1122
|
+
}),
|
|
1123
|
+
contentType: element.rollupPath[0],
|
|
1124
|
+
path: `tags.${element.rollupPath[1]}`,
|
|
1125
|
+
source: getSourceConfig(),
|
|
1126
|
+
target: {
|
|
1127
|
+
filterType: "nestedRollupTagType",
|
|
1128
|
+
rollupPath: element.rollupPath,
|
|
1129
|
+
...isAnno && { isAnno: true }
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
case "rollupValuePathType": {
|
|
1134
|
+
const rollupFilterKey = generateFilterKey({
|
|
1135
|
+
filterType: "rollupValuePathType",
|
|
1136
|
+
tagTypeCollectionToRollup: element.tagTypeCollectionToRollup,
|
|
1137
|
+
valuePathInRolledUpCollection: element.valuePathInRolledUpCollection,
|
|
1138
|
+
scope: section.filterScope
|
|
1139
|
+
});
|
|
1140
|
+
return {
|
|
1141
|
+
filterId: `${section.filterScope}_${element.tagTypeCollectionToRollup}_${element.valuePathInRolledUpCollection.replaceAll(".", "_DOT_")}`,
|
|
1142
|
+
display: element.filterDisplay,
|
|
1143
|
+
value: element.filterDisplay,
|
|
1144
|
+
filterKey: rollupFilterKey,
|
|
1145
|
+
tooltip: `Indirect filter: ${element.filterDisplay} > ${getTplTitle(element.tagTypeCollectionToRollup, allTpls) || element.tagTypeCollectionToRollup}`,
|
|
1146
|
+
contentType: element.tagTypeCollectionToRollup,
|
|
1147
|
+
path: element.filterSourceValuePath,
|
|
1148
|
+
source: {
|
|
1149
|
+
filterType: "tplType",
|
|
1150
|
+
contentType: element.tagTypeCollectionToRollup,
|
|
1151
|
+
valuePath: element.filterSourceValuePath,
|
|
1152
|
+
scope: section.filterScope
|
|
1153
|
+
},
|
|
1154
|
+
target: {
|
|
1155
|
+
filterType: "rollupValuePathType",
|
|
1156
|
+
tagTypeCollectionToRollup: element.tagTypeCollectionToRollup,
|
|
1157
|
+
valuePathInRolledUpCollection: element.valuePathInRolledUpCollection,
|
|
1158
|
+
...isAnno && { isAnno: true }
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
case "tagType":
|
|
1163
|
+
default: {
|
|
1164
|
+
const tagFilterKey = generateFilterKey({
|
|
1165
|
+
filterType: "tagType",
|
|
1166
|
+
tagType: element.tagType,
|
|
1167
|
+
scope: section.filterScope
|
|
1168
|
+
});
|
|
1169
|
+
return {
|
|
1170
|
+
filterId: isAnno ? `annoTags_${element.tagType}` : `tags_${element.tagType}`,
|
|
1171
|
+
display: allTpls.find((t) => t.kp_content_type === element.tagType)?.general?.content?.title || element.tagType,
|
|
1172
|
+
value: element.tagType,
|
|
1173
|
+
filterKey: tagFilterKey,
|
|
1174
|
+
contentType: element.tagType,
|
|
1175
|
+
path: `tags.${element.tagType}`,
|
|
1176
|
+
source: allProfileTpls.some(
|
|
1177
|
+
(tpl) => tpl.kp_content_type === element.tagType
|
|
1178
|
+
) ? {
|
|
1179
|
+
filterType: "usersType",
|
|
1180
|
+
profileTypes: [element.tagType],
|
|
1181
|
+
scope: isAnno ? "annoTags" : "tags"
|
|
1182
|
+
} : {
|
|
1183
|
+
filterType: "tagType",
|
|
1184
|
+
tagType: element.tagType,
|
|
1185
|
+
scope: isAnno ? "annoTags" : "tags"
|
|
1186
|
+
},
|
|
1187
|
+
target: {
|
|
1188
|
+
filterType: "tagType",
|
|
1189
|
+
tagType: element.tagType,
|
|
1190
|
+
...isAnno && { isAnno: true }
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
return groups.sort((a, b) => b.contentTypes.length - a.contentTypes.length).map((group) => {
|
|
1197
|
+
const section = createFilterSection({ group, type, totalTpls: selectedTpls.length, isRollup, allTpls });
|
|
1198
|
+
return {
|
|
1199
|
+
sectionId: section.id,
|
|
1200
|
+
sectionTitle: section.title,
|
|
1201
|
+
sectionSubtitle: section.subtitle,
|
|
1202
|
+
configs: section.elements.map((element) => {
|
|
1203
|
+
const config = buildFilterConfig(element, section);
|
|
1204
|
+
return config;
|
|
1205
|
+
}).reduce(
|
|
1206
|
+
(acc, next) => [...acc, ...Array.isArray(next) ? next : [next]],
|
|
1207
|
+
[]
|
|
1208
|
+
)
|
|
1209
|
+
};
|
|
1210
|
+
});
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/compareAndGroupBlocks.ts
|
|
1214
|
+
var compareAndGroupBlocks = (blocksPerTpl) => {
|
|
1215
|
+
if (!blocksPerTpl || blocksPerTpl.length === 0) return [];
|
|
1216
|
+
if (blocksPerTpl.length === 1) {
|
|
1217
|
+
return [{
|
|
1218
|
+
contentTypes: [blocksPerTpl[0].contentType],
|
|
1219
|
+
elements: blocksPerTpl[0].blocks || []
|
|
1220
|
+
}];
|
|
1221
|
+
}
|
|
1222
|
+
const getFilterElementKey = (element) => {
|
|
1223
|
+
switch (element.filterType) {
|
|
1224
|
+
case "tagType":
|
|
1225
|
+
return `tagType:${element.tagType}`;
|
|
1226
|
+
case "valuePathType":
|
|
1227
|
+
return `valuePathType:${element.valuePath}`;
|
|
1228
|
+
case "dateRangeType":
|
|
1229
|
+
return `dateRangeType:${element.valuePath}`;
|
|
1230
|
+
case "nestedRollupTagType":
|
|
1231
|
+
return `nestedRollupTagType:${JSON.stringify(element.rollupPath)}`;
|
|
1232
|
+
case "rollupValuePathType":
|
|
1233
|
+
return `rollupValuePathType:${element.tagTypeCollectionToRollup}:${element.valuePathInRolledUpCollection}`;
|
|
1234
|
+
default:
|
|
1235
|
+
return JSON.stringify(element);
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
const filterToTemplates = /* @__PURE__ */ new Map();
|
|
1239
|
+
blocksPerTpl.forEach((template) => {
|
|
1240
|
+
const blocks = template.blocks || [];
|
|
1241
|
+
blocks.forEach((block) => {
|
|
1242
|
+
const filterKey = getFilterElementKey(block);
|
|
1243
|
+
if (!filterToTemplates.has(filterKey)) {
|
|
1244
|
+
filterToTemplates.set(filterKey, {
|
|
1245
|
+
element: block,
|
|
1246
|
+
contentTypes: /* @__PURE__ */ new Set()
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
filterToTemplates.get(filterKey).contentTypes.add(template.contentType);
|
|
1250
|
+
});
|
|
1251
|
+
});
|
|
1252
|
+
const templateGroupToFilters = /* @__PURE__ */ new Map();
|
|
1253
|
+
for (const [filterKey, data] of filterToTemplates) {
|
|
1254
|
+
const templatesKey = Array.from(data.contentTypes).sort().join("|");
|
|
1255
|
+
if (!templateGroupToFilters.has(templatesKey)) {
|
|
1256
|
+
templateGroupToFilters.set(templatesKey, {
|
|
1257
|
+
contentTypes: Array.from(data.contentTypes).sort(),
|
|
1258
|
+
elements: []
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
templateGroupToFilters.get(templatesKey).elements.push(data.element);
|
|
1262
|
+
}
|
|
1263
|
+
return Array.from(templateGroupToFilters.values());
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/extractAndOrganizeBlocks.ts
|
|
1267
|
+
var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
1268
|
+
const extractedBlocks = {};
|
|
1269
|
+
const templateBlocksCache = /* @__PURE__ */ new Map();
|
|
1270
|
+
const getCachedBlocks = (tpl) => {
|
|
1271
|
+
if (!templateBlocksCache.has(tpl.kp_content_type)) {
|
|
1272
|
+
templateBlocksCache.set(tpl.kp_content_type, extractAllBlocksFromTpl({ tpl }));
|
|
1273
|
+
}
|
|
1274
|
+
return templateBlocksCache.get(tpl.kp_content_type);
|
|
1275
|
+
};
|
|
1276
|
+
extractedBlocks.annoTagBlocks = selectedTpls.map((tpl) => {
|
|
1277
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1278
|
+
const allTagTypes = allBlocks.filter((block) => block.props?.annotation?.enable).flatMap((block) => block.props.annotation.tagTypesConfig?.map((d) => d.tagType) || []);
|
|
1279
|
+
const uniqueTagTypes = [...new Set(allTagTypes)];
|
|
1280
|
+
return {
|
|
1281
|
+
contentType: tpl.kp_content_type,
|
|
1282
|
+
blocks: uniqueTagTypes.map((tagType) => ({
|
|
1283
|
+
tagType,
|
|
1284
|
+
filterType: "tagType"
|
|
1285
|
+
}))
|
|
1286
|
+
};
|
|
1287
|
+
});
|
|
1288
|
+
extractedBlocks.annoEnabledBlocks = selectedTpls.map((tpl) => {
|
|
1289
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1290
|
+
return {
|
|
1291
|
+
contentType: tpl.kp_content_type,
|
|
1292
|
+
blocks: allBlocks.filter((block) => block.props?.annotation?.enable)
|
|
1293
|
+
};
|
|
1294
|
+
});
|
|
1295
|
+
extractedBlocks.annoRollupBlocks = selectedTpls.map((tpl) => {
|
|
1296
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1297
|
+
const uniqueTagTypes = Array.from(new Set(
|
|
1298
|
+
allBlocks.filter((block) => block.props?.annotation?.enable).flatMap((block) => block.props.annotation.tagTypesConfig || []).map((conf) => conf.tagType)
|
|
1299
|
+
));
|
|
1300
|
+
return {
|
|
1301
|
+
contentType: tpl.kp_content_type,
|
|
1302
|
+
blocks: uniqueTagTypes.flatMap((tagType) => {
|
|
1303
|
+
const possibilities = getRollupPossibilities({ tagType, allTpls });
|
|
1304
|
+
return possibilities.map((p) => ({
|
|
1305
|
+
...p,
|
|
1306
|
+
filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
|
|
1307
|
+
}));
|
|
1308
|
+
})
|
|
1309
|
+
};
|
|
1310
|
+
});
|
|
1311
|
+
extractedBlocks.docTagBlocks = selectedTpls.map((tpl) => {
|
|
1312
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1313
|
+
return {
|
|
1314
|
+
contentType: tpl.kp_content_type,
|
|
1315
|
+
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.")).map((block) => ({
|
|
1316
|
+
tagType: block.props.tagType,
|
|
1317
|
+
filterType: "tagType"
|
|
1318
|
+
}))
|
|
1319
|
+
};
|
|
1320
|
+
});
|
|
1321
|
+
extractedBlocks.docRollupBlocks = selectedTpls.map((tpl) => {
|
|
1322
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1323
|
+
return {
|
|
1324
|
+
contentType: tpl.kp_content_type,
|
|
1325
|
+
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.") && ["TagsInputSingle", "TagsInputMulti"].includes(block.comp)).flatMap((block) => {
|
|
1326
|
+
const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls });
|
|
1327
|
+
return possibilities.map((p) => ({
|
|
1328
|
+
...p,
|
|
1329
|
+
filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
|
|
1330
|
+
}));
|
|
1331
|
+
})
|
|
1332
|
+
};
|
|
1333
|
+
});
|
|
1334
|
+
extractedBlocks.valuePathBlocks = selectedTpls.map((tpl) => {
|
|
1335
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1336
|
+
return {
|
|
1337
|
+
contentType: tpl.kp_content_type,
|
|
1338
|
+
blocks: allBlocks.filter((block) => ["DropdownSingle", "DropdownMulti", "RadioList", "CheckboxList"].includes(block.comp)).map((block) => ({
|
|
1339
|
+
valuePath: block.valuePath,
|
|
1340
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1341
|
+
value: block.valuePath,
|
|
1342
|
+
saveValueAsString: block.props?.saveValueAsString,
|
|
1343
|
+
contentType: tpl.kp_content_type,
|
|
1344
|
+
filterType: "valuePathType"
|
|
1345
|
+
}))
|
|
1346
|
+
};
|
|
1347
|
+
});
|
|
1348
|
+
extractedBlocks.groupQuestionsBlocks = selectedTpls.map((tpl) => {
|
|
1349
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1350
|
+
return {
|
|
1351
|
+
contentType: tpl.kp_content_type,
|
|
1352
|
+
blocks: allBlocks.filter((block) => ["GroupQuestionsInputSingle"].includes(block.comp)).map((block) => ({
|
|
1353
|
+
valuePath: block.valuePath,
|
|
1354
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1355
|
+
value: block.valuePath,
|
|
1356
|
+
saveValueAsString: block.props?.saveValueAsString,
|
|
1357
|
+
contentType: tpl.kp_content_type,
|
|
1358
|
+
block,
|
|
1359
|
+
filterType: "split_valuePathType"
|
|
1360
|
+
}))
|
|
1361
|
+
};
|
|
1362
|
+
});
|
|
1363
|
+
extractedBlocks.dateBlocks = selectedTpls.map((tpl) => {
|
|
1364
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1365
|
+
return {
|
|
1366
|
+
contentType: tpl.kp_content_type,
|
|
1367
|
+
blocks: allBlocks.filter((block) => ["DatePicker", "DateRangePicker", "DateTimePicker", "DateTimeRangePicker"].includes(block.comp)).map((block) => ({
|
|
1368
|
+
valuePath: block.valuePath,
|
|
1369
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1370
|
+
value: block.valuePath,
|
|
1371
|
+
contentType: tpl.kp_content_type,
|
|
1372
|
+
filterType: "dateRangeType"
|
|
1373
|
+
}))
|
|
1374
|
+
};
|
|
1375
|
+
});
|
|
1376
|
+
extractedBlocks.numberBlocks = selectedTpls.map((tpl) => {
|
|
1377
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1378
|
+
return {
|
|
1379
|
+
contentType: tpl.kp_content_type,
|
|
1380
|
+
blocks: allBlocks.filter((block) => block.comp === "NumberInput").map((block) => ({
|
|
1381
|
+
valuePath: block.valuePath,
|
|
1382
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1383
|
+
value: block.valuePath,
|
|
1384
|
+
contentType: tpl.kp_content_type,
|
|
1385
|
+
filterType: "numberRangeType"
|
|
1386
|
+
}))
|
|
1387
|
+
};
|
|
1388
|
+
});
|
|
1389
|
+
extractedBlocks.combinedDocumentBlocks = selectedTpls.map((tpl) => {
|
|
1390
|
+
const docTagBlocks = extractedBlocks.docTagBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1391
|
+
const valuePathBlocks = extractedBlocks.valuePathBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1392
|
+
const groupQuestionsBlocks = extractedBlocks.groupQuestionsBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1393
|
+
const dateBlocks = extractedBlocks.dateBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1394
|
+
const numberBlocks = extractedBlocks.numberBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1395
|
+
const rollupBlocks = extractedBlocks.docRollupBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1396
|
+
return {
|
|
1397
|
+
contentType: tpl.kp_content_type,
|
|
1398
|
+
blocks: [...docTagBlocks, ...valuePathBlocks, ...groupQuestionsBlocks, ...dateBlocks, ...numberBlocks, ...rollupBlocks]
|
|
1399
|
+
};
|
|
1400
|
+
});
|
|
1401
|
+
return extractedBlocks;
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/processAuthorAndCommonFilters.ts
|
|
1405
|
+
var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks = []) => {
|
|
1406
|
+
const allProfileTpls = allTpls.filter((d) => d.category === "userProfiles");
|
|
1407
|
+
const authorTagGroups = allProfileTpls.flatMap((tpl) => {
|
|
1408
|
+
const blocks = tpl.kp_templates.myProfileConfig.reduce((acc, config) => [...acc, ...config.blocks], []).filter((block) => !!block.props?.tagType).map((block) => ({
|
|
1409
|
+
...block,
|
|
1410
|
+
tplContentType: tpl.kp_content_type
|
|
1411
|
+
}));
|
|
1412
|
+
return blocks;
|
|
1413
|
+
}).reduce((acc, block) => {
|
|
1414
|
+
const existing = acc.find((b) => b.props.tagType === block.props.tagType);
|
|
1415
|
+
if (existing) {
|
|
1416
|
+
existing.tplContentTypes = [...existing.tplContentTypes, block.tplContentType];
|
|
1417
|
+
} else {
|
|
1418
|
+
acc.push({
|
|
1419
|
+
...block,
|
|
1420
|
+
tplContentTypes: [block.tplContentType]
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
return acc;
|
|
1424
|
+
}, []);
|
|
1425
|
+
const authorTagConfigs = authorTagGroups.map((block) => ({
|
|
1426
|
+
filterId: `authorTagFilter_${block.props.tagType}`,
|
|
1427
|
+
blockId: `authorTagFilter_${block.props.tagType}`,
|
|
1428
|
+
display: `Author Tag: ${block.props.tagType}`,
|
|
1429
|
+
value: block.tplContentTypes,
|
|
1430
|
+
filterKey: generateFilterKey({
|
|
1431
|
+
filterType: "rollupRelationshipType",
|
|
1432
|
+
relationshipValuePath: "meta.kp_contributed_by",
|
|
1433
|
+
rollupResourceTypes: block.tplContentTypes,
|
|
1434
|
+
tagType: block.props.tagType,
|
|
1435
|
+
scope: "doc"
|
|
1436
|
+
}),
|
|
1437
|
+
source: {
|
|
1438
|
+
filterType: "tagType",
|
|
1439
|
+
tagType: block.props.tagType,
|
|
1440
|
+
scope: "tags"
|
|
1441
|
+
},
|
|
1442
|
+
target: {
|
|
1443
|
+
filterType: "rollupRelationshipType",
|
|
1444
|
+
tagType: block.props.tagType,
|
|
1445
|
+
rollupResourceTypes: block.tplContentTypes,
|
|
1446
|
+
relationshipValuePath: "meta.kp_contributed_by"
|
|
1447
|
+
}
|
|
1448
|
+
}));
|
|
1449
|
+
const commonAnnotationFilters = filterScopes.includes("anno") ? [{
|
|
1450
|
+
sectionId: "commonAnnotationFilters",
|
|
1451
|
+
sectionTitle: "Common Annotation Filters",
|
|
1452
|
+
configs: [
|
|
1453
|
+
{
|
|
1454
|
+
filterId: "annoAuthorFilter",
|
|
1455
|
+
blockId: "annoAuthorFilter",
|
|
1456
|
+
display: "Annotation Author",
|
|
1457
|
+
value: "annotation_author",
|
|
1458
|
+
filterKey: generateFilterKey({
|
|
1459
|
+
filterType: "valuePathType",
|
|
1460
|
+
valuePath: "annotations.author.id",
|
|
1461
|
+
scope: "anno"
|
|
1462
|
+
}),
|
|
1463
|
+
source: {
|
|
1464
|
+
filterType: "usersType",
|
|
1465
|
+
profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type)
|
|
1466
|
+
},
|
|
1467
|
+
target: {
|
|
1468
|
+
filterType: "valuePathType",
|
|
1469
|
+
valuePath: `annotations.author.id`
|
|
1470
|
+
}
|
|
1471
|
+
},
|
|
1472
|
+
...annoEnabledBlocks.length > 0 ? [{
|
|
1473
|
+
filterId: "annoEnabledBlockValuePathFilter",
|
|
1474
|
+
blockId: "annoEnabledBlockValuePathFilter",
|
|
1475
|
+
display: "Document Field",
|
|
1476
|
+
value: "annotation_value_path",
|
|
1477
|
+
filterKey: generateFilterKey({
|
|
1478
|
+
filterType: "valuePathType",
|
|
1479
|
+
valuePath: "meta.valuePath",
|
|
1480
|
+
scope: "anno"
|
|
1481
|
+
}),
|
|
1482
|
+
source: {
|
|
1483
|
+
filterType: "staticType",
|
|
1484
|
+
options: annoEnabledBlocks.map((block) => ({
|
|
1485
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1486
|
+
value: block.valuePath
|
|
1487
|
+
}))
|
|
1488
|
+
},
|
|
1489
|
+
target: {
|
|
1490
|
+
filterType: "valuePathType",
|
|
1491
|
+
valuePath: `meta.valuePath`
|
|
1492
|
+
}
|
|
1493
|
+
}] : []
|
|
1494
|
+
]
|
|
1495
|
+
}] : [];
|
|
1496
|
+
const commonDocumentFilters = filterScopes.includes("doc") ? [{
|
|
1497
|
+
sectionId: "commonDocumentFilters",
|
|
1498
|
+
sectionTitle: "Common Document Filters",
|
|
1499
|
+
configs: [
|
|
1500
|
+
{
|
|
1501
|
+
filterId: "authorFilter",
|
|
1502
|
+
blockId: "authorFilter",
|
|
1503
|
+
display: "Author",
|
|
1504
|
+
value: "author",
|
|
1505
|
+
filterKey: generateFilterKey({
|
|
1506
|
+
filterType: "valuePathType",
|
|
1507
|
+
valuePath: "meta.kp_contributed_by",
|
|
1508
|
+
scope: "doc"
|
|
1509
|
+
}),
|
|
1510
|
+
source: {
|
|
1511
|
+
filterType: "authorsType",
|
|
1512
|
+
profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
|
|
1513
|
+
scope: "tags"
|
|
1514
|
+
},
|
|
1515
|
+
target: {
|
|
1516
|
+
filterType: "valuePathType",
|
|
1517
|
+
valuePath: `meta.kp_contributed_by`
|
|
1518
|
+
}
|
|
1519
|
+
},
|
|
1520
|
+
...authorTagConfigs,
|
|
1521
|
+
{
|
|
1522
|
+
filterId: "publishedDateFilter",
|
|
1523
|
+
blockId: "publishedDateFilter",
|
|
1524
|
+
display: "Published Date",
|
|
1525
|
+
value: "published_date",
|
|
1526
|
+
filterKey: generateFilterKey({
|
|
1527
|
+
filterType: "dateRangeType",
|
|
1528
|
+
valuePath: "kp_date_published",
|
|
1529
|
+
scope: "doc"
|
|
1530
|
+
}),
|
|
1531
|
+
source: {
|
|
1532
|
+
filterType: "dateRangeType"
|
|
1533
|
+
},
|
|
1534
|
+
target: {
|
|
1535
|
+
filterType: "dateRangeType",
|
|
1536
|
+
valuePath: "kp_date_published"
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
]
|
|
1540
|
+
}] : [];
|
|
1541
|
+
return { authorTagConfigs, commonAnnotationFilters, commonDocumentFilters };
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_getFixedAnnoTagBlock.ts
|
|
1545
|
+
var _self_managed_getFixedAnnoTagBlock = (selectedTpls, annotationTagsCount) => {
|
|
1546
|
+
if (!annotationTagsCount?.tags || annotationTagsCount.tags === 0) {
|
|
1547
|
+
return [];
|
|
1548
|
+
}
|
|
1549
|
+
const selfManagedTagBlocks = selectedTpls.map((tpl) => ({
|
|
1550
|
+
contentType: tpl.kp_content_type,
|
|
1551
|
+
blocks: [
|
|
1552
|
+
{
|
|
1553
|
+
tagType: "tags",
|
|
1554
|
+
filterType: "tagType"
|
|
1555
|
+
}
|
|
1556
|
+
]
|
|
1557
|
+
}));
|
|
1558
|
+
return compareAndGroupBlocks(selfManagedTagBlocks);
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_getFixedAnnoRollupBlocks.ts
|
|
1562
|
+
var _self_managed_getFixedAnnoRollupBlocks = ({ selectedTpls, allTpls, annotationTagsCount }) => {
|
|
1563
|
+
const rollupBlocks = [];
|
|
1564
|
+
if (annotationTagsCount?.subThemes > 0 && annotationTagsCount?.themes > 0) {
|
|
1565
|
+
rollupBlocks.push({
|
|
1566
|
+
rollupType: "tagType",
|
|
1567
|
+
rollupPath: ["tags", "subThemes", "themes"],
|
|
1568
|
+
filterType: "nestedRollupTagType"
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
if (annotationTagsCount?.subThemes > 0) {
|
|
1572
|
+
rollupBlocks.push({
|
|
1573
|
+
rollupType: "tagType",
|
|
1574
|
+
rollupPath: ["tags", "subThemes"],
|
|
1575
|
+
filterType: "nestedRollupTagType"
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
if (rollupBlocks.length === 0) {
|
|
1579
|
+
return [];
|
|
1580
|
+
}
|
|
1581
|
+
const selfManagedRollupBlocks = selectedTpls.map((tpl) => ({
|
|
1582
|
+
contentType: tpl.kp_content_type,
|
|
1583
|
+
blocks: rollupBlocks
|
|
1584
|
+
}));
|
|
1585
|
+
return compareAndGroupBlocks(selfManagedRollupBlocks);
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildAnnoHierarchyConfig.ts
|
|
1589
|
+
var FILTER_IDS = {
|
|
1590
|
+
themes: "anno_themes",
|
|
1591
|
+
subThemes: "anno_subThemes",
|
|
1592
|
+
tags: "anno_tags"
|
|
1593
|
+
};
|
|
1594
|
+
var _self_managed_buildAnnoHierarchyConfig = ({
|
|
1595
|
+
annotationTagsCount
|
|
1596
|
+
}) => {
|
|
1597
|
+
const hasThemes = annotationTagsCount?.themes > 0;
|
|
1598
|
+
const hasSubThemes = annotationTagsCount?.subThemes > 0;
|
|
1599
|
+
const hasTags = annotationTagsCount?.tags > 0;
|
|
1600
|
+
if (!hasThemes && !hasSubThemes && !hasTags) {
|
|
1601
|
+
return null;
|
|
1602
|
+
}
|
|
1603
|
+
const hierarchyLevels = [
|
|
1604
|
+
hasThemes && { level: "themes", filterId: FILTER_IDS.themes, tagType: "themes" },
|
|
1605
|
+
hasSubThemes && { level: "subThemes", filterId: FILTER_IDS.subThemes, tagType: "subThemes" },
|
|
1606
|
+
hasTags && { level: "tags", filterId: FILTER_IDS.tags, tagType: "tags" }
|
|
1607
|
+
].filter(Boolean);
|
|
1608
|
+
return {
|
|
1609
|
+
target: { filterType: "annoHierarchyType" },
|
|
1610
|
+
filterId: "annoHierarchy_annotation_filters",
|
|
1611
|
+
display: "Annotation Filters",
|
|
1612
|
+
filterKey: "annoHierarchyType::anno",
|
|
1613
|
+
source: {
|
|
1614
|
+
filterType: "annoHierarchyType",
|
|
1615
|
+
annotationTagsCount: {
|
|
1616
|
+
themes: hasThemes,
|
|
1617
|
+
subThemes: hasSubThemes,
|
|
1618
|
+
tags: hasTags
|
|
1619
|
+
},
|
|
1620
|
+
levelLabels: {
|
|
1621
|
+
themes: "Themes",
|
|
1622
|
+
subThemes: "Independent Sub-Themes",
|
|
1623
|
+
tags: "Independent Tags"
|
|
1624
|
+
},
|
|
1625
|
+
folderSelectionMode: "inclusive",
|
|
1626
|
+
hierarchyLevels
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
};
|
|
1630
|
+
|
|
1631
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/TEMP_removeDuplicateFilters.ts
|
|
1632
|
+
var TEMP_removeDuplicateFilters = (filterGroups) => {
|
|
1633
|
+
return filterGroups.map((group) => {
|
|
1634
|
+
if (!group.elements || !Array.isArray(group.elements)) {
|
|
1635
|
+
return group;
|
|
1636
|
+
}
|
|
1637
|
+
const seenFilters = /* @__PURE__ */ new Set();
|
|
1638
|
+
const deduplicatedElements = [];
|
|
1639
|
+
group.elements.forEach((element) => {
|
|
1640
|
+
let uniqueKey;
|
|
1641
|
+
if (element.filterType === "nestedRollupTagType" && element.rollupPath && Array.isArray(element.rollupPath)) {
|
|
1642
|
+
const finalTarget = element.rollupPath[element.rollupPath.length - 1];
|
|
1643
|
+
const firstContentType = group.contentTypes?.[0] || "unknown";
|
|
1644
|
+
uniqueKey = `rollup_${firstContentType}_${finalTarget}`;
|
|
1645
|
+
} else if (element.filterType === "tagType") {
|
|
1646
|
+
const tagType = element.tagType || "unknown";
|
|
1647
|
+
uniqueKey = `tag_${tagType}`;
|
|
1648
|
+
} else {
|
|
1649
|
+
deduplicatedElements.push(element);
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
if (!seenFilters.has(uniqueKey)) {
|
|
1653
|
+
seenFilters.add(uniqueKey);
|
|
1654
|
+
deduplicatedElements.push(element);
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
return {
|
|
1658
|
+
...group,
|
|
1659
|
+
elements: deduplicatedElements
|
|
1660
|
+
};
|
|
1661
|
+
});
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/getFilterKeyForBlock.ts
|
|
1665
|
+
var TAG_INPUT_COMPONENTS = ["TagsInputSingle", "TagsInputMulti"];
|
|
1666
|
+
var DATE_INPUT_COMPONENTS = ["DatePicker", "DateRangePicker", "DateTimePicker", "DateTimeRangePicker"];
|
|
1667
|
+
var NUMBER_INPUT_COMPONENTS = ["NumberInput"];
|
|
1668
|
+
var getFilterKeyForBlock = ({ block, scope = "tags" } = {}) => {
|
|
1669
|
+
if (!block) return void 0;
|
|
1670
|
+
const valuePath = block.valuePath;
|
|
1671
|
+
const comp = block.comp;
|
|
1672
|
+
const props = block.props || {};
|
|
1673
|
+
const isTagBlock = typeof valuePath === "string" && valuePath.startsWith("tags.") || TAG_INPUT_COMPONENTS.includes(comp) || !!props.tagType;
|
|
1674
|
+
if (isTagBlock) {
|
|
1675
|
+
const tagType = props.tagType || (typeof valuePath === "string" ? valuePath.split(".")[1] : void 0);
|
|
1676
|
+
if (!tagType) return void 0;
|
|
1677
|
+
return generateFilterKey({
|
|
1678
|
+
filterType: "tagType",
|
|
1679
|
+
tagType,
|
|
1680
|
+
scope
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
if (DATE_INPUT_COMPONENTS.includes(comp)) {
|
|
1684
|
+
return generateFilterKey({ filterType: "dateRangeType", valuePath, scope });
|
|
1685
|
+
}
|
|
1686
|
+
if (NUMBER_INPUT_COMPONENTS.includes(comp)) {
|
|
1687
|
+
return generateFilterKey({ filterType: "numberRangeType", valuePath, scope });
|
|
1688
|
+
}
|
|
1689
|
+
if (valuePath) {
|
|
1690
|
+
return generateFilterKey({ filterType: "valuePathType", valuePath, scope });
|
|
1691
|
+
}
|
|
1692
|
+
return void 0;
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1695
|
+
// src/utils/autoGenFilterConfigsFromTpl/index.ts
|
|
1696
|
+
var autoGenFilterConfigsFromTpl = ({
|
|
1697
|
+
selectedTpls,
|
|
1698
|
+
allTpls,
|
|
1699
|
+
filterScopes,
|
|
1700
|
+
isSelfManagedTenant = false,
|
|
1701
|
+
annotationTagsCount
|
|
1702
|
+
}) => {
|
|
1703
|
+
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls);
|
|
1704
|
+
const allAnnoEnabledBlocks = filterScopes.includes("anno") ? extractedBlocks.annoEnabledBlocks.flatMap((item) => item.blocks).reduce((acc, block) => {
|
|
1705
|
+
if (!acc.find((b) => b.valuePath === block.valuePath)) {
|
|
1706
|
+
acc.push(block);
|
|
1707
|
+
}
|
|
1708
|
+
return acc;
|
|
1709
|
+
}, []) : [];
|
|
1710
|
+
const { authorTagConfigs, commonAnnotationFilters, commonDocumentFilters } = processAuthorAndCommonFilters(allTpls, filterScopes, allAnnoEnabledBlocks);
|
|
1711
|
+
const annoTagGroups = filterScopes.includes("anno") ? isSelfManagedTenant ? _self_managed_getFixedAnnoTagBlock(selectedTpls, annotationTagsCount) : compareAndGroupBlocks(extractedBlocks.annoTagBlocks) : [];
|
|
1712
|
+
let annoRollupGroups = filterScopes.includes("anno") ? isSelfManagedTenant ? _self_managed_getFixedAnnoRollupBlocks({ selectedTpls, allTpls, annotationTagsCount }) : compareAndGroupBlocks(extractedBlocks.annoRollupBlocks) : [];
|
|
1713
|
+
const TEMP_deduplicatedAnnoTagGroups = TEMP_removeDuplicateFilters(annoTagGroups);
|
|
1714
|
+
const TEMP_deduplicatedAnnoRollupGroups = TEMP_removeDuplicateFilters(annoRollupGroups);
|
|
1715
|
+
const combinedDocumentGroups = filterScopes.includes("doc") ? compareAndGroupBlocks(extractedBlocks.combinedDocumentBlocks) : [];
|
|
1716
|
+
const TEMP_deduplicatedCombinedDocumentGroups = TEMP_removeDuplicateFilters(combinedDocumentGroups);
|
|
1717
|
+
const annotationTagSections = buildFilterConfigurations({
|
|
1718
|
+
groups: TEMP_deduplicatedAnnoTagGroups,
|
|
1719
|
+
type: "annoTags",
|
|
1720
|
+
selectedTpls,
|
|
1721
|
+
allTpls,
|
|
1722
|
+
isRollup: false,
|
|
1723
|
+
isAnno: true
|
|
1724
|
+
});
|
|
1725
|
+
const annotationRollupSections = buildFilterConfigurations({
|
|
1726
|
+
groups: TEMP_deduplicatedAnnoRollupGroups,
|
|
1727
|
+
type: "annoTags",
|
|
1728
|
+
selectedTpls,
|
|
1729
|
+
allTpls,
|
|
1730
|
+
isRollup: true,
|
|
1731
|
+
isAnno: true
|
|
1732
|
+
});
|
|
1733
|
+
const documentTagSections = buildFilterConfigurations({
|
|
1734
|
+
groups: TEMP_deduplicatedCombinedDocumentGroups,
|
|
1735
|
+
type: "tags",
|
|
1736
|
+
selectedTpls,
|
|
1737
|
+
allTpls,
|
|
1738
|
+
isRollup: false,
|
|
1739
|
+
isAnno: false
|
|
1740
|
+
});
|
|
1741
|
+
const final_annotationTagsFilterConfigs = {
|
|
1742
|
+
sectionId: "annotationTagsSection",
|
|
1743
|
+
sectionTitle: "Annotation Filters",
|
|
1744
|
+
configs: isSelfManagedTenant ? [
|
|
1745
|
+
{
|
|
1746
|
+
sectionId: "self_managed_consolidated_anno_filters",
|
|
1747
|
+
configs: (() => {
|
|
1748
|
+
const annoHierarchyConfig = _self_managed_buildAnnoHierarchyConfig({
|
|
1749
|
+
annotationTagsCount
|
|
1750
|
+
});
|
|
1751
|
+
const annoConfigs = annoHierarchyConfig ? [annoHierarchyConfig] : [
|
|
1752
|
+
...annotationRollupSections.flatMap((conf) => conf.configs),
|
|
1753
|
+
...annotationTagSections.flatMap((conf) => conf.configs)
|
|
1754
|
+
];
|
|
1755
|
+
return [
|
|
1756
|
+
...annoConfigs,
|
|
1757
|
+
...commonAnnotationFilters.flatMap((conf) => conf.configs)
|
|
1758
|
+
];
|
|
1759
|
+
})()
|
|
1760
|
+
}
|
|
1761
|
+
] : [
|
|
1762
|
+
...commonAnnotationFilters,
|
|
1763
|
+
...annotationTagSections,
|
|
1764
|
+
...annotationRollupSections
|
|
1765
|
+
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
1766
|
+
};
|
|
1767
|
+
const final_documentTagsFilterConfigs = {
|
|
1768
|
+
sectionId: "documentTagsSection",
|
|
1769
|
+
sectionTitle: "Document Filters",
|
|
1770
|
+
configs: [
|
|
1771
|
+
...commonDocumentFilters,
|
|
1772
|
+
...documentTagSections
|
|
1773
|
+
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
1774
|
+
};
|
|
1775
|
+
const result = [
|
|
1776
|
+
final_annotationTagsFilterConfigs.configs.length > 0 ? final_annotationTagsFilterConfigs : null,
|
|
1777
|
+
final_documentTagsFilterConfigs.configs.length > 0 ? final_documentTagsFilterConfigs : null
|
|
1778
|
+
].filter(Boolean);
|
|
1779
|
+
return result;
|
|
1780
|
+
};
|
|
816
1781
|
export {
|
|
817
1782
|
BASE_BULLMQ_CONFIG,
|
|
1783
|
+
FILTER_IDS,
|
|
1784
|
+
TEMP_removeDuplicateFilters,
|
|
1785
|
+
UI_CONTENT,
|
|
1786
|
+
_self_managed_buildAnnoHierarchyConfig,
|
|
1787
|
+
_self_managed_getFixedAnnoRollupBlocks,
|
|
1788
|
+
_self_managed_getFixedAnnoTagBlock,
|
|
1789
|
+
autoGenFilterConfigsFromTpl,
|
|
1790
|
+
buildFilterConfigurations,
|
|
1791
|
+
compareAndGroupBlocks,
|
|
818
1792
|
deleteVal,
|
|
819
1793
|
extractAllBlocksFromTpl,
|
|
1794
|
+
extractAndOrganizeBlocks,
|
|
820
1795
|
genTagId,
|
|
1796
|
+
generateFilterKey,
|
|
1797
|
+
getFilterKeyForBlock,
|
|
821
1798
|
getPlatformContextContent,
|
|
822
1799
|
getRollupPossibilities,
|
|
1800
|
+
getRoutePathToEditContent,
|
|
1801
|
+
getRoutePathToModerateContent,
|
|
1802
|
+
getRoutePathToPublishedContent,
|
|
823
1803
|
getVal,
|
|
824
1804
|
mergeAnnoDataIntoAnnotationsTags,
|
|
1805
|
+
parseSpecialConfigSyntax,
|
|
1806
|
+
processAuthorAndCommonFilters,
|
|
825
1807
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
826
1808
|
segrigateDocs,
|
|
827
1809
|
setVal,
|