cook log
This commit is contained in:
68
vue/src/components/CookLog.vue
Normal file
68
vue/src/components/CookLog.vue
Normal file
@ -0,0 +1,68 @@
|
||||
<template>
|
||||
|
||||
<div>
|
||||
|
||||
<b-modal class="modal" id="id_modal_cook_log" :title="_('Log Recipe Cooking')" :ok-title="_('Save')"
|
||||
:cancel-title="_('Close')" @ok="logCook()">
|
||||
|
||||
<p>{{ _('All fields are optional and can be left empty.') }}</p>
|
||||
<form>
|
||||
|
||||
<label for="id_log_servings">{{ _('Servings') }}</label>
|
||||
<input class="form-control" type="number" id="id_log_servings" v-model="logObject.servings">
|
||||
<label style="margin-top: 2vh" for="id_log_rating">{{ _('Rating') }} - <span
|
||||
id="id_rating_show">{{ logObject.rating }}/5</span></label>
|
||||
<input type="range" class="custom-range" min="0" max="5" id="id_log_rating" name="log_rating"
|
||||
value="0" v-model="logObject.rating">
|
||||
|
||||
<label for="id_date" style="margin-top: 2vh">{{ _('Date') }}</label>
|
||||
<input type="datetime-local" id="id_date" class="form-control" v-model="logObject.created_at">
|
||||
</form>
|
||||
</b-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {GettextMixin} from "@/utils/utils";
|
||||
|
||||
import moment from 'moment'
|
||||
|
||||
Vue.prototype.moment = moment
|
||||
|
||||
import Vue from "vue";
|
||||
import {BootstrapVue} from "bootstrap-vue";
|
||||
import {apiLogCooking} from "@/utils/api";
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
export default {
|
||||
name: 'CookLog',
|
||||
mixins: [
|
||||
GettextMixin,
|
||||
],
|
||||
props: {
|
||||
recipe: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
logObject: {
|
||||
recipe: this.recipe.id,
|
||||
servings: 0,
|
||||
rating: 0,
|
||||
created_at: moment().format('yyyy-MM-DDTHH:MM')
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
logCook: function () {
|
||||
|
||||
let obj = JSON.parse(JSON.stringify(this.logObject))
|
||||
|
||||
obj.created_at = moment(obj.created_at, 'yyyy-MM-DDTHH:MM').format('yyyy-MM-DD HH:MM')
|
||||
console.log('updating: ', obj)
|
||||
apiLogCooking(this.logObject)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
@ -12,7 +12,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<i class="fas fa-fire fa-fw"></i> {{ _('Calories') }}
|
||||
<i class="fas fa-fire fa-fw text-primary"></i> {{ _('Calories') }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{{ calculateAmount(recipe.nutrition.calories) }} kcal
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<i class="fas fa-bread-slice fa-fw"></i> {{ _('Carbohydrates') }}
|
||||
<i class="fas fa-bread-slice fa-fw text-primary"></i> {{ _('Carbohydrates') }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<i class="fas fa-cheese fa-fw"></i> {{ _('Fats') }}
|
||||
<i class="fas fa-cheese fa-fw text-primary"></i> {{ _('Fats') }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{{ calculateAmount(recipe.nutrition.fats) }} g
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<i class="fas fa-drumstick-bite fa-fw"></i> {{ _('Proteins') }}
|
||||
<i class="fas fa-drumstick-bite fa-fw text-primary"></i> {{ _('Proteins') }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{{ calculateAmount(recipe.nutrition.proteins) }} g
|
||||
|
@ -1,53 +1,54 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<div class="dropdown">
|
||||
<a class="btn shadow-none" href="#" role="button" id="dropdownMenuLink"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</a>
|
||||
<div class="dropdown">
|
||||
<a class="btn shadow-none" href="#" role="button" id="dropdownMenuLink"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('edit_recipe', recipe.id)"><i
|
||||
class="fas fa-pencil-alt fa-fw"></i> {{ _('Edit') }}</a>
|
||||
<button class="dropdown-item" onclick="$('#bookmarkModal').modal({'show':true})">
|
||||
<i class="fas fa-bookmark fa-fw"></i> {{ _('Add to Book') }}
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('edit_recipe', recipe.id)"><i
|
||||
class="fas fa-pencil-alt fa-fw"></i> {{ _('Edit') }}</a>
|
||||
<button class="dropdown-item" onclick="$('#bookmarkModal').modal({'show':true})">
|
||||
<i class="fas fa-bookmark fa-fw"></i> {{ _('Add to Book') }}
|
||||
</button>
|
||||
|
||||
<a class="dropdown-item" :href="recipe.name" v-if="true"> <!--TODO implement -->
|
||||
<i class="fas fa-shopping-cart fa-fw"></i> {{ _('Add to Shopping') }} </a>
|
||||
<a class="dropdown-item" :href="recipe.name" v-if="true"> <!--TODO implement -->
|
||||
<i class="fas fa-shopping-cart fa-fw"></i> {{ _('Add to Shopping') }} </a>
|
||||
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('new_meal_plan', recipe.id)"><i
|
||||
class="fas fa-calendar fa-fw"></i> {{ _('Add to Plan') }}</a>
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('new_meal_plan', recipe.id)"><i
|
||||
class="fas fa-calendar fa-fw"></i> {{ _('Add to Plan') }}</a>
|
||||
|
||||
<!--
|
||||
<button class="dropdown-item" :onclick="openCookLogModal(recipe.id)"><i
|
||||
class="fas fa-clipboard-list fa-fw"></i> {{ _('Log Cooking') }}
|
||||
</button>
|
||||
-->
|
||||
<button class="dropdown-item" onclick="window.print()"><i
|
||||
class="fas fa-print fa-fw"></i> {{ _('Print') }}
|
||||
</button>
|
||||
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('view_export', recipe.id)" target="_blank"
|
||||
rel="noopener noreferrer"><i class="fas fa-file-export fa-fw"></i> {{ _('Export') }}</a>
|
||||
<button class="dropdown-item" @click="$bvModal.show('id_modal_cook_log')"><i
|
||||
class="fas fa-clipboard-list fa-fw"></i> {{ _('Log Cooking') }}
|
||||
</button>
|
||||
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('new_share_link', recipe.id)" target="_blank"
|
||||
rel="noopener noreferrer" v-if="recipe.internal"><i class="fas fa-share-alt fa-fw"></i> {{
|
||||
_('Share')
|
||||
}}</a>
|
||||
</div>
|
||||
<button class="dropdown-item" onclick="window.print()"><i
|
||||
class="fas fa-print fa-fw"></i> {{ _('Print') }}
|
||||
</button>
|
||||
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('view_export', recipe.id)" target="_blank"
|
||||
rel="noopener noreferrer"><i class="fas fa-file-export fa-fw"></i> {{ _('Export') }}</a>
|
||||
|
||||
<a class="dropdown-item" :href="resolveDjangoUrl('new_share_link', recipe.id)" target="_blank"
|
||||
rel="noopener noreferrer" v-if="recipe.internal"><i class="fas fa-share-alt fa-fw"></i> {{
|
||||
_('Share')
|
||||
}}</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<cook-log :recipe="recipe"></cook-log>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {GettextMixin, ResolveUrlMixin} from "@/utils/utils";
|
||||
import CookLog from "@/components/CookLog";
|
||||
|
||||
export default {
|
||||
name: 'RecipeContextMenu',
|
||||
@ -55,6 +56,9 @@ export default {
|
||||
ResolveUrlMixin,
|
||||
GettextMixin
|
||||
],
|
||||
components: {
|
||||
CookLog
|
||||
},
|
||||
props: {
|
||||
recipe: Object,
|
||||
}
|
||||
|
Reference in New Issue
Block a user