Skip to content

Commit

Permalink
UDF #5 - Updating README.md with component usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Sep 20, 2022
1 parent fc44444 commit 0e99e63
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ gem install user_defined_fields

## Usage

#### Migrations
### Migrations
To install the database table necessary to support user defined fields, use the following command:

```bash
Expand Down Expand Up @@ -49,5 +49,31 @@ class AddUserDefinedFieldsToMyModel < ActiveRecord::Migration[7.0]
end
```

### Components

User defined fields can be configured one of two ways: At the application level, or at the model level.

##### Application Level
If configured at the application level, each record in the specified table will contain the same user defined fields.

For example: You could define `first_name` and `last_name` fields for all of the `people` records. Anytime a user is editing a a person form, the `first_name` and `last_name` fields will be available as inputs.

```jsx
<UserDefinedFieldsList />
```

##### Model Level
If configured at the model level, records can contain different fields dependent on a parent record.

For example: You could define a `location` field for `resources` that belong to Project A, then define a `project_stage` field for `resources` that belong to Project B. On the edit for for Project A, only the `location` field will be available. On the edit form for Project B, only the `project_stage` field will be available.

```jsx
<UserDefinedFieldsEmbeddedList
items={props.item.user_defined_fields}
onDelete={props.onDeleteChildAssociation.bind(this, 'user_defined_fields')}
onSave={props.onSaveChildAssociation.bind(this, 'user_defined_fields')}
/>
```

## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

0 comments on commit 0e99e63

Please sign in to comment.