Skip to content

Commit

Permalink
fix(pwa): input default value
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Nov 30, 2022
1 parent 94b5258 commit c01d4e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pwa/src/component/job-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class JobItem extends AlwatrElement {
@property({attribute: false, type: Object}) job?: Job;

override render(): TemplateResult | typeof nothing {
if (this.job == null) return nothing;
if (this.job == null || this.job.detail == null) return nothing;

return html`
<ion-item-sliding>
Expand All @@ -104,7 +104,7 @@ export class JobItem extends AlwatrElement {
${this.__renderTitle(i18nCityList[this.job.detail.origin], i18nCityList[this.job.detail.dest])}
${this.__renderSubtitle(
this.job.detail.date,
this.job.detail.dayPart.map((part) => i18nDayPartList[part]).join(' - '),
this.job.detail?.dayPart.map((part) => i18nDayPartList[part]).join(' - '),
)}
${this.__renderDescription(this.job.detail.description)}
</ion-label>
Expand Down
17 changes: 12 additions & 5 deletions pwa/src/component/page-flight-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export class PageFlightFinder extends AlwatrElement {

return html`<ion-select-option value=${++monthNumber}>${month}</ion-select-option>`;
});
private __newJob: Partial<NewJobDetail> = {};
private __newJob: Partial<NewJobDetail> = {
seatCount: 1,
};

override connectedCallback(): void {
super.connectedCallback();
Expand Down Expand Up @@ -202,7 +204,12 @@ export class PageFlightFinder extends AlwatrElement {
</div>
<ion-item fill="solid">
<ion-label position="floating">تعداد صندلی</ion-label>
<ion-select name="seatCount" interface="popover" @ionChange=${this.__inputChanged}>
<ion-select
name="seatCount"
interface="popover"
.value=${this.__newJob.seatCount?.toString() ?? '1'}
@ionChange=${this.__inputChanged}
>
${PageFlightFinder.seatListTemplate}
</ion-select>
</ion-item>
Expand Down Expand Up @@ -240,8 +247,8 @@ export class PageFlightFinder extends AlwatrElement {
detail: {
dest: this.__newJob.dest as string,
origin: this.__newJob.origin as string,
dayPart: this.__newJob.dayPart as dayParts[],
maxPrice: this.__newJob.maxPrice ?? 0,
dayPart: (this.__newJob.dayPart as dayParts[]) ?? [],
maxPrice: this.__newJob.maxPrice ?? null,
seatCount: this.__newJob.seatCount ?? 1,
description: this.__newJob.description ?? '',
date: `${currentYear}/${this.__newJob.month}/${this.__newJob.day}`,
Expand Down Expand Up @@ -284,6 +291,6 @@ export class PageFlightFinder extends AlwatrElement {
}

private get __formValidate(): boolean {
return Object.keys(this.__newJob).length >= 5;
return Object.keys(this.__newJob).length >= 4;
}
}

0 comments on commit c01d4e7

Please sign in to comment.