testing with vue mixings and components
This commit is contained in:
parent
4b719af4e1
commit
9044f9e1ff
12
cookbook/static/vue/components/Toast.js
Normal file
12
cookbook/static/vue/components/Toast.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
let toast_mixin = Vue.mixin({
|
||||||
|
methods: {
|
||||||
|
makeToast: function (title, message, variant = null) {
|
||||||
|
this.$bvToast.toast(message, {
|
||||||
|
title: title,
|
||||||
|
variant: variant,
|
||||||
|
toaster: 'b-toaster-top-center',
|
||||||
|
solid: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -122,7 +122,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<draggable class="list-group" :list="recipes"
|
<draggable class="list-group" :list="recipes"
|
||||||
:group="{ name: 'plan', pull: 'clone', put: false }" :clone="cloneRecipe">
|
:group="{ name: 'plan', pull: 'clone', put: false }" :clone="cloneRecipe">
|
||||||
<div class="list-group-item d-flex align-items-center justify-content-between" v-for="(element, index) in recipes" :key="element.id">
|
<div class="list-group-item d-flex align-items-center justify-content-between"
|
||||||
|
v-for="(element, index) in recipes" :key="element.id">
|
||||||
<span>
|
<span>
|
||||||
<i class="fas fa-arrows-alt"></i> [[element.name]]
|
<i class="fas fa-arrows-alt"></i> [[element.name]]
|
||||||
</span>
|
</span>
|
||||||
@ -369,8 +370,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{% url 'javascript-catalog' %}"></script>
|
<script src="{% url 'javascript-catalog' %}"></script>
|
||||||
|
|
||||||
|
<script src="{% static 'vue/components/Toast.js' %}" type="application/javascript"></script>
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
moment.locale('{{request.LANGUAGE_CODE}}');
|
moment.locale('{{request.LANGUAGE_CODE}}');
|
||||||
|
|
||||||
@ -380,6 +384,7 @@
|
|||||||
let app = new Vue({
|
let app = new Vue({
|
||||||
delimiters: ['[[', ']]'],
|
delimiters: ['[[', ']]'],
|
||||||
el: '#app',
|
el: '#app',
|
||||||
|
mixin: [toast_mixin],
|
||||||
data: {
|
data: {
|
||||||
start_date: undefined,
|
start_date: undefined,
|
||||||
start_offset: 0,
|
start_offset: 0,
|
||||||
@ -417,17 +422,11 @@
|
|||||||
|
|
||||||
this.updatePlan();
|
this.updatePlan();
|
||||||
this.getRecipes();
|
this.getRecipes();
|
||||||
|
|
||||||
|
//this.makeToast('success', 'this actually works', 'success')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
makeToast: function (title, message, variant = null) {
|
|
||||||
//TODO remove duplicate function in favor of central one
|
|
||||||
this.$bvToast.toast(message, {
|
|
||||||
title: title,
|
|
||||||
variant: variant,
|
|
||||||
toaster: 'b-toaster-top-center',
|
|
||||||
solid: true
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updatePlan: function () {
|
updatePlan: function () {
|
||||||
this.dates = [];
|
this.dates = [];
|
||||||
for (var i = 0; i <= (this.number_of_days - 1); i++) {
|
for (var i = 0; i <= (this.number_of_days - 1); i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user