@isrd-isi-edu/ermrestjs 2.6.1 → 2.8.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/js/ag_reference.js +2 -1
- package/js/core.js +11 -5
- package/js/utils/helpers.js +2 -460
- package/js/utils/pseudocolumn_helpers.js +37 -5
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/models/active-list-condition.ts +72 -29
- package/src/models/reference/reference.ts +8 -2
- package/src/models/reference/tuple.ts +14 -1
- package/src/models/reference-column/reference-column.ts +14 -5
- package/src/models/source-object-wrapper.ts +4 -4
- package/src/services/active-list.ts +6 -1
- package/src/services/handlebars.ts +69 -10
- package/src/utils/column-utils.ts +1 -1
- package/src/utils/constants.ts +84 -0
- package/src/utils/format-utils.ts +755 -0
- package/src/utils/reference-utils.ts +29 -2
- package/tsconfig.json +1 -2
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
type Tuple,
|
|
20
20
|
type VisibleColumn,
|
|
21
21
|
} from '@isrd-isi-edu/ermrestjs/src/models/reference';
|
|
22
|
+
import ActiveListCondition from '@isrd-isi-edu/ermrestjs/src/models/active-list-condition';
|
|
22
23
|
|
|
23
24
|
// services
|
|
24
25
|
import $log from '@isrd-isi-edu/ermrestjs/src/services/logger';
|
|
@@ -1031,9 +1032,35 @@ export function generateColumnsList(
|
|
|
1031
1032
|
}
|
|
1032
1033
|
}
|
|
1033
1034
|
|
|
1035
|
+
applyNoSourceConditions(resultColumns, (col) => col.resolvedCondition);
|
|
1036
|
+
|
|
1034
1037
|
return resultColumns;
|
|
1035
1038
|
}
|
|
1036
1039
|
|
|
1040
|
+
/**
|
|
1041
|
+
* Splice items whose no-source condition evaluates to "hide". With-source
|
|
1042
|
+
* conditions are left in place (handled by chaise after the main read).
|
|
1043
|
+
* Mutates `items` in place.
|
|
1044
|
+
*/
|
|
1045
|
+
export function applyNoSourceConditions<T>(items: T[], getCondition: (item: T) => ActiveListCondition | null | undefined): void {
|
|
1046
|
+
for (let i = 0; i < items.length; i++) {
|
|
1047
|
+
const cond = getCondition(items[i]);
|
|
1048
|
+
if (!cond || cond.column !== null) continue; // no condition, or with-source
|
|
1049
|
+
|
|
1050
|
+
let shouldShow = true;
|
|
1051
|
+
try {
|
|
1052
|
+
shouldShow = cond.evaluateCondition({}, null).shouldShow;
|
|
1053
|
+
} catch (e) {
|
|
1054
|
+
$log.warn('no-source condition evaluation failed; defaulting to show: ' + (e instanceof Error ? e.message : String(e)));
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
if (!shouldShow) {
|
|
1058
|
+
items.splice(i, 1);
|
|
1059
|
+
i--;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1037
1064
|
/**
|
|
1038
1065
|
* Generate a list of facetColumns that should be used for the given reference.
|
|
1039
1066
|
* will also attach _facetColumns to the reference.
|
|
@@ -1110,7 +1137,7 @@ export function generateFacetColumns(
|
|
|
1110
1137
|
|
|
1111
1138
|
try {
|
|
1112
1139
|
if ('and' in obj) {
|
|
1113
|
-
const fow = new FacetObjectGroupWrapper(obj, reference
|
|
1140
|
+
const fow = new FacetObjectGroupWrapper(obj, reference, hasFilterOrFacet);
|
|
1114
1141
|
// avoid duplicate groups
|
|
1115
1142
|
if (fow.displayname.unformatted! in addedGroups) {
|
|
1116
1143
|
throw new Error(`Duplicate facet group name: ${fow.displayname.unformatted}`);
|
|
@@ -1118,7 +1145,7 @@ export function generateFacetColumns(
|
|
|
1118
1145
|
addedGroups[fow.displayname.unformatted!] = true;
|
|
1119
1146
|
facetObjectWrappers.push(fow);
|
|
1120
1147
|
} else {
|
|
1121
|
-
const wrapper = helpers.sourceDefToFacetObjectWrapper(obj, reference
|
|
1148
|
+
const wrapper = helpers.sourceDefToFacetObjectWrapper(obj, reference, hasFilterOrFacet);
|
|
1122
1149
|
facetObjectWrappers.push(wrapper);
|
|
1123
1150
|
}
|
|
1124
1151
|
} catch (exp) {
|
package/tsconfig.json
CHANGED