Commit graph

61 commits

Author SHA1 Message Date
Sacha Greif
5230f3ae06
Merge pull request #2011 from OrigenStudio/field-value-merge
FormComponent value handling improvements
2018-06-30 09:35:42 +02:00
SachaG
7a10103590 Pass down disabled prop explicitely 2018-06-30 09:23:49 +02:00
ochicf
affd4d61f1 remove added props to remove complexity
this commit undoes some changes introduced in this PR that added more complexity than usefulness
2018-06-29 20:03:54 +02:00
ochicf
057896f0df remove shouldMergeValue prop 2018-06-29 12:55:03 +02:00
SachaG
2d2d1033b5 Enable required locale validation for individual locales; add support for intl: true on schema fields 2018-06-28 21:35:44 +02:00
SachaG
a01ca2ab6e Move FormIntl/FormNested switch from FromComponentInner to FormComponent 2018-06-28 18:36:57 +02:00
ochicf
d3f24f43cd use shouldMergeValue and mergeValue & allow them to be injected as props 2018-06-28 12:32:32 +02:00
ochicf
c821610d46 allow injection of emptyValue and defaultValue
both default to '' so they behave the same way as they did
2018-06-28 12:30:56 +02:00
ochicf
8025590020 allow injection of isEmptyValue as prop, default to FormUtils' one 2018-06-28 12:20:45 +02:00
SachaG
91ade8cd15 Do not use defaultValues for edit forms 2018-06-02 08:33:50 +09:00
Erik Schannen
373857131a SubSchema Fields
- Added support for fields that have their own subschema
- The code flattens the subschema fields, so the path for `address: { street }`` becomes `'address.street'`
- Several places needed to be changed to properly support paths, so `currentValues[path]` becomes `get(currentValues, path)`
- In Form.getData(), replaced underscore's `pick` with lodash's `pick` which properly supports paths and returns a new object
- Fixed a bug in collection.getParameters that made it impossible to specify a `limit` with addView or addDefaultView
2018-05-23 16:02:36 -04:00
SachaG
2b05700e41 Pass "raw" component constructor down to FormComponentInner instead of passing function that instantiates it 2018-05-23 17:12:04 +09:00
SachaG
2b0f8cdd88 Change data structure of translations in db to match MongoDB standards 2018-05-21 09:42:08 +09:00
SachaG
b10d8bdb5c Formatting 2018-05-11 09:52:04 +09:00
SachaG
ab674a1163 Merge branch 'devel' into i18n2
# Conflicts:
#	packages/vulcan-forms/lib/components/Form.jsx
#	packages/vulcan-forms/lib/components/FormComponent.jsx
2018-05-11 09:48:34 +09:00
SachaG
9638e4a759 Merge branch 'erikdakoda5' of https://github.com/ErikDakoda/Vulcan into ErikDakoda-erikdakoda5
# Conflicts:
#	packages/vulcan-forms/lib/components/FormComponent.jsx
2018-05-11 09:40:45 +09:00
Erik Dakoda
2fe3b2cd28
Merge branch 'devel' into erikdakoda5 2018-05-10 10:10:27 -04:00
Erik Schannen
150d9392e7 Changes to SmartForm behaviour - refactoring
- Added new `FormComponent.isCustomInput` method
 - Pulled `renderComponent` up from `FormComponentInner` to `FormComponent`
 - Pulled some input-type-specific logic up when it was universal, or pushed it down when it should be handled by each ui library
2018-05-10 10:03:59 -04:00
SachaG
d60b16ea0d Merge branch 'erikdakoda5' of https://github.com/ErikDakoda/Vulcan into ErikDakoda-erikdakoda5
# Conflicts:
#	packages/vulcan-forms/lib/components/FormComponent.jsx
2018-05-10 09:44:50 +09:00
SachaG
6a30f44adf Merge branch 'devel' into i18n2
# Conflicts:
#	packages/vulcan-forms/lib/components/FormComponent.jsx
2018-05-10 08:34:50 +09:00
ochicf
d3cd373606 merge value only when is array or object and is an accepted type 2018-05-09 15:59:59 +02:00
Erik Schannen
c3f33cb7e0 Changes to SmartForm behaviour
- Moved UI portions of FormComponent to FormComponentInner.jsx in vulcan-ui-bootstrap

 - Added user alert when the user navigates to another route while there are unsaved changed in the form (disabled by default)

 - Added setting forms.warnUnsavedChanges and SmartForm property warnUnsavedChanges to enable user alert

 - Added optional Revert button in FormSubmits to allow the user to discard any changes to the form; this is activated by passing a "revertCallback" property to SmartForm (which can be empty: () => {})

 - Added two functions that form components can access in the child context: refetchForm() to refetch the document from the database (in case it was updated by a background process), isChanged() to determine if there are any unsaved changes

 - For any phrases I have added to en_US.js I also added it to es_ES.js and fr_FR.js with the comment // TODO: translate

 - Updated Form.clearForm and Form.mutationSuccessCallback so that the user can continue working on the document after submitting it

 - The form now scrolls the flash message into view when a submit results in errors

 - Fixed bugs in FormComponent.shouldComponentUpdate() and Form.getDocument()

 - Fixed bug in FormComponent.handleChange() - number fields could not be cleared, only set to 0

 - Fixed a bug in FormComponent.getValue() - it returned the initial value of a checkbox even after it was set to false, and a number even after it was set to 0
2018-05-08 20:09:42 -04:00
SachaG
2c03bd352a Use two-field strategy for getting all locale strings 2018-05-08 11:05:24 +09:00
SachaG
55800a9b30 Add support for intl fields to API and SmartForm 2018-05-07 17:41:22 +09:00
SachaG
dd0ff54f9a Disable FormComponent shouldComponentUpdate callback for now 2018-05-02 18:14:15 +09:00
SachaG
94fc8fffe9 Only rerender FormComponent when necessary 2018-04-30 09:36:42 +09:00
SachaG
7b1c66cb43 Factor out error handling code; clean up form props; pass currentUser down to FormComponent 2018-04-28 10:54:03 +09:00
SachaG
45d508ca89 control -> input; forn -> inputProperties 2018-04-14 18:09:35 +09:00
SachaG
bef525eea8 Improve upload error handling; add clearFieldErrors; 2018-04-14 17:21:10 +09:00
SachaG
cc97d1a473 Improve form error handling; fix control css class 2018-04-09 13:10:42 +09:00
SachaG
7c33b37004 Clean up form props/context 2018-04-06 17:56:25 +09:00
SachaG
6735f9aaf3 Improve errors & validation; improve getValue; get rid of autoValue 2018-03-29 11:58:24 +09:00
SachaG
7f67f21eb9 handle arrays better when merging 2018-03-28 16:31:58 +09:00
SachaG
325cf4b140 Handle deleted values better 2018-03-28 11:51:18 +09:00
SachaG
759899212f Remove __typename from datatable; fix select options 2018-03-28 11:20:41 +09:00
SachaG
ce7e0b0b25 Get errors through props instead of context 2018-03-28 11:14:15 +09:00
SachaG
ceabbc1314 Get current value through props instead of through context 2018-03-27 10:45:17 +09:00
SachaG
97c26e23c8 More small fixes 2018-03-26 18:00:26 +09:00
SachaG
5675b50fb5 Cleaning up FormComponent props 2018-03-26 17:50:03 +09:00
SachaG
5bfa885de5 More refactoring 2018-03-26 14:27:45 +09:00
SachaG
754bb14889 Values are now fetched from FormComponent through context instead of being passed as props 2018-03-25 12:13:30 +09:00
SachaG
1d7cef5556 Work on form errors & validation 2018-03-25 10:54:45 +09:00
SachaG
4c99bc2a6d Use lodash set/unset 2018-03-24 11:16:11 +09:00
SachaG
a7bd9fd92a Handle form submission with new getData() method 2018-03-23 15:46:31 +09:00
SachaG
6f6eefae26 Use dot-object and deepmerge to let forms handle multiple nesting levels 2018-03-23 08:51:24 +09:00
SachaG
268090dcb2 Working on nested forms support 2018-03-22 19:22:54 +09:00
SachaG
d2d66a211b Debounce on timeout's leading edge to always include form field value 2018-03-22 16:53:52 +09:00
SachaG
e7b0110e5f Replace FormComponent onBlur handler by debounced onChange; add date component 2018-03-19 11:59:30 +09:00
SachaG
08016947db Split select form component into select and selectmultiple; Make "--select option--" the default selection for select form components 2018-03-08 11:28:29 +09:00
SachaG
d4910cf2c5 Add clear to time control 2018-03-03 11:09:58 +09:00