@bigbinary/neeto-fields-frontend 1.3.23 → 1.3.24-beta
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 +210 -299
- package/dist/index.cjs.js +247 -2299
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +232 -2284
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/types.d.ts +1 -0
package/README.md
CHANGED
|
@@ -1,138 +1,97 @@
|
|
|
1
1
|
# neeto-fields-nano
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
referred as custom fields)
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- Field has a `name`, `kind`, `resource_type` and `owner`.
|
|
42
|
-
|
|
43
|
-
- Field value has a `field` and `resource` item associated to it.
|
|
44
|
-
|
|
45
|
-
- `resource_type` is the type of resource for which we are creating the field.
|
|
46
|
-
It is used for the categorized fetching and rendering of the fields. _eg:
|
|
47
|
-
users, tickets, deals, etc_
|
|
48
|
-
|
|
49
|
-
- `owner` is basically scope of a field. It is whom to the field belongs. _eg:
|
|
50
|
-
Organization, Project, etc_
|
|
51
|
-
|
|
52
|
-
- `kind` is the nature of the data meant as value for the field. All available
|
|
53
|
-
`kinds` are:
|
|
54
|
-
|
|
55
|
-
`text`, `number`, `monetary`, `single_option`, `multi_option`, `date`, `time`,
|
|
56
|
-
`date_range`, `time_range`, `textarea`, `person`, `checkbox`, `regex`,
|
|
57
|
-
`integer`, `decimal`, `datetime`.
|
|
58
|
-
|
|
59
|
-
# Installation instructions
|
|
60
|
-
|
|
61
|
-
## Engine installation
|
|
3
|
+
The `neeto-fields-nano` enables the management of dynamically added fields (often
|
|
4
|
+
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.
|
|
5
|
+
|
|
6
|
+
# Contents
|
|
7
|
+
|
|
8
|
+
1. [Development with Host Application](#development-with-host-application)
|
|
9
|
+
- [Engine](#engine)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [customizability](#customizability)
|
|
12
|
+
- [Frontend package](#frontend-package)
|
|
13
|
+
- [Installation](#installation-1)
|
|
14
|
+
- [Instructions for development](#instructions-for-development)
|
|
15
|
+
- [Components](#components)
|
|
16
|
+
- [FieldsDashBoard](#1-fieldsdashboard)
|
|
17
|
+
- [FieldsPane](#2-fieldspane)
|
|
18
|
+
- [FieldValuesContainer](#3-fieldvaluescontainer)
|
|
19
|
+
- [FieldInputs](#4-fieldinputs)
|
|
20
|
+
- [InlineFieldValueInputProps](#5-inlinefieldvalueinput)
|
|
21
|
+
- [FieldDeleteAlert](#6-fielddeletealert)
|
|
22
|
+
- [Functions](#functions)
|
|
23
|
+
- [mergeInitialValues](#1-neetofieldsutilsmergeinitialvalues)
|
|
24
|
+
- [transformValues](#2-neetofieldsutilstransformvalues)
|
|
25
|
+
- [Hooks](#hooks)
|
|
26
|
+
- [useFetchFields](#1-usefetchfields)
|
|
27
|
+
- [useShowFields](#2-useshowfield)
|
|
28
|
+
- [useCreateField](#3-usecreatefield)
|
|
29
|
+
- [useUpdateField](#4-useupdatefield)
|
|
30
|
+
- [useDestroyField](#5-usedestroyfield)
|
|
31
|
+
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
32
|
+
|
|
33
|
+
## Development with Host Application
|
|
34
|
+
|
|
35
|
+
### Engine
|
|
36
|
+
|
|
37
|
+
The engine is used to manage fields for any entity across neeto products.
|
|
38
|
+
|
|
39
|
+
#### Installation
|
|
62
40
|
|
|
63
41
|
1. Add this line to your application's Gemfile:
|
|
64
42
|
|
|
65
|
-
|
|
43
|
+
```ruby
|
|
66
44
|
source "NEETO_GEM_SERVER_URL" do
|
|
67
|
-
|
|
45
|
+
# ..existing gems
|
|
68
46
|
|
|
69
47
|
gem 'neeto-fields-engine'
|
|
70
48
|
end
|
|
71
|
-
|
|
49
|
+
```
|
|
72
50
|
|
|
73
51
|
2. And then execute:
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
```ruby
|
|
54
|
+
bundle install
|
|
55
|
+
```
|
|
78
56
|
|
|
79
|
-
3. Add this line to your application's
|
|
57
|
+
3. Add this line to your application's `config/routes.rb` file:
|
|
80
58
|
|
|
81
|
-
|
|
59
|
+
```ruby
|
|
82
60
|
mount NeetoFieldsEngine::Engine => "/neeto_fields_engine"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
4. Add required migrations in the `db/migrate` folder. Run the following
|
|
86
|
-
commands to generate the migrations.
|
|
87
|
-
|
|
88
|
-
```zsh
|
|
89
|
-
rails g neeto_fields_engine:install
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
This will generate the migration to create the `neeto_fields_engine_fields`
|
|
93
|
-
table (which holds the fields) and `neeto_fields_engine_field_values` table
|
|
94
|
-
(which holds the value for the fields).
|
|
61
|
+
```
|
|
95
62
|
|
|
96
|
-
|
|
63
|
+
4. Run the following command to copy the migrations from the engine to the host application:
|
|
97
64
|
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```
|
|
65
|
+
```ruby
|
|
66
|
+
rails g neeto_fields_engine:install
|
|
67
|
+
```
|
|
101
68
|
|
|
102
|
-
|
|
103
|
-
command:
|
|
69
|
+
5. Add the migrations to the database:
|
|
104
70
|
|
|
105
|
-
```
|
|
106
|
-
rails
|
|
107
|
-
```
|
|
71
|
+
```ruby
|
|
72
|
+
bundle exec rails db:migrate
|
|
73
|
+
```
|
|
108
74
|
|
|
109
|
-
|
|
75
|
+
6. Generate the required associations between models using the following command:
|
|
110
76
|
|
|
111
|
-
|
|
112
|
-
|
|
77
|
+
```ruby
|
|
78
|
+
rails g neeto_fields_engine:associations
|
|
79
|
+
```
|
|
113
80
|
|
|
114
|
-
|
|
115
|
-
Organization, Project, etc depending on the business logic. _The field will
|
|
116
|
-
`belongs_to` Owner._
|
|
81
|
+
This will prompt the user to enter 2 things:
|
|
117
82
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
business logic. _The field_value `belongs_to` each Resource._
|
|
83
|
+
1. Name of Owner model.
|
|
84
|
+
2. Names of Resource models.
|
|
121
85
|
|
|
122
|
-
|
|
123
|
-
initializer file, which is required for the functioning of the engine.
|
|
86
|
+
Explore [Owner & Resource Information](docs/engine/owner-resource-information.md) for details.
|
|
124
87
|
|
|
125
|
-
|
|
126
|
-
considered as Owner and Resources.
|
|
88
|
+
#### Customizability
|
|
127
89
|
|
|
128
|
-
|
|
129
|
-
> are normally inserted to top most lines of the file, to satisfy the Rails
|
|
130
|
-
> standards._
|
|
90
|
+
Refer [Engine customizability](docs/engine/customizability.md) to learn about customizing the engine's default behavior.
|
|
131
91
|
|
|
132
|
-
|
|
133
|
-
**neeto-fields-engine**.
|
|
92
|
+
### Frontend package
|
|
134
93
|
|
|
135
|
-
|
|
94
|
+
#### Installation
|
|
136
95
|
|
|
137
96
|
Install the latest `neetoFields nano` package using the below command:
|
|
138
97
|
|
|
@@ -140,7 +99,7 @@ Install the latest `neetoFields nano` package using the below command:
|
|
|
140
99
|
yarn add @bigbinary/neeto-fields-frontend
|
|
141
100
|
```
|
|
142
101
|
|
|
143
|
-
|
|
102
|
+
#### Dependency
|
|
144
103
|
|
|
145
104
|
`neeto-fields-nano` has a peer dependency which is required to use the nano
|
|
146
105
|
properly. Install the peer dependency using the below command:
|
|
@@ -149,23 +108,25 @@ properly. Install the peer dependency using the below command:
|
|
|
149
108
|
yarn add uuid
|
|
150
109
|
```
|
|
151
110
|
|
|
152
|
-
|
|
111
|
+
### Instructions for development
|
|
153
112
|
|
|
154
|
-
|
|
113
|
+
Check the [Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0) for step-by-step instructions to develop the frontend package.
|
|
155
114
|
|
|
156
|
-
|
|
115
|
+
### Components
|
|
157
116
|
|
|
158
|
-
|
|
117
|
+
#### 1. `FieldsDashboard`
|
|
159
118
|
|
|
160
119
|
<div align="center">
|
|
161
120
|
<img src="https://i.ibb.co/8NYn403/Screenshot-2023-07-13-20-04-54.png" alt="Dashboard image"/>
|
|
162
121
|
</div>
|
|
163
122
|
|
|
164
|
-
|
|
123
|
+
<br>
|
|
124
|
+
|
|
125
|
+
The `FieldsDashboard` component serves as a dashboard for managing all
|
|
165
126
|
custom-field related operations. It functions without requiring any props by
|
|
166
127
|
default, but you can customize its behavior by passing optional props.
|
|
167
128
|
|
|
168
|
-
#### Props
|
|
129
|
+
#### Props
|
|
169
130
|
|
|
170
131
|
1. `rowData`: Represents the rowData for the table within the dashboard.
|
|
171
132
|
2. `buildColumnData` : A function that builds the column data (in neetoUI table
|
|
@@ -211,89 +172,96 @@ default, but you can customize its behavior by passing optional props.
|
|
|
211
172
|
> menu bar will fetch all resource types. For owner-based categorization, it
|
|
212
173
|
> will fetch and list all owners in the organization.
|
|
213
174
|
|
|
214
|
-
#### Usage
|
|
175
|
+
#### Usage
|
|
215
176
|
|
|
216
|
-
When Organization is the owner of the fields.
|
|
177
|
+
1. When `Organization` is the owner of the fields.
|
|
178
|
+
|
|
179
|
+
```jsx
|
|
180
|
+
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
181
|
+
|
|
182
|
+
<FieldsDashboard
|
|
183
|
+
allowedKinds={["text", "number"]}
|
|
184
|
+
buildColumnData={({ defaultColumns }) => [
|
|
185
|
+
...defaultColumns,
|
|
186
|
+
{
|
|
187
|
+
dataIndex: "isSystem",
|
|
188
|
+
index: "isSystem",
|
|
189
|
+
title: t("titles.systemField"),
|
|
190
|
+
render: boolVal => (boolVal ? "Yes" : "No"),
|
|
191
|
+
},
|
|
192
|
+
]}
|
|
193
|
+
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
|
|
194
|
+
paneProps={{
|
|
195
|
+
children: <HostSpecificInputFields />,
|
|
196
|
+
validations: {
|
|
197
|
+
hostSpecificInputName: validationSchema,
|
|
198
|
+
},
|
|
199
|
+
initialValues: {
|
|
200
|
+
hostSpecificInputName: initialValue,
|
|
201
|
+
},
|
|
202
|
+
}}
|
|
203
|
+
breadcrumbs={[
|
|
204
|
+
{
|
|
205
|
+
link: "/",
|
|
206
|
+
text: "Home",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
link: "/",
|
|
210
|
+
text: "Settings",
|
|
211
|
+
},
|
|
212
|
+
]}
|
|
213
|
+
/>;
|
|
214
|
+
```
|
|
217
215
|
|
|
218
|
-
|
|
219
|
-
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
220
|
-
|
|
221
|
-
<FieldsDashboard
|
|
222
|
-
allowedKinds={["text", "number"]}
|
|
223
|
-
buildColumnData={({ defaultColumns }) => [
|
|
224
|
-
...defaultColumns,
|
|
225
|
-
{
|
|
226
|
-
dataIndex: "isSystem",
|
|
227
|
-
index: "isSystem",
|
|
228
|
-
title: t("titles.systemField"),
|
|
229
|
-
render: boolVal => (boolVal ? "Yes" : "No"),
|
|
230
|
-
},
|
|
231
|
-
]}
|
|
232
|
-
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
|
|
233
|
-
paneProps={{
|
|
234
|
-
children: <HostSpecificInputFields />,
|
|
235
|
-
validations: {
|
|
236
|
-
hostSpecificInputName: validationSchema,
|
|
237
|
-
},
|
|
238
|
-
initialValues: {
|
|
239
|
-
hostSpecificInputName: initialValue,
|
|
240
|
-
},
|
|
241
|
-
}}
|
|
242
|
-
breadcrumbs={[
|
|
243
|
-
{
|
|
244
|
-
link: "/",
|
|
245
|
-
text: "Home",
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
link: "/",
|
|
249
|
-
text: "Settings",
|
|
250
|
-
},
|
|
251
|
-
]}
|
|
252
|
-
/>;
|
|
253
|
-
```
|
|
216
|
+
#### Usage in [neetoDesk](https://github.com/bigbinary/neeto-desk-web/blob/34068bb579335d3eb6041279f6f3f660099d7f1c/app/javascript/src/components/TicketFields/List/index.jsx#L119C8-L130C11)
|
|
254
217
|
|
|
255
|
-
When Organization is not owner of the fields. Lets say the owner is Project.
|
|
256
218
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
219
|
+
2. When `Organization` is not owner of the fields. Let's say the owner is `Project`.
|
|
220
|
+
|
|
221
|
+
```jsx
|
|
222
|
+
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
223
|
+
|
|
224
|
+
<FieldsDashboard
|
|
225
|
+
allowedKinds={["text", "number"]}
|
|
226
|
+
resourceType="tasks"
|
|
227
|
+
showOwnersInMenu
|
|
228
|
+
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
|
|
229
|
+
paneProps={{
|
|
230
|
+
children: <HostSpecificInputFields />,
|
|
231
|
+
validations: {
|
|
232
|
+
hostSpecificInputName: validationSchema,
|
|
233
|
+
},
|
|
234
|
+
initialValues: {
|
|
235
|
+
hostSpecificInputName: initialValue,
|
|
236
|
+
},
|
|
237
|
+
}}
|
|
238
|
+
breadcrumbs={[
|
|
239
|
+
{
|
|
240
|
+
link: "/",
|
|
241
|
+
text: "Home",
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
link: "/",
|
|
245
|
+
text: "Settings",
|
|
246
|
+
},
|
|
247
|
+
]}
|
|
248
|
+
/>;
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### Usage in [neetoForm](https://github.com/bigbinary/neeto-form-web/blob/1ae06a0f49f62b20ced313c1672fb336553b867c/app/javascript/src/components/Form/Settings/Fields.jsx#L35C7-L47C9)
|
|
252
|
+
|
|
287
253
|
|
|
288
|
-
|
|
254
|
+
#### 2. `FieldsPane`
|
|
289
255
|
|
|
290
256
|
<div align="center">
|
|
291
257
|
<img src="https://s11.gifyu.com/images/SWngt.gif" alt="AddField component gif" width="700"/>
|
|
292
258
|
</div>
|
|
293
259
|
|
|
294
|
-
|
|
260
|
+
<br>
|
|
295
261
|
|
|
296
|
-
|
|
262
|
+
The `FieldsPane` component handles the `Add / Edit` operations of the field.
|
|
263
|
+
|
|
264
|
+
#### Props
|
|
297
265
|
|
|
298
266
|
1. `isOpen`: Boolean state which specifies the open/close state of the pane.
|
|
299
267
|
2. `onClose`: The function to be executed on closing the pane.
|
|
@@ -311,26 +279,26 @@ This is the pane which handles the Add / Edit operations of the field.
|
|
|
311
279
|
11. `onMutationSuccess`: The callback function which is triggered on the success
|
|
312
280
|
of mutation functions( create, update & delete).
|
|
313
281
|
|
|
314
|
-
#### Usage
|
|
282
|
+
#### Usage
|
|
315
283
|
|
|
316
|
-
```jsx
|
|
317
|
-
import { FieldsPane } from "@biginary/neeto-fields-frontend";
|
|
284
|
+
```jsx
|
|
285
|
+
import { FieldsPane } from "@biginary/neeto-fields-frontend";
|
|
318
286
|
|
|
319
|
-
const [fieldPaneOpen, setFieldPaneOpen] = useState(false);
|
|
287
|
+
const [fieldPaneOpen, setFieldPaneOpen] = useState(false);
|
|
320
288
|
|
|
321
|
-
<FieldsPane
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
>
|
|
331
|
-
|
|
332
|
-
</FieldsPane>;
|
|
333
|
-
```
|
|
289
|
+
<FieldsPane
|
|
290
|
+
isOpen={fieldPaneOpen}
|
|
291
|
+
allowedKinds={["text", "number"]}
|
|
292
|
+
resourceType="users"
|
|
293
|
+
additionalValidations={{
|
|
294
|
+
hostSpecificInputName: validationSchema,
|
|
295
|
+
}}
|
|
296
|
+
initialValues={{ hostSpecificInputName: initialValue }}
|
|
297
|
+
onClose={() => setFieldPaneOpen(false)}
|
|
298
|
+
>
|
|
299
|
+
<HostSpecificInputFields />
|
|
300
|
+
</FieldsPane>;
|
|
301
|
+
```
|
|
334
302
|
|
|
335
303
|
## 3. `FieldValuesContainer`
|
|
336
304
|
|
|
@@ -338,10 +306,12 @@ const [fieldPaneOpen, setFieldPaneOpen] = useState(false);
|
|
|
338
306
|
<img src="https://i.ibb.co/K6Gz0FF/Neeto-Fields-Nano-2023-07-13-19-57-27.png" alt="FieldValuesContainer Image" width="500"/>
|
|
339
307
|
</div>
|
|
340
308
|
|
|
309
|
+
<br>
|
|
310
|
+
|
|
341
311
|
The `FieldValuesContainer` component handles field values associated with a
|
|
342
312
|
specific resource.
|
|
343
313
|
|
|
344
|
-
#### Props
|
|
314
|
+
#### Props
|
|
345
315
|
|
|
346
316
|
1. `resourceType`: The type of resource.
|
|
347
317
|
2. `fieldValues`: Field values associated with the resource obtained from the
|
|
@@ -378,9 +348,9 @@ specific resource.
|
|
|
378
348
|
- `submitButtonLabel`
|
|
379
349
|
- `cancelButtonLabel`
|
|
380
350
|
|
|
381
|
-
#### Usage
|
|
351
|
+
#### Usage
|
|
382
352
|
|
|
383
|
-
Say the resource over here is a user
|
|
353
|
+
Say the resource over here is a `user`.
|
|
384
354
|
|
|
385
355
|
```jsx
|
|
386
356
|
import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
|
|
@@ -411,10 +381,11 @@ const queryClient = useQueryClient();
|
|
|
411
381
|
<img src="https://i.ibb.co/9TmXnCx/Neeto-Fields-Nano-2023-07-14-00-38-03.png" alt="FieldInputs image" width="400"/>
|
|
412
382
|
</div>
|
|
413
383
|
|
|
414
|
-
|
|
415
|
-
|
|
384
|
+
<br>
|
|
385
|
+
|
|
386
|
+
The `FieldInputs` component render the input UI for the fetched fields.
|
|
416
387
|
|
|
417
|
-
#### Props
|
|
388
|
+
#### Props
|
|
418
389
|
|
|
419
390
|
1. `fields`: An array of all the fetched fields.
|
|
420
391
|
2. `customComponents`: If the host application has any extra kind other than the
|
|
@@ -431,13 +402,13 @@ the following props:
|
|
|
431
402
|
> :memo: **_Note:_**
|
|
432
403
|
>
|
|
433
404
|
> To initialize the values for this formik fields, you need to use
|
|
434
|
-
> [`mergeInitialValues`](#1-
|
|
405
|
+
> [`mergeInitialValues`](#1-neetofieldsutilsmergeinitialvalues) function.
|
|
435
406
|
>
|
|
436
407
|
> To submit the values from this formik form, you need to use
|
|
437
|
-
> [`transformValues`](#2-
|
|
408
|
+
> [`transformValues`](#2-neetofieldsutilstransformvalues) function to capture the right
|
|
438
409
|
> data from neeto-fields.
|
|
439
410
|
|
|
440
|
-
#### Usage
|
|
411
|
+
#### Usage
|
|
441
412
|
|
|
442
413
|
```jsx
|
|
443
414
|
import {
|
|
@@ -481,10 +452,9 @@ const HostForm = () => {
|
|
|
481
452
|
|
|
482
453
|
### 5. `InlineFieldValueInput`
|
|
483
454
|
|
|
484
|
-
The InlineFieldValueInput component render the field value input UI.
|
|
485
|
-
the following props:
|
|
455
|
+
The `InlineFieldValueInput` component render the field value input UI.
|
|
486
456
|
|
|
487
|
-
#### Props
|
|
457
|
+
#### Props
|
|
488
458
|
|
|
489
459
|
1. `fields`: An array of all the fetched fields.
|
|
490
460
|
2. `fieldValues`: Field values associated with the resource.
|
|
@@ -495,7 +465,7 @@ the following props:
|
|
|
495
465
|
7. `onMutationSuccess`: The callback function which is triggered on the success
|
|
496
466
|
of mutation functions of field value.
|
|
497
467
|
|
|
498
|
-
#### Usage
|
|
468
|
+
#### Usage
|
|
499
469
|
|
|
500
470
|
Usually this is used as a component for inline editing of field values in
|
|
501
471
|
tables. The example shows one such usage of building the `columnData` for table
|
|
@@ -528,7 +498,7 @@ const buildColumnDataForFields = (fields, onFieldValueUpdateSuccess) =>
|
|
|
528
498
|
|
|
529
499
|
The `FieldDeleteAlert` component handles delete operation on fields. It accepts the following props:
|
|
530
500
|
|
|
531
|
-
#### Props
|
|
501
|
+
#### Props
|
|
532
502
|
|
|
533
503
|
1. `selectedField`: The field that needs to be deleted.
|
|
534
504
|
2. `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
@@ -538,7 +508,7 @@ The `FieldDeleteAlert` component handles delete operation on fields. It accepts
|
|
|
538
508
|
6. `handleDelete`: The callback function responsible for deleting the specified field.
|
|
539
509
|
7. `handleAlertClose`: The callback function to be executed on closing the alert.
|
|
540
510
|
|
|
541
|
-
#### Usage
|
|
511
|
+
#### Usage
|
|
542
512
|
|
|
543
513
|
```jsx
|
|
544
514
|
import { FieldDeleteAlert } from "@biginary/neeto-fields-frontend";
|
|
@@ -561,18 +531,18 @@ const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false);
|
|
|
561
531
|
The package exports the `neetoFieldsUtils`, which contains two utility
|
|
562
532
|
functions.
|
|
563
533
|
|
|
564
|
-
|
|
534
|
+
#### 1. `neetoFieldsUtils.mergeInitialValues`
|
|
565
535
|
|
|
566
536
|
This function builds the initial values for the Formik form that wraps the
|
|
567
537
|
`<FieldInputs />` component.
|
|
568
538
|
|
|
569
|
-
#### Arguments
|
|
539
|
+
#### Arguments
|
|
570
540
|
|
|
571
541
|
- `initialValues`: The initial value object without considering
|
|
572
542
|
`<FieldInputs />`
|
|
573
543
|
- `fields`: An array of all the fetched fields.
|
|
574
544
|
|
|
575
|
-
#### Usage
|
|
545
|
+
#### Usage
|
|
576
546
|
|
|
577
547
|
```jsx
|
|
578
548
|
import { useFetchFields } from "@bigbinary/neeto-fields-frontend";
|
|
@@ -587,17 +557,17 @@ const initialValues = neetoFieldsUtils.mergeInitialValues({
|
|
|
587
557
|
});
|
|
588
558
|
```
|
|
589
559
|
|
|
590
|
-
|
|
560
|
+
#### 2. `neetoFieldsUtils.transformValues`
|
|
591
561
|
|
|
592
562
|
This function transforms the Formik form values and builds the `values` object
|
|
593
563
|
including the data from `<FieldInputs />`. This transformed object can be passed
|
|
594
564
|
to the `onSubmit` function of the Formik form.
|
|
595
565
|
|
|
596
|
-
#### Arguments
|
|
566
|
+
#### Arguments
|
|
597
567
|
|
|
598
568
|
- `values`: The Formik form values.
|
|
599
569
|
|
|
600
|
-
#### Usage
|
|
570
|
+
#### Usage
|
|
601
571
|
|
|
602
572
|
```jsx
|
|
603
573
|
import { useFetchFields } from "@bigbinary/neeto-fields-frontend";
|
|
@@ -619,18 +589,18 @@ const {
|
|
|
619
589
|
</Form>;
|
|
620
590
|
```
|
|
621
591
|
|
|
622
|
-
|
|
592
|
+
### Hooks
|
|
623
593
|
|
|
624
594
|
#### 1. `useFetchFields`
|
|
625
595
|
|
|
626
596
|
This is a React Query hook for fetching all the fields.
|
|
627
597
|
|
|
628
|
-
#### Arguments
|
|
598
|
+
#### Arguments
|
|
629
599
|
|
|
630
600
|
- `resourceType`: The resource_type of the fields to be fetched.
|
|
631
601
|
- `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
632
602
|
|
|
633
|
-
#### Usage
|
|
603
|
+
#### Usage
|
|
634
604
|
|
|
635
605
|
```jsx
|
|
636
606
|
const {
|
|
@@ -645,7 +615,7 @@ const {
|
|
|
645
615
|
|
|
646
616
|
This is a React Query hook for fetching details of a field.
|
|
647
617
|
|
|
648
|
-
####
|
|
618
|
+
#### Arguments
|
|
649
619
|
|
|
650
620
|
- `fieldId`: The ID of field for fetching details.
|
|
651
621
|
- `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
@@ -700,77 +670,18 @@ delete({ fieldId })
|
|
|
700
670
|
_Pass the `ownerId` too with the payload in case the owner is not an
|
|
701
671
|
organization._
|
|
702
672
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
## Engine customizability
|
|
706
|
-
|
|
707
|
-
In order to customize the engine's default behavior, we have several ways.
|
|
708
|
-
|
|
709
|
-
- For improving the customizability, we've made every actions' duties into
|
|
710
|
-
separate services, which can be overridden from the host apps as and when
|
|
711
|
-
required.
|
|
712
|
-
- If you wish to perform anything before or after the core logic of an action,
|
|
713
|
-
we have provision to do it as a **single transaction**.
|
|
714
|
-
- Every action has `before_{action}_process` method invoked before the core
|
|
715
|
-
action logic and `after_{action}_process` method invoked after the core action
|
|
716
|
-
logic.
|
|
717
|
-
- These methods can be overridden by defining them in the concern
|
|
718
|
-
`NeetoFieldsEngine::Fields::Customizable` or
|
|
719
|
-
`NeetoFieldsEngine::FieldValues::Customizable` depending on the context.
|
|
720
|
-
|
|
721
|
-
> _Eg: If you want to do something before the update action of
|
|
722
|
-
> `FieldsController`, then define it in `before_update_process` method inside
|
|
723
|
-
> the `NeetoFieldsEngine::Fields::Customizable` concern._
|
|
724
|
-
|
|
725
|
-
# Development instructions
|
|
726
|
-
|
|
727
|
-
## Engine development
|
|
728
|
-
|
|
729
|
-
1. Add this line to your application's Gemfile (replace the path to the local
|
|
730
|
-
copy of neeto-fields-engine):
|
|
731
|
-
|
|
732
|
-
```ruby
|
|
733
|
-
gem 'neeto-fields-engine', path: '../neeto-fields-engine'
|
|
734
|
-
```
|
|
735
|
-
|
|
736
|
-
2. And then execute:
|
|
737
|
-
|
|
738
|
-
```shell
|
|
739
|
-
bundle install
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
3. Refer [engine installation](#engine-installation) steps 3 and onwards.
|
|
743
|
-
|
|
744
|
-
## Frontend package development
|
|
745
|
-
|
|
746
|
-
The usage of `yalc` is explained in this video:
|
|
747
|
-
https://www.youtube.com/watch?v=QBiYGP0Rhe0
|
|
748
|
-
|
|
749
|
-
1. See the changes in the host app by executing the following command \
|
|
750
|
-
<br/> Use this command if releasing a package for the first time.
|
|
751
|
-
|
|
752
|
-
```shell
|
|
753
|
-
yarn build && yalc publish
|
|
754
|
-
```
|
|
755
|
-
|
|
756
|
-
Use this command to see changes after the initial publish.
|
|
757
|
-
|
|
758
|
-
```shell
|
|
759
|
-
yarn release
|
|
760
|
-
```
|
|
761
|
-
### Instructions for development
|
|
762
|
-
Check the [Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0) for step-by-step instructions to develop the frontend package.
|
|
763
|
-
|
|
764
|
-
### Setup dummy host app
|
|
765
|
-
|
|
766
|
-
Setup
|
|
767
|
-
[Instructions](https://github.com/bigbinary/neeto-engineering/tree/main/Local-Development-Setup).
|
|
768
|
-
|
|
769
|
-
Visit http://spinkart.lvh.me:9100 and login with email `oliver@example.com` and
|
|
770
|
-
password `welcome`.
|
|
673
|
+
## Instructions for Publishing
|
|
771
674
|
|
|
772
|
-
|
|
675
|
+
Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
|
|
773
676
|
|
|
774
|
-
|
|
677
|
+
## Integrations
|
|
775
678
|
|
|
776
|
-
|
|
679
|
+
| Projects | Integrated |
|
|
680
|
+
| ------------- | :----------------: |
|
|
681
|
+
| neetoForm | :white_check_mark: |
|
|
682
|
+
| neetoDesk | :white_check_mark: |
|
|
683
|
+
| neetoPlanner | :white_check_mark: |
|
|
684
|
+
| neetoCrm | :white_check_mark: |
|
|
685
|
+
| neetoChat | :white_check_mark: |
|
|
686
|
+
| neetoCal | :white_check_mark: |
|
|
687
|
+
| neetoTestify | :white_check_mark: |
|