Skip to content

Commit 9105236

Browse files
author
philippe lhardy
committed
js/ts/vue lint - no functional change -
npm run format:fix Signed-off-by: philippe lhardy <philippe.lhardy@astrolabe.coop>
1 parent db51610 commit 9105236

10 files changed

Lines changed: 89 additions & 66 deletions

File tree

src/Api/modules/polls.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { httpInstance, createCancelTokenHandler } from './HttpApi'
77
import type { AxiosResponse } from '@nextcloud/axios'
88
import type { ApiEmailAdressList, FullPollResponse } from './api.types'
99
import type { PollGroup } from '../../stores/pollGroups.types'
10-
import type { Poll, PollConfiguration, PollType, VotingVariant } from '../../stores/poll.types'
10+
import type {
11+
Poll,
12+
PollConfiguration,
13+
PollType,
14+
VotingVariant,
15+
} from '../../stores/poll.types'
1116

1217
export type Confirmations = {
1318
sentMails: { emailAddress: string; displayName: string }[]
@@ -87,7 +92,11 @@ const polls = {
8792
})
8893
},
8994

90-
addPoll(type: PollType, title: string, votingVariant: VotingVariant): Promise<AxiosResponse<{ poll: Poll }>> {
95+
addPoll(
96+
type: PollType,
97+
title: string,
98+
votingVariant: VotingVariant,
99+
): Promise<AxiosResponse<{ poll: Poll }>> {
91100
return httpInstance.request({
92101
method: 'POST',
93102
url: 'poll/add',

src/components/Configuration/ConfigRankOptions.vue

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
<div class="option-container">
33
<!-- Menu to choose the rank for this poll -->
44
<select v-model="selectedOption">
5-
<option v-for="(option, index) in internalChosenRank" :key="index" :value="option">
6-
{{ option }}
5+
<option
6+
v-for="(option, index) in internalChosenRank"
7+
:key="index"
8+
:value="option">
9+
{{ option }}
710
</option>
811
</select>
912
<!-- text field to add a new value to the rank -->
1013
<NcTextField
1114
v-model="newOption"
1215
:placeholder="t('polls', 'Enter a new option')"
1316
:label="t('polls', 'New option')"
14-
class="nc-text-field"
15-
/>
17+
class="nc-text-field" />
1618
<NcButton icon @click="addOption">
1719
<PlusIcon />
1820
</NcButton>
@@ -24,7 +26,7 @@
2426
</template>
2527

2628
<script setup>
27-
import { ref,onMounted } from 'vue'
29+
import { ref, onMounted } from 'vue'
2830
import { usePollStore } from '../../stores/poll.js'
2931
import { t } from '@nextcloud/l10n'
3032
import { NcButton, NcTextField } from '@nextcloud/vue'
@@ -41,11 +43,11 @@ const newOption = ref('')
4143
4244
onMounted(() => {
4345
try {
44-
const initialValue = JSON.parse(pollStore.configuration.chosenRank || '[]');
45-
if ( Array.isArray(initialValue) ) {
46-
internalChosenRank.value = initialValue;
46+
const initialValue = JSON.parse(pollStore.configuration.chosenRank || '[]')
47+
if (Array.isArray(initialValue)) {
48+
internalChosenRank.value = initialValue
4749
} else {
48-
internalChosenRank.value = [initialValue];
50+
internalChosenRank.value = [initialValue]
4951
}
5052
if (internalChosenRank.value.length > 0) {
5153
selectedOption.value = internalChosenRank.value[0]
@@ -79,33 +81,33 @@ async function addOption() {
7981
}
8082
8183
async function removeOption() {
82-
const updated = internalChosenRank.value.filter(o => o !== selectedOption.value)
84+
const updated = internalChosenRank.value.filter(
85+
(o) => o !== selectedOption.value,
86+
)
8387
internalChosenRank.value = updated
8488
selectedOption.value = updated[0] || null
8589
await updateChosenRank(updated)
8690
}
87-
8891
</script>
8992

9093
<style scoped>
9194
.option-container {
92-
display: flex;
93-
align-items: center;
94-
gap: 8px;
95-
margin-bottom: 8px;
95+
display: flex;
96+
align-items: center;
97+
gap: 8px;
98+
margin-bottom: 8px;
9699
}
97100
98101
.nc-text-field {
99-
flex-grow: 1;
100-
margin-right: 8px;
101-
margin-bottom: 8px;
102-
width: 100px;
102+
flex-grow: 1;
103+
margin-right: 8px;
104+
margin-bottom: 8px;
105+
width: 100px;
103106
}
104107
105108
.option-item {
106-
display: flex;
107-
align-items: center;
108-
gap: 4px;
109+
display: flex;
110+
align-items: center;
111+
gap: 4px;
109112
}
110113
</style>
111-

src/components/Create/PollCreateDlg.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function addPoll() {
6161
const poll = await pollStore.add({
6262
type: pollType.value,
6363
title: pollTitle.value,
64-
votingVariant: votingVariant.value
64+
votingVariant: votingVariant.value,
6565
})
6666
6767
if (poll) {

src/components/Navigation/PollNavigationItems.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const sessionStore = useSessionStore()
3434
"
3535
:class="{ closed: poll.status.isExpired }">
3636
<template #icon>
37-
<TextPollIcon v-if="poll.type === 'textPoll'"/>
37+
<TextPollIcon v-if="poll.type === 'textPoll'" />
3838
<DatePollIcon v-else />
3939
</template>
4040
<template #actions>

src/components/SideBar/SideBarTabConfiguration.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ const votesStore = useVotesStore()
7373
v-if="pollStore.configuration.allowComment"
7474
@change="pollStore.write" />
7575
<template v-if="pollStore.votingVariant === 'generic'">
76-
<ConfigAllowMayBe @change="pollStore.write" />
77-
<ConfigUseNo @change="pollStore.write" />
78-
<ConfigAnonymous @change="pollStore.write" />
76+
<ConfigAllowMayBe @change="pollStore.write" />
77+
<ConfigUseNo @change="pollStore.write" />
78+
<ConfigAnonymous @change="pollStore.write" />
7979
</template>
8080
<ConfigVoteLimit @change="pollStore.write" />
8181
<ConfigOptionLimit @change="pollStore.write" />
8282
</ConfigBox>
8383

84-
<ConfigBox v-if="pollStore.votingVariant === 'generic'" :name="t('polls', 'Generic Options')">
84+
<ConfigBox
85+
v-if="pollStore.votingVariant === 'generic'"
86+
:name="t('polls', 'Generic Options')">
8587
<template #icon>
8688
<PollConfigIcon />
8789
</template>

src/components/VoteTable/VoteButton.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const vote = computed(() =>
4848
}),
4949
)
5050
51-
const chosenRank=JSON.parse(pollStore.configuration.chosenRank)
51+
const chosenRank = JSON.parse(pollStore.configuration.chosenRank)
5252
5353
const nextAnswer = computed<richAnswer>(() => {
5454
if (['no', ''].includes(vote.value.answer)) {
@@ -78,20 +78,20 @@ async function setVote() {
7878
}
7979
}
8080
81-
async function handleRankSelected(event){
81+
async function handleRankSelected(event) {
8282
const selectElement = event.target
8383
const rank = selectElement.value
8484
try {
8585
await votesStore.set({
8686
option,
8787
setTo: String(rank),
88-
});
89-
showSuccess(t('polls', 'Vote saved'), { timeout: 2000 });
88+
})
89+
showSuccess(t('polls', 'Vote saved'), { timeout: 2000 })
9090
} catch (error) {
9191
if ((error as AxiosError).status === 409) {
92-
showError(t('polls', 'Vote already booked out'));
92+
showError(t('polls', 'Vote already booked out'))
9393
} else {
94-
showError(t('polls', 'Error saving vote'));
94+
showError(t('polls', 'Error saving vote'))
9595
}
9696
}
9797
}
@@ -100,13 +100,13 @@ async function handleRankSelected(event){
100100
<template>
101101
<div v-if="pollStore.votingVariant === 'generic'" class="generic-vote">
102102
<select
103-
:value="vote.answer"
104-
class="vote-ranking"
105-
@change="handleRankSelected">
106-
<option disabled value=""></option>
107-
<option v-for="rank in chosenRank" :key="rank" :value="rank">
108-
{{ rank }}
109-
</option>
103+
:value="vote.answer"
104+
class="vote-ranking"
105+
@change="handleRankSelected">
106+
<option disabled value=""></option>
107+
<option v-for="rank in chosenRank" :key="rank" :value="rank">
108+
{{ rank }}
109+
</option>
110110
</select>
111111
</div>
112112
<div v-else>

src/components/VoteTable/VoteItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const iconAnswer = computed(() => {
4545
</script>
4646

4747
<template>
48-
<div v-if="pollStore.votingVariant==='generic'" class="generic-vote">
49-
{{vote.answer}}
48+
<div v-if="pollStore.votingVariant === 'generic'" class="generic-vote">
49+
{{ vote.answer }}
5050
</div>
5151
<div v-else class="vote-item" :class="vote.answer">
5252
<VoteIndicator :answer="iconAnswer" />

src/components/VoteTable/VoteTable.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ function isVotable(participant: User, option: Option) {
149149
</StickyDiv>
150150

151151
<Counter
152-
v-if="pollStore.votingVariant === 'simple' && pollStore.permissions.seeResults"
152+
v-if="
153+
pollStore.votingVariant === 'simple'
154+
&& pollStore.permissions.seeResults
155+
"
153156
:id="`counter-${option.id}`"
154157
:key="`counter-${option.id}`"
155158
:class="{

src/stores/poll.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type {
3030
PollStore,
3131
PollTypesType,
3232
VotingVariant,
33-
VotingVariantsType
33+
VotingVariantsType,
3434
} from './poll.types'
3535
import type { ViewMode } from './preferences.types'
3636

@@ -53,10 +53,10 @@ export const votingVariants: Record<VotingVariant, VotingVariantsType> = {
5353
},
5454
generic: {
5555
name: t('polls', 'Generic variant'),
56-
}
56+
},
5757
}
5858

59-
const DEFAULT_CHOSEN_RANK : Array<string> = [] ;
59+
const DEFAULT_CHOSEN_RANK: Array<string> = []
6060

6161
export const usePollStore = defineStore('poll', {
6262
state: (): PollStore => ({
@@ -148,14 +148,13 @@ export const usePollStore = defineStore('poll', {
148148
}),
149149

150150
getters: {
151-
152151
getChosenRank(): string[] {
153152
try {
154-
const parsed = JSON.parse(this.configuration.chosenRank || '[]')
155-
return Array.isArray(parsed) ? parsed : []
156-
} catch {
157-
return DEFAULT_CHOSEN_RANK;
158-
}
153+
const parsed = JSON.parse(this.configuration.chosenRank || '[]')
154+
return Array.isArray(parsed) ? parsed : []
155+
} catch {
156+
return DEFAULT_CHOSEN_RANK
157+
}
159158
},
160159
viewMode(state): ViewMode {
161160
const sessionStore = useSessionStore()
@@ -263,15 +262,15 @@ export const usePollStore = defineStore('poll', {
263262
},
264263

265264
actions: {
266-
267265
setChosenRank(ranks: string[]) {
268-
const validItems = Array.isArray(ranks)
269-
? ranks.map(item => String(item).trim())
270-
.filter(item => item !== '')
271-
: [];
272-
this.configuration.chosenRank = JSON.stringify(validItems.sort());
266+
const validItems = Array.isArray(ranks)
267+
? ranks
268+
.map((item) => String(item).trim())
269+
.filter((item) => item !== '')
270+
: []
271+
this.configuration.chosenRank = JSON.stringify(validItems.sort())
273272
},
274-
273+
275274
reset(): void {
276275
this.$reset()
277276
},
@@ -314,11 +313,19 @@ export const usePollStore = defineStore('poll', {
314313
}
315314
},
316315

317-
async add(payload: { type: PollType; title: string; votingVariant: VotingVariant }): Promise<Poll | void> {
316+
async add(payload: {
317+
type: PollType
318+
title: string
319+
votingVariant: VotingVariant
320+
}): Promise<Poll | void> {
318321
const pollsStore = usePollsStore()
319322

320323
try {
321-
const response = await PollsAPI.addPoll(payload.type, payload.title, payload.votingVariant)
324+
const response = await PollsAPI.addPoll(
325+
payload.type,
326+
payload.title,
327+
payload.votingVariant,
328+
)
322329
return response.data.poll
323330
} catch (error) {
324331
if ((error as AxiosError)?.code === 'ERR_CANCELED') {

src/stores/poll.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type PollTypesType = {
1414
export type VotingVariant = 'simple' | 'generic'
1515

1616
export type VotingVariantsType = {
17-
name : string
17+
name: string
1818
}
1919

2020
export type AccessType = 'private' | 'open'

0 commit comments

Comments
 (0)