fix: plugin-mobile-client, support set data scope (#956)
Reviewed-on: daoyoucloud/tachybase#956 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
4f26e6e8c9
commit
12a2f7c1bb
5
.changeset/eighty-peas-explode.md
Normal file
5
.changeset/eighty-peas-explode.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@tachybase/plugin-mobile-client": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
tab-search
|
@ -55,7 +55,7 @@ function useAssociationFields(type: 'textField' | 'choiceField') {
|
|||||||
const { name, allFields } = collection || {};
|
const { name, allFields } = collection || {};
|
||||||
|
|
||||||
const { getCollectionFields } = useCollectionFields_custom();
|
const { getCollectionFields } = useCollectionFields_custom();
|
||||||
const isMobield = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
const cm = useCollectionManager();
|
const cm = useCollectionManager();
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ function useAssociationFields(type: 'textField' | 'choiceField') {
|
|||||||
label,
|
label,
|
||||||
schemaName: field.name,
|
schemaName: field.name,
|
||||||
},
|
},
|
||||||
isMobield,
|
isMobile,
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
@ -100,7 +100,7 @@ function useAssociationFields(type: 'textField' | 'choiceField') {
|
|||||||
label,
|
label,
|
||||||
schemaName: field.name,
|
schemaName: field.name,
|
||||||
},
|
},
|
||||||
isMobield,
|
isMobile,
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
@ -111,7 +111,7 @@ function useAssociationFields(type: 'textField' | 'choiceField') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: 递归生成 schema 树
|
// NOTE: 递归生成 schema 树
|
||||||
function getItemInput(params: ItemInterface, isMobield?: boolean) {
|
function getItemInput(params: ItemInterface, isMobile?: boolean) {
|
||||||
const {
|
const {
|
||||||
field,
|
field,
|
||||||
label,
|
label,
|
||||||
@ -140,15 +140,18 @@ function getItemInput(params: ItemInterface, isMobield?: boolean) {
|
|||||||
const label = canBeRelatedField(field.interface)
|
const label = canBeRelatedField(field.interface)
|
||||||
? cm.getCollection(`${name}.${field.name}`)?.titleField
|
? cm.getCollection(`${name}.${field.name}`)?.titleField
|
||||||
: field.name;
|
: field.name;
|
||||||
return getItemInput({
|
return getItemInput(
|
||||||
field: subField,
|
{
|
||||||
label,
|
field: subField,
|
||||||
schemaName: `${schemaName}.${subField.name}`,
|
label,
|
||||||
collectionName: collectionName,
|
schemaName: `${schemaName}.${subField.name}`,
|
||||||
getCollectionFields: getCollectionFields,
|
collectionName: collectionName,
|
||||||
processedCollections: [...processedCollections, field.target],
|
getCollectionFields: getCollectionFields,
|
||||||
collectionManager: cm,
|
processedCollections: [...processedCollections, field.target],
|
||||||
});
|
collectionManager: cm,
|
||||||
|
},
|
||||||
|
isMobile,
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.filter(Boolean),
|
.filter(Boolean),
|
||||||
} as SchemaInitializerItemType;
|
} as SchemaInitializerItemType;
|
||||||
@ -199,8 +202,8 @@ function getItemInput(params: ItemInterface, isMobield?: boolean) {
|
|||||||
// 'x-decorator': 'FormItem',
|
// 'x-decorator': 'FormItem',
|
||||||
// 'x-component': 'CollectionField',
|
// 'x-component': 'CollectionField',
|
||||||
'x-component': matchTruthValue({
|
'x-component': matchTruthValue({
|
||||||
['TabSearchCollapsibleInputMItem']: isMobield,
|
['TabSearchCollapsibleInputMItem']: isMobile,
|
||||||
['TabSearchCollapsibleInputItem']: !isMobield,
|
['TabSearchCollapsibleInputItem']: !isMobile,
|
||||||
}),
|
}),
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
fieldNames: {
|
fieldNames: {
|
||||||
@ -220,7 +223,7 @@ function getItemInput(params: ItemInterface, isMobield?: boolean) {
|
|||||||
} as SchemaInitializerItemType;
|
} as SchemaInitializerItemType;
|
||||||
}
|
}
|
||||||
// NOTE: 递归生成 schema 树
|
// NOTE: 递归生成 schema 树
|
||||||
function getItemChoice(params: ItemInterface, isMobield?: boolean) {
|
function getItemChoice(params: ItemInterface, isMobile?: boolean) {
|
||||||
const {
|
const {
|
||||||
field,
|
field,
|
||||||
label,
|
label,
|
||||||
@ -266,16 +269,19 @@ function getItemChoice(params: ItemInterface, isMobield?: boolean) {
|
|||||||
)
|
)
|
||||||
.map((subField) => {
|
.map((subField) => {
|
||||||
const label = cm.getCollection(field.target)?.getPrimaryKey() || 'id';
|
const label = cm.getCollection(field.target)?.getPrimaryKey() || 'id';
|
||||||
return getItemChoice({
|
return getItemChoice(
|
||||||
field: subField,
|
{
|
||||||
label,
|
field: subField,
|
||||||
schemaName: `${schemaName}.${subField.name}`,
|
label,
|
||||||
collectionName: collectionName,
|
schemaName: `${schemaName}.${subField.name}`,
|
||||||
getCollectionFields: getCollectionFields,
|
collectionName: collectionName,
|
||||||
processedCollections: [...processedCollections, field.target],
|
getCollectionFields: getCollectionFields,
|
||||||
collectionManager: cm,
|
processedCollections: [...processedCollections, field.target],
|
||||||
currentCollection: field.target,
|
collectionManager: cm,
|
||||||
});
|
currentCollection: field.target,
|
||||||
|
},
|
||||||
|
isMobile,
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.filter(Boolean),
|
.filter(Boolean),
|
||||||
} as SchemaInitializerItemType;
|
} as SchemaInitializerItemType;
|
||||||
@ -312,8 +318,8 @@ function getItemChoice(params: ItemInterface, isMobield?: boolean) {
|
|||||||
// 'x-decorator': 'FormItem',
|
// 'x-decorator': 'FormItem',
|
||||||
// 'x-component': 'CollectionField',
|
// 'x-component': 'CollectionField',
|
||||||
'x-component': matchTruthValue({
|
'x-component': matchTruthValue({
|
||||||
['TabSearchFieldMItem']: isMobield,
|
['TabSearchFieldMItem']: isMobile,
|
||||||
['TabSearchFieldItem']: !isMobield,
|
['TabSearchFieldItem']: !isMobile,
|
||||||
}),
|
}),
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
fieldNames: {
|
fieldNames: {
|
||||||
|
@ -35,9 +35,10 @@ export const TabSearchItemFieldSettings = new SchemaSettings({
|
|||||||
const { form } = useFormBlockContext();
|
const { form } = useFormBlockContext();
|
||||||
const field = useField();
|
const field = useField();
|
||||||
const cm = useCollectionManager();
|
const cm = useCollectionManager();
|
||||||
const c = useCollection();
|
const collection = useCollection();
|
||||||
const collectionField =
|
const collectionField =
|
||||||
c.getField(fieldSchema['name']) || cm.getCollectionField(fieldSchema['x-collection-field']);
|
collection.getField(fieldSchema['fieldName']) ||
|
||||||
|
cm.getCollectionField(fieldSchema['x-collection-field']);
|
||||||
const { dn } = useDesignable();
|
const { dn } = useDesignable();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user