-
Notifications
You must be signed in to change notification settings - Fork 0
feat(committees): require organization fields when voting or business… #373
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,9 @@ | |
|
|
||
| <!-- Organization Search --> | ||
| <div> | ||
| <label for="organization-search" class="block text-sm font-medium text-gray-700 mb-1">Organization</label> | ||
| <label for="organization-search" class="block text-sm font-medium text-gray-700 mb-1"> | ||
| Organization @if (orgRequired) { <span class="text-red-500">*</span> } | ||
| </label> | ||
| <lfx-organization-search | ||
| [form]="form()" | ||
| nameControl="organization" | ||
|
|
@@ -99,6 +101,15 @@ | |
| panelStyleClass="text-sm w-full" | ||
| dataTestId="member-form-organization-search"> | ||
| </lfx-organization-search> | ||
| @if (form().get('organization')?.errors?.['required'] && form().get('organization')?.touched) { | ||
| <p class="mt-1 text-xs text-red-600">Organization name is required</p> | ||
| } | ||
| @if (form().get('organization_url')?.errors?.['required'] && form().get('organization_url')?.touched) { | ||
| <p class="mt-1 text-xs text-red-600">Organization website is required</p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Major: Validation errors reference a field the user cannot directly editProblem: Why it matters:
Fix: @if (form().get('organization_url')?.errors && form().get('organization_url')?.touched) {
<p class="mt-1 text-xs text-red-600">
The selected organization is missing a valid website. Please select a different organization.
</p>
}This tells the user what to do rather than describing a field they can't see.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user also can enter a url manually -- this is a "find it via search, or type it yourself" flow. |
||
| } | ||
| @if (form().get('organization_url')?.errors?.['pattern'] && form().get('organization_url')?.touched) { | ||
| <p class="mt-1 text-xs text-red-600">Please enter a valid URL</p> | ||
| } | ||
| </div> | ||
| </div> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import { CalendarComponent } from '@components/calendar/calendar.component'; | |
| import { InputTextComponent } from '@components/input-text/input-text.component'; | ||
| import { OrganizationSearchComponent } from '@components/organization-search/organization-search.component'; | ||
| import { SelectComponent } from '@components/select/select.component'; | ||
| import { APPOINTED_BY_OPTIONS, LINKEDIN_PROFILE_PATTERN, MEMBER_ROLES, VOTING_STATUSES } from '@lfx-one/shared/constants'; | ||
| import { APPOINTED_BY_OPTIONS, LINKEDIN_PROFILE_PATTERN, MEMBER_ROLES, VOTING_STATUSES, WEBSITE_URL_PATTERN } from '@lfx-one/shared/constants'; | ||
| import { Committee, CommitteeMember, CreateCommitteeMemberRequest, MemberFormValue } from '@lfx-one/shared/interfaces'; | ||
| import { formatDateToISOString, parseISODateString } from '@lfx-one/shared/utils'; | ||
| import { CommitteeService } from '@services/committee.service'; | ||
|
|
@@ -43,6 +43,11 @@ export class MemberFormComponent { | |
| // Wizard mode: returns data instead of calling API (used when committee doesn't exist yet) | ||
| public readonly wizardMode: boolean; | ||
|
|
||
| // Organization fields are required when voting is enabled OR business email is required | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Major:
|
||
| public get orgRequired(): boolean { | ||
| return !!(this.committee?.enable_voting || this.committee?.business_email_required); | ||
| } | ||
|
|
||
| // Member options | ||
| public roleOptions = MEMBER_ROLES; | ||
| public votingStatusOptions = VOTING_STATUSES; | ||
|
|
@@ -205,8 +210,8 @@ export class MemberFormComponent { | |
| email: new FormControl('', [Validators.required, Validators.email]), | ||
| job_title: new FormControl(''), | ||
| linkedin_profile: new FormControl('', [Validators.pattern(LINKEDIN_PROFILE_PATTERN)]), | ||
| organization: new FormControl(''), | ||
| organization_url: new FormControl(''), | ||
| organization: new FormControl('', this.orgRequired ? [Validators.required] : []), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Major: Validators are baked in at construction time — won't react to committee changesProblem: Why it matters:
Fix: effect(() => {
const required = this.orgRequired();
const orgCtrl = this.form().get('organization');
const urlCtrl = this.form().get('organization_url');
orgCtrl?.setValidators(required ? [Validators.required] : []);
urlCtrl?.setValidators(
required
? [Validators.required, Validators.pattern(WEBSITE_URL_PATTERN)]
: [Validators.pattern(WEBSITE_URL_PATTERN)]
);
orgCtrl?.updateValueAndValidity();
urlCtrl?.updateValueAndValidity();
});This keeps validators in sync with the committee state and pairs naturally with the |
||
| organization_url: new FormControl('', this.orgRequired ? [Validators.required, Validators.pattern(WEBSITE_URL_PATTERN)] : [Validators.pattern(WEBSITE_URL_PATTERN)]), | ||
| role: new FormControl('', this.committee?.enable_voting ? [Validators.required] : []), | ||
| voting_status: new FormControl('', this.committee?.enable_voting ? [Validators.required] : []), | ||
| appointed_by: new FormControl(''), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.