Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 18 additions & 29 deletions src/views/Voting/BallotLeaders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,26 @@
</v-row>
<v-row justify="center" v-if="isLoading">
<v-col class="text-center">
<v-progress-circular
class="mt-6"
color="cwhqBlue"
size="100"
width="10"
indeterminate
/>
<v-progress-circular class="mt-6" color="cwhqBlue" size="100" width="10" indeterminate />
</v-col>
</v-row>
<v-row justify="center" v-else>
<ballot-card
v-for="(item, i) in pageData.items"
:key="i"
v-bind="item"
@click="showCode(item)"
/>
<ballot-card v-for="(item, i) in pageData.items" :key="i" v-bind="item" @click="showCode(item)" />
</v-row>
<code-modal v-bind="this.item" v-model="showModal" />
</v-container>
</template>

<script>
import Vue from "vue";
import { voting } from "@/api";
import BallotCard from "./BallotCard";
import CodeModal from "./CodeModal";
import Vue from 'vue';
import { voting } from '@/api';
import BallotCard from './BallotCard';
import CodeModal from './CodeModal';

export default {
components: {
BallotCard,
CodeModal
CodeModal,
},
data() {
return {
Expand All @@ -56,8 +45,8 @@ export default {
items: [],
prevNum: null,
totalItems: 0,
totalPages: 0
}
totalPages: 0,
},
};
},
mounted() {
Expand All @@ -69,19 +58,19 @@ export default {
this.showModal = true;
},
async setResult(result) {
await new Promise(resolve =>
await new Promise((resolve) =>
setTimeout(async () => {
for (const [key, value] of Object.entries(result)) {
if (key !== "items") {
if (key !== 'items') {
Vue.set(this.pageData, key, value);
}
}
this.$emit("input", this.pageData.items.length);
this.$emit('input', this.pageData.items.length);
const items = result.items.sort((a, b) => {
return a.numVotes < b.numVotes;
});
items.splice(0, 3);
Vue.set(this.pageData, "items", items);
items.splice(3, items.length - 3);
Vue.set(this.pageData, 'items', items);
resolve();
}, 1000)
);
Expand All @@ -93,21 +82,21 @@ export default {
await this.setResult(results);

this.requestCount--;
}
},
},
computed: {
isLoading() {
return this.requestCount > 0;
}
}
},
},
};
</script>

<style lang="scss" scoped>
h2 {
text-align: center;
color: #0d1d41;
font-family: "Barlow", sans-serif;
font-family: 'Barlow', sans-serif;
font-weight: bold;
margin-bottom: 12px;
}
Expand Down