@applica-software-guru/react-admin 1.5.258 → 1.5.260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "type": "module",
116
116
  "types": "dist/index.d.ts",
117
117
  "typings": "dist/index.d.ts",
118
- "version": "1.5.258"
118
+ "version": "1.5.260"
119
119
  }
@@ -2,7 +2,7 @@ import { Button as RaButton } from './Button';
2
2
  import { Toolbar } from '@/components/ra-forms';
3
3
  import { PlusCircleOutlined } from '@ant-design/icons';
4
4
  import { Breakpoint, Button, Dialog, DialogContent } from '@mui/material';
5
- import { CreateBase, UseCreateMutateParams, useResourceContext, useTranslate } from 'ra-core';
5
+ import { CreateBase, UseCreateMutateParams, useNotify, useResourceContext, useTranslate } from 'ra-core';
6
6
  import { ButtonProps, CreateButton, CreateButtonProps, CreateProps, SaveButton } from 'ra-ui-materialui';
7
7
  import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
8
8
  import { FieldValues, useFormContext } from 'react-hook-form';
@@ -117,6 +117,7 @@ function CreateInDialogButton(props: CreateInDialogButtonProps) {
117
117
  const translate = useTranslate();
118
118
  const Child = Children.only(children);
119
119
  const [open, setOpen] = useState(false);
120
+ const notify = useNotify();
120
121
  const handleOpen = useCallback(() => setOpen(true), []);
121
122
  const handleClose = useCallback(() => setOpen(false), []);
122
123
  const handleSuccess = useCallback(
@@ -135,9 +136,10 @@ function CreateInDialogButton(props: CreateInDialogButtonProps) {
135
136
  updatedAt
136
137
  });
137
138
  handleClose();
139
+ notify('ra.notification.created', { messageArgs: { smart_count: 1 } });
138
140
  props?.mutationOptions?.onSuccess?.(data, params, context);
139
141
  },
140
- [handleClose, props.mutationOptions, queryClient, resource]
142
+ [handleClose, notify, props.mutationOptions, queryClient, resource]
141
143
  );
142
144
 
143
145
  return (
@@ -1,7 +1,7 @@
1
1
  import { Button } from './Button';
2
2
  import { Toolbar } from '@/components/ra-forms';
3
3
  import { Breakpoint, Dialog, DialogContent } from '@mui/material';
4
- import { EditBase, UseUpdateMutateParams, useRecordContext } from 'ra-core';
4
+ import { EditBase, UseUpdateMutateParams, useNotify, useRecordContext } from 'ra-core';
5
5
  import { EditButton, EditProps, SaveButton } from 'ra-ui-materialui';
6
6
  import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
7
7
  import { FieldValues, useFormContext } from 'react-hook-form';
@@ -86,6 +86,7 @@ function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
86
86
  scroll = 'paper',
87
87
  ...rest
88
88
  } = props;
89
+ const notify = useNotify();
89
90
  const [open, setOpen] = useState(false);
90
91
  const Child = Children.only(children);
91
92
  const handleOpen = useCallback(() => setOpen(true), []);
@@ -93,9 +94,13 @@ function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
93
94
  const handleSuccess = useCallback(
94
95
  (data: any, params: UseUpdateMutateParams<any>, context: unknown) => {
95
96
  handleClose();
97
+ notify('ra.notification.updated', {
98
+ messageArgs: { smart_count: 1 },
99
+ undoable: props?.mutationMode === 'undoable'
100
+ });
96
101
  props?.mutationOptions?.onSuccess?.(data, params, context);
97
102
  },
98
- [handleClose, props.mutationOptions]
103
+ [handleClose, notify, props.mutationOptions, props.mutationMode]
99
104
  );
100
105
  const record = useRecordContext();
