mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Fix char values issue (#13946)
* Fix selection highlight in avatar editor * Add validation for Fix Character Values fields
This commit is contained in:
@@ -143,12 +143,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close () {
|
close () {
|
||||||
|
this.validateInputs();
|
||||||
this.$root.$emit('bv::hide::modal', 'restore');
|
this.$root.$emit('bv::hide::modal', 'restore');
|
||||||
},
|
},
|
||||||
restore () {
|
restore () {
|
||||||
if (this.restoreValues.stats.lvl < 1) {
|
if (!this.validateInputs()) {
|
||||||
// @TODO:
|
|
||||||
// Notification.error(env.t('invalidLevel'), true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +174,35 @@ export default {
|
|||||||
this.$store.dispatch('user:set', settings);
|
this.$store.dispatch('user:set', settings);
|
||||||
this.$root.$emit('bv::hide::modal', 'restore');
|
this.$root.$emit('bv::hide::modal', 'restore');
|
||||||
},
|
},
|
||||||
|
validateInputs () {
|
||||||
|
const canRestore = ['hp', 'exp', 'gp', 'mp'];
|
||||||
|
let valid = true;
|
||||||
|
|
||||||
|
for (const stat of canRestore) {
|
||||||
|
if (this.restoreValues.stats[stat] === '') {
|
||||||
|
this.restoreValues.stats[stat] = this.user.stats[stat];
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputLevel = Number(this.restoreValues.stats.lvl);
|
||||||
|
if (this.restoreValues.stats.lvl === ''
|
||||||
|
|| !Number.isInteger(inputLevel)
|
||||||
|
|| inputLevel < 1) {
|
||||||
|
this.restoreValues.stats.lvl = this.user.stats.lvl;
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputStreak = Number(this.restoreValues.achievements.streak);
|
||||||
|
if (this.restoreValues.achievements.streak === ''
|
||||||
|
|| !Number.isInteger(inputStreak)
|
||||||
|
|| inputStreak < 0) {
|
||||||
|
this.restoreValues.achievements.streak = this.user.achievements.streak;
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user