Cleanup old code

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2020-04-29 11:23:08 +02:00
parent 4c0bb4b971
commit 669d341500
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
17 changed files with 14 additions and 443 deletions

View file

@ -35,6 +35,7 @@
<script>
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import { getCurrentUser } from '@nextcloud/auth'
export default {
components: {
@ -81,8 +82,8 @@ export default {
computedDisplayName() {
let value = this.displayName
if (this.userId === OC.getCurrentUser().uid) {
value = OC.getCurrentUser().displayName
if (this.userId === getCurrentUser().uid) {
value = getCurrentUser().displayName
} else {
if (!this.displayName) {
value = this.userId

View file

@ -1,52 +0,0 @@
<!--
- @copyright Copyright (c) 2018 René Gieling <github@dartcafe.de>
-
- @author René Gieling <github@dartcafe.de>
-
- @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 <http://www.gnu.org/licenses/>.
-
-->
<template>
<li>
<div>{{ option.timestamp | localFullDate }}</div>
<div>
<a class="icon-delete" @click="$emit('remove')" />
</div>
</li>
</template>
<script>
import moment from '@nextcloud/moment'
export default {
filters: {
localFullDate(timestamp) {
if (!timestamp) return ''
if (!moment(timestamp).isValid()) return 'Invalid Date'
if (timestamp < 999999999999) timestamp = timestamp * 1000
return moment(timestamp).format('llll')
},
},
props: {
option: {
type: Object,
default: undefined,
},
},
}
</script>

View file

@ -1,86 +0,0 @@
<!--
-
-
- @author Nick Gallo
-
- @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 <http://www.gnu.org/licenses/>.
-
-->
<template>
<li>
<div>{{ question.text }}</div>
<div>
<input v-show="(question.type != 'text') && (question.type != 'comment')"
v-model="newOption"
style="height:30px;"
:placeholder=" t('forms', 'Add Option')"
@keyup.enter="emitNewOption(question)">
<transitionGroup
id="form-list"
name="list"
tag="ul"
class="form-table">
<TextFormItem
v-for="(opt, index) in options"
:key="opt.id"
:option="opt"
@remove="emitRemoveOption(question, opt, index)" />
</transitionGroup>
</div>
<div>
<a class="icon icon-delete svg delete-form" @click="$emit('deleteQuestion')" />
</div>
</li>
</template>
<script>
import TextFormItem from './textFormItem'
export default {
components: {
TextFormItem,
},
props: {
question: {
type: Object,
default: undefined,
},
},
data() {
return {
nextOptionId: 1,
newOption: '',
type: '',
}
},
computed: {
options() {
return this.question.options || []
},
},
methods: {
emitNewOption(question) {
this.$emit('addOption', this, question)
},
emitRemoveOption(question, option, index) {
this.$emit('deleteOption', question, option, index)
},
},
}
</script>

View file

@ -62,10 +62,12 @@
</template>
<script>
import { generateUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
// TODO: replace with same design as core sharing
import UserDiv from './_base-UserDiv'
import axios from '@nextcloud/axios'
export default {
components: {
@ -129,7 +131,7 @@ export default {
loadUsersAsync(query) {
this.isLoading = false
this.siteUsersListOptions.query = query
axios.post(OC.generateUrl('apps/forms/get/siteusers'), this.siteUsersListOptions)
axios.post(generateUrl('apps/forms/get/siteusers'), this.siteUsersListOptions)
.then((response) => {
this.users = response.data.siteusers
this.isLoading = false

View file

@ -1,43 +0,0 @@
<!--
- @copyright Copyright (c) 2018 René Gieling <github@dartcafe.de>
-
- @author René Gieling <github@dartcafe.de>
-
- @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 <http://www.gnu.org/licenses/>.
-
-->
<template>
<li>
<div>{{ option.text }}</div>
<div>
<a class="icon icon-delete svg delete-form" @click="$emit('remove')" />
</div>
</li>
</template>
<script>
export default {
props: {
option: {
type: Object,
default: undefined,
},
},
}
</script>

View file

@ -32,20 +32,12 @@ import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'
import router from './router'
import Forms from './Forms'
import Modal from './plugins/plugin.js'
// TODO: not use global registration
Vue.directive('tooltip', Tooltip)
Vue.use(Modal)
Vue.prototype.t = translate
Vue.prototype.n = translatePlural
// TODO: see if necessary
Vue.prototype.OC = OC
Vue.prototype.OCA = OCA
// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(getRequestToken())

View file

@ -1,97 +0,0 @@
<template>
<div v-if="visible" class="modal-dialog">
<div class="modal-header">
<h2>{{ title }}</h2>
</div>
<div class="modal-text">
<p>{{ text }}</p>
</div>
<slot />
<div class="modal-buttons">
<button class="button" @click="hide">
{{ buttonHideText }}
</button>
<button class="button primary" @click="confirm">
{{ buttonConfirmText }}
</button>
</div>
</div>
</template>
<script>
// we must import our Modal plugin instance
// because it contains reference to our Eventbus
import Modal from './plugin.js'
export default {
name: 'ModalDialog',
data() {
return {
visible: false,
title: '',
text: '',
buttonHideText: 'Close',
buttonConfirmText: 'OK',
onConfirm: {},
}
},
beforeMount() {
// here we need to listen for emited events
// we declared those events inside our plugin
Modal.EventBus.$on('show', (params) => {
this.show(params)
})
},
methods: {
hide() {
this.visible = false
},
confirm() {
// we must check if this.onConfirm is function
if (typeof this.onConfirm === 'function') {
// run passed function and then close the modal
this.onConfirm()
this.hide()
} else {
// we only close the modal
this.hide()
}
},
show(params) {
// making modal visible
this.visible = true
// setting texts
this.title = params.title
this.text = params.text
this.buttonHideText = params.buttonHideText
this.buttonConfirmText = params.buttonConfirmText
// setting callback function
this.onConfirm = params.onConfirm
},
},
}
</script>
<style scoped lang="scss">
.modal-dialog {
display: flex;
flex-direction: column;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: 300px;
max-width: 500px;
z-index: 1000;
background-color: var(--color-main-background);
box-shadow: 0 0 3px rgba(77, 77, 77, 0.5);
padding: 20px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
}
</style>

View file

@ -1,30 +0,0 @@
// we need our modal component
import ModalDialog from './ModalDialog'
const Modal = {
// every plugin for Vue.js needs install method
// this method will run after Vue.use(<your-plugin-here>) 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
// eslint-disable-next-line vue/match-component-file-name
Vue.component('ModalDialog', 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

View file

@ -45,19 +45,6 @@ export default new Router({
path: '/',
name: 'root',
},
{
path: '/new',
components: {
default: Create,
sidebar: Sidebar,
},
name: 'create',
},
{
path: '/:hash',
name: 'fill',
props: { default: true },
},
{
path: '/:hash/edit',
components: {
@ -73,14 +60,5 @@ export default new Router({
name: 'results',
props: { default: true },
},
{
path: '/:hash/clone',
components: {
default: Create,
sidebar: Sidebar,
},
name: 'clone',
props: { default: true },
},
],
})

View file

@ -20,10 +20,6 @@
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
- UPDATE: Adds Quiz option and takes the input:
- is yet to store input of quizzes and cannot represtent them
- requires quizFormItem.vue (should be added to svn)
-->
<template>
@ -129,9 +125,8 @@ import answerTypes from '../models/AnswerTypes'
import EmptyContent from '../components/EmptyContent'
import Question from '../components/Questions/Question'
import QuestionLong from '../components/Questions/QuestionLong'
import QuestionShort from '../components/Questions/QuestionShort'
import QuestionMultiple from '../components/Questions/QuestionMultiple'
import QuizFormItem from '../components/quizFormItem'
import QuestionShort from '../components/Questions/QuestionShort'
import TopBar from '../components/TopBar'
import ViewsMixin from '../mixins/ViewsMixin'
@ -149,7 +144,6 @@ export default {
QuestionLong,
QuestionShort,
QuestionMultiple,
QuizFormItem,
TopBar,
},

View file

@ -81,14 +81,13 @@ import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import AppContent from '@nextcloud/vue/dist/Components/AppContent'
import axios from '@nextcloud/axios'
import json2csvParser from 'json2csv'
import EmptyContent from '../components/EmptyContent'
import ResultItem from '../components/resultItem'
import TopBar from '../components/TopBar'
import ViewsMixin from '../mixins/ViewsMixin'
import ResultItem from '../components/resultItem'
import json2csvParser from 'json2csv'
export default {
name: 'Results',
@ -181,7 +180,7 @@ export default {
download() {
this.loading = true
axios.get(OC.generateUrl('apps/forms/get/form/' + this.$route.params.hash))
axios.get(generateUrl('apps/forms/get/form/' + this.$route.params.hash))
.then((response) => {
this.json2csvParser = ['userId', 'questionId', 'questionText', 'Answer'] // TODO Is this one necessary??
const formattedAns = []

View file

@ -118,6 +118,7 @@ import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar'
import DatetimePicker from '@nextcloud/vue/dist/Components/DatetimePicker'
import moment from '@nextcloud/moment'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { getLocale, getLanguage } from '@nextcloud/l10n'
import ShareDiv from '../components/shareDiv'
import ViewsMixin from '../mixins/ViewsMixin'
@ -176,9 +177,9 @@ export default {
},
created() {
this.lang = OC.getLanguage()
this.lang = getLanguage()
try {
this.locale = OC.getLocale()
this.locale = getLocale()
} catch (e) {
if (e instanceof TypeError) {
this.locale = this.lang

View file

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
viewBox="0 0 32 32"
x="0px"
y="0px"
enable-background="new 0 0 595.275 311.111"
width="32"
height="32"
xml:space="preserve"
version="1.1"><metadata
id="metadata14"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs12" /><rect
id="rect2"
y="2"
x="3"
height="26"
width="7"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.93541431" /><rect
id="rect4"
y="12"
x="12"
height="16"
width="7"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.93541431" /><rect
id="rect6"
y="8"
x="21"
height="20"
width="7"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.8918826" /></svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1,14 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">
<ellipse
style="opacity:1;fill:none;fill-opacity:1;stroke:#f45573;stroke-width:1.49987304;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
cx="8"
cy="8"
rx="6.2500634"
ry="6.2500639" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffc107;stroke-width:0.86666656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
width="5.6333332"
height="5.6333332"
x="5.1833334"
y="5.1833334" />
</svg>

Before

Width:  |  Height:  |  Size: 569 B

View file

@ -1,11 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">
<ellipse
style="opacity:1;fill:none;fill-opacity:1;stroke:#f45573;stroke-width:1.49987304;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
cx="8"
cy="8"
rx="6.2500634"
ry="6.2500639" />
<path
d="M 6.9766048,11.334813 3.39273,7.7509392 4.4157633,6.7271819 6.9766048,9.285851 11.569757,4.6651869 12.60727,5.7034244 Z"
style="fill:#49bc49;fill-opacity:1" />
</svg>

Before

Width:  |  Height:  |  Size: 476 B

View file

@ -1,14 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">
<path
style="opacity:1;fill:none;fill-opacity:1;stroke:#49bc49;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 14.244065,8.0059972 c 0,3.4518138 -2.798249,6.2500608 -6.2500623,6.2500608 -3.4518138,0 -6.250062,-2.798247 -6.2500622,-6.2500608 0,-3.4518134 2.7982482,-6.2500612 6.2500622,-6.2500612" />
<path
style="fill:#49bc49;fill-opacity:1;stroke:none;stroke-width:0.11827402;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 7.9774453,0.41685427 11.667719,1.8149286 7.9774453,3.2780296 v 0 z" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffc107;stroke-width:0.86666656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
width="5.6333332"
height="5.6333332"
x="5.1833334"
y="5.1833334" />
</svg>

Before

Width:  |  Height:  |  Size: 958 B

View file

@ -1,11 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">
<path
d="M 6.9766048,11.334813 3.39273,7.750939 4.4157633,6.7271817 6.9766048,9.2858508 11.569757,4.6651867 12.60727,5.7034243 Z"
style="fill:#49bc49;fill-opacity:1" />
<path
style="opacity:1;fill:none;fill-opacity:1;stroke:#49bc49;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 14.250063,7.9999999 c 0,3.4518141 -2.798249,6.2500611 -6.2500635,6.2500611 -3.4518138,0 -6.250062,-2.798247 -6.2500622,-6.2500611 0,-3.4518134 2.7982482,-6.2500609 6.2500622,-6.2500609" />
<path
style="fill:#49bc49;fill-opacity:1;stroke:none;stroke-width:0.11827402;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 7.977,0.4168247 11.667274,1.8148987 7.977,3.278 v 0 z" />
</svg>

Before

Width:  |  Height:  |  Size: 852 B