Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
feat(#2): reschedule viewings requests without any dates
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Sep 23, 2018
1 parent 4a5977b commit 05d5dc1
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class ItemAppointmentsDatePickerComponent extends AbstractPickAppointment
@Input() unavailableAppointmentDates: number[];
@Input() rejectedAppointmentDates: number[]; // In case of to_reschedule appointments

// Output
selectedAppointmentsStartTime: number[] = new Array();

manyPossibleTimeSlots: boolean = true;
Expand Down Expand Up @@ -122,11 +121,13 @@ export class ItemAppointmentsDatePickerComponent extends AbstractPickAppointment
});
}

selectAppointments() {
if (this.hasSelectedAppointments()) {
this.notifiySelected.emit(this.selectedAppointmentsStartTime);
async selectAppointments() {
// User could send viewings requests without any dates selected
// as long as advertiser did not specified particular dates
if (!this.hasSelectedAppointments() && this.hasFavoritesDates()) {
await this.displayAlertAtLeastOneAppointment();
} else {
this.displayAlertAtLeastOneAppointment();
this.notifiySelected.emit(this.selectedAppointmentsStartTime);
}
}

Expand Down Expand Up @@ -246,6 +247,10 @@ export class ItemAppointmentsDatePickerComponent extends AbstractPickAppointment
return Comparator.hasElements(this.selectedAppointmentsStartTime);
}

private hasFavoritesDates(): boolean {
return Comparator.hasElements(this.favoriteDates);
}

swipeDatePicker($event: any) {
this.swipeCard($event, this.scrollX.nativeElement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export class PickItemAppointmentsComponent extends AbstractItemsPage {
schedule(selectedAppointmentStartTimes: number[]) {
this.selectedAppointmentStartTimes = selectedAppointmentStartTimes;

this.subscriptionService.couldAddLike().then((result: boolean) => {
this.subscriptionService.couldAddLike().then(async (result: boolean) => {
if (result) {
this.initAndDoSchedule();
await this.initAndDoSchedule();
} else {
this.showProductModal(this.doProductCallback);
await this.showProductModal(this.doProductCallback);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class ApplicantAppointmentsModal extends AbstractApplicantSelectionPage {
});
}

select(startTime: Date) {
async select(startTime: Date) {

this.gaTrackEvent(this.platform, this.googleAnalyticsNativeService, this.RESOURCES.GOOGLE.ANALYTICS.TRACKER.EVENT.CATEGORY.ADS.ADS, this.RESOURCES.GOOGLE.ANALYTICS.TRACKER.EVENT.ACTION.ADS.APPLICANT.APPLICANT_SELECT);

Expand All @@ -132,6 +132,6 @@ export class ApplicantAppointmentsModal extends AbstractApplicantSelectionPage {
}
}

this.updateAndExportToCalendar(this.RESOURCES.APPLICANT.STATUS.ACCEPTED, null);
await this.updateAndExportToCalendar(this.RESOURCES.APPLICANT.STATUS.ACCEPTED, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class RescheduleAppointmentsModal extends AbstractApplicantSelectionPage
this.updatedSchedule = selectedDate;
}

doReschedule() {
async doReschedule() {
if (this.updatedSchedule == null) {
this.displayAlertAtLeastOneAppointment();
return;
Expand All @@ -89,7 +89,7 @@ export class RescheduleAppointmentsModal extends AbstractApplicantSelectionPage
const previousSelectedDate: Date = this.applicant.selected;
this.applicant.selected = this.updatedSchedule;

this.updateAndExportToCalendar(this.RESOURCES.APPLICANT.STATUS.ACCEPTED, previousSelectedDate);
await this.updateAndExportToCalendar(this.RESOURCES.APPLICANT.STATUS.ACCEPTED, previousSelectedDate);
}

isApplicantReschedule(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<ion-content role="browse" [scrollY]="false" padding>

<ng-container *ngIf="loaded">
<h2 text-center *ngIf="isItemFlat()" padding>
<h2 text-center *ngIf="isItemFlat()" padding no-margin>
{{ 'ITEM_APPOINTMENTS.VIEWING_WHEN_TEXT_FLAT' | translate:{who: item.user.facebook.firstName == null ? '' : item.user.facebook.firstName} }}
</h2>

<h2 text-center *ngIf="isItemShare()" padding>
<h2 text-center *ngIf="isItemShare()" padding no-margin>
{{ 'ITEM_APPOINTMENTS.VIEWING_WHEN_TEXT_SHARE' | translate:{who: item.user.facebook.firstName == null ? '' : item.user.facebook.firstName} }}
</h2>

Expand Down
26 changes: 13 additions & 13 deletions src/app/pages/advertise/applicant/abstract-applicant-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export abstract class AbstractApplicantSelectionPage extends AbstractPage {
protected reschedule() {
this.gaTrackEvent(this.platform, this.googleAnalyticsNativeService, this.RESOURCES.GOOGLE.ANALYTICS.TRACKER.EVENT.CATEGORY.ADS.ADS, this.RESOURCES.GOOGLE.ANALYTICS.TRACKER.EVENT.ACTION.ADS.APPLICANT.APPLICANT_RESCHEDULE);

this.setAllStatusCancelled().then(() => {
this.updateApplication(this.RESOURCES.APPLICANT.STATUS.TO_RESCHEDULE, null);
this.setAllStatusCancelled().then(async () => {
await this.updateApplication(this.RESOURCES.APPLICANT.STATUS.TO_RESCHEDULE, null);
});
}

Expand Down Expand Up @@ -81,8 +81,8 @@ export abstract class AbstractApplicantSelectionPage extends AbstractPage {
this.exportToCalendar(self.user, self.item, updatedApplicant, newStatus, previousStatus, previousDate, loading);
});
}, (errorResponse: HttpErrorResponse) => {
loading.dismiss().then(() => {
this.errorMsg(this.toastController, this.translateService, 'ERRORS.APPLICANT_SELECTION.NOT_UPDATED');
loading.dismiss().then(async () => {
await this.errorMsg(this.toastController, this.translateService, 'ERRORS.APPLICANT_SELECTION.NOT_UPDATED');
});
});
});
Expand Down Expand Up @@ -155,11 +155,11 @@ export abstract class AbstractApplicantSelectionPage extends AbstractPage {
});
}

protected updateAndExportToCalendar(newStatus: string, previousDate: Date) {
protected async updateAndExportToCalendar(newStatus: string, previousDate: Date) {
if (this.user.userParams.appSettings.calendarExport === null && this.ENV_CORDOVA) {
this.askUserAndExportIfNeeded(newStatus, previousDate);
} else {
this.updateApplication(newStatus, previousDate);
await this.updateApplication(newStatus, previousDate);
}
}

Expand All @@ -179,30 +179,30 @@ export abstract class AbstractApplicantSelectionPage extends AbstractPage {
buttons: [
{
text: data[3],
handler: () => {
this.updateUserAndUpdateApplication(false, newStatus, previousDate);
handler: async () => {
await this.updateUserAndUpdateApplication(false, newStatus, previousDate);
}
},
{
text: data[2],
handler: () => {
this.updateUserAndUpdateApplication(true, newStatus, previousDate);
handler: async () => {
await this.updateUserAndUpdateApplication(true, newStatus, previousDate);
}
}
]
});

confirm.present();
} else {
this.updateUserAndUpdateApplication(false, newStatus, previousDate);
await this.updateUserAndUpdateApplication(false, newStatus, previousDate);
}
}
);
}

private updateUserAndUpdateApplication(choice: boolean, newStatus: string, previousDate: Date) {
private async updateUserAndUpdateApplication(choice: boolean, newStatus: string, previousDate: Date) {
this.saveUserChoice(choice);
this.updateApplication(newStatus, previousDate);
await this.updateApplication(newStatus, previousDate);
}

private saveUserChoice(choice: boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ <h2 *ngIf="!isAppointmentInThePast()" padding-start padding-end>
</ion-card>

<div *ngIf="isStatusNew() && userProfileLoaded && availableDatesLoaded" padding-start padding-end id="newApplicantTitle">
<h3 padding-start padding-end *ngIf="!hasSelectedDates()">{{'APPLICANT_SELECTION.NO_APPOINTMENTS_FOUND' | translate}}</h3>
<h3 padding-start padding-end *ngIf="hasSelectedDates()">{{ 'APPLICANT_SELECTION.NEW_REQUEST_TITLE' | translate:{who: applicant.user.facebook.firstName} }}</h3>
<h3 padding>{{ 'APPLICANT_SELECTION.NEW_REQUEST_TITLE' | translate:{who: applicant.user.facebook.firstName} }}</h3>
</div>

<div *ngIf="isStatusNew() && userProfileLoaded && availableDatesLoaded" id="actions-buttons" padding margin-bottom>
Expand All @@ -55,6 +54,11 @@ <h3 padding-start padding-end *ngIf="hasSelectedDates()">{{ 'APPLICANT_SELECTION
[bigButton]="false" [mediumButton]="true" [mediumButtonAds]="true" *ngIf="hasSelectedDates()"
[icon]="'checkmark'" [label]="'APPLICANT_SELECTION.ACCEPT_REQUEST'">
</app-big-button>

<app-big-button (clicked)="doReschedule()" [adDisplay]="true"
[bigButton]="false" [mediumButton]="true" [mediumButtonAds]="true" *ngIf="!hasSelectedDates()"
[icon]="'checkmark'" [label]="'APPLICANT_SELECTION.ACCEPT_REQUEST_CHAT'">
</app-big-button>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ion-card, ion-card.card-md {
width: 100%;
justify-content: center;
align-items: center;
margin-bottom: 60px;
margin-bottom: 100px;

app-big-button:first-of-type {
margin-right: 24px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ export class ApplicantSelectionPage extends AbstractApplicantSelectionPage {
}
}

convertDate(selected: string): Date {
return new Date(selected);
}

// Agenda

// Filter proposed dates with the one already scheduled, in case it changed
Expand Down Expand Up @@ -220,22 +216,22 @@ export class ApplicantSelectionPage extends AbstractApplicantSelectionPage {

myButtons.push({
text: data[2],
handler: () => {
this.declineWithReason(this.RESOURCES.APPLICANT.CANCELLATION.REASON.FOUND_SOMEONE_ELSE);
handler: async () => {
await this.declineWithReason(this.RESOURCES.APPLICANT.CANCELLATION.REASON.FOUND_SOMEONE_ELSE);
}
});

myButtons.push({
text: data[3],
handler: () => {
this.declineWithReason(this.RESOURCES.APPLICANT.CANCELLATION.REASON.NOT_ENOUGH_DETAILS);
handler: async () => {
await this.declineWithReason(this.RESOURCES.APPLICANT.CANCELLATION.REASON.NOT_ENOUGH_DETAILS);
}
});

myButtons.push({
text: data[4],
handler: () => {
this.declineWithReason(this.RESOURCES.APPLICANT.CANCELLATION.REASON.NO_REASON);
handler: async () => {
await this.declineWithReason(this.RESOURCES.APPLICANT.CANCELLATION.REASON.NO_REASON);
}
});

Expand All @@ -257,12 +253,12 @@ export class ApplicantSelectionPage extends AbstractApplicantSelectionPage {
);
}

private declineWithReason(reason: string) {
private async declineWithReason(reason: string) {
this.gaTrackEvent(this.platform, this.googleAnalyticsNativeService, this.RESOURCES.GOOGLE.ANALYTICS.TRACKER.EVENT.CATEGORY.ADS.ADS, this.RESOURCES.GOOGLE.ANALYTICS.TRACKER.EVENT.ACTION.ADS.APPLICANT.APPLICANT_DECLINE);

this.applicant.cancellation = new ApplicantCancellation(reason);

this.updateApplication(this.RESOURCES.APPLICANT.STATUS.CANCELLED, null);
await this.updateApplication(this.RESOURCES.APPLICANT.STATUS.CANCELLED, null);
}

isStatusNew(): boolean {
Expand Down Expand Up @@ -316,6 +312,12 @@ export class ApplicantSelectionPage extends AbstractApplicantSelectionPage {
modal.present();
}

doReschedule() {
if (this.isStatusNew() && !this.hasSelectedDates()) {
this.reschedule();
}
}

protected finishUpdateApplication(updatedApplicant: Applicant) {
this.callCallback(updatedApplicant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<ion-toolbar role="buttons" *ngIf="item != null && isAppointmentActionAllowed() && displayButtons" padding-start padding-end>
<ion-button expand="full" shape="round" (click)="navigateToAppointment()" [disabled]="actionInProgress">
{{'ITEM_APPOINTMENTS.VIEWING_REQUEST_TITLE' | translate}}
<ion-icon slot="end" name="send"></ion-icon>
</ion-button>
</ion-toolbar>
</ion-footer>
Expand Down
14 changes: 7 additions & 7 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@
"PROPOSAL": "{{who}} bietet dir {{howmany}} mögliche Termine an; wähle eins aus, um die Anfrage anzunehmen",
"PROPOSAL_SINGLE": "{{who}} bietet dir folgenden Termin an",
"CONFIRM": "Annehmen",
"NO_APPOINTMENTS_FOUND": "Leider passen keine der vorgeschlagenen Termine mit deinem Kalender",
"RESCHEDULE_IN_PROGRESS": "Du hast {{who}} für einen Besichtigungstermin angefragt",
"CANCELLED": "Du hast die Besichtigungsanfrage von {{who}} abgelehnt",
"APPOINTMENT_IN_THE_PAST": "Du hast die Wohnung bereits besichtigt",
"APPOINTMENT_IN_THE_FUTURE": "Die Besichtigung mit {{who}} ist an folgendem Tag",
"NEW_REQUEST_TITLE": "{{who}} möchte deine Wohnung besichtigen – möchtest du die Anfrage annehmen?",
"ACCEPT_REQUEST": "<strong>Annehmen</strong> und Termin wählen",
"ACCEPT_REQUEST_CHAT": "Annehmen und <strong>chatten</strong>, um einen Termin zu vereinbaren",
"REJECT_REQUEST": "Ablehnen",
"NO_SELECTED_TIME": "Wähle einen Besichtigungstermin, um die Anfrage anzunehmen",
"APPOINTMENT_SCHEDULED_FOR": {
Expand All @@ -219,7 +219,7 @@
"ACTION_SHEET": {
"ACCEPT": "Diese Besichtigungsanfrage annehmen",
"DECLINE": "Diese Besichtigungsanfrage ablehnen",
"ASK_RESCHEDULE": "Neue Besichtigungstermine anfragen",
"ASK_RESCHEDULE": "Annehmen und chatten, um einen Termin zu vereinbaren",
"FOUND_SOMEONE_ELSE": "Sorry, ich habe bereits jemand gefunden",
"NOT_ENOUGH_DETAILS": "Das Profil enthält nicht genügend Informationen",
"NO_REASON": "Ich möchte lieber noch andere Interessenten kennenlernen",
Expand Down Expand Up @@ -643,15 +643,15 @@
"VIEWING_WHEN_TEXT_SHARE": "Wann kannst du die WG von {{who}} besichtigen?",
"VIEWING_WHEN_TEXT_FLAT": "Wann kannst du die Wohnung von {{who}} besichtigen?",
"SELECTED_COUNT": {
"NO_SELECTED_BROWSE": "Wähle eine oder mehrere Zeitfenster aus und erhöhe deine Chancen auf einen Termin",
"NO_SELECTED_BROWSE": "Wähle eine oder mehrere Zeitfenster aus, um den Termin zu vereinbaren",
"SELECTED_COUNT_AVAILABILITY": {
"SINGULAR": "Du hast <strong>{{count}} möglichen Termin</strong> ausgewählt",
"PLURAL": "Du hast <strong>{{count}} mögliche Termine</strong> ausgewählt"
},
"NO_SPECIAL_AVAILABILITY": "Du bist <strong>flexibel</strong>, was Besichtigungstermine angeht"
},
"CONFIRM": "Bestätigen",
"SEND": "Senden",
"SEND": "Jetzt senden",
"MISSING_PHONE": {
"TITLE": "Deine Telefonnummer",
"SUB_TITLE": "Unter dieser Nummer, die Personen mit denen du eine vereinbarte Besichtigung hast, können dich erreichen",
Expand All @@ -660,9 +660,9 @@
},
"TIPS": {
"SELECT_MANY_TIMESLOTS": {
"BEGIN": "Wähle",
"HIGHLIGHT": "mehrere Zeitfenster",
"END": "aus und erhöhe deine Chancen auf einen Termin!"
"BEGIN": "Füge hinzu",
"HIGHLIGHT": "deine Verfügbarkeit",
"END": "und erhöhe deine Chancen auf einen Termin!"
},
"SELECT_MANY_DAYS": {
"BEGIN": "Vielleicht sogar noch",
Expand Down
12 changes: 6 additions & 6 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@
"PROPOSAL": "{{who}} offers you {{howmany}} possible time slots, select one of them to accept the request",
"PROPOSAL_SINGLE": "{{who}} offers you this time slot",
"CONFIRM": "Accept",
"NO_APPOINTMENTS_FOUND": "Unfortunately, none of the proposed time slots fit your calendar.",
"RESCHEDULE_IN_PROGRESS": "You requested a viewing from {{who}}",
"CANCELLED": "You declined {{who}}'s request",
"APPOINTMENT_IN_THE_PAST": "The viewing with {{who}} already took place",
"APPOINTMENT_IN_THE_FUTURE": "The viewing with {{who}} is the following date",
"NEW_REQUEST_TITLE": "{{who}} has applied for a viewing, would you like to accept the request?",
"ACCEPT_REQUEST": "<strong>Accept</strong> and select the viewing",
"ACCEPT_REQUEST_CHAT": "Accept and <strong>chat</strong> to schedule a viewing",
"REJECT_REQUEST": "Reject",
"NO_SELECTED_TIME": "Select a time slot to accept the request",
"APPOINTMENT_SCHEDULED_FOR": {
Expand All @@ -219,7 +219,7 @@
"ACTION_SHEET": {
"ACCEPT": "Accept this request",
"DECLINE": "Decline this request",
"ASK_RESCHEDULE": "Request new viewings' time slots",
"ASK_RESCHEDULE": "Accept and chat to schedule a viewing",
"FOUND_SOMEONE_ELSE": "Sorry, I found someone else",
"NOT_ENOUGH_DETAILS": "The profile does not contain enough information",
"NO_REASON": "I rather like to meet other candidates",
Expand Down Expand Up @@ -643,15 +643,15 @@
"VIEWING_WHEN_TEXT_SHARE": "When can you visit {{who}}'s flat?",
"VIEWING_WHEN_TEXT_FLAT": "When can you visit {{who}}'s flat?",
"SELECTED_COUNT": {
"NO_SELECTED_BROWSE": "Pick one or many time slots to increase your chances to get a viewing",
"NO_SELECTED_BROWSE": "Pick one or many time slots to get a viewing",
"SELECTED_COUNT_AVAILABILITY": {
"SINGULAR": "<strong>{{count}} potential time slot</strong>",
"PLURAL": "<strong>{{count}} potential time slots</strong>"
},
"NO_SPECIAL_AVAILABILITY": "You are <strong>flexible</strong> and have no special dates"
},
"CONFIRM": "Confirm",
"SEND": "Send",
"SEND": "Send now",
"MISSING_PHONE": {
"TITLE": "Your phone number",
"SUB_TITLE": "The persons with whom you have an appointment can reach you at this number",
Expand All @@ -660,8 +660,8 @@
},
"TIPS": {
"SELECT_MANY_TIMESLOTS": {
"BEGIN": "Select",
"HIGHLIGHT": "multiple time slots",
"BEGIN": "Add",
"HIGHLIGHT": "your availabilities",
"END": "to increase your chances of getting a viewing!"
},
"SELECT_MANY_DAYS": {
Expand Down

0 comments on commit 05d5dc1

Please sign in to comment.