fix(dashboard): fix cards not updating after editing
This commit is contained in:
parent
990c2d9f4c
commit
a84192f8f7
@ -13,14 +13,10 @@
|
|||||||
|
|
||||||
let err: string[] = [];
|
let err: string[] = [];
|
||||||
|
|
||||||
let input: Group = {...group};
|
let input: Group = group;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
function update() {
|
|
||||||
dispatch('update', group);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deletion() {
|
function deletion() {
|
||||||
dispatch('deletion', group.id);
|
dispatch('deletion', group.id);
|
||||||
}
|
}
|
||||||
@ -45,7 +41,6 @@
|
|||||||
let res = await api().groups(group.id).patch({data});
|
let res = await api().groups(group.id).patch({data});
|
||||||
group = {...group, ...res};
|
group = {...group, ...res};
|
||||||
err = [];
|
err = [];
|
||||||
update();
|
|
||||||
editMode = false;
|
editMode = false;
|
||||||
loading = false;
|
loading = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Row, Col, Button, Alert, ListGroup, ListGroupItem, Spinner } from 'sveltestrap';
|
import { Row, Col, Button, Alert, ListGroup, ListGroupItem, Spinner } from 'sveltestrap';
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import ListPagination from "../ListPagination.svelte";
|
import ListPagination from "../ListPagination.svelte";
|
||||||
import twemoji from "twemoji";
|
import twemoji from "twemoji";
|
||||||
import FaUserPlus from 'svelte-icons/fa/FaUserPlus.svelte'
|
import FaUserPlus from 'svelte-icons/fa/FaUserPlus.svelte'
|
||||||
@ -29,7 +28,9 @@
|
|||||||
|
|
||||||
let smallPages = true;
|
let smallPages = true;
|
||||||
|
|
||||||
$: if (group.members) {
|
updateMemberList();
|
||||||
|
|
||||||
|
function updateMemberList() {
|
||||||
membersInGroup = members.filter(member => group.members.includes(member.uuid));
|
membersInGroup = members.filter(member => group.members.includes(member.uuid));
|
||||||
membersInGroup = membersInGroup.sort((a, b) => a.name.localeCompare(b.name));
|
membersInGroup = membersInGroup.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|
||||||
@ -62,19 +63,13 @@ function memberListRenderer(item: any) {
|
|||||||
'member-list': memberListRenderer
|
'member-list': memberListRenderer
|
||||||
});
|
});
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
|
|
||||||
function update() {
|
|
||||||
dispatch("updateMembers", group)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitAdd() {
|
async function submitAdd() {
|
||||||
let data = membersToBeAdded;
|
let data = membersToBeAdded;
|
||||||
try {
|
try {
|
||||||
loading = true;
|
loading = true;
|
||||||
await api().groups(group.id).members.add.post({data});
|
await api().groups(group.id).members.add.post({data});
|
||||||
data.forEach(member => group.members.push(member));
|
data.forEach(member => group.members.push(member));
|
||||||
update();
|
updateMemberList();
|
||||||
err = null;
|
err = null;
|
||||||
membersToBeAdded = [];
|
membersToBeAdded = [];
|
||||||
loading = false;
|
loading = false;
|
||||||
@ -91,7 +86,7 @@ function memberListRenderer(item: any) {
|
|||||||
loading = true;
|
loading = true;
|
||||||
await api().groups(group.id).members.remove.post({data});
|
await api().groups(group.id).members.remove.post({data});
|
||||||
group.members = group.members.filter(m => !data.includes(m));
|
group.members = group.members.filter(m => !data.includes(m));
|
||||||
update();
|
updateMemberList();
|
||||||
err = null;
|
err = null;
|
||||||
membersToBeRemoved = [];
|
membersToBeRemoved = [];
|
||||||
loading = false;
|
loading = false;
|
||||||
|
@ -15,14 +15,10 @@
|
|||||||
|
|
||||||
let err: string[] = [];
|
let err: string[] = [];
|
||||||
|
|
||||||
let input: Member = {...member};
|
let input: Member = member;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
function update() {
|
|
||||||
dispatch('update', member);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deletion() {
|
function deletion() {
|
||||||
dispatch('deletion', member.id);
|
dispatch('deletion', member.id);
|
||||||
}
|
}
|
||||||
@ -71,7 +67,6 @@
|
|||||||
let res = await api().members(member.id).patch({data});
|
let res = await api().members(member.id).patch({data});
|
||||||
member = res;
|
member = res;
|
||||||
err = [];
|
err = [];
|
||||||
update();
|
|
||||||
editMode = false;
|
editMode = false;
|
||||||
loading = false;
|
loading = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Row, Col, Button, Alert, ListGroup, ListGroupItem, Spinner } from 'sveltestrap';
|
import { Row, Col, Button, Alert, ListGroup, ListGroupItem, Spinner } from 'sveltestrap';
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import ListPagination from "../ListPagination.svelte";
|
import ListPagination from "../ListPagination.svelte";
|
||||||
import twemoji from "twemoji";
|
import twemoji from "twemoji";
|
||||||
import Svelecte, { addFormatter } from 'svelecte';
|
import Svelecte, { addFormatter } from 'svelecte';
|
||||||
@ -30,7 +29,9 @@
|
|||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let smallPages = true;
|
let smallPages = true;
|
||||||
|
|
||||||
$: if (groups) {
|
updateGroupLists();
|
||||||
|
|
||||||
|
function updateGroupLists() {
|
||||||
groupsWithMember = groups.filter(group => group.members && group.members.includes(member.uuid));
|
groupsWithMember = groups.filter(group => group.members && group.members.includes(member.uuid));
|
||||||
groupsWithMember.sort((a, b) => a.name.localeCompare(b.name));
|
groupsWithMember.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|
||||||
@ -63,19 +64,13 @@
|
|||||||
'member-list': groupListRenderer
|
'member-list': groupListRenderer
|
||||||
});
|
});
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
|
|
||||||
function updateGroups() {
|
|
||||||
dispatch("updateGroups", groups);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitAdd() {
|
async function submitAdd() {
|
||||||
let data = groupsToBeAdded;
|
let data = groupsToBeAdded;
|
||||||
try {
|
try {
|
||||||
loading = true;
|
loading = true;
|
||||||
await api().members(member.id).groups.add.post({data});
|
await api().members(member.id).groups.add.post({data});
|
||||||
groups.forEach(group => data.includes(group.uuid) && group.members.push(member.uuid));
|
groups.forEach(group => data.includes(group.uuid) && group.members.push(member.uuid));
|
||||||
updateGroups();
|
updateGroupLists();
|
||||||
err = null;
|
err = null;
|
||||||
groupsToBeAdded = [];
|
groupsToBeAdded = [];
|
||||||
loading = false;
|
loading = false;
|
||||||
@ -92,7 +87,7 @@
|
|||||||
loading = true;
|
loading = true;
|
||||||
await api().members(member.id).groups.remove.post({data});
|
await api().members(member.id).groups.remove.post({data});
|
||||||
groups.forEach(group => {if (data.includes(group.uuid)) group.members = group.members.filter(m => m !== member.uuid)});
|
groups.forEach(group => {if (data.includes(group.uuid)) group.members = group.members.filter(m => m !== member.uuid)});
|
||||||
updateGroups();
|
updateGroupLists();
|
||||||
err = null;
|
err = null;
|
||||||
groupsToBeRemoved = [];
|
groupsToBeRemoved = [];
|
||||||
loading = false;
|
loading = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user