@civicactions/cmsds-open-data-components 4.0.15 → 4.0.16-alpha.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/main.js +53 -19
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2776,13 +2776,31 @@ const $7264a673914aa746$export$5f89a5ae87bc48e1 = [
|
|
|
2776
2776
|
{
|
|
2777
2777
|
label: 'Less Than',
|
|
2778
2778
|
value: '<'
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
label: 'Is Empty',
|
|
2782
|
+
value: 'is_empty'
|
|
2783
|
+
},
|
|
2784
|
+
{
|
|
2785
|
+
label: 'Not Empty',
|
|
2786
|
+
value: 'not_empty'
|
|
2779
2787
|
}
|
|
2780
2788
|
];
|
|
2781
2789
|
function $7264a673914aa746$export$d243819c3ad678fb(operatorValue) {
|
|
2782
2790
|
const operator = $7264a673914aa746$export$5f89a5ae87bc48e1.find((op)=>op.value === operatorValue);
|
|
2783
2791
|
return operator ? operator.label : operatorValue; // Return original value if not found
|
|
2784
2792
|
}
|
|
2785
|
-
function $7264a673914aa746$export$2b9377795161999(type) {
|
|
2793
|
+
function $7264a673914aa746$export$2b9377795161999(type, enableEmptyFilters = false) {
|
|
2794
|
+
const emptyOptions = enableEmptyFilters ? [
|
|
2795
|
+
{
|
|
2796
|
+
label: 'Is Empty',
|
|
2797
|
+
value: 'is_empty'
|
|
2798
|
+
},
|
|
2799
|
+
{
|
|
2800
|
+
label: 'Not Empty',
|
|
2801
|
+
value: 'not_empty'
|
|
2802
|
+
}
|
|
2803
|
+
] : [];
|
|
2786
2804
|
switch(type){
|
|
2787
2805
|
case 'text':
|
|
2788
2806
|
case 'string':
|
|
@@ -2806,7 +2824,8 @@ function $7264a673914aa746$export$2b9377795161999(type) {
|
|
|
2806
2824
|
{
|
|
2807
2825
|
label: 'Or',
|
|
2808
2826
|
value: 'in'
|
|
2809
|
-
}
|
|
2827
|
+
},
|
|
2828
|
+
...emptyOptions
|
|
2810
2829
|
];
|
|
2811
2830
|
case 'date':
|
|
2812
2831
|
return [
|
|
@@ -2825,7 +2844,8 @@ function $7264a673914aa746$export$2b9377795161999(type) {
|
|
|
2825
2844
|
{
|
|
2826
2845
|
label: 'Less Than',
|
|
2827
2846
|
value: '<'
|
|
2828
|
-
}
|
|
2847
|
+
},
|
|
2848
|
+
...emptyOptions
|
|
2829
2849
|
];
|
|
2830
2850
|
default:
|
|
2831
2851
|
// These 2 should be safe for all data types
|
|
@@ -2837,7 +2857,8 @@ function $7264a673914aa746$export$2b9377795161999(type) {
|
|
|
2837
2857
|
{
|
|
2838
2858
|
label: 'Is Not',
|
|
2839
2859
|
value: '<>'
|
|
2840
|
-
}
|
|
2860
|
+
},
|
|
2861
|
+
...emptyOptions
|
|
2841
2862
|
];
|
|
2842
2863
|
}
|
|
2843
2864
|
}
|
|
@@ -3552,7 +3573,7 @@ function $eadd6431fddf4b6c$var$getStartDate(condition, schema, id) {
|
|
|
3552
3573
|
}
|
|
3553
3574
|
return new Date();
|
|
3554
3575
|
}
|
|
3555
|
-
const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index: index, update: update, remove: remove, propertyOptions: propertyOptions, schema: schema, className: className = '' })=>{
|
|
3576
|
+
const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index: index, update: update, remove: remove, propertyOptions: propertyOptions, schema: schema, className: className = '', enableEmptyFilters: enableEmptyFilters })=>{
|
|
3556
3577
|
const [operator, setOperator] = (0, $hgUW1$useState)(condition.operator);
|
|
3557
3578
|
const [property, setProperty] = (0, $hgUW1$useState)(condition.property);
|
|
3558
3579
|
const [value, setValue] = (0, $hgUW1$useState)(condition.value);
|
|
@@ -3621,7 +3642,7 @@ const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index:
|
|
|
3621
3642
|
onChange: (e)=>setProperty(e.target.value)
|
|
3622
3643
|
}),
|
|
3623
3644
|
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
|
|
3624
|
-
options: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[property].mysql_type),
|
|
3645
|
+
options: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[property].mysql_type, enableEmptyFilters),
|
|
3625
3646
|
className: "ds-u-padding-x--0",
|
|
3626
3647
|
value: operator,
|
|
3627
3648
|
label: "Condition",
|
|
@@ -3702,6 +3723,16 @@ var $2eec38d4d0dbf714$export$2e2bcd8739ae039 = $2eec38d4d0dbf714$var$ClearFilter
|
|
|
3702
3723
|
function $6f4318b1e14124e5$var$updateQueryForDatastore(condition) {
|
|
3703
3724
|
let cond = condition;
|
|
3704
3725
|
delete cond.key;
|
|
3726
|
+
if (cond.operator === 'is_empty') {
|
|
3727
|
+
cond.operator = '=';
|
|
3728
|
+
cond.value = '';
|
|
3729
|
+
return cond;
|
|
3730
|
+
}
|
|
3731
|
+
if (cond.operator === 'not_empty') {
|
|
3732
|
+
cond.operator = '<>';
|
|
3733
|
+
cond.value = '';
|
|
3734
|
+
return cond;
|
|
3735
|
+
}
|
|
3705
3736
|
if (cond.operator === '=' || cond.operator === '<>') {
|
|
3706
3737
|
if (Array.isArray(cond.value)) cond.value = cond.value.join();
|
|
3707
3738
|
cond.value = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
@@ -3718,7 +3749,7 @@ function $6f4318b1e14124e5$var$updateQueryForDatastore(condition) {
|
|
|
3718
3749
|
return cond;
|
|
3719
3750
|
}
|
|
3720
3751
|
const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
3721
|
-
const { distribution: distribution, resource: resource, customColumns: customColumns = [] } = (0, $hgUW1$useContext)((0, $43a30d745a7bbc86$export$2e2bcd8739ae039));
|
|
3752
|
+
const { distribution: distribution, resource: resource, customColumns: customColumns = [], enableEmptyFilters: enableEmptyFilters } = (0, $hgUW1$useContext)((0, $43a30d745a7bbc86$export$2e2bcd8739ae039));
|
|
3722
3753
|
const { setPage: setPage } = (0, $hgUW1$useContext)((0, $ee0d4d4f34048447$export$f814ea079e65d8fe));
|
|
3723
3754
|
if (!resource) return null;
|
|
3724
3755
|
const customColumnHeaders = (0, $7264a673914aa746$export$8049e8f40a9bdfb8)(customColumns, resource.columns, resource.schema[distribution.identifier]);
|
|
@@ -3741,7 +3772,7 @@ const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
|
3741
3772
|
{
|
|
3742
3773
|
property: fields[0],
|
|
3743
3774
|
value: '',
|
|
3744
|
-
operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type)[0].value,
|
|
3775
|
+
operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type, enableEmptyFilters)[0].value,
|
|
3745
3776
|
key: Date.now().toString()
|
|
3746
3777
|
}
|
|
3747
3778
|
]);
|
|
@@ -3758,7 +3789,7 @@ const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
|
3758
3789
|
{
|
|
3759
3790
|
property: fields[0],
|
|
3760
3791
|
value: '',
|
|
3761
|
-
operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type)[0].value,
|
|
3792
|
+
operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type, enableEmptyFilters)[0].value,
|
|
3762
3793
|
key: Date.now().toString()
|
|
3763
3794
|
}
|
|
3764
3795
|
]);
|
|
@@ -3792,14 +3823,14 @@ const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
|
3792
3823
|
};
|
|
3793
3824
|
const submitConditions = ()=>{
|
|
3794
3825
|
// only update the data conditions when "Apply filters" is pressed
|
|
3795
|
-
const
|
|
3826
|
+
const filteredConditions = queryConditions.filter((oc)=>{
|
|
3796
3827
|
if (oc.property) return oc;
|
|
3797
3828
|
return false;
|
|
3798
|
-
})
|
|
3829
|
+
});
|
|
3830
|
+
const completeConditions = conditionsReadyToSubmit(filteredConditions).map((oc)=>{
|
|
3799
3831
|
let cond = Object.assign({}, oc);
|
|
3800
3832
|
return $6f4318b1e14124e5$var$updateQueryForDatastore(cond);
|
|
3801
3833
|
});
|
|
3802
|
-
const completeConditions = conditionsReadyToSubmit(submitConditions);
|
|
3803
3834
|
if (completeConditions.length) {
|
|
3804
3835
|
setConditions(completeConditions);
|
|
3805
3836
|
setPage(1);
|
|
@@ -3818,7 +3849,8 @@ const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
|
3818
3849
|
};
|
|
3819
3850
|
const completeConditions = conditions.filter((condition)=>{
|
|
3820
3851
|
if (condition) {
|
|
3821
|
-
|
|
3852
|
+
const isEmptyOperator = condition.operator === 'is_empty' || condition.operator === 'not_empty';
|
|
3853
|
+
if (!isEmpty(condition.property) && !isEmpty(condition.operator) && (isEmptyOperator || !isEmpty(condition.value))) return condition;
|
|
3822
3854
|
}
|
|
3823
3855
|
});
|
|
3824
3856
|
return completeConditions;
|
|
@@ -3863,9 +3895,9 @@ const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
|
3863
3895
|
children: [
|
|
3864
3896
|
/*#__PURE__*/ (0, $hgUW1$jsx)("span", {
|
|
3865
3897
|
className: "dkan-dataset-toolbar-button-label",
|
|
3866
|
-
children: conditions.length > 0 ? `Edit Filters` : 'Filter Dataset'
|
|
3898
|
+
children: conditions && conditions.length > 0 ? `Edit Filters` : 'Filter Dataset'
|
|
3867
3899
|
}),
|
|
3868
|
-
conditions.length > 0 && ` (${conditions.length})`
|
|
3900
|
+
conditions && conditions.length > 0 && ` (${conditions.length})`
|
|
3869
3901
|
]
|
|
3870
3902
|
})
|
|
3871
3903
|
]
|
|
@@ -3946,7 +3978,8 @@ const $6f4318b1e14124e5$var$FilterDataset = ()=>{
|
|
|
3946
3978
|
propertyOptions: propertyOptions,
|
|
3947
3979
|
update: updateCondition,
|
|
3948
3980
|
remove: removeCondition,
|
|
3949
|
-
className: index !== 0 ? "ds-u-border-top--1" : "ds-u-border--0"
|
|
3981
|
+
className: index !== 0 ? "ds-u-border-top--1" : "ds-u-border--0",
|
|
3982
|
+
enableEmptyFilters: enableEmptyFilters
|
|
3950
3983
|
}, qf.key))
|
|
3951
3984
|
}),
|
|
3952
3985
|
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
@@ -4247,7 +4280,7 @@ const $85f8ff1ff89899c7$var$DataTableToolbar = ({ resource: resource, id: id, co
|
|
|
4247
4280
|
children: [
|
|
4248
4281
|
conditions.length > 0 ? conditions.map((condition, index)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $c5b172e8d1a8197c$export$2e2bcd8739ae039), {
|
|
4249
4282
|
iconClass: "far fa-filter",
|
|
4250
|
-
text: `"${condition.property}" ${(0, $7264a673914aa746$export$d243819c3ad678fb)(condition.operator).toLowerCase()} ${condition.value}`,
|
|
4283
|
+
text: `"${condition.property}" ${(0, $7264a673914aa746$export$d243819c3ad678fb)(condition.operator).toLowerCase()}${condition.value === '' ? '' : ` ${condition.value}`}`,
|
|
4251
4284
|
onClick: ()=>{
|
|
4252
4285
|
removeCondition(index);
|
|
4253
4286
|
}
|
|
@@ -6428,7 +6461,7 @@ const $a0f13962e513caa1$var$getDataDictionary = (dataDictionaryUrl)=>{
|
|
|
6428
6461
|
dataDictionaryLoading: isPending
|
|
6429
6462
|
};
|
|
6430
6463
|
};
|
|
6431
|
-
const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, customColumns: customColumns, setDatasetTitle: setDatasetTitle, customMetadataMapping: customMetadataMapping, apiPageUrl: apiPageUrl = "/api", dataDictionaryUrl: dataDictionaryUrl, borderlessTabs: borderlessTabs = false, defaultPageSize: defaultPageSize = 25, dataDictionaryCSV: dataDictionaryCSV = false, dataDictionaryBanner: dataDictionaryBanner = false, disableTableControls: disableTableControls = false, hideDataDictionary: hideDataDictionary = false, customDescription: customDescription, updateAriaLive: updateAriaLive, showRowLimitNotice: showRowLimitNotice = false })=>{
|
|
6464
|
+
const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, customColumns: customColumns, setDatasetTitle: setDatasetTitle, customMetadataMapping: customMetadataMapping, apiPageUrl: apiPageUrl = "/api", dataDictionaryUrl: dataDictionaryUrl, borderlessTabs: borderlessTabs = false, defaultPageSize: defaultPageSize = 25, dataDictionaryCSV: dataDictionaryCSV = false, dataDictionaryBanner: dataDictionaryBanner = false, disableTableControls: disableTableControls = false, hideDataDictionary: hideDataDictionary = false, customDescription: customDescription, updateAriaLive: updateAriaLive, showRowLimitNotice: showRowLimitNotice = false, enableEmptyFilters: enableEmptyFilters = false })=>{
|
|
6432
6465
|
const options = location.search ? {
|
|
6433
6466
|
...(0, $hgUW1$qs).parse(location.search, {
|
|
6434
6467
|
ignoreQueryPrefix: true
|
|
@@ -6586,7 +6619,8 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, customColumns
|
|
|
6586
6619
|
rootUrl: rootUrl,
|
|
6587
6620
|
customColumns: customColumns,
|
|
6588
6621
|
dataDictionaryBanner: dataDictionaryBanner && displayDataDictionaryTab,
|
|
6589
|
-
datasetTableControls: !disableTableControls
|
|
6622
|
+
datasetTableControls: !disableTableControls,
|
|
6623
|
+
enableEmptyFilters: enableEmptyFilters
|
|
6590
6624
|
},
|
|
6591
6625
|
children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $39bc4d98030a5599$export$2e2bcd8739ae039), {})
|
|
6592
6626
|
}) : /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
|