DONE: settle disable vote for voter with saham under 500, fix issue on...
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<div class="vote-page row col-md-10 col-md-offset-1">
|
||||
<div v-if="!canVoteBySaham" class="col-xs-12 vote-saham-block-banner">
|
||||
<div class="alert alert-danger vote-saham-block-alert" role="alert">
|
||||
<i class="fa fa-ban" aria-hidden="true"></i>
|
||||
<span>{{ sahamVoteBlockedMessage }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 vote-sidebar-column">
|
||||
<div class="vote-summary-card">
|
||||
<div class="vote-section-kicker">Ringkasan Undian</div>
|
||||
@@ -24,7 +30,8 @@
|
||||
</li>
|
||||
|
||||
<li class="list-group-item vote-summary-action">
|
||||
<button class="btn btn-success btn-block vote-submit-button" @click="checkUndi()">UNDI</button>
|
||||
<button class="btn btn-success btn-block vote-submit-button" :disabled="!canVoteBySaham"
|
||||
@click="checkUndi()">UNDI</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -98,7 +105,7 @@
|
||||
</div>
|
||||
<div class="modal-footer vote-modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
|
||||
<button type="button" class="btn btn-primary" @click="submit()">Hantar</button>
|
||||
<button type="button" class="btn btn-primary" :disabled="!canVoteBySaham" @click="submit()">Hantar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -107,8 +114,16 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const SAHAM_MINIMUM_UNDIAN = 500;
|
||||
|
||||
export default {
|
||||
created: function () {
|
||||
const saham = Number(this.data?.user?.saham);
|
||||
if (Number.isNaN(saham) || saham < SAHAM_MINIMUM_UNDIAN) {
|
||||
this.util.notify(this.sahamVoteBlockedMessage, 'error');
|
||||
this.$router.push({ name: 'Voter Home' });
|
||||
return;
|
||||
}
|
||||
if (this.data.result.length > 0 || this.data.election.status != 2)
|
||||
this.$router.push({ name: 'Voter Home' })
|
||||
for (var i in this.data.positions) {
|
||||
@@ -130,6 +145,15 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
canVoteBySaham() {
|
||||
const s = Number(this.data?.user?.saham);
|
||||
return !Number.isNaN(s) && s >= SAHAM_MINIMUM_UNDIAN;
|
||||
},
|
||||
|
||||
sahamVoteBlockedMessage() {
|
||||
return 'Undian tidak tersedia: jumlah saham anda mestilah sekurang-kurangnya RM 500.';
|
||||
},
|
||||
|
||||
/** All nominee ids chosen across every position (sidebar + modal must use this, not selected[0]). */
|
||||
allSelectedNomineeIds() {
|
||||
var ids = [];
|
||||
@@ -143,6 +167,9 @@ export default {
|
||||
},
|
||||
|
||||
disabledCheckboxes() {
|
||||
if (!this.canVoteBySaham) {
|
||||
return this.data.nominees.map(() => true);
|
||||
}
|
||||
const selectedNomineeIds = this.allSelectedNomineeIds;
|
||||
return this.data.nominees.map(nominee => {
|
||||
return selectedNomineeIds.includes(nominee.id) ? false : this.checkDisabled();
|
||||
@@ -167,6 +194,10 @@ export default {
|
||||
this.util.showModal('#vote-modal')
|
||||
},
|
||||
submit: function () {
|
||||
if (!this.canVoteBySaham) {
|
||||
this.util.notify(this.sahamVoteBlockedMessage, 'error');
|
||||
return;
|
||||
}
|
||||
if (this.totalSelectedCount() !== this.max) {
|
||||
// No selections made
|
||||
this.util.notify(`Sila pastikan anda memilih (${this.max}) orang calon.`, 'error');
|
||||
@@ -288,6 +319,10 @@ export default {
|
||||
},
|
||||
|
||||
checkUndi: function () {
|
||||
if (!this.canVoteBySaham) {
|
||||
this.util.notify(this.sahamVoteBlockedMessage, 'error');
|
||||
return;
|
||||
}
|
||||
if (this.totalSelectedCount() <= 0) {
|
||||
this.util.notify('Sila pastikan anda memilih (1) orang calon.', 'error');
|
||||
} else {
|
||||
@@ -315,6 +350,25 @@ export default {
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
|
||||
.vote-saham-block-banner {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.vote-saham-block-alert {
|
||||
margin-bottom: 0;
|
||||
border-radius: 14px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
font-size: 1.3rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.vote-saham-block-alert .fa {
|
||||
flex-shrink: 0;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.vote-sidebar-column,
|
||||
.vote-content-column {
|
||||
margin-bottom: 24px;
|
||||
|
||||
Reference in New Issue
Block a user