Fix v-if with v-for

environments/review-front-deve-otr6gc/deployments/13419
Kasper Seweryn 2022-05-01 16:35:58 +02:00 zatwierdzone przez Georg Krause
rodzic 57aef1001e
commit 4865bf77be
5 zmienionych plików z 186 dodań i 182 usunięć

Wyświetl plik

@ -24,7 +24,6 @@ module.exports = {
], ],
rules: { rules: {
'vue/no-v-html': 'off', // TODO: tackle this properly 'vue/no-v-html': 'off', // TODO: tackle this properly
'vue/no-use-v-if-with-v-for': 'off',
// NOTE: Handled by typescript // NOTE: Handled by typescript
'no-undef': 'off', 'no-undef': 'off',
@ -42,6 +41,9 @@ module.exports = {
// TODO (wvffle): Migration to pinia // TODO (wvffle): Migration to pinia
// Vuex 3 store does not have types defined, hence we use `any` // Vuex 3 store does not have types defined, hence we use `any`
'@typescript-eslint/no-explicit-any': 'off' '@typescript-eslint/no-explicit-any': 'off',
// TODO (wvffle): Migrate to <script setup>
'vue/require-explicit-emits': 'off'
} }
} }

Wyświetl plik

@ -72,10 +72,8 @@
</translate> </translate>
</div> </div>
</div> </div>
<template <template v-if="plugin.conf?.length > 0">
v-for="(field, key) in plugin.conf" <template v-for="(field, key) in plugin.conf">
v-if="plugin.conf && plugin.conf.length > 0"
>
<div <div
v-if="field.type === 'text'" v-if="field.type === 'text'"
:key="key" :key="key"
@ -142,6 +140,7 @@
/> />
</div> </div>
</template> </template>
</template>
<button <button
type="submit" type="submit"
:class="['ui', {'loading': isLoading}, 'right', 'floated', 'button']" :class="['ui', {'loading': isLoading}, 'right', 'floated', 'button']"

Wyświetl plik

@ -97,8 +97,7 @@
</template> </template>
<template v-else> <template v-else>
<span <span
v-for="(part, key) in field.diff" v-for="(part, key) in field.diff.filter(p => !p.added)"
v-if="!part.added"
:key="key" :key="key"
:class="['diff', {removed: part.removed}]" :class="['diff', {removed: part.removed}]"
> >
@ -125,8 +124,7 @@
</template> </template>
<template v-else> <template v-else>
<span <span
v-for="(part, key) in field.diff" v-for="(part, key) in field.diff.filter(p => !p.removed)"
v-if="!part.removed"
:key="key" :key="key"
:class="['diff', {added: part.added}]" :class="['diff', {added: part.added}]"
> >

Wyświetl plik

@ -95,9 +95,9 @@
You don't have the permission to edit this object, but you can suggest changes. Once submitted, suggestions will be reviewed before approval. You don't have the permission to edit this object, but you can suggest changes. Once submitted, suggestions will be reviewed before approval.
</translate> </translate>
</div> </div>
<template v-if="values">
<div <div
v-for="fieldConfig in config.fields" v-for="fieldConfig in config.fields"
v-if="values"
:key="fieldConfig.id" :key="fieldConfig.id"
class="ui field" class="ui field"
> >
@ -197,6 +197,7 @@
</button> </button>
</div> </div>
</div> </div>
</template>
<div class="field"> <div class="field">
<label for="summary"><translate translate-context="*/*/*">Summary (optional)</translate></label> <label for="summary"><translate translate-context="*/*/*">Summary (optional)</translate></label>
<textarea <textarea

Wyświetl plik

@ -189,8 +189,7 @@
<table class="queue"> <table class="queue">
<tbody> <tbody>
<tr <tr
v-for="(track, index) in tracks" v-for="(track, index) in filteredTracks"
v-if="track.sources.length > 0"
:id="'queue-item-' + index" :id="'queue-item-' + index"
:key="index" :key="index"
role="button" role="button"
@ -249,6 +248,7 @@ import axios from 'axios'
import Logo from '~/components/Logo.vue' import Logo from '~/components/Logo.vue'
import updateQueryString from '~/composables/updateQueryString' import updateQueryString from '~/composables/updateQueryString'
import time from '~/utils/time' import time from '~/utils/time'
import { reactive, computed } from 'vue'
function getURLParams () { function getURLParams () {
let match let match
@ -265,6 +265,12 @@ function getURLParams () {
export default { export default {
name: 'App', name: 'App',
components: { Logo }, components: { Logo },
setup () {
const tracks = reactive([])
const filteredTracks = computed(() => tracks.filter(track => track.sources.length > 0))
return { tracks, filteredTracks }
},
data () { data () {
return { return {
time, time,
@ -273,7 +279,6 @@ export default {
error: null, error: null,
type: null, type: null,
id: null, id: null,
tracks: [],
autoplay: false, autoplay: false,
url: null, url: null,
isLoading: true, isLoading: true,
@ -404,26 +409,25 @@ export default {
}) })
}, },
fetchTrack (id) { fetchTrack (id) {
const self = this
const url = `${this.baseUrl}/api/v1/tracks/${id}/` const url = `${this.baseUrl}/api/v1/tracks/${id}/`
axios.get(url).then(response => { axios.get(url).then(() => {
self.tracks = self.parseTracks([response.data]) this.tracks = this.parseTracks([response.data])
self.isLoading = false this.isLoading = false
}).catch(error => { }).catch(error => {
if (error.response) { if (error.response) {
if (error.response.status === 404) { if (error.response.status === 404) {
self.error = 'server_not_found' this.error = 'server_not_found'
} else if (error.response.status === 403) { } else if (error.response.status === 403) {
self.error = 'server_requires_auth' this.error = 'server_requires_auth'
} else if (error.response.status === 500) { } else if (error.response.status === 500) {
self.error = 'server_error' this.error = 'server_error'
} else { } else {
self.error = 'server_unknown_error' this.error = 'server_unknown_error'
} }
} else { } else {
self.error = 'server_unknown_error' this.error = 'server_unknown_error'
} }
self.isLoading = false this.isLoading = false
}) })
}, },
fetchTracks (filters, path) { fetchTracks (filters, path) {