Skip to content

Commit 53c999f

Browse files
committed
Refactor code for compliance with new eslint version
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent b0f26c5 commit 53c999f

59 files changed

Lines changed: 2880 additions & 4897 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { recommendedVue2 } from '@nextcloud/eslint-config'
2+
3+
export default [
4+
...recommendedVue2,
5+
]

package-lock.json

Lines changed: 2132 additions & 4047 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@mdi/svg": "^7.4.47",
5656
"@nextcloud/browserslist-config": "^3.0.1",
5757
"@nextcloud/e2e-test-server": "^0.2.1",
58-
"@nextcloud/eslint-config": "^8.4.2",
58+
"@nextcloud/eslint-config": "^9.0.0-rc.5",
5959
"@nextcloud/prettier-config": "^1.2.0",
6060
"@nextcloud/stylelint-config": "^3.1.0",
6161
"@nextcloud/vite-config": "^1.7.1",

src/Forms.vue

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
v-for="form in ownedForms"
3030
:key="form.id"
3131
:form="form"
32-
:read-only="false"
3332
@open-sharing="openSharing"
3433
@mobile-close-navigation="mobileCloseNavigation"
3534
@clone="onCloneForm"
@@ -77,7 +76,7 @@
7776
<NcEmptyContent
7877
v-if="loading"
7978
class="forms-emptycontent"
80-
:name="t('forms', 'Loading forms ')">
79+
:name="t('forms', 'Loading forms ')">
8180
<template #icon>
8281
<NcLoadingIcon :size="64" />
8382
</template>
@@ -138,13 +137,12 @@
138137
</template>
139138

