Skip to content
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

Merged
merged 4 commits into from
Oct 12, 2023
Merged

Creates Initiative FE #39

merged 4 commits into from
Oct 12, 2023

Conversation

gbdubs
Copy link
Contributor

@gbdubs gbdubs commented Oct 12, 2023

Creates an initiative editor + list view, fixing #37

  • Creates useSimpleAsyncData - Fixes Make standard composable for data fetching #22
  • Adds a Back Button
  • Uses purely hierarchical props for forms + sets out a way of doing that consistently.
  • Removes Cursive as a fallback, at the request of an unnamed party.
  • fixes a typechecking error in getAccountByHomeId

@gbdubs gbdubs requested a review from bcspragu October 12, 2023 00:26
Copy link
Collaborator

@bcspragu bcspragu left a 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/assets/css/theme.css Show resolved Hide resolved
frontend/components/ExplicitInputSwitch.vue Outdated Show resolved Hide resolved
frontend/components/TitleBar.vue Outdated Show resolved Hide resolved
Comment on lines 27 to 31
const invalidFieldName = computed(() => {
if (props.required && !props.completed) { return props.requiredLabel }
return undefined
})
defineExpose({ invalidFieldName })
Copy link
Collaborator

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".

Copy link
Contributor Author

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/components/initiative/Editor.vue Show resolved Hide resolved
frontend/lib/editor/common.ts Outdated Show resolved Hide resolved
frontend/lib/editor/common.ts Outdated Show resolved Hide resolved
Comment on lines 19 to 98
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,
},
}
}
Copy link
Collaborator

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, and getComputedIncompleteFields 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.

Copy link
Contributor Author

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.

frontend/pages/admin/initiative/[id].vue Outdated Show resolved Hide resolved
frontend/pages/admin/initiative/new.vue Show resolved Hide resolved
@gbdubs gbdubs requested a review from bcspragu October 12, 2023 17:48
Copy link
Collaborator

@bcspragu bcspragu left a 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

frontend/lib/editor/initiative.ts Outdated Show resolved Hide resolved
frontend/public/img/flags/es.svg Outdated Show resolved Hide resolved
@gbdubs gbdubs enabled auto-merge (squash) October 12, 2023 20:23
@gbdubs gbdubs merged commit c6947bc into main Oct 12, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make standard composable for data fetching
2 participants