add warning message if vote than 2
This commit is contained in:
@@ -161,21 +161,25 @@ export default {
|
||||
selected[i]['nominee_id'] = null;
|
||||
}
|
||||
},
|
||||
|
||||
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
|
||||
this.selected[0]['nominee_id'].push(nominee_id);
|
||||
} else {
|
||||
// Nominee found, remove it
|
||||
this.selected[0]['nominee_id'].splice(index, 1);
|
||||
}
|
||||
console.log(this.selected[0])
|
||||
},
|
||||
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) {
|
||||
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');
|
||||
}
|
||||
} else {
|
||||
// Nominee found, remove it
|
||||
this.selected[0]['nominee_id'].splice(index, 1);
|
||||
}
|
||||
console.log(this.selected[0])
|
||||
},
|
||||
|
||||
getSelectedNomineeName: function (id) {
|
||||
return this.getNominee(id);
|
||||
|
||||
Reference in New Issue
Block a user