@bigbinary/neeto-fields-frontend 1.0.2
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 +163 -0
- package/dist/index.cjs.js +6889 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.js +6850 -0
- package/dist/index.js.map +1 -0
- package/package.json +178 -0
- package/types.d.ts +87 -0
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# neeto-fields-nano
|
|
2
|
+
|
|
3
|
+
[](https://bigbinary.semaphoreci.com/projects/neeto-fields-engine)
|
|
4
|
+
|
|
5
|
+
**neeto-fields-nano** enables the management of dynamically added fields (often
|
|
6
|
+
referred as custom fields) for the resources across neeto products.
|
|
7
|
+
|
|
8
|
+
# Installation instructions
|
|
9
|
+
|
|
10
|
+
## Engine installation
|
|
11
|
+
|
|
12
|
+
1. Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
16
|
+
# ..existing gems
|
|
17
|
+
|
|
18
|
+
gem 'neeto-fields-engine'
|
|
19
|
+
end
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. And then execute:
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
bundle install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Add this line to your application's `config/routes.rb` file
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
mount NeetoFieldsEngine::Engine => "/neeto_fields_engine"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
4. Add required migrations in the `db/migrate` folder. Run the following
|
|
35
|
+
commands to generate the migrations.
|
|
36
|
+
|
|
37
|
+
```zsh
|
|
38
|
+
rails g neeto_fields_engine:install
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This will generate the migration to create the `neeto_fields_engine_fields`
|
|
42
|
+
table (which holds the fields) and `neeto_fields_engine_field_values` table
|
|
43
|
+
(which holds the value for the fields).
|
|
44
|
+
|
|
45
|
+
5. Run the following command to create the tables.
|
|
46
|
+
|
|
47
|
+
```zsh
|
|
48
|
+
rails db:migrate
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
6. Generate the required associations between models using the following
|
|
52
|
+
command:
|
|
53
|
+
|
|
54
|
+
```zsh
|
|
55
|
+
rails g neeto_fields_engine:associations
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This will prompt the user to enter 2 things:
|
|
59
|
+
|
|
60
|
+
1. Name of Owner model.
|
|
61
|
+
2. Names of Resource models.
|
|
62
|
+
|
|
63
|
+
- Owner: It is the ultimate owner of the fields being added. It can be
|
|
64
|
+
Organization, Project, etc depending on the business logic. _The field will
|
|
65
|
+
`belongs_to` Owner._
|
|
66
|
+
|
|
67
|
+
- Resource: These are the models, to which we want the dynamic fields to be
|
|
68
|
+
attached with. This case be anything like Ticket, Deal, etc depending on the
|
|
69
|
+
business logic. _The field_value `belongs_to` each Resource._
|
|
70
|
+
|
|
71
|
+
Once you enter the appropriate entries for the prompts asked. It will create an
|
|
72
|
+
initializer file, which is required for the functioning of the engine.
|
|
73
|
+
|
|
74
|
+
It will also add necessary associations to respective models, which were
|
|
75
|
+
considered as Owner and Resources.
|
|
76
|
+
|
|
77
|
+
> **_Note:_** _You might need to re-arrange the associations statements which
|
|
78
|
+
> are normally inserted to top most lines of the file, to satisfy the Rails
|
|
79
|
+
> standards._
|
|
80
|
+
|
|
81
|
+
Once you have completed these steps, you are ready to use the
|
|
82
|
+
**neeto-fields-engine**.
|
|
83
|
+
|
|
84
|
+
## Frontend package installation
|
|
85
|
+
|
|
86
|
+
Install the latest `neetoFields nano` package using the below command:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
yarn add @bigbinary/neeto-fields-frontend
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
# Customizability
|
|
93
|
+
|
|
94
|
+
## Engine customizability
|
|
95
|
+
|
|
96
|
+
In order to customize the engine's default behavior, we have several ways.
|
|
97
|
+
|
|
98
|
+
- For improving the customizability, we've made every actions' duties into
|
|
99
|
+
separate services, which can be overridden from the host apps as and when
|
|
100
|
+
required.
|
|
101
|
+
- If you wish to perform anything before or after the core logic of an action,
|
|
102
|
+
we have provision to do it as a **single transaction**.
|
|
103
|
+
- Every action has `before_{action}_process` method invoked before the core
|
|
104
|
+
action logic and `after_{action}_process` method invoked after the core action
|
|
105
|
+
logic.
|
|
106
|
+
- These methods can be overridden by defining them in the concern
|
|
107
|
+
`NeetoFieldsEngine::Fields::Customizable` or
|
|
108
|
+
`NeetoFieldsEngine::FieldValues::Customizable` depending on the context.
|
|
109
|
+
|
|
110
|
+
> _Eg: If you want to do something before update action of `FieldsController`,
|
|
111
|
+
> then define it in `before_update_process` method inside the
|
|
112
|
+
> `NeetoFieldsEngine::Fields::Customizable` concern._
|
|
113
|
+
|
|
114
|
+
# Development instructions
|
|
115
|
+
|
|
116
|
+
## Engine development
|
|
117
|
+
|
|
118
|
+
1. Add this line to your application's Gemfile (replace the path to the local
|
|
119
|
+
copy of neeto-fields-engine):
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
gem 'neeto-fields-engine', path: '../neeto-fields-engine'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. And then execute:
|
|
126
|
+
|
|
127
|
+
```shell
|
|
128
|
+
bundle install
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
3. Refer [engine installation](#engine-installation) steps 3 and onwards.
|
|
132
|
+
|
|
133
|
+
## Frontend package development
|
|
134
|
+
|
|
135
|
+
The usage of `yalc` is explained in this video:
|
|
136
|
+
https://www.youtube.com/watch?v=QBiYGP0Rhe0
|
|
137
|
+
|
|
138
|
+
1. See the changes in the host app by executing the following command \
|
|
139
|
+
<br/> Use this command if releasing package for the first time.
|
|
140
|
+
|
|
141
|
+
```shell
|
|
142
|
+
yarn build && yalc publish
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Use this command to see changes after the initial publish.
|
|
146
|
+
|
|
147
|
+
```shell
|
|
148
|
+
yarn release
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Setup dummy host app
|
|
152
|
+
|
|
153
|
+
Setup
|
|
154
|
+
[Instructions](https://github.com/bigbinary/neeto-engineering/tree/main/Local-Development-Setup).
|
|
155
|
+
|
|
156
|
+
Visit http://spinkart.lvh.me:9100 and login with email `oliver@example.com` and
|
|
157
|
+
password `welcome`.
|
|
158
|
+
|
|
159
|
+
### Additional instructions
|
|
160
|
+
|
|
161
|
+
- Run `yarn build` to bundle the app.
|
|
162
|
+
|
|
163
|
+
### [Read about building and releasing](docs/building-and-releasing.md)
|