diff --git a/src/components/ChapterEditor.vue b/src/components/ChapterEditor.vue
new file mode 100644
index 0000000..e8c35f9
--- /dev/null
+++ b/src/components/ChapterEditor.vue
@@ -0,0 +1,292 @@
+
+ div
+ .ChapterEditor
+ div
+ h2 Change chapter's title
+ WTLField(grouped=true)
+ WTLInput.ChapterEditor__title(
+ v-model="newChapter.title"
+ )
+ WTLButton(
+ @click="patchChapter"
+ icon="done"
+ type="success"
+ ) Update chapter title
+ div
+ h2 Change page order by dragging them
+ .ChapterEditor__pages-container
+ ol.ChapterEditor__old-pages
+ li.ChapterEditor__page(v-for="(page, index) in chapter.pages") {{ index+1 }}. {{ page.title }}
+ VueDraggable.ChapterEditor__pages(
+ v-if="newPages"
+ v-model="newPages"
+ @start="drag=true"
+ @end="drag=false"
+ )
+ .ChapterEditor__page(
+ v-for="(page, index) in newPages"
+ :key="page._id"
+ )
+ WTLIcon(icon="swap_vertical")
+ | {{ page.title }}
+ .ChapterEditor__page-icons
+ WTLIcon(icon="delete", clickable=true, @click.native="deletePageDialog(page, index)")
+ div.flex-container.flex-content-end
+ h3 Confirm changes?
+ WTLButton(
+ @click="patchChapterPages"
+ icon="done"
+ type="success"
+ ) Update pages order
+ div
+ h2 Insert new page
+ WTLField(grouped=true)
+ WTLInput.ChapterEditor__new-page(
+ v-model="newPage.title"
+ placeholder="Insert title"
+ )
+ WTLButton(
+ @click="postPage"
+ icon="done"
+ type="success"
+ ) Add new page
+
+ WTLModal(v-if="showModal", ref="modal", @close="showModal = false", title="Edit page")
+ template(slot="content")
+ WTLField(grouped=true, label="Page title")
+ WTLInput(v-model="page.title")
+ template(slot="actions")
+ WTLButton(@click="closeModal", icon="close") Cancel
+ WTLButton(@click="patchPage", icon="done", type="success") Confirm edit
+
+
+
+
+
diff --git a/src/components/ChapterPages.vue b/src/components/ChapterPages.vue
index eccfc9d..338f2c9 100644
--- a/src/components/ChapterPages.vue
+++ b/src/components/ChapterPages.vue
@@ -1,44 +1,65 @@
.ChapterPages
- h3.ChapterPages__title {{ number }}. {{ chapter.title }}
+ h3.ChapterPages__title
+ WTLIcon(
+ v-if="$keycloak && $keycloak.authenticated",
+ clickable=true,
+ icon="edit",
+ @click.native="goToEditChapter"
+ )
+ | {{ number }}. {{ chapter.title }}
ul
li(
v-for="page in chapter.pages"
:key="page._id"
)
router-link(:to=`{
name: "Page",
append: true,
params: {
pageTitle: page._id
}
}`) {{ page.title }}
diff --git a/src/components/CourseEditor.vue b/src/components/CourseEditor.vue
index d8161ee..2587341 100644
--- a/src/components/CourseEditor.vue
+++ b/src/components/CourseEditor.vue
@@ -1,327 +1,305 @@
div
.CourseEditor
div
h2 Change course's title
WTLField(grouped=true)
WTLInput.CourseEditor__title(
v-model="newCourse.title"
)
WTLButton(
@click="patchCourse"
icon="done"
type="success"
) Update course title
div
h2 Change chapter order by dragging them
.CourseEditor__chapters-container
ol.CourseEditor__old-chapters
li.CourseEditor__chapter(v-for="(chapter, index) in course.chapters") {{ index+1 }}. {{ chapter.title }}
VueDraggable.CourseEditor__chapters(
v-if="newChapters"
v-model="newChapters"
@start="drag=true"
@end="drag=false"
+ :options={
+ handle: ".draggable-handle"
+ }
)
.CourseEditor__chapter(
v-for="(chapter, index) in newChapters"
:key="chapter._id"
- )
- WTLIcon(icon="swap_vertical")
+ )
+ .draggable-handle
+ WTLIcon(icon="swap_vertical")
| {{ chapter.title }}
.CourseEditor__chapter-icons
- WTLIcon(icon="edit", clickable=true, @click.native="editChapter(chapter)")
WTLIcon(icon="delete", clickable=true, @click.native="deleteChapterDialog(chapter, index)")
div.flex-container.flex-content-end
h3 Confirm changes?
WTLButton(
@click="patchCourseChapters"
icon="done"
type="success"
) Update chapters order
div
h2 Insert new chapter
WTLField(grouped=true)
WTLInput.CourseEditor__new-chapter(
v-model="newChapter.title"
placeholder="Insert title"
)
WTLButton(
@click="postChapter"
icon="done"
type="success"
) Add new chapter
- WTLModal(v-if="showModal", ref="modal", @close="showModal = false", title="Edit chapter")
+ // WTLModal(v-if="showModal", ref="modal", @close="showModal = false", title="Edit chapter")
template(slot="content")
WTLField(grouped=true, label="Chapter title")
WTLInput(v-model="chapter.title")
template(slot="actions")
WTLButton(@click="closeModal", icon="close") Cancel
WTLButton(@click="patchChapter", icon="done", type="success") Confirm edit
diff --git a/src/components/CourseRenderer.vue b/src/components/CourseRenderer.vue
index 4e68b9a..6a5ac9a 100644
--- a/src/components/CourseRenderer.vue
+++ b/src/components/CourseRenderer.vue
@@ -1,78 +1,79 @@
.CourseRenderer
h3.CourseRenderer__name(v-if="showName") {{ course.name }}
ul.CourseRenderer__chapters
li.CourseRenderer__chapter(
v-for="(chapter, index) in course.chapters"
:key="chapter._id"
)
ChapterPages(
:chapter="chapter"
:number="index + 1"
+ :courseName="course._id"
)
//
router-link(:to=`{
name: "Chapter",
append: true,
params: {
chapterName: chapter._id
}
}`) {{ chapter.title }}
diff --git a/src/components/Editor.vue b/src/components/Editor.vue
deleted file mode 100644
index bab85d3..0000000
--- a/src/components/Editor.vue
+++ /dev/null
@@ -1,35 +0,0 @@
-
- NoSSR
- .Editor
- vue-ckeditor(type="classic", :editors="editors", v-model="mutableContent")
-
-
-
-
diff --git a/src/components/PageEditor.vue b/src/components/PageEditor.vue
new file mode 100644
index 0000000..7418510
--- /dev/null
+++ b/src/components/PageEditor.vue
@@ -0,0 +1,102 @@
+
+ NoSSR
+ div
+ WTLField(grouped=true, label="Update page title")
+ WTLInput(v-model="newPage.title")
+ WTLButton(type="success", @click="patchPage", icon="done") Update page title
+ // WTLButton(@click="newTheorem") Inserisci teorema
+ .Editor(id="editor")
+ div(id="editor-toolbar")
+ div(id="editor-editable")
+
+
+
+
+
diff --git a/src/router/index.js b/src/router/index.js
index 3027991..3c57fa5 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,66 +1,66 @@
import Router from "vue-router"
// We are also using Webpack code splitting here so that each route's associated
// component code is loaded on-demand only when the route is visited.
// When do you use on-demand load? When the view is not one of the important one. When a route is important? You decide
let routes = []
import Home from "views/Home"
import Department from "views/Department"
import Course from "views/Course"
import EditChapter from "views/EditChapter"
import Courses from "views/Courses"
import Page from "views/Page"
const EditPage = () => import("views/EditPage")
routes = routes.concat([
{ path: "/", component: Home, name: "Home" },
{ path: "/d/:departmentName", component: Department, name: "Department" },
{ path: "/c", component: Courses, name: "Courses" },
{ path: "/c/:courseName", component: Course, name: "Course" },
{ path: "/c/:courseName/:chapterName/edit", component: EditChapter, name: "EditChapter" },
- { path: "/p/:pageTitle(.+)/edit", component: EditPage, name: "EditPage" },
- { path: "/p/:pageTitle(.+)", component: Page, name: "Page" }
+ { path: "/p/:pageTitle/edit", component: EditPage, name: "EditPage" },
+ { path: "/p/:pageTitle", component: Page, name: "Page" }
])
if (process.env.NODE_ENV !== "production") {
const Showcase = () => import("views/dev/Showcase") // load dynamically when needed
const Login = () => import("views/dev/Login")
routes.push({ path: "/showcase", component: Showcase })
routes.push({ path: "/login", component: Login })
}
const UIDemo = () => import("views/dev/UIDemo")
const UIDemoComponentsList = () => import("views/dev/ui/ComponentsList")
const UIDemoButton = () => import("views/dev/ui/Button")
const UIDemoDialog = () => import("views/dev/ui/Dialog")
const UIDemoAsync = () => import("views/dev/ui/Async")
const UIDemoInput = () => import("views/dev/ui/Input")
const UIDemoField = () => import("views/dev/ui/Field")
routes.push({
path: "/uidemo", component: UIDemo,
children: [
{ path: "", component: UIDemoComponentsList },
{ path: "button", component: UIDemoButton },
{ path: "dialog", component: UIDemoDialog },
{ path: "async", component: UIDemoAsync },
{ path: "input", component: UIDemoInput },
{ path: "field", component: UIDemoField }
]
})
const NotFound = () => import("views/NotFound")
routes.push({ path: "/404", component: NotFound, name: "NotFound" })
// push as last element because the wildcard match will catch all the unknown urls
routes.push({ path: "*", component: NotFound })
export function createRouter() {
return new Router({
mode: "history",
scrollBehavior: () => ({ y: 0 }),
routes
})
}
diff --git a/src/views/EditChapter.vue b/src/views/EditChapter.vue
new file mode 100644
index 0000000..807e91b
--- /dev/null
+++ b/src/views/EditChapter.vue
@@ -0,0 +1,51 @@
+
+ .view--EditChapter
+ h1.EditChapter__title {{ chapterName }}
+ ChapterEditor(
+ v-if="chapter",
+ :chapter="chapter"
+ )
+
+
+
+
+
diff --git a/src/views/EditPage.vue b/src/views/EditPage.vue
index f1b81a3..2fd0189 100644
--- a/src/views/EditPage.vue
+++ b/src/views/EditPage.vue
@@ -1,42 +1,42 @@
.view--EditPage
h1.EditPage__title {{ pageTitle }}
- Editor(
+ PageEditor(
v-if="page",
- :content="page.content"
+ :page="page"
)
diff --git a/src/views/Page.vue b/src/views/Page.vue
index 881f060..2fb7161 100644
--- a/src/views/Page.vue
+++ b/src/views/Page.vue
@@ -1,63 +1,63 @@
.view--Page
template(v-if="page")
.view--Page__buttons
router-link(
:to=`{
name: 'EditPage',
params: { pageTitle: $route.params.pageTitle }
}`
)
WTLButton(type="success", icon="mode_edit") Edit Page
PageRenderer(
v-if="page",
:page="page"
)