fix(dashboard): editing and backing out should not update the card
This commit is contained in:
parent
68d15b98f7
commit
e2b958c305
@ -143,9 +143,9 @@
|
|||||||
<Link to={getGroupPageUrl(true)}><button class="link-button button-right btn btn-secondary" style={isPublic ? "float: none !important; margin-left: 0;" : ""} tabindex={-1} aria-label="randomize group members">Randomize group</button></Link>
|
<Link to={getGroupPageUrl(true)}><button class="link-button button-right btn btn-secondary" style={isPublic ? "float: none !important; margin-left: 0;" : ""} tabindex={-1} aria-label="randomize group members">Randomize group</button></Link>
|
||||||
|
|
||||||
{:else if editMode}
|
{:else if editMode}
|
||||||
<Edit on:deletion bind:group bind:editMode />
|
<Edit on:update on:deletion bind:group bind:editMode />
|
||||||
{:else if memberMode}
|
{:else if memberMode}
|
||||||
<MemberEdit bind:group bind:memberMode bind:members />
|
<MemberEdit on:updateGroupMembers bind:group bind:memberMode bind:members />
|
||||||
{/if}
|
{/if}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
dispatch('deletion', group.id);
|
dispatch('deletion', group.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update(group: Group) {
|
||||||
|
dispatch('update', group);
|
||||||
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
let data = input;
|
let data = input;
|
||||||
err = [];
|
err = [];
|
||||||
@ -45,7 +49,7 @@
|
|||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
let res = await api().groups(group.id).patch({data});
|
let res = await api().groups(group.id).patch({data});
|
||||||
group = {...group, ...res};
|
update({...group, ...res});
|
||||||
err = [];
|
err = [];
|
||||||
success = true;
|
success = true;
|
||||||
loading = false;
|
loading = false;
|
||||||
|
@ -129,9 +129,9 @@
|
|||||||
<Collapse isOpen={isOpenArray[indexStart + index]}>
|
<Collapse isOpen={isOpenArray[indexStart + index]}>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
{#if itemType === "member"}
|
{#if itemType === "member"}
|
||||||
<MemberBody on:deletion bind:isPublic bind:groups bind:member={item} />
|
<MemberBody on:update on:deletion bind:isPublic groups={groups} member={item} />
|
||||||
{:else if itemType === "group"}
|
{:else if itemType === "group"}
|
||||||
<GroupBody on:deletion {isPublic} {members} bind:group={item} />
|
<GroupBody on:update on:deletion bind:isPublic {members} group={item} />
|
||||||
{/if}
|
{/if}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
@ -161,9 +161,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
{#if itemType === "member"}
|
{#if itemType === "member"}
|
||||||
<MemberBody on:deletion bind:isPublic bind:groups bind:member={item} />
|
<MemberBody on:update on:deletion bind:isPublic groups={groups} member={item} />
|
||||||
{:else if itemType === "group"}
|
{:else if itemType === "group"}
|
||||||
<GroupBody on:deletion {isPublic} {members} bind:group={item} />
|
<GroupBody on:update on:deletion bind:isPublic {members} group={item} />
|
||||||
{/if}
|
{/if}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -96,12 +96,20 @@
|
|||||||
function updateDelete(event: any) {
|
function updateDelete(event: any) {
|
||||||
if (itemType === "member") {
|
if (itemType === "member") {
|
||||||
members = members.filter(m => m.id !== event.detail);
|
members = members.filter(m => m.id !== event.detail);
|
||||||
list = members;
|
|
||||||
} else if (itemType === "group") {
|
} else if (itemType === "group") {
|
||||||
groups = groups.filter(g => g.id !== event.detail);
|
groups = groups.filter(g => g.id !== event.detail);
|
||||||
list = groups;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update(event: any) {
|
||||||
|
console.log(event.detail);
|
||||||
|
if (itemType === "member") {
|
||||||
|
members = members.map(m => m.id === event.detail.id ? m = event.detail : m);
|
||||||
|
} else if (itemType === "group") {
|
||||||
|
groups = groups.map(g => g.id === event.detail.id ? g = event.detail : g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ListControl {itemType} {isPublic} {memberList} {groups} {groupList} {list} bind:finalList={processedList} bind:searchValue bind:searchBy bind:itemsPerPageValue bind:currentPage />
|
<ListControl {itemType} {isPublic} {memberList} {groups} {groupList} {list} bind:finalList={processedList} bind:searchValue bind:searchBy bind:itemsPerPageValue bind:currentPage />
|
||||||
@ -131,6 +139,6 @@
|
|||||||
<NewGroup on:create={addItemToList} />
|
<NewGroup on:create={addItemToList} />
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<CardsList on:deletion={updateDelete} bind:list={slicedList} bind:groups bind:members isPublic={isPublic} itemType={itemType} itemsPerPage={itemsPerPage} currentPage={currentPage} fullLength={list.length} />
|
<CardsList on:update={update} on:deletion={updateDelete} list={slicedList} groups={groups} members={members} isPublic={isPublic} itemType={itemType} itemsPerPage={itemsPerPage} currentPage={currentPage} fullLength={list.length} />
|
||||||
<ListPagination bind:currentPage {pageAmount} />
|
<ListPagination bind:currentPage {pageAmount} />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -187,8 +187,8 @@
|
|||||||
<Link to={getSystemPageUrl()}><Button style="flex: 0; {!isPublic && "float: right;"}" color="primary" tabindex={-1} aria-label="view member's system">View system</Button></Link>
|
<Link to={getSystemPageUrl()}><Button style="flex: 0; {!isPublic && "float: right;"}" color="primary" tabindex={-1} aria-label="view member's system">View system</Button></Link>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if editMode}
|
{:else if editMode}
|
||||||
<Edit on:deletion bind:member bind:editMode />
|
<Edit on:update on:deletion bind:member bind:editMode />
|
||||||
{:else if groupMode}
|
{:else if groupMode}
|
||||||
<GroupEdit bind:member bind:groups bind:groupMode />
|
<GroupEdit on:updateMemberGroups bind:member bind:groups bind:groupMode />
|
||||||
{/if}
|
{/if}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
let err: string[] = [];
|
let err: string[] = [];
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
let input: Member = member;
|
let input: Member = JSON.parse(JSON.stringify(member));
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
@ -24,6 +24,10 @@
|
|||||||
dispatch('deletion', member.id);
|
dispatch('deletion', member.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update(member: Member) {
|
||||||
|
dispatch('update', member);
|
||||||
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
let data = input;
|
let data = input;
|
||||||
err = [];
|
err = [];
|
||||||
@ -69,7 +73,7 @@
|
|||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
let res = await api().members(member.id).patch({data});
|
let res = await api().members(member.id).patch({data});
|
||||||
member = res;
|
update({...member, ...res});
|
||||||
success = true;
|
success = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user