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

Commit 9bf6054

Browse files
authored
Merge pull request #151 from codewizardshq/voting-tips
i forgot how sort works
2 parents 35b6612 + 962c580 commit 9bf6054

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

src/views/Voting/BallotLeaders.vue

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

2233
<script>
23-
import Vue from 'vue';
24-
import { voting } from '@/api';
25-
import BallotCard from './BallotCard';
26-
import CodeModal from './CodeModal';
34+
import Vue from "vue";
35+
import { voting } from "@/api";
36+
import BallotCard from "./BallotCard";
37+
import CodeModal from "./CodeModal";
2738
2839
export default {
2940
components: {
3041
BallotCard,
31-
CodeModal,
42+
CodeModal
3243
},
3344
data() {
3445
return {
@@ -45,8 +56,8 @@ export default {
4556
items: [],
4657
prevNum: null,
4758
totalItems: 0,
48-
totalPages: 0,
49-
},
59+
totalPages: 0
60+
}
5061
};
5162
},
5263
mounted() {
@@ -58,19 +69,19 @@ export default {
5869
this.showModal = true;
5970
},
6071
async setResult(result) {
61-
await new Promise((resolve) =>
72+
await new Promise(resolve =>
6273
setTimeout(async () => {
6374
for (const [key, value] of Object.entries(result)) {
64-
if (key !== 'items') {
75+
if (key !== "items") {
6576
Vue.set(this.pageData, key, value);
6677
}
6778
}
68-
this.$emit('input', this.pageData.items.length);
79+
this.$emit("input", this.pageData.items.length);
6980
const items = result.items.sort((a, b) => {
70-
return a.numVotes < b.numVotes;
81+
return a.numVotes > b.numVotes ? 1 : -1;
7182
});
7283
items.splice(3, items.length - 3);
73-
Vue.set(this.pageData, 'items', items);
84+
Vue.set(this.pageData, "items", items);
7485
resolve();
7586
}, 1000)
7687
);
@@ -82,21 +93,21 @@ export default {
8293
await this.setResult(results);
8394
8495
this.requestCount--;
85-
},
96+
}
8697
},
8798
computed: {
8899
isLoading() {
89100
return this.requestCount > 0;
90-
},
91-
},
101+
}
102+
}
92103
};
93104
</script>
94105

95106
<style lang="scss" scoped>
96107
h2 {
97108
text-align: center;
98109
color: #0d1d41;
99-
font-family: 'Barlow', sans-serif;
110+
font-family: "Barlow", sans-serif;
100111
font-weight: bold;
101112
margin-bottom: 12px;
102113
}

0 commit comments

Comments
 (0)