-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creates Initiative FE #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, solid base to build the rest of the app on. Main concern is that the form stuff seems really overdone, I'd like to better understand how existing solutions handle stuff like this.
frontend/components/form/Field.vue
Outdated
const invalidFieldName = computed(() => { | ||
if (props.required && !props.completed) { return props.requiredLabel } | ||
return undefined | ||
}) | ||
defineExpose({ invalidFieldName }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't actually see this used anywhere, but in either case, here's an example of where I think we can get away without using an expose
. Instead, I'd run your invalidFieldName
logic on an event like blur
and, if invalid, emit an @invalidField
or whatever event. That way it's a "push" versus a "pull".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes! It's no longer nescessary - it was the anti-pattern I was trying to design out. I'll leave this open to discuss the other part of the suggesiton.
frontend/lib/editor/initiative.ts
Outdated
const createEditorInitiative = (initiative: Initiative): EditorInitiative => { | ||
return { | ||
id: { | ||
name: 'id', | ||
label: 'ID', | ||
isRequired: true, | ||
validation: Validation.AlphanumericAndDashesAndUnderscores, | ||
originalValue: initiative.id, | ||
currentValue: initiative.id, | ||
}, | ||
name: { | ||
name: 'name', | ||
label: 'Name', | ||
isRequired: true, | ||
validation: Validation.NotEmpty, | ||
originalValue: initiative.name, | ||
currentValue: initiative.name, | ||
}, | ||
affiliation: { | ||
name: 'affiliation', | ||
label: 'Affiliation', | ||
originalValue: initiative.affiliation, | ||
currentValue: initiative.affiliation, | ||
}, | ||
publicDescription: { | ||
name: 'publicDescription', | ||
label: 'Public Description', | ||
isRequired: true, | ||
validation: Validation.NotEmpty, | ||
originalValue: initiative.publicDescription, | ||
currentValue: initiative.publicDescription, | ||
}, | ||
internalDescription: { | ||
name: 'internalDescription', | ||
label: 'Internal Description', | ||
originalValue: initiative.internalDescription, | ||
currentValue: initiative.internalDescription, | ||
}, | ||
requiresInvitationToJoin: { | ||
name: 'requiresInvitationToJoin', | ||
label: 'Requires Invitation to Join', | ||
originalValue: initiative.requiresInvitationToJoin, | ||
currentValue: initiative.requiresInvitationToJoin, | ||
}, | ||
isAcceptingNewMembers: { | ||
name: 'isAcceptingNewMembers', | ||
label: 'Accepting New Members', | ||
originalValue: initiative.isAcceptingNewMembers, | ||
currentValue: initiative.isAcceptingNewMembers, | ||
}, | ||
isAcceptingNewPortfolios: { | ||
name: 'isAcceptingNewPortfolios', | ||
label: 'Accepting New Portfolios', | ||
originalValue: initiative.isAcceptingNewPortfolios, | ||
currentValue: initiative.isAcceptingNewPortfolios, | ||
}, | ||
language: { | ||
name: 'language', | ||
label: 'Language', | ||
isRequired: true, | ||
validation: Validation.NotEmpty, | ||
originalValue: initiative.language, | ||
currentValue: initiative.language, | ||
}, | ||
pactaVersion: { | ||
name: 'pactaVersion', | ||
label: 'PACTA Version', | ||
isRequired: true, | ||
validation: Validation.NotEmpty, | ||
originalValue: initiative.pactaVersion, | ||
currentValue: initiative.pactaVersion, | ||
}, | ||
createdAt: { | ||
name: 'createdAt', | ||
label: 'Created At', | ||
originalValue: initiative.createdAt, | ||
currentValue: initiative.createdAt, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this part, in the sense that it describes each field and required/validation status, but everything else below is a ton of very error-prone boiler plate. Some ideas:
- Take a look at VeeValidate and see if it's worth using that (or at least borrowing some ideas)
- If not, it should be possible to replace
computedX
,getComputedXChanges
, andgetComputedIncompleteFields
with just one of each, instead of one-per-entity, by iterating over the object properties and doing more or less what you're doing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done the second one - PTAL, and lmk if you're comfortable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updates to the editor/validation are great, much more succinct/less boilerplate. The only problem is that now the code is completely incomprehensible to me and will likely be hard to update, but I guess that's the tradeoff for this sort of metaprogramming, so LGTM
Creates an initiative editor + list view, fixing #37
useSimpleAsyncData
- Fixes Make standard composable for data fetching #22getAccountByHomeId