Fix tag deletion and views update
This commit is contained in:
parent
29ab752170
commit
9d38545179
|
@ -10,10 +10,12 @@
|
|||
let tagType = getTagTypeFromId(projectTag.type);
|
||||
</script>
|
||||
|
||||
<td>
|
||||
{#if tagType?.hasOptions}
|
||||
<SelectTags multiple={false} {projectTag} {card} bind:tagValue />
|
||||
{:else if !tagType?.hasOptions}
|
||||
<input />
|
||||
{/if}
|
||||
</td>
|
||||
{#if tagType}
|
||||
<td>
|
||||
{#if tagType?.hasOptions}
|
||||
<SelectTags multiple={false} {projectTag} {card} bind:tagValue />
|
||||
{:else if !tagType?.hasOptions}
|
||||
<input />
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
|
|
|
@ -79,6 +79,10 @@
|
|||
}
|
||||
|
||||
tagValue = undefined;
|
||||
|
||||
card.tags = card.tags.filter((t) => t.tag_id !== projectTag.id);
|
||||
|
||||
cards.reload();
|
||||
}
|
||||
|
||||
function createOption() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { get } from 'svelte/store';
|
||||
import type { Project, TagValue, View } from '../../stores/interfaces';
|
||||
import { cards, currentView } from '../../stores/smallStore';
|
||||
import { cards, currentView, views } from '../../stores/smallStore';
|
||||
import projectTags from '../../stores/projectTags';
|
||||
import GroupMenu from './groupMenu.svelte';
|
||||
|
||||
|
@ -25,10 +25,16 @@
|
|||
async function setGroup(id: number): Promise<boolean> {
|
||||
if ($currentView == null) return false;
|
||||
|
||||
return await currentView.update({
|
||||
const view = {
|
||||
...$currentView,
|
||||
primary_tag_id: id
|
||||
});
|
||||
};
|
||||
|
||||
const res = await views.edit(view);
|
||||
|
||||
if (res) currentView.set(view);
|
||||
|
||||
return res;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, tick } from 'svelte';
|
||||
import api, { processError } from '../utils/api';
|
||||
import type { Project, View } from '../stores/interfaces';
|
||||
import { currentView, views } from '../stores/smallStore';
|
||||
|
@ -35,9 +35,10 @@
|
|||
}
|
||||
|
||||
async function saveView(view: View) {
|
||||
await tick();
|
||||
if (!view || !$views.includes(view)) return;
|
||||
if (viewEditId === view.id && viewEditValue !== view.title) {
|
||||
if (!(await views.update(view))) return;
|
||||
if (!(await views.edit(view))) return;
|
||||
}
|
||||
|
||||
viewEditId = -1;
|
||||
|
|
|
@ -10,19 +10,19 @@ export const currentView = (() => {
|
|||
|
||||
return {
|
||||
subscribe,
|
||||
set,
|
||||
update: async (view: View): Promise<boolean> => {
|
||||
const response = await api.put(`/v1/views/${view.id}`, view);
|
||||
set
|
||||
// update: async (view: View): Promise<boolean> => {
|
||||
// const response = await api.put(`/v1/views/${view.id}`, view);
|
||||
|
||||
if (response.status !== status.NoContent) {
|
||||
processError(response, 'Failed to update view');
|
||||
return false;
|
||||
}
|
||||
// if (response.status !== status.NoContent) {
|
||||
// processError(response, 'Failed to update view');
|
||||
// return false;
|
||||
// }
|
||||
|
||||
set(view);
|
||||
// set(view);
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
};
|
||||
})();
|
||||
|
||||
|
@ -136,6 +136,6 @@ export const views = (() => {
|
|||
init,
|
||||
add,
|
||||
remove,
|
||||
update: edit
|
||||
edit
|
||||
};
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue