add no.calon for selectednominee
This commit is contained in:
@@ -9,8 +9,9 @@
|
|||||||
</li>
|
</li>
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<li class="list-group-item" v-for="nominee_id in selected[0].nominee_id">
|
<li class="list-group-item" v-for="nominee_id in selected[0].nominee_id">
|
||||||
<b> - {{ getSelectedNomineeName(nominee_id) }}</b>
|
<b> - [{{ getNomineeNo(nominee_id) }}] {{ getSelectedNomineeName(nominee_id) }}</b>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
@@ -43,7 +44,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(nominee, index) in data.nominees" v-if="nominee.position_id == position.id"
|
<tr v-for="(nominee, index) in data.nominees" v-if="nominee.position_id == position.id"
|
||||||
:key="nominee.id">
|
:key="nominee.id">
|
||||||
<td><input type="checkbox" :id="nominee.id" :disabled="disabledCheckboxes[index]" @change="vote(position.id, nominee.id)" />
|
<td><input type="checkbox" :id="nominee.id" :disabled="disabledCheckboxes[index]"
|
||||||
|
@change="vote(position.id, nominee.id)" />
|
||||||
</td>
|
</td>
|
||||||
<td>{{ nominee.no_calon }}</td>
|
<td>{{ nominee.no_calon }}</td>
|
||||||
<td><img @click="view(i)" :src="createBase64ImageUrl(nominee.photo)" class="thumbnail"
|
<td><img @click="view(i)" :src="createBase64ImageUrl(nominee.photo)" class="thumbnail"
|
||||||
@@ -108,7 +110,7 @@ export default {
|
|||||||
disabledCheckboxes() {
|
disabledCheckboxes() {
|
||||||
const selectedNomineeIds = this.selected[0]['nominee_id'];
|
const selectedNomineeIds = this.selected[0]['nominee_id'];
|
||||||
return this.data.nominees.map(nominee => {
|
return this.data.nominees.map(nominee => {
|
||||||
return selectedNomineeIds.includes(nominee.id) ? false : this.checkDisabled();
|
return selectedNomineeIds.includes(nominee.id) ? false : this.checkDisabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -169,29 +171,35 @@ export default {
|
|||||||
},
|
},
|
||||||
vote: function (position_id, nominee_id) {
|
vote: function (position_id, nominee_id) {
|
||||||
|
|
||||||
if (!this.selected[0]['position_id']) {
|
if (!this.selected[0]['position_id']) {
|
||||||
this.$set(this.selected[0], position_id, []);
|
this.$set(this.selected[0], position_id, []);
|
||||||
}
|
}
|
||||||
const index = this.selected[0]['nominee_id'].indexOf(nominee_id);
|
const index = this.selected[0]['nominee_id'].indexOf(nominee_id);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
// Nominee not found, add it
|
// Nominee not found, add it
|
||||||
if (this.selected[0]['nominee_id'].length < this.max) {
|
if (this.selected[0]['nominee_id'].length < this.max) {
|
||||||
this.selected[0]['nominee_id'].push(nominee_id);
|
this.selected[0]['nominee_id'].push(nominee_id);
|
||||||
} else {
|
} else {
|
||||||
// Display warning message if more than 2 nominees are selected
|
// Display warning message if more than 2 nominees are selected
|
||||||
this.util.notify(`Boleh mengundi (${this.max}) calon sahaja!`, 'warning');
|
this.util.notify(`Boleh mengundi (${this.max}) calon sahaja!`, 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Nominee found, remove it
|
// Nominee found, remove it
|
||||||
this.selected[0]['nominee_id'].splice(index, 1);
|
this.selected[0]['nominee_id'].splice(index, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectedNomineeName: function (id) {
|
getSelectedNomineeName: function (id) {
|
||||||
return this.getNominee(id);
|
return this.getNominee(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNomineeNo(id) {
|
||||||
|
const nominee = this.data.nominees.find(n => n.id === id);
|
||||||
|
return nominee ? nominee.no_calon : '';
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
getName: function (id) {
|
getName: function (id) {
|
||||||
let positions = this.data.positions;
|
let positions = this.data.positions;
|
||||||
let selected = this.selected;
|
let selected = this.selected;
|
||||||
@@ -232,17 +240,17 @@ export default {
|
|||||||
return "data:image/png;base64," + base64ImageData;
|
return "data:image/png;base64," + base64ImageData;
|
||||||
},
|
},
|
||||||
|
|
||||||
checkUndi: function(){
|
checkUndi: function () {
|
||||||
if(this.selected[0]['nominee_id'].length <= 0){
|
if (this.selected[0]['nominee_id'].length <= 0) {
|
||||||
this.util.notify('Sila pastikan anda memilih (1) orang calon.', 'error');
|
this.util.notify('Sila pastikan anda memilih (1) orang calon.', 'error');
|
||||||
}else{
|
} else {
|
||||||
this.util.showModal('#vote-modal');
|
this.util.showModal('#vote-modal');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
checkDisabled: function(){
|
checkDisabled: function () {
|
||||||
if(this.selected[0]['nominee_id'].length >= this.max){
|
if (this.selected[0]['nominee_id'].length >= this.max) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user