mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Improve hero saving
This commit is contained in:
@@ -256,11 +256,14 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async saveItem (item) {
|
async saveItem (item) {
|
||||||
// prepare the item's new value and path for being saved
|
await this.saveHero({
|
||||||
this.hero.achievementPath = item.path;
|
hero: {
|
||||||
this.hero.achievementVal = item.value;
|
_id: this.hero._id,
|
||||||
|
achievementPath: item.path,
|
||||||
await this.saveHero({ hero: this.hero, msg: item.path });
|
achievementVal: item.value,
|
||||||
|
},
|
||||||
|
msg: item.path,
|
||||||
|
});
|
||||||
item.modified = false;
|
item.modified = false;
|
||||||
},
|
},
|
||||||
enableValueChange (item) {
|
enableValueChange (item) {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="saveHero({ hero, msg: 'Contributor details', clearData: true })">
|
<form @submit.prevent="saveHero({ hero: {
|
||||||
|
_id: hero._id,
|
||||||
|
contributor: hero.contributor,
|
||||||
|
secret: hero.secret,
|
||||||
|
permissions: hero.permissions,
|
||||||
|
}, msg: 'Contributor details', clearData: true })">
|
||||||
<div class="card mt-2">
|
<div class="card mt-2">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3
|
<h3
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<form
|
<form
|
||||||
@submit.prevent="saveHero({ hero: {
|
@submit.prevent="saveHero({ hero: {
|
||||||
|
_id: hero._id,
|
||||||
auth: hero.auth,
|
auth: hero.auth,
|
||||||
preferences: hero.preferences,
|
preferences: hero.preferences,
|
||||||
}, msg: 'Authentication' })"
|
}, msg: 'Authentication' })"
|
||||||
@@ -61,12 +62,12 @@
|
|||||||
<div class="col-sm-9 col-form-label">
|
<div class="col-sm-9 col-form-label">
|
||||||
<strong>
|
<strong>
|
||||||
{{ hero.auth.timestamps.loggedin | formatDate }}</strong>
|
{{ hero.auth.timestamps.loggedin | formatDate }}</strong>
|
||||||
<button
|
<a
|
||||||
class="btn btn-warning btn-sm ml-4"
|
class="btn btn-warning btn-sm ml-4"
|
||||||
@click="resetCron()"
|
@click="resetCron()"
|
||||||
>
|
>
|
||||||
Reset Cron to Yesterday
|
Reset Cron to Yesterday
|
||||||
</button>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
@@ -118,13 +119,14 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-sm-3 col-form-label">API Token</label>
|
<label class="col-sm-3 col-form-label">API Token</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<button
|
<a
|
||||||
|
href="#"
|
||||||
value="Change API Token"
|
value="Change API Token"
|
||||||
class="btn btn-danger"
|
class="btn btn-danger"
|
||||||
@click="changeApiToken()"
|
@click="changeApiToken()"
|
||||||
>
|
>
|
||||||
Change API Token
|
Change API Token
|
||||||
</button>
|
</a>
|
||||||
<div
|
<div
|
||||||
v-if="tokenModified"
|
v-if="tokenModified"
|
||||||
>
|
>
|
||||||
@@ -276,13 +278,24 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
async changeApiToken () {
|
async changeApiToken () {
|
||||||
this.hero.changeApiToken = true;
|
await this.saveHero({
|
||||||
await this.saveHero({ hero: this.hero, msg: 'API Token' });
|
hero: {
|
||||||
|
_id: this.hero._id,
|
||||||
|
changeApiToken: true,
|
||||||
|
},
|
||||||
|
msg: 'API Token',
|
||||||
|
});
|
||||||
this.tokenModified = true;
|
this.tokenModified = true;
|
||||||
},
|
},
|
||||||
resetCron () {
|
resetCron () {
|
||||||
this.hero.resetCron = true;
|
this.saveHero({
|
||||||
this.saveHero({ hero: this.hero, msg: 'Last Cron', clearData: true });
|
hero: {
|
||||||
|
_id: this.hero._id,
|
||||||
|
resetCron: true,
|
||||||
|
},
|
||||||
|
msg: 'Last Cron',
|
||||||
|
clearData: true,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -232,11 +232,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async saveItem (item) {
|
async saveItem (item) {
|
||||||
// prepare the item's new value and path for being saved
|
await this.saveHero({ hero: {
|
||||||
this.hero.purchasedPath = item.path;
|
_id: this.hero._id,
|
||||||
this.hero.purchasedVal = item.value;
|
purchasedPath: item.path,
|
||||||
|
purchasedVal: item.value,
|
||||||
await this.saveHero({ hero: this.hero, msg: item.path });
|
}, msg: item.path });
|
||||||
item.modified = false;
|
item.modified = false;
|
||||||
},
|
},
|
||||||
enableValueChange (item) {
|
enableValueChange (item) {
|
||||||
|
|||||||
@@ -269,16 +269,19 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async saveItem (item) {
|
async saveItem (item) {
|
||||||
// prepare the item's new value and path for being saved
|
// prepare the item's new value and path for being saved
|
||||||
this.hero.itemPath = item.path;
|
const toSave = {
|
||||||
|
_id: this.hero._id,
|
||||||
|
};
|
||||||
|
toSave.itemPath = item.path;
|
||||||
if (item.value === null) {
|
if (item.value === null) {
|
||||||
this.hero.itemVal = 'null';
|
toSave.itemVal = 'null';
|
||||||
} else if (item.value === false) {
|
} else if (item.value === false) {
|
||||||
this.hero.itemVal = 'false';
|
toSave.itemVal = 'false';
|
||||||
} else {
|
} else {
|
||||||
this.hero.itemVal = item.value;
|
toSave.itemVal = item.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.saveHero({ hero: this.hero, msg: item.key });
|
await this.saveHero({ hero: toSave, msg: item.key });
|
||||||
item.neverOwned = false;
|
item.neverOwned = false;
|
||||||
item.modified = false;
|
item.modified = false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="saveHero({hero, msg: 'Privileges or Gems or Moderation Notes'})">
|
<form @submit.prevent="saveHero({hero: {
|
||||||
|
_id: hero._id,
|
||||||
|
flags: hero.flags,
|
||||||
|
balance: hero.balance,
|
||||||
|
auth: hero.auth,
|
||||||
|
secret: hero.secret,
|
||||||
|
}, msg: 'Privileges or Gems or Moderation Notes'})">
|
||||||
<div class="card mt-2">
|
<div class="card mt-2">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3
|
<h3
|
||||||
|
|||||||
Reference in New Issue
Block a user