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 "
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 >
138137</template >
139138
140139<script >
140+ import axios from ' @nextcloud/axios'
141+ import { showError } from ' @nextcloud/dialogs'
141142import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
142- import { generateOcsUrl } from ' @nextcloud/router'
143143import { loadState } from ' @nextcloud/initial-state'
144- import { showError } from ' @nextcloud/dialogs'
145- import axios from ' @nextcloud/axios'
146144import moment from ' @nextcloud/moment'
147-
145+ import { generateOcsUrl } from ' @nextcloud/router '
148146import { useIsMobile } from ' @nextcloud/vue'
149147import NcAppContent from ' @nextcloud/vue/components/NcAppContent'
150148import NcAppNavigation from ' @nextcloud/vue/components/NcAppNavigation'
@@ -154,20 +152,19 @@ import NcButton from '@nextcloud/vue/components/NcButton'
154152import NcContent from ' @nextcloud/vue/components/NcContent'
155153import NcEmptyContent from ' @nextcloud/vue/components/NcEmptyContent'
156154import NcLoadingIcon from ' @nextcloud/vue/components/NcLoadingIcon'
157-
158155import IconArchive from ' vue-material-design-icons/ArchiveOutline.vue'
159156import IconPlus from ' vue-material-design-icons/Plus.vue'
160-
161- import ArchivedFormsModal from ' ./components/ArchivedFormsModal.vue'
162157import AppNavigationForm from ' ./components/AppNavigationForm.vue'
158+ import ArchivedFormsModal from ' ./components/ArchivedFormsModal.vue'
163159import FormsIcon from ' ./components/Icons/FormsIcon.vue'
164- import OcsResponse2Data from ' ./utils/OcsResponse2Data.js'
165- import PermissionTypes from ' ./mixins/PermissionTypes.js'
166160import Sidebar from ' ./views/Sidebar.vue'
167- import logger from ' ./utils/Logger .js'
161+ import PermissionTypes from ' ./mixins/PermissionTypes .js'
168162import { FormState } from ' ./models/Constants.ts'
163+ import logger from ' ./utils/Logger.js'
164+ import OcsResponse2Data from ' ./utils/OcsResponse2Data.js'
169165
170166export 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 }
0 commit comments