Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@bigbinary/neeto-fields-frontend
Advanced tools
A repo acts as the source of truth for the new nano's structure, configs, data etc.
The neeto-fields-nano
enables the management of dynamically added fields
(often referred to as custom fields) across neeto applications. The nano exports
the @bigbinary/neeto-fields-frontend
NPM package and neeto-fields-engine
Rails engine for development.
The engine is used to manage fields for any entity across neeto products.
Add this line to your application's Gemfile:
source "NEETO_GEM_SERVER_URL" do
# ..existing gems
gem 'neeto-fields-engine'
end
And then execute:
bundle install
Add this line to your application's config/routes.rb
file:
mount NeetoFieldsEngine::Engine => "/neeto_fields_engine"
Run the following command to copy the migrations from the engine to the host application:
rails g neeto_fields_engine:install
Add the migrations to the database:
bundle exec rails db:migrate
Generate the required associations between models using the following command:
rails g neeto_fields_engine:associations
This will prompt the user to enter 2 things:
Explore Owner & Resource Information for details.
Refer Engine customizability to learn about customizing the engine's default behavior.
Install the latest neetoFields nano
package using the below command:
yarn add @bigbinary/neeto-fields-frontend
neeto-fields-nano
has a peer dependency which is required to use the nano
properly. Install the peer dependency using the below command:
yarn add uuid
Check the Frontend package development guide for step-by-step instructions to develop the frontend package.
FieldsDashboard
The FieldsDashboard
component serves as a dashboard for managing all
custom-field related operations. It functions without requiring any props by
default, but you can customize its behavior by passing optional props.
rowData
: Represents the rowData for the table within the dashboard.
buildColumnData
: A function that builds the column data (in neetoUI table
format) for the dashboard table. This function gets the onDeleteClick
,
onEditClick
callbacks and defaultColumns
as arguments.
showOwnersInMenu
: Accepts a boolean value. When set to true
, the fields
are displayed in categorized form (side menu) based on owners. By default,
fields are categorized based on the resourceType.
resourceType
: Explicitly specifies the resource_type
of the fields to be
shown in the dashboard table. This prop is expected when showOwnersInMenu
is set to true
.
allowedKinds
:Specifies the list of field kinds allowed to be created.
paneProps
: Props to be passed to the Add/Edit pane. It accepts the
following.
children
: The children components to be rendered inside the pane.validations
: The validations for the formik input fields in the
children
. validations
must be provided as an object with the field name
as key and the corresponding yup validation schema as the value.initialValues
: The initial values for the formik input fields in the
children
. It is provided as an object with the field name as key and the
corresponding value.hideRequiredSwitch
: A boolean value when set to true
hides the toggle
switch for isRequried
.onMutationSuccess
: Callback function which is triggered on the success of
mutation functions (create, update & delete).showStateFilter
: Boolean value which specifies whether to show or hide
state filters.
fieldStatesTaxonomy
: Specifies the names to be rendered for active
and
inactive
states.
breadcrumbs
: Specifies the breadcrumbs to be displayed on the dashboard
page.
helpDescription
: To set the description of the popover, this can be a
string or a custom component.
helpDocUrl
: Specify the URL to the help documentation about fields. This
URL will be shown in the NoData
screen.
nameAliases
: This property accepts alias names as key-value pairs to be
displayed for the names of resource types in header and menubar.
headerTitle
: Specify the header title explicitly. Default is 'fields'. It
also specifies the title of HelpPopover
.
resources
: For owner-based field categorization, provide an array of
objects with id
and name
properties for each owner. For resource
type-based categorization, use an array of objects with label
and value
properties representing each resource types.
headerSize
: To specify the header size explicitly. Default is 'small'.
If no resources are provided, for resource type-based categorization, the menu bar will fetch all resource types. For owner-based categorization, it will fetch and list all owners in the organization.
When Organization
is the owner of the fields.
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
<FieldsDashboard
allowedKinds={["text", "number"]}
buildColumnData={({ defaultColumns }) => [
...defaultColumns,
{
dataIndex: "isSystem",
index: "isSystem",
title: t("titles.systemField"),
render: boolVal => (boolVal ? "Yes" : "No"),
},
]}
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
paneProps={{
children: <HostSpecificInputFields />,
validations: {
hostSpecificInputName: validationSchema,
},
initialValues: {
hostSpecificInputName: initialValue,
},
}}
breadcrumbs={[
{
link: "/",
text: "Home",
},
{
link: "/",
text: "Settings",
},
]}
/>;
When Organization
is not owner of the fields. Let's say the owner is
Project
.
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
<FieldsDashboard
allowedKinds={["text", "number"]}
resourceType="tasks"
showOwnersInMenu
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
paneProps={{
children: <HostSpecificInputFields />,
validations: {
hostSpecificInputName: validationSchema,
},
initialValues: {
hostSpecificInputName: initialValue,
},
}}
breadcrumbs={[
{
link: "/",
text: "Home",
},
{
link: "/",
text: "Settings",
},
]}
/>;
FieldsPane
The FieldsPane
component handles the Add / Edit
operations of the field.
isOpen
: Boolean state which specifies the open/close state of the pane.onClose
: The function to be executed on closing the pane.resourceType
: Specifies the resource_type of the field to be created via
the pane.allowedKinds
: Specifies the list of field kinds allowed to be created.children
: Children components for the pane.additionalValidations
: Validations for the formik fields in children
.initialValues
: Initial values for the formik fields in children
.selectedField
: The field object whose editing is concerned with. If this
prop is given, the pane will act as an Edit pane. Else it act as Add pane.hideRequiredSwitch
: Specify whether to hide the Is required
toggle switch
for field in pane.ownerId
: The ID of the owner in case the owner is not an organization.onMutationSuccess
: The callback function which is triggered on the success
of mutation functions( create, update & delete).import { FieldsPane } from "@biginary/neeto-fields-frontend";
const [fieldPaneOpen, setFieldPaneOpen] = useState(false);
<FieldsPane
isOpen={fieldPaneOpen}
allowedKinds={["text", "number"]}
resourceType="users"
additionalValidations={{
hostSpecificInputName: validationSchema,
}}
initialValues={{ hostSpecificInputName: initialValue }}
onClose={() => setFieldPaneOpen(false)}
>
<HostSpecificInputFields />
</FieldsPane>;
FieldValuesContainer
The FieldValuesContainer
component handles field values associated with a
specific resource.
resourceType
: The type of resource.fieldValues
: Field values associated with the resource obtained from the
response.fields
: Fields associated with resource type. This is an optional prop. If
not provided the component will fetch the fields internally.resourceId
: The ID of the resource.ownerId
:The ID of the owner. This prop is required only if the owner is not
an organization.customComponents
: If the host application has any extra kind
other than
the supported ones, you can specify the component to be displayed
corresponding to that kind using this prop. It takes the kind
name as the
key and the component rendering callback function as the value. The callback
function can expect the field
object as argument.className
: Class names for styling.showBorder
: Boolean value to specify whether to show or hide borders.
Default true.formRefs
: A React Ref object that can be used to access the Formik context
of the forms corresponding to each field as key value pairs.disabled
: Boolean value to specify whether to disable all fields.isRequiredColumnName
: The name of column which holds the value which
suggests if a field value is a required
one or not. Default is
isRequired
column.fieldClassName
: Class names for styling the div
containing the input
field.onMutationSuccess
: The callback function which is triggered on the success
of mutation functions( create, update & delete).blockNavigation
: Boolean value to specify whether to block the navigation
if we have unsaved field values entered in field inputs.blockNavigationAlertProps
: Props to be passed to the Alert. It accepts the
following.
title
message
submitButtonLabel
cancelButtonLabel
Say the resource over here is a user
.
import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
const formRefs = useRef({});
const queryClient = useQueryClient();
<FieldValuesContainer
blockNavigation
formRefs={formRefs}
fieldValues={user.fieldValues} // We expect the user response from host's backend to send associated field_values with it.
resourceId={user?.id}
resourceType="users"
onMutationSuccess={() => queryClient.invalidateQueries({ queryKey: ["users"]})}
customComponents={{
hostSpecificKindName: field => <HostSpecificInputFields />,
}}
blockNavigationProps={{
title: "Changes not saved!",
message: "You've not saved the changes made.",
}}
/>;
FieldInputs
The FieldInputs
component render the input UI for the fetched fields.
fields
: An array of all the fetched fields.customComponents
: If the host application has any extra kind other than the
supported ones, you can specify the component to be displayed corresponding
to that kind using this prop. It takes the kind name as the key and the
component rendering callback function as the value. The callback function can
expect the field
object.formRefs
: A React Ref object that can be used to access the Formik context
of the form.disabled
: Boolean value to specify whether to disable all fields.isRequiredColumnName
: The name of column which holds the value which
suggests if a field value is a required
one or not.:memo: Note:
To initialize the values for this formik fields, you need to use
mergeInitialValues
function.To submit the values from this formik form, you need to use
transformValues
function to capture the right data from neeto-fields.
import {
FieldInputs,
useFetchFields,
neetoFieldsUtils,
} from "@bigbinary/neeto-fields-frontend";
const formRef = useRef();
const HostForm = () => {
const {
data: { fields },
} = useFetchFields({
resourceType: "users",
});
const initialValues = neetoFieldsUtils.mergeInitialValues({
initialValues: INITIAL_VALUES,
fields,
});
return (
<Form
formikProps={{
initialValues,
validationSchema: VALIDATION_SCHEMA,
onSubmit: values =>
onSubmit(neetoFieldsUtils.transformValues({ values, fields })),
enableReinitialize: true,
}}
>
{/* Other host specific input fields */}
<FieldInputs formRef={formRef} fields={fields} />
<Button type="submit" label="Submit" />
</Form>
);
};
InlineFieldValueInput
The InlineFieldValueInput
component render the field value input UI.
fields
: An array of all the fetched fields.fieldValues
: Field values associated with the resource.resourceType
: The type of resource.resourceId
: The ID of the resource.ownerId
: The ID of the owner in case the owner is not an organization.onMutate
: The callback function which is triggered on the mutationsonMutationSuccess
: The callback function which is triggered on the success
of mutation functions of field value.Usually this is used as a component for inline editing of field values in
tables. The example shows one such usage of building the columnData
for table
with inline editable field value inputs in cell.
const buildColumnDataForFields = (fields, onFieldValueUpdateSuccess) =>
fields.map(field => ({
dataIndex: "field.id",
key: field.id,
title: field.name,
width: 250,
render: (_, user) => (
<InlineFieldValueInput
{...{ field }}
fieldValues={user.fieldValues}
resourceId={user.id}
resourceType="users"
onMutationSuccess={onFieldValueUpdateSuccess}
/>
),
}));
FieldDeleteAlert
The FieldDeleteAlert
component handles delete operation on fields. It accepts
the following props:
selectedField
: The field that needs to be deleted.ownerId
: The ID of the owner in case the owner is not an organization.resourceTypeName
: The type of resource.isDeleteAlertOpen
: Boolean state which specifies whether the alert is open.isDeleting
: Boolean state indicating whether the field is being deleted.handleDelete
: The callback function responsible for deleting the specified
field.handleAlertClose
: The callback function to be executed on closing the
alert.import { FieldDeleteAlert } from "@biginary/neeto-fields-frontend";
const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false);
<FieldDeleteAlert
selectedField={field}
ownerId={formId}
resourceTypeName="submission"
isDeleteAlertOpen={isDeleteAlertOpen}
isDeleting={isDeleting}
handleDelete={handleDelete}
handleAlertClose={() => setIsDeleteAlertOpen(false)}
/>;
The package exports the neetoFieldsUtils
, which contains two utility
functions.
neetoFieldsUtils.mergeInitialValues
This function builds the initial values for the Formik form that wraps the
<FieldInputs />
component.
initialValues
: The initial value object without considering
<FieldInputs />
fields
: An array of all the fetched fields.import { useFetchFields } from "@bigbinary/neeto-fields-frontend";
const {
data: { fields },
} = useFetchFields({ resourceType: "users" });
const initialValues = neetoFieldsUtils.mergeInitialValues({
initialValues: FORMIK_INITIAL_VALUES,
fields,
});
neetoFieldsUtils.transformValues
This function transforms the Formik form values and builds the values
object
including the data from <FieldInputs />
. This transformed object can be passed
to the onSubmit
function of the Formik form.
values
: The Formik form values.import { useFetchFields } from "@bigbinary/neeto-fields-frontend";
const {
data: { fields },
} = useFetchFields({ resourceType: "users" });
<Form
formikProps={{
initialValues,
validationSchema: VALIDATION_SCHEMA,
onSubmit: values =>
onSubmit(neetoFieldsUtils.transformValues({ values, fields })),
enableReinitialize: true,
}}
>
{/* Form's children */}
</Form>;
useFetchFields
This is a React Query hook for fetching all the fields.
resourceType
: The resource_type of the fields to be fetched.ownerId
: The ID of the owner in case the owner is not an organization.const {
data: { fields, count, activeFieldsCount, inactiveFieldsCount },
} = useFetchFields({
resourceType: "users",
ownerId: "ownerId",
});
useShowField
This is a React Query hook for fetching details of a field.
fieldId
: The ID of field for fetching details.ownerId
: The ID of the owner in case the owner is not an organization.const {
data: { field },
} = useShowField({ fieldId, ownerId });
useCreateField
This is a React Query hook for creating a field.
const { mutate: create } = useCreateField();
const payload = {
field: { name, kind, resourceType, ownerId, displayOrder, data },
};
create(payload);
useUpdateField
This is a React Query hook for updating a field.
const { mutate: update } = useUpdateField();
const payload = {
field: { name, kind, resourceType, ownerId, displayOrder, data },
};
update({ fieldId, payload });
useDestroyField
This is a React Query hook for deleting a field.
const { mutate: delete } = useDestroyField();
delete({ fieldId })
Pass the ownerId
too with the payload in case the owner is not an
organization.
Consult the building and releasing packages guide for details on how to publish.
Projects | Integrated |
---|---|
neetoForm | :white_check_mark: |
neetoDesk | :white_check_mark: |
neetoPlanner | :white_check_mark: |
neetoCrm | :white_check_mark: |
neetoChat | :white_check_mark: |
neetoCal | :white_check_mark: |
neetoTestify | :white_check_mark: |
FAQs
A repo acts as the source of truth for the new nano's structure, configs, data etc.
The npm package @bigbinary/neeto-fields-frontend receives a total of 233 weekly downloads. As such, @bigbinary/neeto-fields-frontend popularity was classified as not popular.
We found that @bigbinary/neeto-fields-frontend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.