fix(Details): block template (#3807)
* fix: add 'Details' in condition * fix: block template
This commit is contained in:
parent
2195a31f5b
commit
0269a1ff7d
@ -330,7 +330,9 @@ export const useParamsFromRecord = () => {
|
|||||||
const { fields } = useCollection_deprecated();
|
const { fields } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { getCollectionJoinField } = useCollectionManager_deprecated();
|
const { getCollectionJoinField } = useCollectionManager_deprecated();
|
||||||
const collectionField = getCollectionJoinField(fieldSchema?.['x-decorator-props']?.resource);
|
const collectionField = getCollectionJoinField(
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association,
|
||||||
|
);
|
||||||
const filterFields = fields
|
const filterFields = fields
|
||||||
.filter((v) => {
|
.filter((v) => {
|
||||||
return ['boolean', 'date', 'integer', 'radio', 'sort', 'string', 'time', 'uid', 'uuid'].includes(v.type);
|
return ['boolean', 'date', 'integer', 'radio', 'sort', 'string', 'time', 'uid', 'uuid'].includes(v.type);
|
||||||
|
@ -177,7 +177,8 @@ export const multiDataDetailsBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'Details',
|
componentName: 'Details',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -16,7 +16,8 @@ export const singleDataDetailsBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
insertAdjacentPosition: 'beforeEnd',
|
insertAdjacentPosition: 'beforeEnd',
|
||||||
componentName: 'ReadPrettyFormItem',
|
componentName: 'ReadPrettyFormItem',
|
||||||
|
@ -51,7 +51,8 @@ export const creationFormBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'FormItem',
|
componentName: 'FormItem',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
@ -117,7 +118,8 @@ export const createFormBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'FormItem',
|
componentName: 'FormItem',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -50,7 +50,8 @@ export const editFormBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'FormItem',
|
componentName: 'FormItem',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -257,7 +257,8 @@ export const gridCardBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
componentName: 'GridCard',
|
componentName: 'GridCard',
|
||||||
|
@ -196,7 +196,8 @@ export const listBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
componentName: 'List',
|
componentName: 'List',
|
||||||
|
@ -359,7 +359,8 @@ export const tableBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'Table',
|
componentName: 'Table',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -22,7 +22,8 @@ export const filterCollapseBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
componentName: 'FilterCollapse',
|
componentName: 'FilterCollapse',
|
||||||
|
@ -23,7 +23,8 @@ export const filterFormBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'FilterFormItem',
|
componentName: 'FilterFormItem',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -18,7 +18,8 @@ export const AssociationFilterBlockDesigner = () => {
|
|||||||
const template = useSchemaTemplate();
|
const template = useSchemaTemplate();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GeneralSchemaDesigner template={template} title={title || name}>
|
<GeneralSchemaDesigner template={template} title={title || name}>
|
||||||
|
@ -62,7 +62,8 @@ export const formSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'FormItem',
|
componentName: 'FormItem',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
@ -103,7 +104,8 @@ export const readPrettyFormSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
insertAdjacentPosition: 'beforeEnd',
|
insertAdjacentPosition: 'beforeEnd',
|
||||||
componentName: 'ReadPrettyFormItem',
|
componentName: 'ReadPrettyFormItem',
|
||||||
@ -294,7 +296,8 @@ export const formDetailsSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection_deprecated();
|
const { name } = useCollection_deprecated();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'Details',
|
componentName: 'Details',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -39,7 +39,8 @@ export const GridCardDesigner = () => {
|
|||||||
const sortFields = useSortFields(name);
|
const sortFields = useSortFields(name);
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
|
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
const columnCount = field.decoratorProps.columnCount || defaultColumnCount;
|
const columnCount = field.decoratorProps.columnCount || defaultColumnCount;
|
||||||
|
|
||||||
const columnCountSchema = useMemo(() => {
|
const columnCountSchema = useMemo(() => {
|
||||||
|
@ -35,7 +35,8 @@ export const ListDesigner = () => {
|
|||||||
const sortFields = useSortFields(name);
|
const sortFields = useSortFields(name);
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
|
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
const sort = defaultSort?.map((item: string) => {
|
const sort = defaultSort?.map((item: string) => {
|
||||||
return item.startsWith('-')
|
return item.startsWith('-')
|
||||||
? {
|
? {
|
||||||
|
@ -78,7 +78,8 @@ export const TableBlockDesigner = () => {
|
|||||||
const { dn } = useDesignable();
|
const { dn } = useDesignable();
|
||||||
|
|
||||||
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
|
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
const supportTemplate = !fieldSchema?.['x-decorator-props']?.disableTemplate;
|
const supportTemplate = !fieldSchema?.['x-decorator-props']?.disableTemplate;
|
||||||
const sort = defaultSort?.map((item: string) => {
|
const sort = defaultSort?.map((item: string) => {
|
||||||
return item?.startsWith('-')
|
return item?.startsWith('-')
|
||||||
|
@ -1685,6 +1685,15 @@ function useAssociationFields({
|
|||||||
const targetCollection = cm.getCollection(field.target);
|
const targetCollection = cm.getCollection(field.target);
|
||||||
const title = `${compile(field.uiSchema.title || field.name)} -> ${compile(targetCollection.title)}`;
|
const title = `${compile(field.uiSchema.title || field.name)} -> ${compile(targetCollection.title)}`;
|
||||||
const templates = getTemplatesByCollection(dataSource, field.target).filter((template) => {
|
const templates = getTemplatesByCollection(dataSource, field.target).filter((template) => {
|
||||||
|
// 针对弹窗中的详情区块
|
||||||
|
if (componentName === 'ReadPrettyFormItem') {
|
||||||
|
if (['hasOne', 'belongsTo'].includes(field.type)) {
|
||||||
|
return template.componentName === 'ReadPrettyFormItem';
|
||||||
|
} else {
|
||||||
|
return template.componentName === 'Details';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
componentName &&
|
componentName &&
|
||||||
template.componentName === componentName &&
|
template.componentName === componentName &&
|
||||||
|
@ -291,7 +291,7 @@ export const SchemaSettingsTemplate = function Template(props) {
|
|||||||
|
|
||||||
const findGridSchema = (fieldSchema) => {
|
const findGridSchema = (fieldSchema) => {
|
||||||
return fieldSchema.reduceProperties((buf, s) => {
|
return fieldSchema.reduceProperties((buf, s) => {
|
||||||
if (s['x-component'] === 'FormV2') {
|
if (s['x-component'] === 'FormV2' || s['x-component'] === 'Details') {
|
||||||
const f = s.reduceProperties((buf, s) => {
|
const f = s.reduceProperties((buf, s) => {
|
||||||
if (s['x-component'] === 'Grid' || s['x-component'] === 'BlockTemplate') {
|
if (s['x-component'] === 'Grid' || s['x-component'] === 'BlockTemplate') {
|
||||||
return s;
|
return s;
|
||||||
@ -308,7 +308,7 @@ const findGridSchema = (fieldSchema) => {
|
|||||||
|
|
||||||
const findBlockTemplateSchema = (fieldSchema) => {
|
const findBlockTemplateSchema = (fieldSchema) => {
|
||||||
return fieldSchema.reduceProperties((buf, s) => {
|
return fieldSchema.reduceProperties((buf, s) => {
|
||||||
if (s['x-component'] === 'FormV2') {
|
if (s['x-component'] === 'FormV2' || s['x-component'] === 'Details') {
|
||||||
const f = s.reduceProperties((buf, s) => {
|
const f = s.reduceProperties((buf, s) => {
|
||||||
if (s['x-component'] === 'BlockTemplate') {
|
if (s['x-component'] === 'BlockTemplate') {
|
||||||
return s;
|
return s;
|
||||||
|
@ -205,7 +205,8 @@ export const calendarBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection();
|
const { name } = useCollection();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'Calendar',
|
componentName: 'Calendar',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
@ -230,7 +230,8 @@ export const mapBlockSettings = new SchemaSettings({
|
|||||||
useComponentProps() {
|
useComponentProps() {
|
||||||
const { name } = useCollection();
|
const { name } = useCollection();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource =
|
||||||
|
fieldSchema?.['x-decorator-props']?.resource || fieldSchema?.['x-decorator-props']?.association;
|
||||||
return {
|
return {
|
||||||
componentName: 'Map',
|
componentName: 'Map',
|
||||||
collectionName: name,
|
collectionName: name,
|
||||||
|
Loading…
Reference in New Issue
Block a user