diff --git a/src/js/main.js b/src/js/main.js
index 1c73cd84a..07234a8d9 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -1,4 +1,4 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
/**
* @copyright Copyright (c) 2018 René Gieling
*
@@ -21,36 +21,58 @@
*
*/
-import Vue from 'vue';
-import Create from './Create.vue';
-import {DatetimePicker} from 'nextcloud-vue';
-import Controls from './components/_base-controls.vue';
-import SideBarClose from './components/sideBarClose.vue';
-import UserDiv from './components/_base-UserDiv.vue';
-import SideBar from './components/_base-SideBar.vue';
-import ShareDiv from './components/shareDiv.vue';
-
-Vue.config.debug = true
-Vue.config.devTools = true
-Vue.component('Controls', Controls);
-Vue.component('DatePicker', DatetimePicker);
-Vue.component('SideBarClose', SideBarClose);
-Vue.component('UserDiv', UserDiv);
-Vue.component('SideBar', SideBar);
-Vue.component('ShareDiv', ShareDiv);
-
-Vue.mixin({
- methods: {
- t: function(app, text, vars, count, options) {
- return OC.L10N.translate(app, text, vars, count, options)
- },
- n: function(app, textSingular, textPlural, count, vars, options) {
- return OC.L10N.translatePlural(app, textSingular, textPlural, count, vars, options)
- }
- }
-});
+import Vue from 'vue'
+import router from './router'
+import axios from 'nextcloud-axios'
+import App from './App.vue'
+import vClickOutside from 'v-click-outside'
+import VueClipboard from 'vue-clipboard2'
+import { DatetimePicker, PopoverMenu, Tooltip } from 'nextcloud-vue'
+
+import Modal from './plugins/plugin.js'
+import Controls from './components/_base-Controls'
+import UserDiv from './components/_base-UserDiv'
+import SideBar from './components/_base-SideBar'
+import SideBarClose from './components/sideBarClose'
+import ShareDiv from './components/shareDiv'
+import LoadingOverlay from './components/_base-LoadingOverlay'
+
+Vue.config.debug = process.env.NODE_ENV !== 'production'
+Vue.config.devTools = process.env.NODE_ENV !== 'production'
+Vue.component('Controls', Controls)
+Vue.component('PopoverMenu', PopoverMenu)
+Vue.component('DatePicker', DatetimePicker)
+Vue.component('UserDiv', UserDiv)
+Vue.component('SideBar', SideBar)
+Vue.component('SideBarClose', SideBarClose)
+Vue.component('ShareDiv', ShareDiv)
+Vue.component('LoadingOverlay', LoadingOverlay)
+
+Vue.directive('tooltip', Tooltip)
+
+Vue.use(vClickOutside)
+Vue.use(VueClipboard)
+Vue.use(Modal)
+
+Vue.prototype.t = t
+Vue.prototype.n = n
+Vue.prototype.$http = axios
+Vue.prototype.OC = OC
+Vue.prototype.OCA = OCA
+
+// CSP config for webpack dynamic chunk loading
+// eslint-disable-next-line
+__webpack_nonce__ = btoa(OC.requestToken)
+
+// Correct the root of the app for chunk loading
+// OC.linkTo matches the apps folders
+// eslint-disable-next-line
+__webpack_public_path__ = OC.linkTo('polls', 'js/')
+
+/* eslint-disable-next-line no-new */
new Vue({
- el: '#create-poll',
- render: h => h(Create)
-});
+ el: '#app-polls',
+ router: router,
+ render: h => h(App)
+})
diff --git a/src/js/plugins/modalDialog.vue b/src/js/plugins/modalDialog.vue
new file mode 100644
index 000000000..43cd6aae4
--- /dev/null
+++ b/src/js/plugins/modalDialog.vue
@@ -0,0 +1,96 @@
+
+
+
+
{{ title }}
+
+
+
{{ text }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/js/plugins/plugin.js b/src/js/plugins/plugin.js
new file mode 100644
index 000000000..4047c86b0
--- /dev/null
+++ b/src/js/plugins/plugin.js
@@ -0,0 +1,30 @@
+/* jshint esversion: 6 */
+// we need our modal component
+import ModalDialog from './modalDialog.vue'
+
+const Modal = {
+ // every plugin for Vue.js needs install method
+ // this method will run after Vue.use() is executed
+ install(Vue, options) {
+ // We must create new Eventbus
+ // which is just another Vue instance that will be listening for and emiting events from our main instance
+ // this EventBus will be available as Modal.EventBus
+ this.EventBus = new Vue()
+
+ // making our modal component global
+ Vue.component('modal-dialog', ModalDialog)
+
+ // exposing global $modal object with method show()
+ // method show() takes object params as argument
+ // inside this object we can have modal title, text, styles... and also our callback confirm function
+ Vue.prototype.$modal = {
+ show(params) {
+ // if we use this.$modal.show(params) inside our original Vue instance
+ // we will emit 'show' event with parameters 'params'
+ Modal.EventBus.$emit('show', params)
+ }
+ }
+ }
+}
+
+export default Modal
diff --git a/src/js/router.js b/src/js/router.js
new file mode 100644
index 000000000..de881dd01
--- /dev/null
+++ b/src/js/router.js
@@ -0,0 +1,72 @@
+/* jshint esversion: 6 */
+/**
+ * @copyright Copyright (c) 2018 Julius Härtl
+ * @copyright Copyright (c) 2018 John Molakvoæ
+ *
+ * @author Julius Härtl
+ * @author John Molakvoæ
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+import Vue from 'vue'
+import Router from 'vue-router'
+
+// Dynamic loading
+const Create = () => import('./views/Create')
+const List = () => import('./views/List')
+
+Vue.use(Router)
+
+export default new Router({
+ mode: 'history',
+ base: OC.generateUrl(''),
+ linkActiveClass: 'active',
+ routes: [
+ {
+ path: '/:index(index.php/)?apps/polls/',
+ components: {
+ default: List
+ },
+ props: false,
+ name: 'list'
+ },
+ {
+ path: '/:index(index.php/)?apps/polls/edit/:hash',
+ components: {
+ default: Create
+ },
+ props: true,
+ name: 'edit'
+ },
+ {
+ path: '/:index(index.php/)?apps/polls/clone/:hash',
+ components: {
+ default: Create
+ },
+ props: true,
+ name: 'clone'
+ },
+ {
+ path: '/:index(index.php/)?apps/polls/new',
+ components: {
+ default: Create
+ },
+ props: false,
+ name: 'create'
+ }
+ ]
+})
diff --git a/src/js/Create.vue b/src/js/views/Create.vue
similarity index 52%
rename from src/js/Create.vue
rename to src/js/views/Create.vue
index 238152704..ba0c204ff 100644
--- a/src/js/Create.vue
+++ b/src/js/views/Create.vue
@@ -20,16 +20,16 @@
-
-->
-
-