Skip to content

Commit

Permalink
Minor changes to the behaviour of the new dateRange based conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
igoramadas committed Sep 12, 2024
1 parent 1883411 commit 8f4a566
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/recipes/AddCondition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
no-filter
></v-autocomplete>
</div>
<div v-else-if="selectedProperty?.type == 'date'">
<div v-else-if="isDateRange">
<v-row>
<v-col cols="12" :sm="12" :md="6">
<v-text-field v-model="valueDateFrom" type="text" prefix="From: " :rules="valueInputRules" :placeholder="inputPlaceholder" @keyup="valueKeyUp" dense outlined rounded></v-text-field>
Expand Down Expand Up @@ -142,6 +142,9 @@ export default {
isWeekday() {
return this.selectedProperty?.value == "weekday"
},
isDateRange() {
return this.selectedProperty?.value == "dateRange"
},
isGarmin() {
return this.selectedProperty?.value == "garmin.sensor"
},
Expand Down Expand Up @@ -352,16 +355,16 @@ export default {
} else if (this.isLocation) {
result.value = this.locationInput.value
result.friendlyValue = this.locationInput.address
} else if (this.selectedProperty.type == "time") {
const arrTime = result.value.split(":")
result.value = parseInt(arrTime[0]) * 3600 + parseInt(arrTime[1]) * 60
result.friendlyValue = this.valueInput
} else if (this.selectedProperty.type == "date") {
} else if (this.isDateRange) {
result.value = `${this.valueDateFrom},${this.valueDateTo}`
const year = new Date().getFullYear()
const fromDate = this.valueDateFrom.length == 5 ? this.$dayjs(`${year}-${this.valueDateFrom}`).format("MMM D") : this.$dayjs(this.valueDateFrom).format("MMM D, YYYY")
const toDate = this.valueDateTo.length == 5 ? this.$dayjs(`${year}-${this.valueDateTo}`).format("MMM D") : this.$dayjs(this.valueDateTo).format("MMM D, YYYY")
result.friendlyValue = `From ${fromDate} to ${toDate}`
} else if (this.selectedProperty.type == "time") {
const arrTime = result.value.split(":")
result.value = parseInt(arrTime[0]) * 3600 + parseInt(arrTime[1]) * 60
result.friendlyValue = this.valueInput
}
}
Expand Down

0 comments on commit 8f4a566

Please sign in to comment.