fix timecard display

This commit is contained in:
hay-kot 2021-04-21 21:49:56 -08:00
commit 7fc9c1a0ec

View file

@ -3,7 +3,7 @@
color="accent" color="accent"
class="custom-transparent d-flex justify-start align-center text-center time-card-flex" class="custom-transparent d-flex justify-start align-center text-center time-card-flex"
tile tile
v-if="totalTime || prepTime || performTime" v-if="showCards"
> >
<v-card flat color="rgb(255, 0, 0, 0.0)"> <v-card flat color="rgb(255, 0, 0, 0.0)">
<v-icon large color="white" class="mx-2"> mdi-clock-outline </v-icon> <v-icon large color="white" class="mx-2"> mdi-clock-outline </v-icon>
@ -16,7 +16,7 @@
flat flat
color="rgb(255, 0, 0, 0.0)" color="rgb(255, 0, 0, 0.0)"
> >
<v-card-text class="white--text py-2"> <v-card-text class="caption white--text py-2">
<div> <div>
<strong> {{ time.name }} </strong> <strong> {{ time.name }} </strong>
</div> </div>
@ -33,30 +33,45 @@ export default {
totalTime: String, totalTime: String,
performTime: String, performTime: String,
}, },
watch: {
showCards(val) {
console.log(val);
},
},
computed: { computed: {
showCards() {
return [this.prepTime, this.totalTime, this.performTime].some(
x => !this.isEmpty(x)
);
},
allTimes() { allTimes() {
return [ return [
this.validateTotalTime, this.validateTotalTime,
this.validatePrepTime, this.validatePrepTime,
this.validatePerformTime, this.validatePerformTime,
]; ].filter(x => x !== null);
}, },
validateTotalTime() { validateTotalTime() {
return this.prepTime return !this.isEmpty(this.totalTime)
? { name: this.$t("recipe.prep-time"), value: this.prepTime } ? { name: this.$t("recipe.total-time"), value: this.totalTime }
: null; : null;
}, },
validatePrepTime() { validatePrepTime() {
return this.prepTime return !this.isEmpty(this.prepTime)
? { name: this.$t("recipe.prep-time"), value: this.prepTime } ? { name: this.$t("recipe.prep-time"), value: this.prepTime }
: null; : null;
}, },
validatePerformTime() { validatePerformTime() {
return this.prepTime return !this.isEmpty(this.performTime)
? { name: this.$t("recipe.perform-time"), value: this.performTime } ? { name: this.$t("recipe.perform-time"), value: this.performTime }
: null; : null;
}, },
}, },
methods: {
isEmpty(str) {
return !str || str.length === 0;
},
},
}; };
</script> </script>