From f86a5c8e797c1660dcd6bb051fa61b594bcef398 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Fri, 18 Sep 2020 20:45:47 +0200 Subject: [PATCH] TreeNode editor | moznost volit treenode id v url --- seminar/urls.py | 4 +- vue_frontend/package.json | 3 +- vue_frontend/src/App.vue | 55 +---------------- vue_frontend/src/components/TreeNodeRoot.vue | 62 ++++++++++++++++++++ vue_frontend/src/main.js | 4 +- vue_frontend/src/router/index.js | 23 ++++++++ vue_frontend/yarn.lock | 5 ++ 7 files changed, 99 insertions(+), 57 deletions(-) create mode 100644 vue_frontend/src/components/TreeNodeRoot.vue create mode 100644 vue_frontend/src/router/index.js diff --git a/seminar/urls.py b/seminar/urls.py index efbfb65f..f62ca8c4 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -1,4 +1,4 @@ -from django.urls import path, include +from django.urls import path, include, re_path from django.contrib.auth.decorators import user_passes_test from . import views, export from .utils import staff_member_required @@ -120,7 +120,7 @@ urlpatterns = [ path('temp/add_solution', views.AddSolutionView.as_view(),name='seminar_vloz_reseni'), path('temp/nahraj_reseni', views.NahrajReseniView.as_view(),name='seminar_nahraj_reseni'), - path('temp/vue',views.VueTestView.as_view(),name='vue_test_view'), + re_path(r'^temp/vue/.*$',views.VueTestView.as_view(),name='vue_test_view'), path('', views.TitulniStranaView.as_view(), name='titulni_strana'), diff --git a/vue_frontend/package.json b/vue_frontend/package.json index 66c53043..c51f8418 100644 --- a/vue_frontend/package.json +++ b/vue_frontend/package.json @@ -12,7 +12,8 @@ "@ckeditor/ckeditor5-vue": "^1.0.1", "axios": "^0.19.2", "core-js": "^3.6.5", - "vue": "^2.6.11" + "vue": "^2.6.11", + "vue-router": "^3.4.3" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.4.0", diff --git a/vue_frontend/src/App.vue b/vue_frontend/src/App.vue index 495994d3..0d64a639 100644 --- a/vue_frontend/src/App.vue +++ b/vue_frontend/src/App.vue @@ -1,58 +1,7 @@ - - diff --git a/vue_frontend/src/components/TreeNodeRoot.vue b/vue_frontend/src/components/TreeNodeRoot.vue new file mode 100644 index 00000000..fd70a028 --- /dev/null +++ b/vue_frontend/src/components/TreeNodeRoot.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/vue_frontend/src/main.js b/vue_frontend/src/main.js index abfcc1e8..0c3b439d 100644 --- a/vue_frontend/src/main.js +++ b/vue_frontend/src/main.js @@ -1,10 +1,12 @@ import Vue from 'vue' import App from './App.vue' +import router from './router' import CKEditor from '@ckeditor/ckeditor5-vue' Vue.config.productionTip = false Vue.use(CKEditor); new Vue({ - render: h => h(App), + router, + render: h => h(App), }).$mount('#app') diff --git a/vue_frontend/src/router/index.js b/vue_frontend/src/router/index.js new file mode 100644 index 00000000..711bbc81 --- /dev/null +++ b/vue_frontend/src/router/index.js @@ -0,0 +1,23 @@ +import Vue from 'vue' +import Router from 'vue-router' +import TreeNodeRoot from '../components/TreeNodeRoot.vue' + +Vue.use(Router) + +export default new Router({ + mode: 'history', + linkActiveClass: 'active', + routes: [{ + path: '/temp/vue', + name: 'treenodedefault', + props: {'tnid': 1}, + component: TreeNodeRoot + }, { + path: '/temp/vue/:tnid', + name: 'treenode', + props: true, + component: TreeNodeRoot + }, + ] +}) + diff --git a/vue_frontend/yarn.lock b/vue_frontend/yarn.lock index 63a49784..0d2d55bb 100644 --- a/vue_frontend/yarn.lock +++ b/vue_frontend/yarn.lock @@ -8122,6 +8122,11 @@ vue-loader@^15.9.2: vue-hot-reload-api "^2.3.0" vue-style-loader "^4.1.0" +vue-router@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.4.3.tgz#fa93768616ee338aa174f160ac965167fa572ffa" + integrity sha512-BADg1mjGWX18Dpmy6bOGzGNnk7B/ZA0RxuA6qedY/YJwirMfKXIDzcccmHbQI0A6k5PzMdMloc0ElHfyOoX35A== + vue-style-loader@^4.1.0, vue-style-loader@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-4.1.2.tgz#dedf349806f25ceb4e64f3ad7c0a44fba735fcf8"