101
106
  return (
@@ -26,7 +26,7 @@ function AttachmentField({
26
26
  const entity = _resource || resource.replace('entities/', '');
27
27
  const entityId = _entityId || record?.id;
28
28
  const attachment = await dataProvider.getFile(
29
- `/attachments/${entity}/${entityId || record?.id}/${property || props?.source}/${item?.id || record?.id}`
29
+ `/attachments/${entity}/${entityId}/${property || props?.source}/${item?.id || record?.id}`
30
30
  );
31
31
  const link = document.createElement('a');
32
32
  link.href = attachment;
@@ -92,8 +92,8 @@ type AttachmentFieldProps = BaseAttachmentFieldProps & {
92
92
  */
93
93
  showUser?: boolean;
94
94
  /**
95
- * When the AttachmentInput is used inside a nested form, you can specify the root entity to use for the REST calls.
96
- * If not specified, the default value is the current entity passed by context.
95
+ * When the AttachmentInput is used inside a nested form, you can specify the root resource to use for the REST calls.
96
+ * If not specified, the default value is the current resource passed by context.
97
97
  */
98
98
  resource?: string;
99
99
  };
@@ -53,7 +53,7 @@ const StyledFileInput = styled(RaFileInput, { slot: 'root' })(
53
53
  function AttachmentInput({
54
54
  // @ts-ignore
55
55
  children = <AttachmentField title="name" source="path" />,
56
- multiple = true,
56
+ multiple = false,
57
57
  disabled = false,
58
58
  type = 'attachment',
59
59
  ...props
@@ -68,7 +68,7 @@ function AttachmentInput({
68
68
  {/** @ts-ignore */}
69
69
  <StyledFileInput type={type} multiple={multiple} disabled={disabled}>
70
70
  {/* @ts-ignore */}
71
- {React.cloneElement(children, { ...children.props, entityId, property })}
71
+ {React.cloneElement(children, { entityId, property, ...children.props })}
72
72
  </StyledFileInput>
73
73
  </LabeledInput>
74
74
  );
@@ -1,5 +1,12 @@
1
- import { BooleanInput, LocalizedTextInput, SimpleForm, required } from '@/';
2
- import { ArrayInput, SimpleFormIterator } from 'ra-ui-materialui';
1
+ import {
2
+ ArrayInput,
3
+ AttachmentInput,
4
+ BooleanInput,
5
+ LocalizedTextInput,
6
+ SimpleForm,
7
+ SimpleFormIterator,
8
+ required
9
+ } from '@/';
3
10
 
4
11
  function requiredAtLeastOneTranslation(message = 'ra.validation.at_least_one_translation') {
5
12
  return (value, values) => {
@@ -14,6 +21,13 @@ function CategoryForm(props) {
14
21
  <SimpleForm {...props}>
15
22
  <LocalizedTextInput source="description" fullWidth validate={requiredAtLeastOneTranslation()} />
16
23
  <BooleanInput source="active" />
24
+ <AttachmentInput source="attachment" fullWidth />
25
+ <AttachmentInput source="attachments" multiple fullWidth />
26
+ <ArrayInput source="subCategories" fullWidth>
27
+ <SimpleFormIterator divider>
28
+ <AttachmentInput label={false} source="attachments" multiple fullWidth />
29
+ </SimpleFormIterator>
30
+ </ArrayInput>
17
31
  </SimpleForm>
18
32
  );
19
33
  }
@@ -1,8 +1,10 @@
1
1
  import { CategoryForm } from '@/playground/components';
2
2
  import {
3
3
  ActionsMenu,
4
+ BooleanField,
4
5
  CreateInDialogButton,
5
6
  Datagrid,
7
+ DeleteWithConfirmButton,
6
8
  EditInDialogButton,
7
9
  Empty,
8
10
  FilterButton,
@@ -53,12 +55,11 @@ function CategoryList() {
53
55
  >
54
56
  <Datagrid>
55
57
  <LocalizedTextField source="description" />
58
+ <BooleanField source="active" />
56
59
  <EditInDialogButton>
57
60
  <CategoryForm />
58
61
  </EditInDialogButton>
59
- <EditInDialogButton label="Edit with Submit" onSubmit={console.log}>
60
- <CategoryForm />
61
- </EditInDialogButton>
62
+ <DeleteWithConfirmButton />
62
63
  </Datagrid>
63
64
  </List>
64
65
  );