@bigbinary/neeto-fields-frontend 1.0.8 → 1.1.0

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/README.md CHANGED
@@ -169,7 +169,9 @@ default, but you can customize its behavior by passing optional props.
169
169
  name as key and the corresponding yup validation schema as the value.
170
170
  `initialValues` must also be provided as a map with the field name as key and
171
171
  the corresponding value. Prop `hideRequiredSwitch` set to `true` hides the
172
- toggle switch for `isRequried`.
172
+ toggle switch for `isRequried`. Also `onMutationSuccess`,a callback function
173
+ which is triggered on the success of mutation functions( create, update &
174
+ delete).
173
175
  7. `showStateFilter`: Boolean value which specifies whether to show or hide
174
176
  state filters.
175
177
  8. `fieldStatesTaxonomy`: Specifies the names to be rendered for `active` and
@@ -251,23 +253,31 @@ import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
251
253
  />;
252
254
  ```
253
255
 
254
- ## 2. `AddField`
256
+ ## 2. `FieldsPane`
255
257
 
256
258
  <div align="center">
257
259
  <img src="https://s11.gifyu.com/images/SWngt.gif" alt="AddField component gif" width="700"/>
258
260
  </div>
259
261
 
260
- The `AddField` component consists of a button and a pane that opens when the
261
- button is clicked.
262
+ This is the pane which handles the Add / Edit operations of the field.
262
263
 
263
264
  #### Props:
264
265
 
265
- 1. `resourceType`: Specifies the resource_type of the field to be created via
266
+ 1. `isOpen`: Boolean state which specifies the open/close state of the pane.
267
+ 2. `onClose`: The function to be executed on closing the pane.
268
+ 3. `resourceType`: Specifies the resource_type of the field to be created via
266
269
  the pane.
267
- 2. `allowedKinds`: Specifies the list of field kinds allowed to be created.
268
- 3. `children`: Children components for the pane.
269
- 4. `additionalValidations`: Validations for the formik fields in `children`.
270
- 5. `initialValues`: Initial values for the formik fields in `children`.
270
+ 4. `allowedKinds`: Specifies the list of field kinds allowed to be created.
271
+ 5. `children`: Children components for the pane.
272
+ 6. `additionalValidations`: Validations for the formik fields in `children`.
273
+ 7. `initialValues`: Initial values for the formik fields in `children`.
274
+ 8. `selectedField`: The field object whose editing is concerned with. If this
275
+ prop is given, the pane will act as an Edit pane. Else it act as Add pane.
276
+ 9. `hideRequiredSwitch`: Specify whether to hide the `Is required` toggle switch
277
+ for field in pane.
278
+ 10. `ownerId`: The ID of the owner in case the owner is not an organization.
279
+ 11. `onMutationSuccess`: The callback function which is triggered on the success
280
+ of mutation functions( create, update & delete).
271
281
 
272
282
  #### Usage:
273
283
 
@@ -305,26 +315,26 @@ specific resource.
305
315
  4. `resourceId`: The ID of the resource.
306
316
  5. `ownerId`:The ID of the owner. This prop is required only if the owner is not
307
317
  an organization.
308
- 6. `queryKeysToBeInvalidatedOnSuccess`: An array of queryKeys that should be
309
- invalidated when changing the field value.
310
- 7. `customComponents`: If the host application has any extra `kind` other than
318
+ 6. `customComponents`: If the host application has any extra `kind` other than
311
319
  the supported ones, you can specify the component to be displayed
312
320
  corresponding to that kind using this prop. It takes the `kind` name as the
313
321
  key and the component rendering callback function as the value. The callback
314
322
  function can expect the `field` object as argument.
315
- 8. `className`: Class names for styling.
316
- 9. `showBorder`: Boolean value to specify whether to show or hide borders.
323
+ 7. `className`: Class names for styling.
324
+ 8. `showBorder`: Boolean value to specify whether to show or hide borders.
317
325
  Default true.
318
- 10. `formRefs`: A React Ref object that can be used to access the Formik context
319
- of the forms corresponding to each field as key value pairs.
320
- 11. `disabled`: Boolean value to specify whether to disable all fields.
321
- 12. `isRequiredColumnName`: The name of column which holds the value which
326
+ 9. `formRefs`: A React Ref object that can be used to access the Formik context
327
+ of the forms corresponding to each field as key value pairs.
328
+ 10. `disabled`: Boolean value to specify whether to disable all fields.
329
+ 11. `isRequiredColumnName`: The name of column which holds the value which
322
330
  suggests if a field value is a `required` one or not. Default is
323
331
  `isRequired` column.
324
- 13. `fieldContainerClassName`: Class names for styling the `div` containing the
332
+ 12. `fieldContainerClassName`: Class names for styling the `div` containing the
325
333
  input field.
326
- 14. `fieldClassName`: Class names for styling the field.
327
- 15. `labelClassName`: Class names for styling the label for fields.
334
+ 13. `fieldClassName`: Class names for styling the field.
335
+ 14. `labelClassName`: Class names for styling the label for fields.
336
+ 15. `onMutationSuccess`: The callback function which is triggered on the success
337
+ of mutation functions( create, update & delete).
328
338
 
329
339
  #### Usage:
330
340
 
@@ -334,13 +344,14 @@ Say the resource over here is a user.
334
344
  import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
335
345
 
336
346
  const formRefs = useRef({});
347
+ const queryClient = useQueryClient();
337
348
 
338
349
  <FieldValuesContainer
339
350
  formRefs={formRefs}
340
351
  fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
341
- queryKeysToBeInvalidatedOnSuccess={["users"]}
342
352
  resourceId={user?.id}
343
353
  resourceType="users"
354
+ onMutationSuccess={() => queryClient.invalidateQueries(["users"])}
344
355
  customComponents={{
345
356
  hostSpecificKindName: field => <HostSpecificInputFields />,
346
357
  }}
@@ -513,13 +524,14 @@ This is a React Query hook for fetching details of a field.
513
524
  #### Argument
514
525
 
515
526
  - `fieldId`: The ID of field for fetching details.
527
+ - `ownerId`: The ID of the owner in case the owner is not an organization.
516
528
 
517
529
  #### Usage
518
530
 
519
531
  ```jsx
520
532
  const {
521
533
  data: { field },
522
- } = useShowField(fieldId);
534
+ } = useShowField({ fieldId, ownerId });
523
535
  ```
524
536
 
525
537
  #### 3. `useCreateField`
@@ -530,7 +542,7 @@ This is a React Query hook for creating a field.
530
542
 
531
543
  ```jsx
532
544
  const { mutate: create } = useCreateField();
533
- const payload = { name, kind, resourceType, ownerId, data };
545
+ const payload = { field: { name, kind, resourceType, ownerId, data } };
534
546
  create(payload);
535
547
  ```
536
548
 
@@ -542,7 +554,7 @@ This is a React Query hook for updating a field.
542
554
 
543
555
  ```jsx
544
556
  const { mutate: update } = useUpdateField();
545
- const payload = { name, kind, resourceType, ownerId, data };
557
+ const payload = { field: { name, kind, resourceType, ownerId, data } };
546
558
  update({ fieldId, payload });
547
559
  ```
548
560
 
@@ -554,9 +566,12 @@ This is a React Query hook for deleting a field.
554
566
 
555
567
  ```jsx
556
568
  const { mutate: delete } = useDestroyField();
557
- delete(fieldId)
569
+ delete({ fieldId })
558
570
  ```
559
571
 
572
+ _Pass the `ownerId` too with the payload in case the owner is not an
573
+ organization._
574
+
560
575
  # Customizability
561
576
 
562
577
  ## Engine customizability