@bigbinary/neeto-fields-frontend 1.0.8 → 1.1.1

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,13 +169,19 @@ 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
176
178
  `inactive` states.
177
179
  9. `breadcrumbs`: Specifies the breadcrumbs to be displayed on the dashboard
178
180
  page.
181
+ 10. `helpDocUrl`: Specify the URL to the help documentation about fields. This
182
+ URL will be shown in the `NoData` screen.
183
+ 11. `nameAliases`: This property accepts alias names as key-value pairs to be
184
+ displayed for the names of resource types in header and menubar.
179
185
 
180
186
  #### Usage:
181
187
 
@@ -251,23 +257,31 @@ import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
251
257
  />;
252
258
  ```
253
259
 
254
- ## 2. `AddField`
260
+ ## 2. `FieldsPane`
255
261
 
256
262
  <div align="center">
257
263
  <img src="https://s11.gifyu.com/images/SWngt.gif" alt="AddField component gif" width="700"/>
258
264
  </div>
259
265
 
260
- The `AddField` component consists of a button and a pane that opens when the
261
- button is clicked.
266
+ This is the pane which handles the Add / Edit operations of the field.
262
267
 
263
268
  #### Props:
264
269
 
265
- 1. `resourceType`: Specifies the resource_type of the field to be created via
270
+ 1. `isOpen`: Boolean state which specifies the open/close state of the pane.
271
+ 2. `onClose`: The function to be executed on closing the pane.
272
+ 3. `resourceType`: Specifies the resource_type of the field to be created via
266
273
  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`.
274
+ 4. `allowedKinds`: Specifies the list of field kinds allowed to be created.
275
+ 5. `children`: Children components for the pane.
276
+ 6. `additionalValidations`: Validations for the formik fields in `children`.
277
+ 7. `initialValues`: Initial values for the formik fields in `children`.
278
+ 8. `selectedField`: The field object whose editing is concerned with. If this
279
+ prop is given, the pane will act as an Edit pane. Else it act as Add pane.
280
+ 9. `hideRequiredSwitch`: Specify whether to hide the `Is required` toggle switch
281
+ for field in pane.
282
+ 10. `ownerId`: The ID of the owner in case the owner is not an organization.
283
+ 11. `onMutationSuccess`: The callback function which is triggered on the success
284
+ of mutation functions( create, update & delete).
271
285
 
272
286
  #### Usage:
273
287
 
@@ -305,26 +319,26 @@ specific resource.
305
319
  4. `resourceId`: The ID of the resource.
306
320
  5. `ownerId`:The ID of the owner. This prop is required only if the owner is not
307
321
  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
322
+ 6. `customComponents`: If the host application has any extra `kind` other than
311
323
  the supported ones, you can specify the component to be displayed
312
324
  corresponding to that kind using this prop. It takes the `kind` name as the
313
325
  key and the component rendering callback function as the value. The callback
314
326
  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.
327
+ 7. `className`: Class names for styling.
328
+ 8. `showBorder`: Boolean value to specify whether to show or hide borders.
317
329
  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
330
+ 9. `formRefs`: A React Ref object that can be used to access the Formik context
331
+ of the forms corresponding to each field as key value pairs.
332
+ 10. `disabled`: Boolean value to specify whether to disable all fields.
333
+ 11. `isRequiredColumnName`: The name of column which holds the value which
322
334
  suggests if a field value is a `required` one or not. Default is
323
335
  `isRequired` column.
324
- 13. `fieldContainerClassName`: Class names for styling the `div` containing the
336
+ 12. `fieldContainerClassName`: Class names for styling the `div` containing the
325
337
  input field.
326
- 14. `fieldClassName`: Class names for styling the field.
327
- 15. `labelClassName`: Class names for styling the label for fields.
338
+ 13. `fieldClassName`: Class names for styling the field.
339
+ 14. `labelClassName`: Class names for styling the label for fields.
340
+ 15. `onMutationSuccess`: The callback function which is triggered on the success
341
+ of mutation functions( create, update & delete).
328
342
 
329
343
  #### Usage:
330
344
 
@@ -334,13 +348,14 @@ Say the resource over here is a user.
334
348
  import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
335
349
 
336
350
  const formRefs = useRef({});
351
+ const queryClient = useQueryClient();
337
352
 
338
353
  <FieldValuesContainer
339
354
  formRefs={formRefs}
340
355
  fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
341
- queryKeysToBeInvalidatedOnSuccess={["users"]}
342
356
  resourceId={user?.id}
343
357
  resourceType="users"
358
+ onMutationSuccess={() => queryClient.invalidateQueries(["users"])}
344
359
  customComponents={{
345
360
  hostSpecificKindName: field => <HostSpecificInputFields />,
346
361
  }}
@@ -513,13 +528,14 @@ This is a React Query hook for fetching details of a field.
513
528
  #### Argument
514
529
 
515
530
  - `fieldId`: The ID of field for fetching details.
531
+ - `ownerId`: The ID of the owner in case the owner is not an organization.
516
532
 
517
533
  #### Usage
518
534
 
519
535
  ```jsx
520
536
  const {
521
537
  data: { field },
522
- } = useShowField(fieldId);
538
+ } = useShowField({ fieldId, ownerId });
523
539
  ```
524
540
 
525
541
  #### 3. `useCreateField`
@@ -530,7 +546,7 @@ This is a React Query hook for creating a field.
530
546
 
531
547
  ```jsx
532
548
  const { mutate: create } = useCreateField();
533
- const payload = { name, kind, resourceType, ownerId, data };
549
+ const payload = { field: { name, kind, resourceType, ownerId, data } };
534
550
  create(payload);
535
551
  ```
536
552
 
@@ -542,7 +558,7 @@ This is a React Query hook for updating a field.
542
558
 
543
559
  ```jsx
544
560
  const { mutate: update } = useUpdateField();
545
- const payload = { name, kind, resourceType, ownerId, data };
561
+ const payload = { field: { name, kind, resourceType, ownerId, data } };
546
562
  update({ fieldId, payload });
547
563
  ```
548
564
 
@@ -554,9 +570,12 @@ This is a React Query hook for deleting a field.
554
570
 
555
571
  ```jsx
556
572
  const { mutate: delete } = useDestroyField();
557
- delete(fieldId)
573
+ delete({ fieldId })
558
574
  ```
559
575
 
576
+ _Pass the `ownerId` too with the payload in case the owner is not an
577
+ organization._
578
+
560
579
  # Customizability
561
580
 
562
581
  ## Engine customizability