Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit 35b6612

Browse files
authored
Merge pull request #150 from codewizardshq/voting-tips
sorting-fix
2 parents 7724b0a + 66dafaa commit 35b6612

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

src/views/Voting/BallotLeaders.vue

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,26 @@
99
</v-row>
1010
<v-row justify="center" v-if="isLoading">
1111
<v-col class="text-center">
12-
<v-progress-circular
13-
class="mt-6"
14-
color="cwhqBlue"
15-
size="100"
16-
width="10"
17-
indeterminate
18-
/>
12+
<v-progress-circular class="mt-6" color="cwhqBlue" size="100" width="10" indeterminate />
1913
</v-col>
2014
</v-row>
2115
<v-row justify="center" v-else>
22-
<ballot-card
23-
v-for="(item, i) in pageData.items"
24-
:key="i"
25-
v-bind="item"
26-
@click="showCode(item)"
27-
/>
16+
<ballot-card v-for="(item, i) in pageData.items" :key="i" v-bind="item" @click="showCode(item)" />
2817
</v-row>
2918
<code-modal v-bind="this.item" v-model="showModal" />
3019
</v-container>
3120
</template>
3221

3322
<script>
34-
import Vue from "vue";
35-
import { voting } from "@/api";
36-
import BallotCard from "./BallotCard";
37-
import CodeModal from "./CodeModal";
23+
import Vue from 'vue';
24+
import { voting } from '@/api';
25+
import BallotCard from './BallotCard';
26+
import CodeModal from './CodeModal';
3827
3928
export default {
4029
components: {
4130
BallotCard,
42-
CodeModal
31+
CodeModal,
4332
},
4433
data() {
4534
return {
@@ -56,8 +45,8 @@ export default {
5645
items: [],
5746
prevNum: null,
5847
totalItems: 0,
59-
totalPages: 0
60-
}
48+
totalPages: 0,
49+
},
6150
};
6251
},
6352
mounted() {
@@ -69,19 +58,19 @@ export default {
6958
this.showModal = true;
7059
},
7160
async setResult(result) {
72-
await new Promise(resolve =>
61+
await new Promise((resolve) =>
7362
setTimeout(async () => {
7463
for (const [key, value] of Object.entries(result)) {
75-
if (key !== "items") {
64+
if (key !== 'items') {
7665
Vue.set(this.pageData, key, value);
7766
}
7867
}
79-
this.$emit("input", this.pageData.items.length);
68+
this.$emit('input', this.pageData.items.length);
8069
const items = result.items.sort((a, b) => {
8170
return a.numVotes < b.numVotes;
8271
});
83-
items.splice(0, 3);
84-
Vue.set(this.pageData, "items", items);
72+
items.splice(3, items.length - 3);
73+
Vue.set(this.pageData, 'items', items);
8574
resolve();
8675
}, 1000)
8776
);
@@ -93,21 +82,21 @@ export default {
9382
await this.setResult(results);
9483
9584
this.requestCount--;
96-
}
85+
},
9786
},
9887
computed: {
9988
isLoading() {
10089
return this.requestCount > 0;
101-
}
102-
}
90+
},
91+
},
10392
};
10493
</script>
10594

10695
<style lang="scss" scoped>
10796
h2 {
10897
text-align: center;
10998
color: #0d1d41;
110-
font-family: "Barlow", sans-serif;
99+
font-family: 'Barlow', sans-serif;
111100
font-weight: bold;
112101
margin-bottom: 12px;
113102
}

0 commit comments

Comments
 (0)