mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
WIP remove challenge tag from list if not in use (#14147)
* if tag not in use after leaving challenge, delete * fix(tags): correct routing in store actions Co-authored-by: Megan Shepherd <meg.d.shep@gmail.com> Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
parent
0224ce7e3e
commit
2eb7bab1dd
2 changed files with 21 additions and 7 deletions
|
|
@ -50,7 +50,21 @@ export default {
|
|||
challengeId: this.challengeId,
|
||||
keep,
|
||||
});
|
||||
await this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true });
|
||||
const userTasksByType = (await this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true })).data;
|
||||
let tagInUse = false;
|
||||
Object.keys(userTasksByType).forEach(taskType => {
|
||||
userTasksByType[taskType].forEach(task => {
|
||||
if (task.tags.indexOf(this.challengeId) > -1) {
|
||||
tagInUse = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!tagInUse) {
|
||||
await this.$store.dispatch(
|
||||
'tags:deleteTag',
|
||||
{ tagId: this.challengeId },
|
||||
);
|
||||
}
|
||||
this.close();
|
||||
},
|
||||
close () {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export async function getTags () {
|
||||
const url = 'api/v4/tags';
|
||||
const url = '/api/v4/tags';
|
||||
const response = await axios.get(url);
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
export async function createTag (store, payload) {
|
||||
const url = 'api/v4/tags';
|
||||
const url = '/api/v4/tags';
|
||||
const response = await axios.post(url, {
|
||||
name: payload.name,
|
||||
});
|
||||
|
|
@ -19,13 +19,13 @@ export async function createTag (store, payload) {
|
|||
}
|
||||
|
||||
export async function getTag (store, payload) {
|
||||
const url = `api/v4/tags/${payload.tagId}`;
|
||||
const url = `/api/v4/tags/${payload.tagId}`;
|
||||
const response = await axios.get(url);
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
export async function updateTag (store, payload) {
|
||||
const url = `api/v4/tags/${payload.tagId}`;
|
||||
const url = `/api/v4/tags/${payload.tagId}`;
|
||||
const response = await axios.put(url, {
|
||||
tagDetails: payload.tagDetails,
|
||||
});
|
||||
|
|
@ -33,7 +33,7 @@ export async function updateTag (store, payload) {
|
|||
}
|
||||
|
||||
export async function sortTag (store, payload) {
|
||||
const url = 'api/v4/reorder-tags';
|
||||
const url = '/api/v4/reorder-tags';
|
||||
const response = await axios.post(url, {
|
||||
tagId: payload.tagId,
|
||||
to: payload.to,
|
||||
|
|
@ -42,7 +42,7 @@ export async function sortTag (store, payload) {
|
|||
}
|
||||
|
||||
export async function deleteTag (store, payload) {
|
||||
const url = `api/v4/tags/${payload.tagId}`;
|
||||
const url = `/api/v4/tags/${payload.tagId}`;
|
||||
const response = await axios.delete(url);
|
||||
return response.data.data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue