🧹 ContactOverview refinement

ref #50
This commit is contained in:
Philipp Dormann 2021-02-15 17:46:01 +01:00
parent 6f4f4ccb16
commit 0f013304ef

View File

@ -2,18 +2,15 @@
import { t, _ } from "svelte-i18n"; import { t, _ } from "svelte-i18n";
import Toastify from "toastify-js"; import Toastify from "toastify-js";
import { GroupContactService } from "@odit/lfk-client-js"; import { GroupContactService } from "@odit/lfk-client-js";
const promise = GroupContactService.groupContactControllerGetAll() const promise = GroupContactService.groupContactControllerGetAll();
import { users as usersstore } from "../store.js"; import { users as usersstore } from "../store.js";
import store from "../store"; import store from "../store";
import TeamsEmptyState from "./TeamsEmptyState.svelte"; import TeamsEmptyState from "./TeamsEmptyState.svelte";
// import ConfirmTeamDeletion from "./ConfirmTeamDeletion.svelte";
$: searchvalue = ""; $: searchvalue = "";
$: active_deletes = []; $: active_deletes = [];
export let current_teams = []; export let contacts = [];
let modal_open = false;
let delete_team = {};
usersstore.subscribe((val) => { usersstore.subscribe((val) => {
current_teams = val; contacts = val;
}); });
promise.then((data) => { promise.then((data) => {
usersstore.set(data); usersstore.set(data);
@ -29,7 +26,7 @@
<p class="text-sm">{$_('this-might-take-a-moment')}</p> <p class="text-sm">{$_('this-might-take-a-moment')}</p>
</div> </div>
{:then} {:then}
{#if current_teams.length === 0} {#if contacts.length === 0}
<TeamsEmptyState /> <TeamsEmptyState />
{:else} {:else}
<input <input
@ -64,7 +61,7 @@
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-gray-200"> <tbody class="divide-y divide-gray-200">
{#each current_teams as t} {#each contacts as t}
{#if Object.values(t) {#if Object.values(t)
.toString() .toString()
.toLowerCase() .toLowerCase()
@ -87,7 +84,7 @@
<a <a
href="../orgs/{t.parentGroup.id}" href="../orgs/{t.parentGroup.id}"
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{t.parentGroup.name}</a> class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{t.parentGroup.name}</a>
{:else}no organization specified{/if} {:else}no groups{/if}
</div> </div>
</div> </div>
</div> </div>
@ -115,19 +112,18 @@
Delete</button> Delete</button>
<button <button
on:click={() => { on:click={() => {
RunnerTeamService.runnerTeamControllerRemove(t.id, false) GroupContactService.groupContactControllerRemove(t.id, true)
.then((resp) => { .then((resp) => {
current_teams = current_teams.filter((obj) => obj.id !== t.id); contacts = contacts.filter((obj) => obj.id !== t.id);
Toastify({ Toastify({
text: 'Organization deleted', text: 'Contact deleted',
duration: 500, duration: 500,
backgroundColor: backgroundColor:
'linear-gradient(to right, #00b09b, #96c93d)', 'linear-gradient(to right, #00b09b, #96c93d)',
}).showToast(); }).showToast();
}) })
.catch((err) => { .catch((err) => {
modal_open = true; //
delete_team = t;
}); });
}} }}
tabindex="0" tabindex="0"