Refactor of CMSApp.tsx to separate LoginView.tsx and CMSRouterSwitch.tsx

This commit is contained in:
francesco
2020-12-05 16:41:46 +01:00
parent de5350cdc9
commit 033b376fdc
7 changed files with 24 additions and 13 deletions

View File

@@ -1,5 +1,12 @@
# Change Log
## [0.19.1] - 2020-12-*
### Changed
- Internal refactor of CMSApp.tsx and contexts.
- [BREAKING] String properties config multiline value can no longer take a number
and only accepts boolean values. Numbers used to be used to indicate the number
of rows but TextField now grow automatically based on the content.
## [0.19.0] - 2020-12-03
### Changed
- Added grouping and breadcrumbs to additional views and redesign.

View File

@@ -422,7 +422,8 @@ Besides the common fields, some properties have specific configurations.
exclusive values the property can take, mapped to the label that it is
displayed in the dropdown.
* `multiline`: Is this string property long enough so it should be displayed in
a multiple line field. Defaults to false.
a multiple line field. Defaults to false. If set to true,
the number of lines adapts to the content.
* `markdown`: Should this string property be displayed as a markdown field. If true,
the field is rendered as a text editors that supports markdown highlight
syntax. It also includes a preview of the result.
@@ -636,6 +637,8 @@ For example, you can have a collection named "translations" under the entity
"Article". You just need to use the same format as for defining your collection
using the field `subcollections`.
Subcollections are easily accessible from the side view while editing an entity
### Filters
Filtering support is currently limited to string, number and boolean values, including

View File

@@ -291,7 +291,7 @@ const blogSchema = buildSchema({
validation: { required: true },
dataType: "string",
config: {
multiline: 6
multiline: true
}
},
images: {

View File

@@ -150,7 +150,7 @@ export default function StringNumberFilterField({ name, property }: StringNumber
<MenuItem key={`select-${key}`}
value={key}>
<CustomChip
colorKey={value as string}
colorKey={key as string}
label={value}
error={!value}
outlined={false}

View File

@@ -31,7 +31,7 @@ export default function DisabledField<S extends EntitySchema>({
<FormHelperText filled
required={property.validation?.required}>
<LabelWithIcon scaledIcon={false} property={property}/>
<LabelWithIcon scaledIcon={true} property={property}/>
</FormHelperText>
<Paper

View File

@@ -8,6 +8,7 @@ import {
FormHelperText,
InputLabel,
Switch,
TextareaAutosize,
Typography
} from "@material-ui/core";
import React from "react";
@@ -29,23 +30,21 @@ export default function TextField({
property,
includeDescription,
allowInfinity,
entitySchema,
entitySchema
}: TextFieldProps) {
const fieldError = getIn(errors, field.name);
const showError = getIn(touched, field.name) && !!fieldError;
let mediaType: MediaType | undefined;
let multiline: boolean | number | undefined;
let multiline: boolean | undefined;
if (property.dataType === "string") {
const url = (property as StringProperty).config?.url;
mediaType = typeof url === "string" ? url : undefined;
multiline = (property as StringProperty).config?.multiline;
}
const rows: number | undefined = !!multiline ?
(typeof multiline === "number" ? multiline as number : 4)
: undefined;
const isMultiline = !!multiline;
const value = field.value ? field.value : (property.dataType === "string" ? "" : field.value === 0 ? 0 : "");
@@ -93,8 +92,9 @@ export default function TextField({
<FilledInput
type={inputType}
multiline={!!multiline}
rows={rows}
inputComponent={isMultiline ? TextareaAutosize : undefined}
multiline={isMultiline}
rows={4}
value={valueIsInfinity ? "Infinity" : value}
disabled={disabled}
onChange={(evt) => {

View File

@@ -640,9 +640,10 @@ export interface StringFieldConfig extends FieldConfig<string> {
/**
* Is this string property long enough so it should be displayed in
* a multiple line field. Defaults to false.
* a multiple line field. Defaults to false. If set to true,
* the number of lines adapts to the content
*/
multiline?: boolean | number;
multiline?: boolean;
/**
* Should this string property be displayed as a markdown field. If true,