从admin-on-rest中的自定义操作强制更新ReferenceManyField

时间:2017-11-04 22:24:05

标签: admin-on-rest

我有以下Edit组件:

const UserEdit = (props) => (
  <Edit  {...props}>
    <TabbedForm>
      <FormTab label="Main">
        <TextInput source="var1" />
        <TextInput source="var2" />
        <TextInput source="var3" />
      </FormTab>


      <FormTab label="Images">
        <ImageUploadComponant />
        <ReferenceManyField label="Images" reference="images" target="user_id">
          <Datagrid>
            <ImageField source="url" />
            <DeleteButton />
          </Datagrid>
        </ReferenceManyField>
      </FormTab>

    </TabbedForm>
  </Edit>
);

ImageUploadComponant是一个使用户能够上传文件的组件,它会在API上创建一个与ReferenceManyField相关的新对象:

class ImageUpload extends Component {
  onDrop = async files => {
    /* Uploading the file */
  };

  render() {
    return (
      /* A componant with an upload field */
    );
  }
}

ImageUpload.propTypes = {
  push: PropTypes.func,
  record: PropTypes.object,
  showNotification: PropTypes.func,
};

export default connect(null, {
  showNotification: showNotificationAction,
  push: pushAction,
})(ImageUpload);

/* Uploading the file */阻止之后,我想刷新ReferenceManyField,以便显示新上传的图片。

我想我必须放一些redux / sagas消息,但我没有设法执行它。有什么想法吗?

0 个答案:

没有答案