currently everything working
This commit is contained in:
parent
7b936ec4fd
commit
816ced83b5
@ -7,7 +7,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<recipe-view></recipe-view>
|
<recipe-view recipe_id="5"></recipe-view>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -16,6 +16,10 @@
|
|||||||
{% block script %}
|
{% block script %}
|
||||||
<script src="{% url 'javascript-catalog' %}"></script>
|
<script src="{% url 'javascript-catalog' %}"></script>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
window.RECIPE_ID = 5;
|
||||||
|
</script>
|
||||||
|
|
||||||
{% render_bundle 'chunk-vendors' %}
|
{% render_bundle 'chunk-vendors' %}
|
||||||
{% render_bundle 'recipe_view' %}
|
{% render_bundle 'recipe_view' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -18,13 +18,10 @@ import {BootstrapVue} from 'bootstrap-vue'
|
|||||||
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
||||||
|
|
||||||
import {makeToast} from "@/utils/utils.js";
|
import {makeToast} from "@/utils/utils.js";
|
||||||
//import {gettext} from "@/utils/jsi18n";
|
|
||||||
|
|
||||||
const _ = window.gettext
|
const _ = window.gettext
|
||||||
|
|
||||||
import Step from "@/components/Step";
|
import Step from "@/components/Step";
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
@ -38,6 +35,7 @@ const store = new Vuex.Store({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
import {apiLoadRecipe} from "@/utils/django";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RecipeView',
|
name: 'RecipeView',
|
||||||
@ -48,29 +46,24 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
|
recipe_id: window.RECIPE_ID,
|
||||||
recipe: undefined,
|
recipe: undefined,
|
||||||
servings: 1,
|
servings: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
//makeToast("Error", "Error", "danger")
|
this.loadRecipe(this.recipe_id)
|
||||||
this.loadRecipe(5)
|
|
||||||
console.log(_('Error'))
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadRecipe: function (recipe_id) {
|
loadRecipe: function (recipe_id) {
|
||||||
axios.get(`/api/recipe/${recipe_id}`).then((response) => {
|
apiLoadRecipe(recipe_id).then(recipe => {
|
||||||
|
this.recipe = recipe
|
||||||
this.recipe = response.data;
|
this.loading = false
|
||||||
this.loading = false;
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
makeToast('Error', 'There was an error loading a resource!', 'danger')
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -4,5 +4,5 @@ import App from './RecipeView.vue'
|
|||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
render: h => h(App),
|
render: h => h(App),
|
||||||
}).$mount('#app')
|
}).$mount('#app')
|
||||||
|
12
vue/src/utils/django.js
Normal file
12
vue/src/utils/django.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import {makeToast} from "@/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
|
export function apiLoadRecipe(recipe_id) {
|
||||||
|
return axios.get(`/api/recipe/${recipe_id}`).then((response) => {
|
||||||
|
return response.data
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
makeToast('Error', 'There was an error loading a resource!', 'danger')
|
||||||
|
})
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
{"status":"done","publicPath":"http://localhost:8080/","chunks":{"chunk-vendors":[{"name":"js/chunk-vendors.js","publicPath":"http://localhost:8080/js/chunk-vendors.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\js\\chunk-vendors.js"}],"recipe_view":[{"name":"js/recipe_view.js","publicPath":"http://localhost:8080/js/recipe_view.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\js\\recipe_view.js"}]},"error":"ModuleError","message":"Module Error (from ./node_modules/eslint-loader/index.js):\n\nF:\\Developement\\Django\\recipes\\vue\\src\\apps\\RecipeView\\RecipeView.vue\n 58:17 error '_' is not defined no-undef\n\n✖ 1 problem (1 error, 0 warnings)\n"}
|
{"status":"done","publicPath":"http://localhost:8080/","error":"ModuleError","message":"Module Error (from ./node_modules/eslint-loader/index.js):\n\nF:\\Developement\\Django\\recipes\\vue\\src\\apps\\RecipeView\\RecipeView.vue\n 47:11 error 'root_element' is not defined no-undef\n\n✖ 1 problem (1 error, 0 warnings)\n","chunks":{"chunk-vendors":[{"name":"js/chunk-vendors.js","publicPath":"http://localhost:8080/js/chunk-vendors.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\js\\chunk-vendors.js"}],"recipe_view":[{"name":"js/recipe_view.js","publicPath":"http://localhost:8080/js/recipe_view.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\js\\recipe_view.js"},{"name":"recipe_view.85b0fba40931a99bbc77.hot-update.js","publicPath":"http://localhost:8080/recipe_view.85b0fba40931a99bbc77.hot-update.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\recipe_view.85b0fba40931a99bbc77.hot-update.js"}]}}
|
@ -3179,6 +3179,11 @@ dir-glob@^2.0.0, dir-glob@^2.2.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
path-type "^3.0.0"
|
path-type "^3.0.0"
|
||||||
|
|
||||||
|
django-js-reverse@^0.10.1-a.0:
|
||||||
|
version "0.10.1-a.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/django-js-reverse/-/django-js-reverse-0.10.1-a.0.tgz#ff915561930d3292c7e33c8b4d6f10ae8cecc8a0"
|
||||||
|
integrity sha512-t0lHG4LMjkpXBtRL6oQwBX1S5aygZgddQ4IEhTX9icRvRcGv2sx5zyrf1sKj6e8xtO7boibzWI94bSphoG6llw==
|
||||||
|
|
||||||
dns-equal@^1.0.0:
|
dns-equal@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.npm.taobao.org/dns-equal/download/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
|
resolved "https://registry.npm.taobao.org/dns-equal/download/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
|
||||||
|
Loading…
Reference in New Issue
Block a user