@firecms/core 3.0.0-canary.112 → 3.0.0-canary.113
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/index.es.js +53 -43
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +53 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/types/datasource.d.ts +8 -6
- package/dist/types/entity_overrides.d.ts +2 -2
- package/package.json +5 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +1 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
- package/src/core/EntityEditView.tsx +2 -2
- package/src/core/SideDialogs.tsx +0 -2
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/useDataSource.tsx +10 -2
- package/src/hooks/useBuildNavigationController.tsx +2 -1
- package/src/internal/useBuildDataSource.ts +41 -67
- package/src/types/datasource.ts +9 -6
- package/src/types/entity_overrides.tsx +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -3252,8 +3252,6 @@
|
|
|
3252
3252
|
const DataSourceContext = React.createContext({});
|
|
3253
3253
|
const useDataSource = (collection) => {
|
|
3254
3254
|
const defaultDataSource = React.useContext(DataSourceContext);
|
|
3255
|
-
if (collection?.overrides?.dataSource)
|
|
3256
|
-
return collection?.overrides.dataSource;
|
|
3257
3255
|
return defaultDataSource;
|
|
3258
3256
|
};
|
|
3259
3257
|
const NavigationContext = React.createContext({});
|
|
@@ -3391,7 +3389,7 @@
|
|
|
3391
3389
|
itemCount,
|
|
3392
3390
|
searchString
|
|
3393
3391
|
}) {
|
|
3394
|
-
const dataSource = useDataSource(
|
|
3392
|
+
const dataSource = useDataSource();
|
|
3395
3393
|
const navigationController = useNavigationController();
|
|
3396
3394
|
const path = navigationController.resolveAliasesFrom(inputPath);
|
|
3397
3395
|
const sortByProperty = sortBy ? sortBy[0] : void 0;
|
|
@@ -3474,7 +3472,7 @@
|
|
|
3474
3472
|
collection,
|
|
3475
3473
|
useCache = false
|
|
3476
3474
|
}) {
|
|
3477
|
-
const dataSource = useDataSource(
|
|
3475
|
+
const dataSource = useDataSource();
|
|
3478
3476
|
const navigationController = useNavigationController();
|
|
3479
3477
|
const path = navigationController.resolveAliasesFrom(inputPath);
|
|
3480
3478
|
const context = useFireCMSContext();
|
|
@@ -3685,7 +3683,8 @@
|
|
|
3685
3683
|
}
|
|
3686
3684
|
}
|
|
3687
3685
|
return dataSource.deleteEntity({
|
|
3688
|
-
entity
|
|
3686
|
+
entity,
|
|
3687
|
+
collection
|
|
3689
3688
|
}).then(() => {
|
|
3690
3689
|
onDeleteSuccess && onDeleteSuccess(entity);
|
|
3691
3690
|
try {
|
|
@@ -10352,7 +10351,7 @@
|
|
|
10352
10351
|
} = collection;
|
|
10353
10352
|
const [popupCell, setPopupCell] = React.useState(void 0);
|
|
10354
10353
|
const navigation = useNavigationController();
|
|
10355
|
-
const dataSource = useDataSource(
|
|
10354
|
+
const dataSource = useDataSource();
|
|
10356
10355
|
const resolvedPath = React.useMemo(() => navigation.resolveAliasesFrom(fullPath), [fullPath, navigation.resolveAliasesFrom]);
|
|
10357
10356
|
const forceFilter = forceFilterFromProps ?? forceFilterFromCollection;
|
|
10358
10357
|
const paginationEnabled = collection.pagination === void 0 || Boolean(collection.pagination);
|
|
@@ -10600,7 +10599,7 @@
|
|
|
10600
10599
|
onMultipleEntitiesDelete,
|
|
10601
10600
|
path
|
|
10602
10601
|
}) {
|
|
10603
|
-
const dataSource = useDataSource(
|
|
10602
|
+
const dataSource = useDataSource();
|
|
10604
10603
|
const customizationController = useCustomizationController();
|
|
10605
10604
|
const snackbarController = useSnackbarController();
|
|
10606
10605
|
const [loading, setLoading] = React.useState(false);
|
|
@@ -10895,7 +10894,8 @@
|
|
|
10895
10894
|
const analyticsController = useAnalyticsController();
|
|
10896
10895
|
const customizationController = useCustomizationController();
|
|
10897
10896
|
const fullPath = navigation.resolveAliasesFrom(pathInput);
|
|
10898
|
-
|
|
10897
|
+
console.trace("Opening reference dialog for path " + fullPath);
|
|
10898
|
+
const dataSource = useDataSource();
|
|
10899
10899
|
const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = React.useState([]);
|
|
10900
10900
|
const toggleEntitySelection = (entity) => {
|
|
10901
10901
|
let newValue;
|
|
@@ -12244,7 +12244,7 @@
|
|
|
12244
12244
|
}) {
|
|
12245
12245
|
const context = useFireCMSContext();
|
|
12246
12246
|
const fullPath = fullPathProp ?? collectionProp.path;
|
|
12247
|
-
const dataSource = useDataSource(
|
|
12247
|
+
const dataSource = useDataSource();
|
|
12248
12248
|
const navigation = useNavigationController();
|
|
12249
12249
|
const sideEntityController = useSideEntityController();
|
|
12250
12250
|
const authController = useAuthController();
|
|
@@ -12378,7 +12378,7 @@
|
|
|
12378
12378
|
value,
|
|
12379
12379
|
property,
|
|
12380
12380
|
entityId
|
|
12381
|
-
}) => dataSource.checkUniqueField(fullPath, name, value, entityId, collection
|
|
12381
|
+
}) => dataSource.checkUniqueField(fullPath, name, value, entityId, collection),
|
|
12382
12382
|
[fullPath]
|
|
12383
12383
|
);
|
|
12384
12384
|
const onValueChange = ({
|
|
@@ -12758,7 +12758,7 @@
|
|
|
12758
12758
|
sortBy,
|
|
12759
12759
|
onCountChange
|
|
12760
12760
|
}) {
|
|
12761
|
-
const dataSource = useDataSource(
|
|
12761
|
+
const dataSource = useDataSource();
|
|
12762
12762
|
const navigation = useNavigationController();
|
|
12763
12763
|
const [count, setCount] = React.useState(void 0);
|
|
12764
12764
|
const [error, setError] = React.useState(void 0);
|
|
@@ -17315,7 +17315,7 @@
|
|
|
17315
17315
|
}, false, 2e3);
|
|
17316
17316
|
const inputCollection = collection;
|
|
17317
17317
|
const authController = useAuthController();
|
|
17318
|
-
const dataSource = useDataSource(
|
|
17318
|
+
const dataSource = useDataSource();
|
|
17319
17319
|
const sideDialogContext = useSideDialogContext();
|
|
17320
17320
|
const sideEntityController = useSideEntityController();
|
|
17321
17321
|
const snackbarController = useSnackbarController();
|
|
@@ -17337,7 +17337,7 @@
|
|
|
17337
17337
|
if (mustSetCustomId) {
|
|
17338
17338
|
return void 0;
|
|
17339
17339
|
} else {
|
|
17340
|
-
return dataSource.generateEntityId(path);
|
|
17340
|
+
return dataSource.generateEntityId(path, collection);
|
|
17341
17341
|
}
|
|
17342
17342
|
} else {
|
|
17343
17343
|
return entityIdProp;
|
|
@@ -17710,7 +17710,7 @@
|
|
|
17710
17710
|
name,
|
|
17711
17711
|
value,
|
|
17712
17712
|
property
|
|
17713
|
-
}) => dataSource.checkUniqueField(path, name, value, entityId, collection
|
|
17713
|
+
}) => dataSource.checkUniqueField(path, name, value, entityId, collection),
|
|
17714
17714
|
[dataSource, path, entityId]
|
|
17715
17715
|
);
|
|
17716
17716
|
const validationSchema = React.useMemo(
|
|
@@ -18263,11 +18263,9 @@
|
|
|
18263
18263
|
setDrawerCloseRequested(false);
|
|
18264
18264
|
};
|
|
18265
18265
|
const onCloseRequest = (force) => {
|
|
18266
|
-
console.log("onCloseRequest", blocked, force);
|
|
18267
18266
|
if (blocked && !force) {
|
|
18268
18267
|
setDrawerCloseRequested(true);
|
|
18269
18268
|
} else {
|
|
18270
|
-
console.log("onCloseRequest closing");
|
|
18271
18269
|
sideDialogsController.close();
|
|
18272
18270
|
panel?.onClose?.();
|
|
18273
18271
|
}
|
|
@@ -18681,7 +18679,8 @@
|
|
|
18681
18679
|
orderBy,
|
|
18682
18680
|
order
|
|
18683
18681
|
}) => {
|
|
18684
|
-
|
|
18682
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18683
|
+
return usedDelegate.fetchCollection({
|
|
18685
18684
|
path,
|
|
18686
18685
|
filter,
|
|
18687
18686
|
limit,
|
|
@@ -18721,10 +18720,10 @@
|
|
|
18721
18720
|
onError
|
|
18722
18721
|
}) => {
|
|
18723
18722
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
18724
|
-
|
|
18725
|
-
if (!
|
|
18723
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18724
|
+
if (!usedDelegate.listenCollection)
|
|
18726
18725
|
throw Error("useBuildDataSource delegate not initialised");
|
|
18727
|
-
return
|
|
18726
|
+
return usedDelegate.listenCollection({
|
|
18728
18727
|
path,
|
|
18729
18728
|
filter,
|
|
18730
18729
|
limit,
|
|
@@ -18748,11 +18747,14 @@
|
|
|
18748
18747
|
path,
|
|
18749
18748
|
entityId,
|
|
18750
18749
|
collection
|
|
18751
|
-
}) =>
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
18755
|
-
|
|
18750
|
+
}) => {
|
|
18751
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18752
|
+
return usedDelegate.fetchEntity({
|
|
18753
|
+
path,
|
|
18754
|
+
entityId,
|
|
18755
|
+
collection
|
|
18756
|
+
});
|
|
18757
|
+
}, [delegate.fetchEntity]),
|
|
18756
18758
|
/**
|
|
18757
18759
|
*
|
|
18758
18760
|
* @param path
|
|
@@ -18770,9 +18772,10 @@
|
|
|
18770
18772
|
onUpdate,
|
|
18771
18773
|
onError
|
|
18772
18774
|
}) => {
|
|
18773
|
-
|
|
18775
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18776
|
+
if (!usedDelegate.listenEntity)
|
|
18774
18777
|
throw Error("useBuildDataSource delegate not initialised");
|
|
18775
|
-
return
|
|
18778
|
+
return usedDelegate.listenEntity({
|
|
18776
18779
|
path,
|
|
18777
18780
|
entityId,
|
|
18778
18781
|
onUpdate,
|
|
@@ -18799,6 +18802,7 @@
|
|
|
18799
18802
|
status
|
|
18800
18803
|
}) => {
|
|
18801
18804
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
18805
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18802
18806
|
console.log("useBuildDatasource save", {
|
|
18803
18807
|
path,
|
|
18804
18808
|
entityId,
|
|
@@ -18814,29 +18818,29 @@
|
|
|
18814
18818
|
fields: propertyConfigs
|
|
18815
18819
|
}) : void 0;
|
|
18816
18820
|
const properties = resolvedCollection?.properties;
|
|
18817
|
-
const firestoreValues =
|
|
18821
|
+
const firestoreValues = usedDelegate.cmsToDelegateModel(
|
|
18818
18822
|
values
|
|
18819
18823
|
);
|
|
18820
|
-
const
|
|
18824
|
+
const updatedValues = properties ? updateDateAutoValues(
|
|
18821
18825
|
{
|
|
18822
18826
|
inputValues: firestoreValues,
|
|
18823
18827
|
properties,
|
|
18824
18828
|
status,
|
|
18825
|
-
timestampNowValue:
|
|
18826
|
-
setDateToMidnight:
|
|
18829
|
+
timestampNowValue: usedDelegate.currentTime?.() ?? /* @__PURE__ */ new Date(),
|
|
18830
|
+
setDateToMidnight: usedDelegate.setDateToMidnight
|
|
18827
18831
|
}
|
|
18828
18832
|
) : firestoreValues;
|
|
18829
|
-
return
|
|
18833
|
+
return usedDelegate.saveEntity({
|
|
18830
18834
|
path,
|
|
18831
18835
|
collection,
|
|
18832
18836
|
entityId,
|
|
18833
|
-
values:
|
|
18837
|
+
values: updatedValues,
|
|
18834
18838
|
status
|
|
18835
18839
|
}).then((res) => {
|
|
18836
18840
|
return {
|
|
18837
18841
|
id: res.id,
|
|
18838
18842
|
path: res.path,
|
|
18839
|
-
values:
|
|
18843
|
+
values: usedDelegate.delegateToCMSModel(updatedValues)
|
|
18840
18844
|
};
|
|
18841
18845
|
});
|
|
18842
18846
|
}, [delegate.saveEntity, navigationController.getCollection]),
|
|
@@ -18847,9 +18851,11 @@
|
|
|
18847
18851
|
* @group Firestore
|
|
18848
18852
|
*/
|
|
18849
18853
|
deleteEntity: React.useCallback(({
|
|
18850
|
-
entity
|
|
18854
|
+
entity,
|
|
18855
|
+
collection
|
|
18851
18856
|
}) => {
|
|
18852
|
-
|
|
18857
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18858
|
+
return usedDelegate.deleteEntity({ entity, collection });
|
|
18853
18859
|
}, [delegate.deleteEntity]),
|
|
18854
18860
|
/**
|
|
18855
18861
|
* Check if the given property is unique in the given collection
|
|
@@ -18861,11 +18867,13 @@
|
|
|
18861
18867
|
* @return `true` if there are no other fields besides the given entity
|
|
18862
18868
|
* @group Firestore
|
|
18863
18869
|
*/
|
|
18864
|
-
checkUniqueField: React.useCallback((path, name, value, entityId,
|
|
18865
|
-
|
|
18870
|
+
checkUniqueField: React.useCallback((path, name, value, entityId, collection) => {
|
|
18871
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18872
|
+
return usedDelegate.checkUniqueField(path, name, value, entityId, collection);
|
|
18866
18873
|
}, [delegate.checkUniqueField]),
|
|
18867
|
-
generateEntityId: React.useCallback((path) => {
|
|
18868
|
-
|
|
18874
|
+
generateEntityId: React.useCallback((path, collection) => {
|
|
18875
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18876
|
+
return usedDelegate.generateEntityId(path, collection);
|
|
18869
18877
|
}, [delegate.generateEntityId]),
|
|
18870
18878
|
countEntities: delegate.countEntities ? async ({
|
|
18871
18879
|
path,
|
|
@@ -18874,7 +18882,8 @@
|
|
|
18874
18882
|
order,
|
|
18875
18883
|
orderBy
|
|
18876
18884
|
}) => {
|
|
18877
|
-
|
|
18885
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18886
|
+
return usedDelegate.countEntities({
|
|
18878
18887
|
path,
|
|
18879
18888
|
filter,
|
|
18880
18889
|
orderBy,
|
|
@@ -18900,9 +18909,10 @@
|
|
|
18900
18909
|
);
|
|
18901
18910
|
}, [delegate.isFilterCombinationValid]),
|
|
18902
18911
|
initTextSearch: React.useCallback(async (props) => {
|
|
18903
|
-
|
|
18912
|
+
const usedDelegate = props.collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18913
|
+
if (!usedDelegate.initTextSearch)
|
|
18904
18914
|
return false;
|
|
18905
|
-
return
|
|
18915
|
+
return usedDelegate.initTextSearch(props);
|
|
18906
18916
|
}, [delegate.initTextSearch])
|
|
18907
18917
|
};
|
|
18908
18918
|
}
|