Skip to content

Commit 432bd0c

Browse files
committed
added capacity error, turned off location input for events seeded from hubs, and added redirect when editing profile
1 parent f9baac4 commit 432bd0c

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

src/app/pages/create-event/create-event.page.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,20 @@
8585
<ion-item>
8686
<ion-input type="number" formControlName="minimumCapacity" placeholder="Min"></ion-input>
8787
<ion-input type="number" formControlName="maximumCapacity" placeholder="Max"></ion-input>
88+
<ion-label>
89+
<ion-text *ngIf="(myForm.hasError('invalidCapacity') || maximumCapacity.hasError('lessThanMin'))
90+
&& (minimumCapacity.touched || maximumCapacity.touched)"
91+
color="danger">*</ion-text>
92+
</ion-label>
93+
<ion-note slot="helper" *ngIf="(myForm.hasError('invalidCapacity') || maximumCapacity.hasError('lessThanMin'))
94+
&& (minimumCapacity.touched || maximumCapacity.touched)"
95+
color="danger">
96+
Min must be less than Max.
97+
</ion-note>
8898
</ion-item>
8999

100+
101+
90102
<ion-list-header class="ion-padding-bottom">
91103
<ion-text>Description</ion-text>
92104
</ion-list-header>
@@ -99,8 +111,8 @@
99111
<ion-text>Location</ion-text>
100112
</ion-list-header>
101113

102-
<ion-item>
103-
<ion-input readonly [disabled]="seedType === 'hub' || seed?.hub" type="text" placeholder="Location" [value]="location.value?.label" (click)="toggleMapModal()"></ion-input>
114+
<ion-item *ngIf="!(seedType === 'hub' || seed?.hub)">
115+
<ion-input type="text" placeholder="Location" [value]="location.value?.label" (click)="toggleMapModal()"></ion-input>
104116
</ion-item>
105117

106118
<app-hub-card

src/app/pages/create-event/create-event.page.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ export const eventGroupValidator: ValidatorFn = (control: AbstractControl): Vali
2121
} : null;
2222
};
2323

24+
export const capacityValidator: ValidatorFn = (group: AbstractControl): ValidationErrors | null => {
25+
const minCtrl = group.get('minimumCapacity');
26+
const maxCtrl = group.get('maximumCapacity');
27+
28+
const minVal = minCtrl.value;
29+
const maxVal = maxCtrl.value;
30+
31+
if (minVal === '' || minVal == null || maxVal === '' || maxVal == null) return null;
32+
33+
const min = Number(minVal);
34+
const max = Number(maxVal);
35+
36+
return max < min
37+
? { invalidCapacity: true, message: 'Min must be less than Max.' }
38+
: null;
39+
};
40+
2441
@Component({
2542
selector: 'app-create-event',
2643
templateUrl: './create-event.page.html',
@@ -108,7 +125,7 @@ export class CreateEventPage implements OnInit, OnDestroy {
108125
minimumCapacity: new FormControl(),
109126
maximumCapacity: new FormControl(),
110127
location: new FormControl(),
111-
}, { validators: eventGroupValidator });
128+
}, { validators: [eventGroupValidator, capacityValidator]});
112129

113130
if (this.seed?.latitude && this.seed?.longitude && this.seed?.locationLabel) {
114131
this.myForm.patchValue({
@@ -149,7 +166,7 @@ export class CreateEventPage implements OnInit, OnDestroy {
149166
.toPromise()
150167
.then(async result => {
151168
this.loading = false;
152-
await this.navCtrl.navigateForward(`/event/${result?.data?.createEvent?.eventId}`);
169+
await this.navCtrl.navigateForward(`/tabs/event/${result?.data?.createEvent?.eventId}`);
153170
})
154171
.catch(err => this.errorService.handleError(err, this.loading));
155172
}

src/app/pages/profile/settings/settings.page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ export class SettingsPage implements OnInit {
154154
this.loading = false;
155155

156156
await this.authService.iOSAutofillSavePassword(this.email.value, this.password.value);
157+
await this.navCtrl.navigateForward('/tabs/profile');
157158
} else {
158159
this.alertService.presentToast('Saved');
159160
this.loading = false;
161+
await this.navCtrl.navigateForward('/tabs/profile');
160162
}
161163
} catch (error) {
162164
this.errorService.handleError(error, this.loading);

0 commit comments

Comments
 (0)