@datawheel/data-explorer 1.0.7 → 1.0.9
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/main.mjs +81 -15
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -2812,14 +2812,35 @@ var propertiesUpdateHandler = (actions2, item, activeProps) => {
|
|
|
2812
2812
|
);
|
|
2813
2813
|
actions2.updateDrilldown({ ...item, properties });
|
|
2814
2814
|
};
|
|
2815
|
-
var removeColumn = (actions2, entity, measures, drilldowns, type) => {
|
|
2815
|
+
var removeColumn = (actions2, entity, measures, drilldowns, type, queryItem, updateURL) => {
|
|
2816
|
+
const newQuery = buildQuery(_.cloneDeep(queryItem));
|
|
2816
2817
|
if ("aggregator" in entity) {
|
|
2817
2818
|
const measure = measures.find((d) => d.name === entity.name);
|
|
2818
|
-
|
|
2819
|
+
if (measure) {
|
|
2820
|
+
const newMeasure = { ...measure, active: false };
|
|
2821
|
+
actions2.updateMeasure(newMeasure);
|
|
2822
|
+
newQuery.params.measures[newMeasure.name] = newMeasure;
|
|
2823
|
+
updateURL({
|
|
2824
|
+
...newQuery,
|
|
2825
|
+
params: {
|
|
2826
|
+
...newQuery.params
|
|
2827
|
+
}
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2819
2830
|
}
|
|
2820
2831
|
if ("depth" in entity) {
|
|
2821
2832
|
const drilldown = drilldowns.find((d) => d.level === entity.name);
|
|
2822
|
-
|
|
2833
|
+
if (drilldown) {
|
|
2834
|
+
const newDrilldown = { ...drilldown, active: false };
|
|
2835
|
+
actions2.updateDrilldown(newDrilldown);
|
|
2836
|
+
newQuery.params.drilldowns[newDrilldown.key] = newDrilldown;
|
|
2837
|
+
updateURL({
|
|
2838
|
+
...newQuery,
|
|
2839
|
+
params: {
|
|
2840
|
+
...newQuery.params
|
|
2841
|
+
}
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2823
2844
|
}
|
|
2824
2845
|
if (isProperty(type)) {
|
|
2825
2846
|
const activeDrilldowns = drilldowns.filter((d) => d.active);
|
|
@@ -3069,6 +3090,7 @@ function useTable({
|
|
|
3069
3090
|
header,
|
|
3070
3091
|
enableHiding: true,
|
|
3071
3092
|
accessorFn: (row) => row[columnKey],
|
|
3093
|
+
// This functions is not being used. Manual sorting is enabled.
|
|
3072
3094
|
sortingFn: (rowA, rowB, columnId) => {
|
|
3073
3095
|
if (rowA.original[columnId] < rowB.original[columnId]) {
|
|
3074
3096
|
return -1;
|
|
@@ -3089,12 +3111,38 @@ function useTable({
|
|
|
3089
3111
|
onClick: () => {
|
|
3090
3112
|
if (!isSorted) {
|
|
3091
3113
|
actions2.updateSorting({ key: entity.name, dir: "desc" });
|
|
3114
|
+
const newQuery = buildQuery(_.cloneDeep(queryItem));
|
|
3115
|
+
updateURL({
|
|
3116
|
+
...newQuery,
|
|
3117
|
+
params: {
|
|
3118
|
+
...newQuery.params,
|
|
3119
|
+
sortKey: `${entity.name}`,
|
|
3120
|
+
sortDir: "desc"
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3092
3123
|
}
|
|
3093
3124
|
if (isSorted && sortDir === "desc") {
|
|
3094
3125
|
actions2.updateSorting({ key: entity.name, dir: "asc" });
|
|
3126
|
+
const newQuery = buildQuery(_.cloneDeep(queryItem));
|
|
3127
|
+
updateURL({
|
|
3128
|
+
...newQuery,
|
|
3129
|
+
params: {
|
|
3130
|
+
...newQuery.params,
|
|
3131
|
+
sortKey: `${entity.name}`,
|
|
3132
|
+
sortDir: "asc"
|
|
3133
|
+
}
|
|
3134
|
+
});
|
|
3095
3135
|
}
|
|
3096
3136
|
if (isSorted && sortDir === "asc") {
|
|
3097
3137
|
actions2.clearSorting();
|
|
3138
|
+
const newQuery = buildQuery(_.cloneDeep(queryItem));
|
|
3139
|
+
updateURL({
|
|
3140
|
+
...newQuery,
|
|
3141
|
+
params: {
|
|
3142
|
+
...newQuery.params,
|
|
3143
|
+
sortKey: void 0
|
|
3144
|
+
}
|
|
3145
|
+
});
|
|
3098
3146
|
}
|
|
3099
3147
|
}
|
|
3100
3148
|
},
|
|
@@ -3104,8 +3152,18 @@ function useTable({
|
|
|
3104
3152
|
{
|
|
3105
3153
|
label: `At least one ${getEntityText(entityType)} is required.`,
|
|
3106
3154
|
key: `remove-${column2.columnDef.header}`,
|
|
3107
|
-
disabled: !showTrashIcon(finalKeys, entityType),
|
|
3108
|
-
onClick: () =>
|
|
3155
|
+
disabled: !showTrashIcon(finalKeys, entityType) || isLoading || isFetching,
|
|
3156
|
+
onClick: () => {
|
|
3157
|
+
removeColumn(
|
|
3158
|
+
actions2,
|
|
3159
|
+
entity,
|
|
3160
|
+
measures,
|
|
3161
|
+
drilldowns,
|
|
3162
|
+
entityType,
|
|
3163
|
+
queryItem,
|
|
3164
|
+
updateURL
|
|
3165
|
+
);
|
|
3166
|
+
},
|
|
3109
3167
|
showTooltip: !showTrashIcon(finalKeys, entityType),
|
|
3110
3168
|
size: 25,
|
|
3111
3169
|
ml: rem(5)
|
|
@@ -4779,16 +4837,24 @@ function QueryProvider({ children, defaultCube }) {
|
|
|
4779
4837
|
newQuery.params.locale = defaultLocale || newQuery.params.locale;
|
|
4780
4838
|
if (newQuery) {
|
|
4781
4839
|
const promises = Object.values(newQuery.params.drilldowns).map((dd) => {
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
return {
|
|
4785
|
-
drilldown:
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4840
|
+
const currentDrilldown = queryItem.params.drilldowns[dd.key];
|
|
4841
|
+
if (currentDrilldown && currentDrilldown.members && currentDrilldown.members.length > 0) {
|
|
4842
|
+
return Promise.resolve({
|
|
4843
|
+
drilldown: currentDrilldown,
|
|
4844
|
+
cut: buildCut({ ...currentDrilldown, active: false })
|
|
4845
|
+
});
|
|
4846
|
+
} else {
|
|
4847
|
+
return fetchMembers(dd.level, newQuery == null ? void 0 : newQuery.params.locale, cube).then((levelMeta) => {
|
|
4848
|
+
const cut = buildCut({ ...dd, active: false });
|
|
4849
|
+
return {
|
|
4850
|
+
drilldown: {
|
|
4851
|
+
...dd,
|
|
4852
|
+
members: levelMeta.members
|
|
4853
|
+
},
|
|
4854
|
+
cut
|
|
4855
|
+
};
|
|
4856
|
+
});
|
|
4857
|
+
}
|
|
4792
4858
|
});
|
|
4793
4859
|
runFetchMembers(Promise.all(promises)).then((data) => {
|
|
4794
4860
|
const drilldowns = data.map((item) => item.drilldown);
|