140139
<script>
140+
import axios from '@nextcloud/axios'
141+
import { showError } from '@nextcloud/dialogs'
141142
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
142-
import { generateOcsUrl } from '@nextcloud/router'
143143
import { loadState } from '@nextcloud/initial-state'
144-
import { showError } from '@nextcloud/dialogs'
145-
import axios from '@nextcloud/axios'
146144
import moment from '@nextcloud/moment'
147-
145+
import { generateOcsUrl } from '@nextcloud/router'
148146
import { useIsMobile } from '@nextcloud/vue'
149147
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
150148
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
@@ -154,20 +152,19 @@ import NcButton from '@nextcloud/vue/components/NcButton'
154152
import NcContent from '@nextcloud/vue/components/NcContent'
155153
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
156154
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
157-
158155
import IconArchive from 'vue-material-design-icons/ArchiveOutline.vue'
159156
import IconPlus from 'vue-material-design-icons/Plus.vue'
160-
161-
import ArchivedFormsModal from './components/ArchivedFormsModal.vue'
162157
import AppNavigationForm from './components/AppNavigationForm.vue'
158+
import ArchivedFormsModal from './components/ArchivedFormsModal.vue'
163159
import FormsIcon from './components/Icons/FormsIcon.vue'
164-
import OcsResponse2Data from './utils/OcsResponse2Data.js'
165-
import PermissionTypes from './mixins/PermissionTypes.js'
166160
import Sidebar from './views/Sidebar.vue'
167-
import logger from './utils/Logger.js'
161+
import PermissionTypes from './mixins/PermissionTypes.js'
168162
import { FormState } from './models/Constants.ts'
163+
import logger from './utils/Logger.js'
164+
import OcsResponse2Data from './utils/OcsResponse2Data.js'
169165
170166
export default {
167+
// eslint-disable-next-line vue/multi-word-component-names
171168
name: 'Forms',
172169
173170
components: {
@@ -211,9 +208,7 @@ export default {
211208
212209
computed: {
213210
canEdit() {
214-
return this.selectedForm.permissions.includes(
215-
this.PERMISSION_TYPES.PERMISSION_EDIT,
216-
)
211+
return this.selectedForm.permissions.includes(this.PERMISSION_TYPES.PERMISSION_EDIT)
217212
},
218213
219214
hasForms() {
@@ -231,18 +226,14 @@ export default {
231226
* All active shared forms
232227
*/
233228
sharedForms() {
234-
return this.allSharedForms.filter(
235-
(form) => form.state !== FormState.FormArchived,
236-
)
229+
return this.allSharedForms.filter((form) => form.state !== FormState.FormArchived)
237230
},
238231
239232
/**
240233
* All forms that have been archived
241234
*/
242235
archivedForms() {
243-
return [...this.forms, ...this.allSharedForms].filter(
244-
(form) => form.state === FormState.FormArchived,
245-
)
236+
return [...this.forms, ...this.allSharedForms].filter((form) => form.state === FormState.FormArchived)
246237
},
247238
248239
routeHash() {
@@ -262,9 +253,7 @@ export default {
262253
}
263254
264255
// Try to find form in owned & shared list
265-
const form = [...this.forms, ...this.allSharedForms].find(
266-
(form) => form.hash === this.routeHash,
267-
)
256+
const form = [...this.forms, ...this.allSharedForms].find((form) => form.hash === this.routeHash)
268257
269258
// If no form found, load it from server. Route will be automatically re-evaluated.
270259
if (form === undefined) {
@@ -285,22 +274,19 @@ export default {
285274
}
286275
return {}
287276
},
277+
288278
set(form) {
289279
// always close sidebar
290280
this.sidebarOpened = false
291281
292282
// If a owned form
293-
let index = this.forms.findIndex(
294-
(search) => search.hash === this.routeHash,
295-
)
283+
let index = this.forms.findIndex((search) => search.hash === this.routeHash)
296284
if (index > -1) {
297285
this.$set(this.forms, index, form)
298286
return
299287
}
300288
// Otherwise a shared form
301-
index = this.allSharedForms.findIndex(
302-
(search) => search.hash === this.routeHash,
303-
)
289+
index = this.allSharedForms.findIndex((search) => search.hash === this.routeHash)
304290
if (index > -1) {
305291
this.$set(this.allSharedForms, index, form)
306292
}
@@ -318,9 +304,7 @@ export default {
318304
},
319305
320306
unmounted() {
321-
unsubscribe('forms:last-updated:set', (id) =>
322-
this.onLastUpdatedByEventBus(id),
323-
)
307+
unsubscribe('forms:last-updated:set', (id) => this.onLastUpdatedByEventBus(id))
324308
unsubscribe('forms:ownership-transfered', (id) => this.onDeleteForm(id))
325309
},
326310
@@ -355,30 +339,22 @@ export default {
355339
356340
// Load Owned forms
357341
try {
358-
const response = await axios.get(
359-
generateOcsUrl('apps/forms/api/v3/forms'),
360-
)
342+
const response = await axios.get(generateOcsUrl('apps/forms/api/v3/forms'))
361343
this.forms = OcsResponse2Data(response)
362344
} catch (error) {
363345
logger.error('Error while loading owned forms list', { error })
364-
showError(
365-
t('forms', 'An error occurred while loading the forms list'),
366-
)
346+
showError(t('forms', 'An error occurred while loading the forms list'))
367347
}
368348
369349
// Load shared forms
370350
try {
371-
const response = await axios.get(
372-
generateOcsUrl('apps/forms/api/v3/forms?type=shared'),
373-
)
351+
const response = await axios.get(generateOcsUrl('apps/forms/api/v3/forms?type=shared'))
374352
this.allSharedForms = OcsResponse2Data(response)
375353
} catch (error) {
376354
logger.error('Error while loading shared forms list', {
377355
error,
378356
})
379-
showError(
380-
t('forms', 'An error occurred while loading the forms list'),
381-
)
357+
showError(t('forms', 'An error occurred while loading the forms list'))
382358
}
383359
384360
this.loading = false
@@ -403,23 +379,17 @@ export default {
403379
404380
this.loading = true
405381
if (
406-
[...this.forms, ...this.allSharedForms].find(
407-
(form) => form.hash === hash,
408-
) === undefined
382+
[...this.forms, ...this.allSharedForms].find((form) => form.hash === hash) === undefined
409383
) {
410384
try {
411-
const response = await axios.get(
412-
generateOcsUrl('apps/forms/api/v3/forms/{id}', {
413-
id: loadState(appName, 'formId'),
414-
}),
415-
)
385+
const response = await axios.get(generateOcsUrl('apps/forms/api/v3/forms/{id}', {
386+
id: loadState(appName, 'formId'),
387+
}))
416388
const form = OcsResponse2Data(response)
417389
418390
// If the user has (at least) submission-permissions, add it to the shared forms
419391
if (
420-
form.permissions.includes(
421-
this.PERMISSION_TYPES.PERMISSION_SUBMIT,
422-
)
392+
form.permissions.includes(this.PERMISSION_TYPES.PERMISSION_SUBMIT)
423393
) {
424394
this.allSharedForms.push(form)
425395
}
@@ -441,9 +411,7 @@ export default {
441411
async onNewForm() {
442412
try {
443413
// Request a new empty form
444-
const response = await axios.post(
445-
generateOcsUrl('apps/forms/api/v3/forms'),
446-
)
414+
const response = await axios.post(generateOcsUrl('apps/forms/api/v3/forms'))
447415
const newForm = OcsResponse2Data(response)
448416
this.forms.unshift(newForm)
449417
this.$router.push({
@@ -464,11 +432,9 @@ export default {
464432
*/
465433
async onCloneForm(id) {
466434
try {
467-
const response = await axios.post(
468-
generateOcsUrl('apps/forms/api/v3/forms?fromId={id}', {
469-
id,
470-
}),
471-
)
435+
const response = await axios.post(generateOcsUrl('apps/forms/api/v3/forms?fromId={id}', {
436+
id,
437+
}))
472438
const newForm = OcsResponse2Data(response)
473439
this.forms.unshift(newForm)
474440
this.$router.push({
@@ -510,9 +476,7 @@ export default {
510476
this.forms[formIndex].lastUpdated = moment().unix()
511477
this.forms.sort((b, a) => a.lastUpdated - b.lastUpdated)
512478
} else {
513-
const sharedFormIndex = this.allSharedForms.findIndex(
514-
(form) => form.id === id,
515-
)
479+
const sharedFormIndex = this.allSharedForms.findIndex((form) => form.id === id)
516480
this.allSharedForms[sharedFormIndex].lastUpdated = moment().unix()
517481
this.allSharedForms.sort((b, a) => a.lastUpdated - b.lastUpdated)
518482
}

src/FormsEmptyContent.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
:name="currentModel.title"
1111
:description="currentModel.description">
1212
<template #icon>
13-
<Icon :is="currentModel.icon" :size="64" />
13+
<component :is="currentModel.icon" :size="64" />
1414
</template>
1515
</NcEmptyContent>
1616
</NcAppContent>
@@ -48,15 +48,18 @@ export default {
4848
description: t('forms', 'This form does not exist'),
4949
icon: FormsIcon,
5050
},
51+
5152
expired: {
5253
title: t('forms', 'Form expired'),
5354
description: t(
5455
'forms',
5556
'This form has expired and is no longer taking answers',
5657
),
58+
5759
icon: IconCheck,
5860
},
5961
},
62+
6063
renderAs: loadState(appName, 'renderAs'),
6164
}
6265
},

src/FormsSettings.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@
5656
</template>
5757

5858
<script>
59+
import axios from '@nextcloud/axios'
5960
import { showError } from '@nextcloud/dialogs'
6061
import { loadState } from '@nextcloud/initial-state'
6162
import { generateUrl } from '@nextcloud/router'
62-
import axios from '@nextcloud/axios'
6363
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
6464
import NcSelect from '@nextcloud/vue/components/NcSelect'
6565
import NcSettingsSection from '@nextcloud/vue/components/NcSettingsSection'
66-
6766
import logger from './utils/Logger.js'
6867
6968
export default {
@@ -98,6 +97,7 @@ export default {
9897
await this.saveAppConfig('restrictCreation', newVal)
9998
el.loading = false
10099
},
100+
101101
async onCreationAllowedGroupsChange(newVal) {
102102
const el = this.$refs.switchRestrictCreation
103103
el.loading = true
@@ -107,18 +107,21 @@ export default {
107107
)
108108
el.loading = false
109109
},
110+
110111
async onAllowPublicLinkChange(newVal) {
111112
const el = this.$refs.switchAllowPublicLink
112113
el.loading = true
113114
await this.saveAppConfig('allowPublicLink', newVal)
114115
el.loading = false
115116
},
117+
116118
async onAllowPermitAllChange(newVal) {
117119
const el = this.$refs.switchAllowPermitAll
118120
el.loading = true
119121
await this.saveAppConfig('allowPermitAll', newVal)
120122
el.loading = false
121123
},
124+
122125
async onAllowShowToAllChange(newVal) {
123126
const el = this.$refs.switchAllowShowToAll
124127
el.loading = true

src/FormsSubmit.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default {
3737
}
3838
},
3939
40-
destroyed() {
40+
unmounted() {
4141
unsubscribe('forms:last-updated:set', this.emitSubmitMessage)
4242
},
4343
@@ -49,11 +49,7 @@ export default {
4949
const resizeObserver = new ResizeObserver((entries) => {
5050
this.emitResizeMessage(entries[0].target)
5151
})
52-
this.$nextTick(() =>
53-
resizeObserver.observe(
54-
document.querySelector('.app-forms-embedded form'),
55-
),
56-
)
52+
this.$nextTick(() => resizeObserver.observe(document.querySelector('.app-forms-embedded form')))
5753
}
5854
},
5955
@@ -80,9 +76,7 @@ export default {
8076
8177
// When submitted the height and width is 0
8278
if (height === 0) {
83-
target = document.querySelector(
84-
'.app-forms-embedded main .empty-content',
85-
)
79+
target = document.querySelector('.app-forms-embedded main .empty-content')
8680
height = target.getBoundingClientRect().top + target.scrollHeight
8781
width = Math.max(
8882
target.scrollWidth,

0 commit comments

Comments
 (0)