fix: setting block cant search items (#814)
Reviewed-on: daoyoucloud/tachybase#814
This commit is contained in:
		
							parent
							
								
									5fdd8903e1
								
							
						
					
					
						commit
						5b8bd6e19c
					
				
							
								
								
									
										5
									
								
								.changeset/lucky-humans-tap.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.changeset/lucky-humans-tap.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
---
 | 
			
		||||
"@hera/plugin-core": patch
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
fix setting blocks
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import { FormOutlined } from '@ant-design/icons';
 | 
			
		||||
import { FormLayout } from '@formily/antd-v5';
 | 
			
		||||
import { SchemaOptionsContext } from '@nocobase/schema';
 | 
			
		||||
import { createFormBlockSchema, useAPIClient, useCollectionManager } from '@nocobase/client';
 | 
			
		||||
import { APIClientProvider, createFormBlockSchema, useAPIClient, useCollectionManager } from '@nocobase/client';
 | 
			
		||||
import {
 | 
			
		||||
  DataBlockInitializer,
 | 
			
		||||
  FormDialog,
 | 
			
		||||
@ -30,33 +30,37 @@ export const SettingBlockInitializer = () => {
 | 
			
		||||
      onCreateBlockSchema={async ({ item }) => {
 | 
			
		||||
        const collection = cm.getCollection(item.name);
 | 
			
		||||
        const titleField = collection.titleField;
 | 
			
		||||
        const result = await api.resource(collection.name).list();
 | 
			
		||||
        const values = await FormDialog(
 | 
			
		||||
          t('Pick a data entry for viewing and editing'),
 | 
			
		||||
          () => {
 | 
			
		||||
            return (
 | 
			
		||||
              <SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
 | 
			
		||||
                <FormLayout layout={'vertical'}>
 | 
			
		||||
                  <SchemaComponent
 | 
			
		||||
                    schema={{
 | 
			
		||||
                      properties: {
 | 
			
		||||
                        id: {
 | 
			
		||||
                          title: tval('Please select'),
 | 
			
		||||
                          enum: result.data.data.map((item) => {
 | 
			
		||||
                            return {
 | 
			
		||||
                              label: item[titleField].toString(),
 | 
			
		||||
                              value: item.id,
 | 
			
		||||
                            };
 | 
			
		||||
                          }),
 | 
			
		||||
                          required: true,
 | 
			
		||||
                          'x-component': 'Select',
 | 
			
		||||
                          'x-decorator': 'FormItem',
 | 
			
		||||
              <APIClientProvider apiClient={api}>
 | 
			
		||||
                <SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
 | 
			
		||||
                  <FormLayout layout={'vertical'}>
 | 
			
		||||
                    <SchemaComponent
 | 
			
		||||
                      schema={{
 | 
			
		||||
                        properties: {
 | 
			
		||||
                          id: {
 | 
			
		||||
                            title: tval('Please select'),
 | 
			
		||||
                            required: true,
 | 
			
		||||
                            'x-component': 'RemoteSelect',
 | 
			
		||||
                            'x-component-props': {
 | 
			
		||||
                              service: {
 | 
			
		||||
                                resource: item.name,
 | 
			
		||||
                              },
 | 
			
		||||
                              fieldNames: {
 | 
			
		||||
                                label: titleField,
 | 
			
		||||
                                value: 'id',
 | 
			
		||||
                              },
 | 
			
		||||
                            },
 | 
			
		||||
                            'x-decorator': 'FormItem',
 | 
			
		||||
                          },
 | 
			
		||||
                        },
 | 
			
		||||
                      },
 | 
			
		||||
                    }}
 | 
			
		||||
                  />
 | 
			
		||||
                </FormLayout>
 | 
			
		||||
              </SchemaComponentOptions>
 | 
			
		||||
                      }}
 | 
			
		||||
                    />
 | 
			
		||||
                  </FormLayout>
 | 
			
		||||
                </SchemaComponentOptions>
 | 
			
		||||
              </APIClientProvider>
 | 
			
		||||
            );
 | 
			
		||||
          },
 | 
			
		||||
          theme,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user