Fix for preview when null value

Version 0.4.4
This commit is contained in:
francesco
2020-05-12 22:02:21 +02:00
parent 660235021a
commit de0be94342
3 changed files with 25 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@camberi/firecms",
"version": "0.4.2",
"version": "0.4.4",
"description": "Awesome Firestore based CMS",
"author": "camberi",
"license": "GPL-3.0",
@@ -86,7 +86,7 @@
"gh-pages": "^2.2.0",
"material-ui-chip-input": "^1.1.0",
"material-ui-popup-state": "^1.5.4",
"microbundle-crl": "^0.13.8",
"microbundle-crl": "^0.13.10",
"npm-run-all": "^4.1.5",
"object-hash": "^2.0.3",
"prettier": "^1.19.1",

View File

@@ -29,15 +29,15 @@ import ReferencePreview from "./ReferencePreview";
import { PreviewComponentProps } from "./PreviewComponentProps";
export default function PreviewComponent<T>({
value,
property,
small
}: PreviewComponentProps<T>
): JSX.Element | any {
value,
property,
small
}: PreviewComponentProps<T>
) {
console.debug("renderPreviewComponent", value, property, small);
if (!value) return <React.Fragment/>;
if (!value) return null;
if (!property) {
console.error("No property assigned for preview component", value, property, small);
@@ -82,7 +82,7 @@ export default function PreviewComponent<T>({
} else if (property.dataType === "boolean") {
content = value ? "Yes" : "No";
} else {
content = typeof value === "object" ? (value as unknown as object).toString() : value;
content = typeof value === "object" ? (value as unknown as object).toString() : (value ? value : null);
}
return content;
}
@@ -100,8 +100,8 @@ function renderMap<T>(property: MapProperty<T>, value: T) {
{listProperties.map(([key, property]) => (
<ListItem key={property.title + key}>
<PreviewComponent value={value[key] as any}
property={property}
small={true}/>
property={property}
small={true}/>
</ListItem>
))}
</List>
@@ -129,9 +129,10 @@ function renderArrayOfMaps(properties: Properties, values: any[]) {
key={`table-cell-${key}`}
component="th"
>
<PreviewComponent value={value[key] as any}
property={property}
small={true}/>
<PreviewComponent
value={value[key] as any}
property={property}
small={true}/>
</TableCell>
)
)}
@@ -190,8 +191,8 @@ function renderGenericArrayCell<T extends EnumType>(
values.map((value, index) =>
<React.Fragment>
<PreviewComponent value={value}
property={property}
small={true}/>
property={property}
small={true}/>
{index < values.length - 1 && <Divider/>}
</React.Fragment>
)}

View File

@@ -403,7 +403,7 @@
"@babel/helper-create-class-features-plugin" "^7.8.3"
"@babel/helper-plugin-utils" "^7.8.3"
"@babel/plugin-proposal-decorators@7.8.3":
"@babel/plugin-proposal-decorators@7.8.3", "@babel/plugin-proposal-decorators@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.8.3.tgz#2156860ab65c5abf068c3f67042184041066543e"
integrity sha512-e3RvdvS4qPJVTe288DlXjwKflpfy1hr0j5dz5WpIYYeP7vQZg2WfAEIp8k5/Lwis/m5REXEteIz6rrcDtXXG7w==
@@ -461,7 +461,7 @@
"@babel/helper-plugin-utils" "^7.8.3"
"@babel/plugin-syntax-optional-catch-binding" "^7.8.0"
"@babel/plugin-proposal-optional-chaining@7.9.0", "@babel/plugin-proposal-optional-chaining@^7.9.0":
"@babel/plugin-proposal-optional-chaining@7.9.0", "@babel/plugin-proposal-optional-chaining@^7.8.3", "@babel/plugin-proposal-optional-chaining@^7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.9.0.tgz#31db16b154c39d6b8a645292472b98394c292a58"
integrity sha512-NDn5tu3tcv4W30jNhmc2hyD5c56G6cXx4TesJubhxrJeCvuuMpttxr0OnNCqbZGhFjLrg+NIhxxC+BK5F6yS3w==
@@ -8529,13 +8529,15 @@ methods@~1.1.2:
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=
microbundle-crl@^0.13.8:
version "0.13.9"
resolved "https://registry.yarnpkg.com/microbundle-crl/-/microbundle-crl-0.13.9.tgz#d4b6a8663dc4093f34997db0d860489507f8aa52"
integrity sha512-IJiuNWikNtSlPJ2s6fO0PVXOC3uq4ofvR5wu7UgLpqehV7Zf/wMHSHGmwxB3NbuLopwZy1SUfiGKH0nzNS/d4Q==
microbundle-crl@^0.13.10:
version "0.13.10"
resolved "https://registry.yarnpkg.com/microbundle-crl/-/microbundle-crl-0.13.10.tgz#38062d0fd6e343ce9df079687064bb0010d4b244"
integrity sha512-S1e1C1q0X8ASRQegt2JaLLvsZc85z32aiAaDx8xTCh6hQmRlM00ablx3WD/ZodiY3MegxwDv0mvbGH0ud5Gj2A==
dependencies:
"@babel/core" "^7.8.7"
"@babel/plugin-proposal-class-properties" "7.7.4"
"@babel/plugin-proposal-decorators" "^7.8.3"
"@babel/plugin-proposal-optional-chaining" "^7.8.3"
"@babel/plugin-syntax-jsx" "^7.7.4"
"@babel/plugin-transform-flow-strip-types" "^7.7.4"
"@babel/plugin-transform-react-jsx" "^7.7.7"