re added stuff

This commit is contained in:
vabene1111
2020-12-28 14:14:34 +01:00
parent 643dbbc294
commit 8b2833f353
5 changed files with 58 additions and 18 deletions

View File

@@ -109,7 +109,7 @@
<div class="col col-md-3">
<div class="input-group d-print-none">
<input type="number" value="1" maxlength="3" class="form-control"
<input type="number" value="1" maxlength="3" class="form-control" style="min-width: 2vw"
v-model="servings"/>
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-calculator"></i></span>
@@ -516,7 +516,12 @@
let csrftoken = Cookies.get('csrftoken');
Vue.http.headers.common['X-CSRFToken'] = csrftoken;
const recipe_servings = {{ recipe.servings }}
{% if user_servings %}
const recipe_servings = {{ user_servings|floatformat:0 }}
{% else %}
const recipe_servings = {{ recipe.servings }}
{% endif %}
let app = new Vue({
delimiters: ['[[', ']]'],

View File

@@ -246,6 +246,7 @@
</div>
<script src="{% url 'javascript-catalog' %}"></script>
<script type="application/javascript">
let csrftoken = Cookies.get('csrftoken');
Vue.http.headers.common['X-CSRFToken'] = csrftoken;
@@ -283,6 +284,8 @@
this.searchKeywords('')
this.searchUnits('')
this.searchIngredients('')
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!'), 'danger')
},
methods: {
makeToast: function (title, message, variant = null) {
@@ -305,12 +308,12 @@
this.error = err.data
this.loading = false
console.log(err)
this.makeToast('{% trans 'Error' %}', '{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
importRecipe: function () {
if (this.importing_recipe) {
this.makeToast('{% trans 'Error' %}', '{% trans 'Already importing the selected recipe, please wait!' %}', 'danger')
this.makeToast(gettext('Error'), gettext('Already importing the selected recipe, please wait!'), 'danger')
return;
}
this.importing_recipe = true
@@ -319,7 +322,7 @@
window.location.href = response.data
}).catch((err) => {
console.log(err);
this.makeToast('{% trans 'Error' %}', '{% trans 'An error occurred while trying to import this recipe!' %}' + err.bodyText, 'danger')
this.makeToast('{% trans 'Error' %}', gettext('An error occurred while trying to import this recipe!') + err.bodyText, 'danger')
})
},
deleteIngredient: function (i) {
@@ -363,7 +366,7 @@
this.keywords_loading = false
}).catch((err) => {
console.log(err)
this.makeToast('{% trans 'Error' %}', '{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
this.makeToast('{% trans 'Error' %}', gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
searchUnits: function (query) {
@@ -381,7 +384,7 @@
this.units_loading = false
}).catch((err) => {
console.log(err)
this.makeToast('{% trans 'Error' %}', '{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
this.makeToast('{% trans 'Error' %}', gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
searchIngredients: function (query) {
@@ -400,7 +403,7 @@
this.ingredients_loading = false
}).catch((err) => {
console.log(err)
this.makeToast('{% trans 'Error' %}', '{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger')
this.makeToast('{% trans 'Error' %}', gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
}