Open braughtg opened 2 months ago
Seems like there is a difference between a base component that is using the BootstrapVueNext components and one that is using the FarmData2 components.
I think it may be necessary to have two distinct idioms. One for when using a FarmData2 component as a sub-component and one when using a BootStrapVueNext component as a sub-component.
Currently components are handling props in different ways (e.g. with
v-bind
+watch
orv-model
). it would be better to have a consistent idiom for the way(s) that components handle props. This issue outlines a proposal for discussion and eventual implementation:A component will include a
prop
for:required
- if it can be required.showValidityStyling
- if it accepts input and can be invalid.A
prop
that is not changed by the component (required
,showValidityStyling
, label, options, etc) will be used directly in thetemplate
(e.g.v-bind
or{{ }}
. There is no need to store them in a localdata
value orwatch
them.For a
prop
representing a value collected by the component:prop
will be assigned to adata
value in the component'sdata
object.watch
for theprop
that updates thedata
value when theprop
changes.data
value will be used in thetemplate
(e.g.v-bind
or{{ }}
)template
used to collect the value will have av-on
for the event that indicates a change in the value that calls an event handler function in the componentsmethods
.update theemit andata
value andupdate:prop
event for theprop
(e.g.update:location
). Theupdate:
event will be suffixed with theprop
name. Note: In this refactoring theprop
names and/orupdate
events should not be changed so that no other code will be affected. Issue #168 will addressprop
andupdate
event names.Note: This structure means avoiding the
v-model
shortcut for updating adata
value without av-on
when its component changes. The reason for doing that is that we need to emit theupdate
event anyway, so we still need thev-on
and by doing the update manually it is more explicit and consistent across all values making the code easier to understand.When the idiom is finalized,
components/README.md
file should be updated to reflect the idiom.The components that should be evaluated and refactored are:
BedPicker
CommentBox
CropSelector
DateSelector
EquipmentSelector
LocationSelector
NumericInput
PickerBase
SelectorBase
SoilDisturbance
SubmitResetButtons
TextDisplay
TraySizeSelector