CSR-1137 | Small refactor
This commit is contained in:
parent
6eb0ba2867
commit
5d6f1069b3
2 changed files with 9 additions and 11 deletions
|
|
@ -324,7 +324,7 @@ export default {
|
||||||
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
||||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||||
const minutes = militaryTimeInput.split(":")[1];
|
const minutes = militaryTimeInput.split(":")[1];
|
||||||
let meridianNotation = hours > 11 ? "PM" : "AM";
|
const meridianNotation = hours > 11 ? "PM" : "AM";
|
||||||
if (hours > 12) {
|
if (hours > 12) {
|
||||||
hours -= 12;
|
hours -= 12;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedTimeSlotId: null,
|
selectedTimeSlotId: null,
|
||||||
isSelectedAppointmentPremium: null,
|
|
||||||
timeSlotModalListButton: timeSlotModalListButton,
|
timeSlotModalListButton: timeSlotModalListButton,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -189,23 +188,22 @@ export default {
|
||||||
},
|
},
|
||||||
// fires any time the footer button is used, is fired before "onModalClosed"
|
// fires any time the footer button is used, is fired before "onModalClosed"
|
||||||
closeModal() {
|
closeModal() {
|
||||||
if (this.selectedTimeSlotId.toString().includes(PREMIUM_TIME_SLOT_ID_FLAG)) {
|
let isSelectedAppointmentPremium = false;
|
||||||
|
if (this.selectedTimeSlotId.includes(PREMIUM_TIME_SLOT_ID_FLAG)) {
|
||||||
this.selectedTimeSlotId = this.removePremiumFlagFromInput(this.selectedTimeSlotId);
|
this.selectedTimeSlotId = this.removePremiumFlagFromInput(this.selectedTimeSlotId);
|
||||||
this.isSelectedAppointmentPremium = true;
|
isSelectedAppointmentPremium = true;
|
||||||
} else {
|
|
||||||
this.isSelectedAppointmentPremium = false;
|
|
||||||
}
|
}
|
||||||
const selectedTimeSlotData = {
|
const selectedTimeSlotData = {
|
||||||
id: this.selectedTimeSlotId,
|
id: this.selectedTimeSlotId,
|
||||||
isPremiumAppointment: this.isSelectedAppointmentPremium,
|
isPremiumAppointment: isSelectedAppointmentPremium,
|
||||||
};
|
};
|
||||||
this.$emit("update:modelValue", selectedTimeSlotData);
|
this.$emit("update:modelValue", selectedTimeSlotData);
|
||||||
this.$refs["timeSlots"].closeModal();
|
this.$refs["timeSlots"].closeModal();
|
||||||
},
|
},
|
||||||
// fires any time the modal is closed, AFTER "closeModal" fires if footer button is used
|
// fires any time the modal is closed, AFTER "closeModal" fires if footer button is used
|
||||||
onModalClosed() {
|
onModalClosed() {
|
||||||
this.isSelectedAppointmentPremium = this.modelValue.isPremiumAppointment;
|
// Reset component state to parent's state
|
||||||
if (this.isSelectedAppointmentPremium) {
|
if (this.modelValue.isPremiumAppointment) {
|
||||||
this.selectedTimeSlotId = this.addPremiumFlagToInput(this.modelValue.id);
|
this.selectedTimeSlotId = this.addPremiumFlagToInput(this.modelValue.id);
|
||||||
} else {
|
} else {
|
||||||
this.selectedTimeSlotId = this.modelValue.id;
|
this.selectedTimeSlotId = this.modelValue.id;
|
||||||
|
|
@ -216,7 +214,7 @@ export default {
|
||||||
getDisplayTextForMilitaryTime(militaryTimeInput) {
|
getDisplayTextForMilitaryTime(militaryTimeInput) {
|
||||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||||
const minutes = militaryTimeInput.split(":")[1];
|
const minutes = militaryTimeInput.split(":")[1];
|
||||||
let meridianNotation = hours > 11 ? "PM" : "AM";
|
const meridianNotation = hours > 11 ? "PM" : "AM";
|
||||||
if (hours > 12) {
|
if (hours > 12) {
|
||||||
hours -= 12;
|
hours -= 12;
|
||||||
}
|
}
|
||||||
|
|
@ -295,7 +293,7 @@ export default {
|
||||||
return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG);
|
return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG);
|
||||||
},
|
},
|
||||||
removePremiumFlagFromInput(timeSlotId) {
|
removePremiumFlagFromInput(timeSlotId) {
|
||||||
return parseInt(timeSlotId.trim(PREMIUM_TIME_SLOT_ID_FLAG.length));
|
return timeSlotId.substring(0, timeSlotId.length - PREMIUM_TIME_SLOT_ID_FLAG.length);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue