@bigbinary/neeto-fields-frontend 1.3.24 → 1.3.26
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 +215 -288
- package/dist/index.cjs.js +61 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +61 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +1 -0
package/README.md
CHANGED
|
@@ -1,138 +1,104 @@
|
|
|
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
|
-
|
|
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
|
|
4
|
+
(often referred to as custom fields) across neeto applications. The nano exports
|
|
5
|
+
the `@bigbinary/neeto-fields-frontend` NPM package and `neeto-fields-engine`
|
|
6
|
+
Rails engine for development.
|
|
7
|
+
|
|
8
|
+
# Contents
|
|
9
|
+
|
|
10
|
+
1. [Development with Host Application](#development-with-host-application)
|
|
11
|
+
- [Engine](#engine)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [customizability](#customizability)
|
|
14
|
+
- [Frontend package](#frontend-package)
|
|
15
|
+
- [Installation](#installation-1)
|
|
16
|
+
- [Instructions for development](#instructions-for-development)
|
|
17
|
+
- [Components](#components)
|
|
18
|
+
- [FieldsDashBoard](#1-fieldsdashboard)
|
|
19
|
+
- [FieldsPane](#2-fieldspane)
|
|
20
|
+
- [FieldValuesContainer](#3-fieldvaluescontainer)
|
|
21
|
+
- [FieldInputs](#4-fieldinputs)
|
|
22
|
+
- [InlineFieldValueInputProps](#5-inlinefieldvalueinput)
|
|
23
|
+
- [FieldDeleteAlert](#6-fielddeletealert)
|
|
24
|
+
- [Functions](#functions)
|
|
25
|
+
- [mergeInitialValues](#1-neetofieldsutilsmergeinitialvalues)
|
|
26
|
+
- [transformValues](#2-neetofieldsutilstransformvalues)
|
|
27
|
+
- [Hooks](#hooks)
|
|
28
|
+
- [useFetchFields](#1-usefetchfields)
|
|
29
|
+
- [useShowFields](#2-useshowfield)
|
|
30
|
+
- [useCreateField](#3-usecreatefield)
|
|
31
|
+
- [useUpdateField](#4-useupdatefield)
|
|
32
|
+
- [useDestroyField](#5-usedestroyfield)
|
|
33
|
+
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
34
|
+
|
|
35
|
+
## Development with Host Application
|
|
36
|
+
|
|
37
|
+
### Engine
|
|
38
|
+
|
|
39
|
+
The engine is used to manage fields for any entity across neeto products.
|
|
40
|
+
|
|
41
|
+
#### Installation
|
|
62
42
|
|
|
63
43
|
1. Add this line to your application's Gemfile:
|
|
64
44
|
|
|
65
45
|
```ruby
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
47
|
+
# ..existing gems
|
|
68
48
|
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
gem 'neeto-fields-engine'
|
|
50
|
+
end
|
|
71
51
|
```
|
|
72
52
|
|
|
73
53
|
2. And then execute:
|
|
74
54
|
|
|
75
|
-
```
|
|
55
|
+
```ruby
|
|
76
56
|
bundle install
|
|
77
57
|
```
|
|
78
58
|
|
|
79
|
-
3. Add this line to your application's
|
|
59
|
+
3. Add this line to your application's `config/routes.rb` file:
|
|
80
60
|
|
|
81
61
|
```ruby
|
|
82
|
-
|
|
62
|
+
mount NeetoFieldsEngine::Engine => "/neeto_fields_engine"
|
|
83
63
|
```
|
|
84
64
|
|
|
85
|
-
4.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```zsh
|
|
89
|
-
rails g neeto_fields_engine:install
|
|
90
|
-
```
|
|
65
|
+
4. Run the following command to copy the migrations from the engine to the host
|
|
66
|
+
application:
|
|
91
67
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
```ruby
|
|
69
|
+
rails g neeto_fields_engine:install
|
|
70
|
+
```
|
|
95
71
|
|
|
96
|
-
5.
|
|
72
|
+
5. Add the migrations to the database:
|
|
97
73
|
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```
|
|
74
|
+
```ruby
|
|
75
|
+
bundle exec rails db:migrate
|
|
76
|
+
```
|
|
101
77
|
|
|
102
78
|
6. Generate the required associations between models using the following
|
|
103
79
|
command:
|
|
104
80
|
|
|
105
|
-
```
|
|
106
|
-
rails g neeto_fields_engine:associations
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
This will prompt the user to enter 2 things:
|
|
110
|
-
|
|
111
|
-
1. Name of Owner model.
|
|
112
|
-
2. Names of Resource models.
|
|
81
|
+
```ruby
|
|
82
|
+
rails g neeto_fields_engine:associations
|
|
83
|
+
```
|
|
113
84
|
|
|
114
|
-
|
|
115
|
-
Organization, Project, etc depending on the business logic. _The field will
|
|
116
|
-
`belongs_to` Owner._
|
|
85
|
+
This will prompt the user to enter 2 things:
|
|
117
86
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
business logic. _The field_value `belongs_to` each Resource._
|
|
87
|
+
1. Name of Owner model.
|
|
88
|
+
2. Names of Resource models.
|
|
121
89
|
|
|
122
|
-
|
|
123
|
-
|
|
90
|
+
Explore
|
|
91
|
+
[Owner & Resource Information](docs/engine/owner-resource-information.md) for
|
|
92
|
+
details.
|
|
124
93
|
|
|
125
|
-
|
|
126
|
-
considered as Owner and Resources.
|
|
94
|
+
#### Customizability
|
|
127
95
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
> standards._
|
|
96
|
+
Refer [Engine customizability](docs/engine/customizability.md) to learn about
|
|
97
|
+
customizing the engine's default behavior.
|
|
131
98
|
|
|
132
|
-
|
|
133
|
-
**neeto-fields-engine**.
|
|
99
|
+
### Frontend package
|
|
134
100
|
|
|
135
|
-
|
|
101
|
+
#### Installation
|
|
136
102
|
|
|
137
103
|
Install the latest `neetoFields nano` package using the below command:
|
|
138
104
|
|
|
@@ -140,7 +106,7 @@ Install the latest `neetoFields nano` package using the below command:
|
|
|
140
106
|
yarn add @bigbinary/neeto-fields-frontend
|
|
141
107
|
```
|
|
142
108
|
|
|
143
|
-
|
|
109
|
+
#### Dependency
|
|
144
110
|
|
|
145
111
|
`neeto-fields-nano` has a peer dependency which is required to use the nano
|
|
146
112
|
properly. Install the peer dependency using the below command:
|
|
@@ -149,23 +115,27 @@ properly. Install the peer dependency using the below command:
|
|
|
149
115
|
yarn add uuid
|
|
150
116
|
```
|
|
151
117
|
|
|
152
|
-
|
|
118
|
+
### Instructions for development
|
|
153
119
|
|
|
154
|
-
|
|
120
|
+
Check the
|
|
121
|
+
[Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0)
|
|
122
|
+
for step-by-step instructions to develop the frontend package.
|
|
155
123
|
|
|
156
|
-
|
|
124
|
+
### Components
|
|
157
125
|
|
|
158
|
-
|
|
126
|
+
#### 1. `FieldsDashboard`
|
|
159
127
|
|
|
160
128
|
<div align="center">
|
|
161
129
|
<img src="https://i.ibb.co/8NYn403/Screenshot-2023-07-13-20-04-54.png" alt="Dashboard image"/>
|
|
162
130
|
</div>
|
|
163
131
|
|
|
164
|
-
|
|
132
|
+
<br>
|
|
133
|
+
|
|
134
|
+
The `FieldsDashboard` component serves as a dashboard for managing all
|
|
165
135
|
custom-field related operations. It functions without requiring any props by
|
|
166
136
|
default, but you can customize its behavior by passing optional props.
|
|
167
137
|
|
|
168
|
-
#### Props
|
|
138
|
+
#### Props
|
|
169
139
|
|
|
170
140
|
1. `rowData`: Represents the rowData for the table within the dashboard.
|
|
171
141
|
2. `buildColumnData` : A function that builds the column data (in neetoUI table
|
|
@@ -197,12 +167,15 @@ default, but you can customize its behavior by passing optional props.
|
|
|
197
167
|
`inactive` states.
|
|
198
168
|
9. `breadcrumbs`: Specifies the breadcrumbs to be displayed on the dashboard
|
|
199
169
|
page.
|
|
200
|
-
10. `
|
|
170
|
+
10. `helpDescription`: To set the description of the popover, this can be a
|
|
171
|
+
string or a custom component.
|
|
172
|
+
11. `helpDocUrl`: Specify the URL to the help documentation about fields. This
|
|
201
173
|
URL will be shown in the `NoData` screen.
|
|
202
|
-
|
|
174
|
+
12. `nameAliases`: This property accepts alias names as key-value pairs to be
|
|
203
175
|
displayed for the names of resource types in header and menubar.
|
|
204
|
-
|
|
205
|
-
|
|
176
|
+
13. `headerTitle`: Specify the header title explicitly. Default is 'fields'. TIt
|
|
177
|
+
also specifies the title of `HelpPopover`.
|
|
178
|
+
14. `resources`: For owner-based field categorization, provide an array of
|
|
206
179
|
objects with `id` and `name` properties for each owner. For resource
|
|
207
180
|
type-based categorization, use an array of objects with `label` and `value`
|
|
208
181
|
properties representing each resource types.
|
|
@@ -211,89 +184,95 @@ default, but you can customize its behavior by passing optional props.
|
|
|
211
184
|
> menu bar will fetch all resource types. For owner-based categorization, it
|
|
212
185
|
> will fetch and list all owners in the organization.
|
|
213
186
|
|
|
214
|
-
#### Usage
|
|
215
|
-
|
|
216
|
-
When Organization is the owner of the fields.
|
|
187
|
+
#### Usage
|
|
217
188
|
|
|
218
|
-
|
|
219
|
-
|
|
189
|
+
1. When `Organization` is the owner of the fields.
|
|
190
|
+
|
|
191
|
+
```jsx
|
|
192
|
+
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
193
|
+
|
|
194
|
+
<FieldsDashboard
|
|
195
|
+
allowedKinds={["text", "number"]}
|
|
196
|
+
buildColumnData={({ defaultColumns }) => [
|
|
197
|
+
...defaultColumns,
|
|
198
|
+
{
|
|
199
|
+
dataIndex: "isSystem",
|
|
200
|
+
index: "isSystem",
|
|
201
|
+
title: t("titles.systemField"),
|
|
202
|
+
render: boolVal => (boolVal ? "Yes" : "No"),
|
|
203
|
+
},
|
|
204
|
+
]}
|
|
205
|
+
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
|
|
206
|
+
paneProps={{
|
|
207
|
+
children: <HostSpecificInputFields />,
|
|
208
|
+
validations: {
|
|
209
|
+
hostSpecificInputName: validationSchema,
|
|
210
|
+
},
|
|
211
|
+
initialValues: {
|
|
212
|
+
hostSpecificInputName: initialValue,
|
|
213
|
+
},
|
|
214
|
+
}}
|
|
215
|
+
breadcrumbs={[
|
|
216
|
+
{
|
|
217
|
+
link: "/",
|
|
218
|
+
text: "Home",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
link: "/",
|
|
222
|
+
text: "Settings",
|
|
223
|
+
},
|
|
224
|
+
]}
|
|
225
|
+
/>;
|
|
226
|
+
```
|
|
220
227
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
228
|
+
#### Usage in [neetoDesk](https://github.com/bigbinary/neeto-desk-web/blob/34068bb579335d3eb6041279f6f3f660099d7f1c/app/javascript/src/components/TicketFields/List/index.jsx#L119C8-L130C11)
|
|
229
|
+
|
|
230
|
+
2. When `Organization` is not owner of the fields. Let's say the owner is
|
|
231
|
+
`Project`.
|
|
232
|
+
|
|
233
|
+
```jsx
|
|
234
|
+
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
235
|
+
|
|
236
|
+
<FieldsDashboard
|
|
237
|
+
allowedKinds={["text", "number"]}
|
|
238
|
+
resourceType="tasks"
|
|
239
|
+
showOwnersInMenu
|
|
240
|
+
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
|
|
241
|
+
paneProps={{
|
|
242
|
+
children: <HostSpecificInputFields />,
|
|
243
|
+
validations: {
|
|
244
|
+
hostSpecificInputName: validationSchema,
|
|
245
|
+
},
|
|
246
|
+
initialValues: {
|
|
247
|
+
hostSpecificInputName: initialValue,
|
|
248
|
+
},
|
|
249
|
+
}}
|
|
250
|
+
breadcrumbs={[
|
|
251
|
+
{
|
|
252
|
+
link: "/",
|
|
253
|
+
text: "Home",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
link: "/",
|
|
257
|
+
text: "Settings",
|
|
258
|
+
},
|
|
259
|
+
]}
|
|
260
|
+
/>;
|
|
261
|
+
```
|
|
254
262
|
|
|
255
|
-
|
|
263
|
+
#### Usage in [neetoForm](https://github.com/bigbinary/neeto-form-web/blob/1ae06a0f49f62b20ced313c1672fb336553b867c/app/javascript/src/components/Form/Settings/Fields.jsx#L35C7-L47C9)
|
|
256
264
|
|
|
257
|
-
|
|
258
|
-
import { FieldsDashboard } from "@bigbinary/neeto-fields-frontend";
|
|
259
|
-
|
|
260
|
-
<FieldsDashboard
|
|
261
|
-
allowedKinds={["text", "number"]}
|
|
262
|
-
ownerId={projectId}
|
|
263
|
-
resourceType="tasks"
|
|
264
|
-
showOwnersInMenu
|
|
265
|
-
fieldStatesTaxonomy={{ active: "Active", inactive: "Deactivated" }}
|
|
266
|
-
paneProps={{
|
|
267
|
-
children: <HostSpecificInputFields />,
|
|
268
|
-
validations: {
|
|
269
|
-
hostSpecificInputName: validationSchema,
|
|
270
|
-
},
|
|
271
|
-
initialValues: {
|
|
272
|
-
hostSpecificInputName: initialValue,
|
|
273
|
-
},
|
|
274
|
-
}}
|
|
275
|
-
breadcrumbs={[
|
|
276
|
-
{
|
|
277
|
-
link: "/",
|
|
278
|
-
text: "Home",
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
link: "/",
|
|
282
|
-
text: "Settings",
|
|
283
|
-
},
|
|
284
|
-
]}
|
|
285
|
-
/>;
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## 2. `FieldsPane`
|
|
265
|
+
#### 2. `FieldsPane`
|
|
289
266
|
|
|
290
267
|
<div align="center">
|
|
291
268
|
<img src="https://s11.gifyu.com/images/SWngt.gif" alt="AddField component gif" width="700"/>
|
|
292
269
|
</div>
|
|
293
270
|
|
|
294
|
-
|
|
271
|
+
<br>
|
|
272
|
+
|
|
273
|
+
The `FieldsPane` component handles the `Add / Edit` operations of the field.
|
|
295
274
|
|
|
296
|
-
#### Props
|
|
275
|
+
#### Props
|
|
297
276
|
|
|
298
277
|
1. `isOpen`: Boolean state which specifies the open/close state of the pane.
|
|
299
278
|
2. `onClose`: The function to be executed on closing the pane.
|
|
@@ -311,7 +290,7 @@ This is the pane which handles the Add / Edit operations of the field.
|
|
|
311
290
|
11. `onMutationSuccess`: The callback function which is triggered on the success
|
|
312
291
|
of mutation functions( create, update & delete).
|
|
313
292
|
|
|
314
|
-
#### Usage
|
|
293
|
+
#### Usage
|
|
315
294
|
|
|
316
295
|
```jsx
|
|
317
296
|
import { FieldsPane } from "@biginary/neeto-fields-frontend";
|
|
@@ -338,10 +317,12 @@ const [fieldPaneOpen, setFieldPaneOpen] = useState(false);
|
|
|
338
317
|
<img src="https://i.ibb.co/K6Gz0FF/Neeto-Fields-Nano-2023-07-13-19-57-27.png" alt="FieldValuesContainer Image" width="500"/>
|
|
339
318
|
</div>
|
|
340
319
|
|
|
320
|
+
<br>
|
|
321
|
+
|
|
341
322
|
The `FieldValuesContainer` component handles field values associated with a
|
|
342
323
|
specific resource.
|
|
343
324
|
|
|
344
|
-
#### Props
|
|
325
|
+
#### Props
|
|
345
326
|
|
|
346
327
|
1. `resourceType`: The type of resource.
|
|
347
328
|
2. `fieldValues`: Field values associated with the resource obtained from the
|
|
@@ -378,9 +359,9 @@ specific resource.
|
|
|
378
359
|
- `submitButtonLabel`
|
|
379
360
|
- `cancelButtonLabel`
|
|
380
361
|
|
|
381
|
-
#### Usage
|
|
362
|
+
#### Usage
|
|
382
363
|
|
|
383
|
-
Say the resource over here is a user
|
|
364
|
+
Say the resource over here is a `user`.
|
|
384
365
|
|
|
385
366
|
```jsx
|
|
386
367
|
import { FieldValuesContainer } from "@bigbinary/neeto-fields-frontend";
|
|
@@ -411,10 +392,11 @@ const queryClient = useQueryClient();
|
|
|
411
392
|
<img src="https://i.ibb.co/9TmXnCx/Neeto-Fields-Nano-2023-07-14-00-38-03.png" alt="FieldInputs image" width="400"/>
|
|
412
393
|
</div>
|
|
413
394
|
|
|
414
|
-
|
|
415
|
-
|
|
395
|
+
<br>
|
|
396
|
+
|
|
397
|
+
The `FieldInputs` component render the input UI for the fetched fields.
|
|
416
398
|
|
|
417
|
-
#### Props
|
|
399
|
+
#### Props
|
|
418
400
|
|
|
419
401
|
1. `fields`: An array of all the fetched fields.
|
|
420
402
|
2. `customComponents`: If the host application has any extra kind other than the
|
|
@@ -431,13 +413,13 @@ the following props:
|
|
|
431
413
|
> :memo: **_Note:_**
|
|
432
414
|
>
|
|
433
415
|
> To initialize the values for this formik fields, you need to use
|
|
434
|
-
> [`mergeInitialValues`](#1-
|
|
416
|
+
> [`mergeInitialValues`](#1-neetofieldsutilsmergeinitialvalues) function.
|
|
435
417
|
>
|
|
436
418
|
> To submit the values from this formik form, you need to use
|
|
437
|
-
> [`transformValues`](#2-
|
|
438
|
-
> data from neeto-fields.
|
|
419
|
+
> [`transformValues`](#2-neetofieldsutilstransformvalues) function to capture
|
|
420
|
+
> the right data from neeto-fields.
|
|
439
421
|
|
|
440
|
-
#### Usage
|
|
422
|
+
#### Usage
|
|
441
423
|
|
|
442
424
|
```jsx
|
|
443
425
|
import {
|
|
@@ -481,10 +463,9 @@ const HostForm = () => {
|
|
|
481
463
|
|
|
482
464
|
### 5. `InlineFieldValueInput`
|
|
483
465
|
|
|
484
|
-
The InlineFieldValueInput component render the field value input UI.
|
|
485
|
-
the following props:
|
|
466
|
+
The `InlineFieldValueInput` component render the field value input UI.
|
|
486
467
|
|
|
487
|
-
#### Props
|
|
468
|
+
#### Props
|
|
488
469
|
|
|
489
470
|
1. `fields`: An array of all the fetched fields.
|
|
490
471
|
2. `fieldValues`: Field values associated with the resource.
|
|
@@ -495,7 +476,7 @@ the following props:
|
|
|
495
476
|
7. `onMutationSuccess`: The callback function which is triggered on the success
|
|
496
477
|
of mutation functions of field value.
|
|
497
478
|
|
|
498
|
-
#### Usage
|
|
479
|
+
#### Usage
|
|
499
480
|
|
|
500
481
|
Usually this is used as a component for inline editing of field values in
|
|
501
482
|
tables. The example shows one such usage of building the `columnData` for table
|
|
@@ -526,19 +507,22 @@ const buildColumnDataForFields = (fields, onFieldValueUpdateSuccess) =>
|
|
|
526
507
|
<img src="https://github.com/bigbinary/neeto-fields-nano/assets/35305344/6518b206-58f3-4375-bc68-7134ad68c168" alt="Field delete alert" width="500"/>
|
|
527
508
|
</div>
|
|
528
509
|
|
|
529
|
-
The `FieldDeleteAlert` component handles delete operation on fields. It accepts
|
|
510
|
+
The `FieldDeleteAlert` component handles delete operation on fields. It accepts
|
|
511
|
+
the following props:
|
|
530
512
|
|
|
531
|
-
#### Props
|
|
513
|
+
#### Props
|
|
532
514
|
|
|
533
515
|
1. `selectedField`: The field that needs to be deleted.
|
|
534
516
|
2. `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
535
517
|
3. `resourceTypeName`: The type of resource.
|
|
536
518
|
4. `isDeleteAlertOpen`: Boolean state which specifies whether the alert is open.
|
|
537
519
|
5. `isDeleting`: Boolean state indicating whether the field is being deleted.
|
|
538
|
-
6. `handleDelete`: The callback function responsible for deleting the specified
|
|
539
|
-
|
|
520
|
+
6. `handleDelete`: The callback function responsible for deleting the specified
|
|
521
|
+
field.
|
|
522
|
+
7. `handleAlertClose`: The callback function to be executed on closing the
|
|
523
|
+
alert.
|
|
540
524
|
|
|
541
|
-
#### Usage
|
|
525
|
+
#### Usage
|
|
542
526
|
|
|
543
527
|
```jsx
|
|
544
528
|
import { FieldDeleteAlert } from "@biginary/neeto-fields-frontend";
|
|
@@ -561,18 +545,18 @@ const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false);
|
|
|
561
545
|
The package exports the `neetoFieldsUtils`, which contains two utility
|
|
562
546
|
functions.
|
|
563
547
|
|
|
564
|
-
|
|
548
|
+
#### 1. `neetoFieldsUtils.mergeInitialValues`
|
|
565
549
|
|
|
566
550
|
This function builds the initial values for the Formik form that wraps the
|
|
567
551
|
`<FieldInputs />` component.
|
|
568
552
|
|
|
569
|
-
#### Arguments
|
|
553
|
+
#### Arguments
|
|
570
554
|
|
|
571
555
|
- `initialValues`: The initial value object without considering
|
|
572
556
|
`<FieldInputs />`
|
|
573
557
|
- `fields`: An array of all the fetched fields.
|
|
574
558
|
|
|
575
|
-
#### Usage
|
|
559
|
+
#### Usage
|
|
576
560
|
|
|
577
561
|
```jsx
|
|
578
562
|
import { useFetchFields } from "@bigbinary/neeto-fields-frontend";
|
|
@@ -587,17 +571,17 @@ const initialValues = neetoFieldsUtils.mergeInitialValues({
|
|
|
587
571
|
});
|
|
588
572
|
```
|
|
589
573
|
|
|
590
|
-
|
|
574
|
+
#### 2. `neetoFieldsUtils.transformValues`
|
|
591
575
|
|
|
592
576
|
This function transforms the Formik form values and builds the `values` object
|
|
593
577
|
including the data from `<FieldInputs />`. This transformed object can be passed
|
|
594
578
|
to the `onSubmit` function of the Formik form.
|
|
595
579
|
|
|
596
|
-
#### Arguments
|
|
580
|
+
#### Arguments
|
|
597
581
|
|
|
598
582
|
- `values`: The Formik form values.
|
|
599
583
|
|
|
600
|
-
#### Usage
|
|
584
|
+
#### Usage
|
|
601
585
|
|
|
602
586
|
```jsx
|
|
603
587
|
import { useFetchFields } from "@bigbinary/neeto-fields-frontend";
|
|
@@ -619,18 +603,18 @@ const {
|
|
|
619
603
|
</Form>;
|
|
620
604
|
```
|
|
621
605
|
|
|
622
|
-
|
|
606
|
+
### Hooks
|
|
623
607
|
|
|
624
608
|
#### 1. `useFetchFields`
|
|
625
609
|
|
|
626
610
|
This is a React Query hook for fetching all the fields.
|
|
627
611
|
|
|
628
|
-
#### Arguments
|
|
612
|
+
#### Arguments
|
|
629
613
|
|
|
630
614
|
- `resourceType`: The resource_type of the fields to be fetched.
|
|
631
615
|
- `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
632
616
|
|
|
633
|
-
#### Usage
|
|
617
|
+
#### Usage
|
|
634
618
|
|
|
635
619
|
```jsx
|
|
636
620
|
const {
|
|
@@ -645,7 +629,7 @@ const {
|
|
|
645
629
|
|
|
646
630
|
This is a React Query hook for fetching details of a field.
|
|
647
631
|
|
|
648
|
-
####
|
|
632
|
+
#### Arguments
|
|
649
633
|
|
|
650
634
|
- `fieldId`: The ID of field for fetching details.
|
|
651
635
|
- `ownerId`: The ID of the owner in case the owner is not an organization.
|
|
@@ -700,77 +684,20 @@ delete({ fieldId })
|
|
|
700
684
|
_Pass the `ownerId` too with the payload in case the owner is not an
|
|
701
685
|
organization._
|
|
702
686
|
|
|
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`.
|
|
687
|
+
## Instructions for Publishing
|
|
771
688
|
|
|
772
|
-
|
|
689
|
+
Consult the
|
|
690
|
+
[building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages)
|
|
691
|
+
guide for details on how to publish.
|
|
773
692
|
|
|
774
|
-
|
|
693
|
+
## Integrations
|
|
775
694
|
|
|
776
|
-
|
|
695
|
+
| Projects | Integrated |
|
|
696
|
+
| ------------ | :----------------: |
|
|
697
|
+
| neetoForm | :white_check_mark: |
|
|
698
|
+
| neetoDesk | :white_check_mark: |
|
|
699
|
+
| neetoPlanner | :white_check_mark: |
|
|
700
|
+
| neetoCrm | :white_check_mark: |
|
|
701
|
+
| neetoChat | :white_check_mark: |
|
|
702
|
+
| neetoCal | :white_check_mark: |
|
|
703
|
+
| neetoTestify | :white_check_mark: |
|