-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from performant-software/feature/udf3_search_…
…filter UDF #3 - Search/sort
- Loading branch information
Showing
15 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#UserDefinedFields | ||
This package is designed to be used with the [user_defined_fields](https://github.com/performant-software/user-defined-fields) Rails gem. The idea is to allow users to define what type of metadata they want to collection about specific models and use these components to add, remove, and modify the configuration of the fields. | ||
|
||
## Installation | ||
|
||
```bash | ||
yarn add @performant-software/user-defined-fields | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
npm install @performant-software/user-defined-fields | ||
``` | ||
|
||
## Components | ||
To load user defined fields directly from the API endpoint, use the `UserDefinedFieldsList` component. | ||
|
||
```jsx | ||
<UserDefinedFieldsList /> | ||
``` | ||
|
||
To add the user defined fields from nested attributes of a parent record, use the `UserDefinedFieldsEmbeddedList` component. | ||
|
||
```jsx | ||
<UserDefinedFieldsEmbeddedList | ||
items={props.item.user_defined_fields} | ||
onDelete={props.onDeleteChildAssociation.bind(this, 'user_defined_fields')} | ||
onSave={props.onSaveChildAssociation.bind(this, 'user_defined_fields')} | ||
/> | ||
``` | ||
|
||
## Services | ||
|
||
```javascript | ||
// Fetch the list of user defined fields | ||
UserDefinedFieldsService.fetchAll(params) | ||
|
||
// Fetch a single user defined field | ||
UserDefinedFieldsService.fetchOne(id) | ||
|
||
// Save a user defined field | ||
UserDefinedFieldsService.save(udf) | ||
|
||
// Delete a user defined field | ||
UserDefinedFieldsService.delete(udf) | ||
|
||
// Fetch a list of tables to which user defined fields can be added | ||
UserDefinedFieldsService.fetchTables() | ||
|
||
// Fetch a list of allowed data types | ||
UserDefinedFieldsService.fetchDataTypes() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// @flow | ||
|
||
import { Form as FormUtils } from '@performant-software/shared-components'; | ||
import _ from 'underscore'; | ||
|
||
/** | ||
* Class responsible for transforming fieldable data. | ||
*/ | ||
class Fieldable { | ||
/** | ||
* Converts the "user_defined" data for the passed fieldable item into form data. | ||
* | ||
* @param formData | ||
* @param prefix | ||
* @param item | ||
*/ | ||
toFormData(formData, prefix, item) { | ||
const { user_defined: userDefined } = item; | ||
|
||
_.each(_.keys(userDefined), (key) => { | ||
FormUtils.setAttribute(formData, `${prefix}[user_defined]`, userDefined, key); | ||
}); | ||
} | ||
} | ||
|
||
const FieldableTransform: Fieldable = new Fieldable(); | ||
export default FieldableTransform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
"packages/user-defined-fields", | ||
"packages/visualize" | ||
], | ||
"version": "0.6.2-beta.5" | ||
"version": "1.0.0" | ||
} |