- |
+ |
|
{{ nominee.no_calon }} |
{
+ return selectedNomineeIds.includes(nominee.id) ? false : this.checkDisabled();
+ });
}
},
@@ -109,9 +119,9 @@ export default {
this.util.showModal('#vote-modal')
},
submit: function () {
- if (this.selected[0]['nominee_id'].length !== 2) {
+ if (this.selected[0]['nominee_id'].length !== this.max) {
// No selections made
- this.util.notify('Sila pastikan anda memilih (2) orang calon.', 'error');
+ this.util.notify(`Sila pastikan anda memilih (${this.max}) orang calon.`, 'error');
return;
}
@@ -123,9 +133,6 @@ export default {
vote: this.selected
};
- // Log the data to ensure it's correctly formatted
- console.log(data);
-
// Send a POST request to the server
axios.post(config.API + 'election/vote', data)
.then(response => {
@@ -154,7 +161,6 @@ export default {
},
reset: function () {
- console.log(this.selectedNominees);
let selected = this.selectedNominees;
for (var i in selected) {
$('#' + selected[i]['nominee_id']).selected(false);
@@ -162,23 +168,24 @@ export default {
}
},
vote: function (position_id, nominee_id) {
+
if (!this.selected[0]['position_id']) {
this.$set(this.selected[0], position_id, []);
}
const index = this.selected[0]['nominee_id'].indexOf(nominee_id);
if (index === -1) {
// Nominee not found, add it
- if (this.selected[0]['nominee_id'].length < 2) {
+ if (this.selected[0]['nominee_id'].length < this.max) {
this.selected[0]['nominee_id'].push(nominee_id);
} else {
// Display warning message if more than 2 nominees are selected
- this.util.notify('Boleh mengundi (2) calon sahaja!', 'warning');
+ this.util.notify(`Boleh mengundi (${this.max}) calon sahaja!`, 'warning');
+ return;
}
} else {
// Nominee found, remove it
this.selected[0]['nominee_id'].splice(index, 1);
}
- console.log(this.selected[0])
},
getSelectedNomineeName: function (id) {
@@ -223,6 +230,21 @@ export default {
createBase64ImageUrl: function (base64ImageData) {
return "data:image/png;base64," + base64ImageData;
+ },
+
+ checkUndi: function(){
+ if(this.selected[0]['nominee_id'].length <= 1){
+ this.util.notify('Sila pastikan anda memilih (2) orang calon.', 'error');
+ }else{
+ this.util.showModal('#vote-modal');
+ }
+ return;
+ },
+
+ checkDisabled: function(){
+ if(this.selected[0]['nominee_id'].length >= this.max){
+ return true;
+ }
}
// uncheck: function (checkedName) {
|