fix: ImportRunnerModal scrolling & team select
This commit is contained in:
parent
3c9b404234
commit
766eeab49f
@ -74,7 +74,7 @@
|
|||||||
/></svg
|
/></svg
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3 sm:text-left max-h-[75vh] overflow-y-auto">
|
<div class="mt-3 sm:text-left">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||||
{$_('delete_runner')}
|
{$_('delete_runner')}
|
||||||
</h3>
|
</h3>
|
||||||
|
@ -1,401 +1,386 @@
|
|||||||
<script>
|
<script>
|
||||||
import csv from "csvtojson";
|
import csv from "csvtojson";
|
||||||
import { read as readXlsx, utils as xlsx_utils } from "xlsx";
|
import { read as readXlsx, utils as xlsx_utils } from "xlsx";
|
||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
import { clickOutside } from "../base/outsideclick";
|
import { clickOutside } from "../base/outsideclick";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ImportService,
|
ImportService,
|
||||||
RunnerTeamService,
|
RunnerTeamService,
|
||||||
RunnerOrganizationService,
|
RunnerOrganizationService,
|
||||||
} from "@odit/lfk-client-js";
|
} from "@odit/lfk-client-js";
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
import Select from "svelte-select";
|
import Select from "svelte-select";
|
||||||
import toast from "svelte-french-toast";
|
import toast from "svelte-french-toast";
|
||||||
export let opened_from;
|
export let opened_from;
|
||||||
export let passed_org;
|
export let passed_org;
|
||||||
export let passed_orgs;
|
export let passed_orgs;
|
||||||
export let passed_team;
|
export let passed_team;
|
||||||
export let import_modal_open;
|
export let import_modal_open;
|
||||||
$: searchvalue = "";
|
$: searchvalue = "";
|
||||||
$: importButtonEnabled =
|
$: importButtonEnabled =
|
||||||
recent_processed &&
|
recent_processed &&
|
||||||
(!(selected_org_or_team == "" || selected_org_or_team == null) ||
|
(!(selected_org_or_team == "" || selected_org_or_team == null) ||
|
||||||
!(passed_org?.id == null || passed_org?.id == 0) ||
|
!(passed_org?.id == null || passed_org?.id == 0) ||
|
||||||
!(passed_team?.id == null || passed_team?.id == 0));
|
!(passed_team?.id == null || passed_team?.id == 0));
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
function cancelModal() {
|
function cancelModal() {
|
||||||
json_output = [];
|
json_output = [];
|
||||||
import_modal_open = false;
|
import_modal_open = false;
|
||||||
dispatch("cancel");
|
dispatch("cancel");
|
||||||
}
|
}
|
||||||
(() => {
|
(() => {
|
||||||
document.onkeydown = (e) => {
|
document.onkeydown = (e) => {
|
||||||
e = e || window.event;
|
e = e || window.event;
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
cancelModal();
|
cancelModal();
|
||||||
}
|
}
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
let groups = [];
|
let groups = [];
|
||||||
RunnerOrganizationService.runnerOrganizationControllerGetAll().then((val) => {
|
RunnerOrganizationService.runnerOrganizationControllerGetAll().then((val) => {
|
||||||
const orgs = val.map((r) => {
|
const orgs = val.map((r) => {
|
||||||
return { label: r.name, value: `ORG_${r.id}` };
|
return { label: r.name, value: `ORG_${r.id}` };
|
||||||
});
|
});
|
||||||
groups = groups.concat(orgs);
|
groups = groups.concat(orgs);
|
||||||
RunnerTeamService.runnerTeamControllerGetAll().then((val) => {
|
RunnerTeamService.runnerTeamControllerGetAll().then((val) => {
|
||||||
const teams = val.map((r) => {
|
const teams = val.map((r) => {
|
||||||
return {
|
return {
|
||||||
label: `${r.parentGroup.name} > ${r.name}`,
|
label: `${r.parentGroup.name} > ${r.name}`,
|
||||||
value: `TEAM_${r.id}`,
|
value: `TEAM_${r.id}`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
groups = groups.concat(teams);
|
groups = groups.concat(teams);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let selected_org;
|
let selected_org;
|
||||||
$: selected_org_or_team = "";
|
$: selected_org_or_team = "";
|
||||||
let files;
|
let files;
|
||||||
let recent_processed = true;
|
let recent_processed = true;
|
||||||
$: json_output = [];
|
$: json_output = [];
|
||||||
$: {
|
$: {
|
||||||
if (files) {
|
if (files) {
|
||||||
if (
|
if (
|
||||||
files[0].type ===
|
files[0].type ===
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||||
) {
|
) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener("load", async (e) => {
|
reader.addEventListener("load", async (e) => {
|
||||||
const data = new Uint8Array(e.target.result);
|
const data = new Uint8Array(e.target.result);
|
||||||
const out = readXlsx(data, { type: "array" });
|
const out = readXlsx(data, { type: "array" });
|
||||||
json_output = xlsx_utils.sheet_to_json(
|
json_output = xlsx_utils.sheet_to_json(
|
||||||
out.Sheets[Object.keys(out.Sheets)[0]]
|
out.Sheets[Object.keys(out.Sheets)[0]]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
reader.readAsArrayBuffer(files[0]);
|
reader.readAsArrayBuffer(files[0]);
|
||||||
} else {
|
} else {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener("load", async (e) => {
|
reader.addEventListener("load", async (e) => {
|
||||||
json_output = await csv({
|
json_output = await csv({
|
||||||
delimiter: [";", ","],
|
delimiter: [";", ","],
|
||||||
trim: true,
|
trim: true,
|
||||||
}).fromString(e.target.result);
|
}).fromString(e.target.result);
|
||||||
});
|
});
|
||||||
reader.readAsText(files[0]);
|
reader.readAsText(files[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function importAction() {
|
function importAction() {
|
||||||
if (recent_processed === true) {
|
if (recent_processed === true) {
|
||||||
toast.loading($_("runners-are-being-imported"));
|
toast.loading($_("runners-are-being-imported"));
|
||||||
recent_processed = false;
|
recent_processed = false;
|
||||||
const mapped = json_output.map(function (runner) {
|
const mapped = json_output.map(function (runner) {
|
||||||
return {
|
return {
|
||||||
firstname: runner[`${$_("csv_import__firstname")}`],
|
firstname: runner[`${$_("csv_import__firstname")}`],
|
||||||
middlename: runner[`${$_("csv_import__middlename")}`],
|
middlename: runner[`${$_("csv_import__middlename")}`],
|
||||||
lastname: runner[`${$_("csv_import__lastname")}`],
|
lastname: runner[`${$_("csv_import__lastname")}`],
|
||||||
team:
|
team:
|
||||||
runner[`${$_("csv_import__team")}`] ||
|
runner[`${$_("csv_import__team")}`] ||
|
||||||
runner[`${$_("csv_import__class")}`],
|
runner[`${$_("csv_import__class")}`],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
let org = 0;
|
let org = 0;
|
||||||
if (opened_from === "OrgDetail") {
|
if (opened_from === "OrgDetail") {
|
||||||
org = passed_org.id;
|
org = passed_org.id;
|
||||||
}
|
}
|
||||||
if (opened_from === "OrgOverview") {
|
if (opened_from === "OrgOverview") {
|
||||||
org = parseInt(selected_org);
|
org = parseInt(selected_org);
|
||||||
}
|
}
|
||||||
if (opened_from === "OrgOverview" || opened_from === "OrgDetail") {
|
if (opened_from === "OrgOverview" || opened_from === "OrgDetail") {
|
||||||
ImportService.importControllerPostOrgsJson(org, mapped)
|
ImportService.importControllerPostOrgsJson(org, mapped)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.success($_("import-finished"));
|
toast.success($_("import-finished"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.error($_("error-during-import"));
|
toast.error($_("error-during-import"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (opened_from === "TeamDetail") {
|
if (opened_from === "TeamDetail") {
|
||||||
ImportService.importControllerPostTeamsJson(passed_team.id, mapped)
|
ImportService.importControllerPostTeamsJson(passed_team.id, mapped)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.success($_("import-finished"));
|
toast.success($_("import-finished"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.error($_("error-during-import"));
|
toast.error($_("error-during-import"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (opened_from === "RunnerOverview") {
|
if (opened_from === "RunnerOverview") {
|
||||||
if (selected_org_or_team.includes("ORG_")) {
|
if (selected_org_or_team.includes("ORG_")) {
|
||||||
selected_org_or_team = selected_org_or_team.split("_")[1];
|
selected_org_or_team = selected_org_or_team.split("_")[1];
|
||||||
ImportService.importControllerPostOrgsJson(
|
ImportService.importControllerPostOrgsJson(
|
||||||
selected_org_or_team,
|
selected_org_or_team,
|
||||||
mapped
|
mapped
|
||||||
)
|
)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
dispatch("created", { runners: resp });
|
dispatch("created", { runners: resp });
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.success($_("import-finished"));
|
toast.success($_("import-finished"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.error($_("error-during-import"));
|
toast.error($_("error-during-import"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (selected_org_or_team.includes("TEAM_")) {
|
if (selected_org_or_team.includes("TEAM_")) {
|
||||||
selected_org_or_team = selected_org_or_team.split("_")[1];
|
selected_org_or_team = selected_org_or_team.split("_")[1];
|
||||||
ImportService.importControllerPostTeamsJson(
|
ImportService.importControllerPostTeamsJson(
|
||||||
selected_org_or_team,
|
selected_org_or_team,
|
||||||
mapped
|
mapped
|
||||||
)
|
)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
dispatch("created", { runners: resp });
|
dispatch("created", { runners: resp });
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.success($_("import-finished"));
|
toast.success($_("import-finished"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
recent_processed = true;
|
recent_processed = true;
|
||||||
toast.error($_("error-during-import"));
|
toast.error($_("error-during-import"));
|
||||||
cancelModal();
|
cancelModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if import_modal_open}
|
{#if import_modal_open}
|
||||||
<div
|
<div
|
||||||
class="fixed z-10 inset-0 overflow-y-hidden"
|
class="fixed z-10 inset-0 overflow-y-hidden"
|
||||||
use:clickOutside
|
use:clickOutside
|
||||||
on:click_outside={() => {
|
on:click_outside={() => {
|
||||||
cancelModal();
|
cancelModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="flex items-end justify-center h-screen text-center sm:block p-0 lg:p-4"
|
class="flex items-end justify-center h-screen text-center sm:block p-0 lg:p-4"
|
||||||
>
|
>
|
||||||
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
|
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
|
||||||
<div
|
<div
|
||||||
class="absolute inset-0 bg-gray-500 opacity-75"
|
class="absolute inset-0 bg-gray-500 opacity-75"
|
||||||
data-id="modal_backdrop"
|
data-id="modal_backdrop"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
class="hidden sm:inline-block sm:align-middle sm:h-screen"
|
class="hidden sm:inline-block sm:align-middle sm:h-screen"
|
||||||
aria-hidden="true">​</span
|
aria-hidden="true">​</span
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="inline-block align-bottom text-left shadow-xl transform transition-all sm:align-middle w-full lg:w-auto min-w-auto lg:min-w-[35vw]"
|
class="inline-block align-bottom text-left shadow-xl transform transition-all sm:align-middle w-full lg:w-auto min-w-auto lg:min-w-[35vw]"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-labelledby="modal-headline"
|
aria-labelledby="modal-headline"
|
||||||
>
|
>
|
||||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-t-xl lg:rounded-xl">
|
<div
|
||||||
<div class="">
|
class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-t-xl lg:rounded-xl"
|
||||||
<div
|
>
|
||||||
class="flex-shrink-0 flex items-center justify-center size-12 rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10"
|
<div class="">
|
||||||
>
|
<div
|
||||||
<svg
|
class="flex-shrink-0 flex items-center justify-center size-12 rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
>
|
||||||
viewBox="0 0 24 24"
|
<svg
|
||||||
class="h-6 w-6 text-blue-600"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
fill="currentColor"
|
viewBox="0 0 24 24"
|
||||||
width="24"
|
class="h-6 w-6 text-blue-600"
|
||||||
height="24"
|
fill="currentColor"
|
||||||
><path fill="none" d="M0 0h24v24H0z" />
|
width="24"
|
||||||
<path
|
height="24"
|
||||||
d="M9.83 8.79L8 9.456V13H6V8.05h.015l5.268-1.918c.244-.093.51-.14.782-.131a2.616 2.616 0 0 1 2.427 1.82c.186.583.356.977.51 1.182A4.992 4.992 0 0 0 19 11v2a6.986 6.986 0 0 1-5.402-2.547l-.581 3.297L15 15.67V23h-2v-5.986l-2.05-1.987-.947 4.298-6.894-1.215.348-1.97 4.924.868L9.83 8.79zM13.5 5.5a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"
|
><path fill="none" d="M0 0h24v24H0z" />
|
||||||
/></svg
|
<path
|
||||||
>
|
d="M9.83 8.79L8 9.456V13H6V8.05h.015l5.268-1.918c.244-.093.51-.14.782-.131a2.616 2.616 0 0 1 2.427 1.82c.186.583.356.977.51 1.182A4.992 4.992 0 0 0 19 11v2a6.986 6.986 0 0 1-5.402-2.547l-.581 3.297L15 15.67V23h-2v-5.986l-2.05-1.987-.947 4.298-6.894-1.215.348-1.97 4.924.868L9.83 8.79zM13.5 5.5a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"
|
||||||
</div>
|
/></svg
|
||||||
<div class="mt-3 sm:mt-0 sm:text-left w-full">
|
>
|
||||||
<h3 class="text-lg leading-6 font-bold mt-2 text-gray-900">
|
</div>
|
||||||
{$_("runner-import")}
|
<div class="mt-3 sm:mt-0 sm:text-left w-full">
|
||||||
</h3>
|
<h3 class="text-lg leading-6 font-bold mt-2 text-gray-900">
|
||||||
</div>
|
{$_("runner-import")}
|
||||||
</div>
|
</h3>
|
||||||
<div class="sm:text-left w-full">
|
</div>
|
||||||
{#if json_output.length === 0}
|
</div>
|
||||||
<div class="mb-6">
|
<div class="sm:text-left w-full">
|
||||||
<p class="text-sm text-gray-500">
|
{#if json_output.length === 0}
|
||||||
{$_("please-provide-the-required-csv-xlsx-file")}
|
<div class="mb-6">
|
||||||
</p>
|
<p class="text-sm text-gray-500">
|
||||||
</div>
|
{$_("please-provide-the-required-csv-xlsx-file")}
|
||||||
<div class="overflow-hidden relative mt-4 mb-4">
|
</p>
|
||||||
<input
|
</div>
|
||||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
<div class="overflow-hidden relative mt-4 mb-4">
|
||||||
bind:files
|
<input
|
||||||
type="file"
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||||
/>
|
bind:files
|
||||||
</div>
|
type="file"
|
||||||
<div class="overflow-hidden relative mt-4 mb-4">
|
/>
|
||||||
<button
|
</div>
|
||||||
on:click={() => {
|
<div class="overflow-hidden relative mt-4 mb-4">
|
||||||
cancelModal();
|
<button
|
||||||
}}
|
on:click={() => {
|
||||||
type="button"
|
cancelModal();
|
||||||
class="w-full justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 hidden lg:block"
|
}}
|
||||||
>
|
type="button"
|
||||||
{$_("cancel")}
|
class="w-full justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 hidden lg:block"
|
||||||
</button>
|
>
|
||||||
</div>
|
{$_("cancel")}
|
||||||
{/if}
|
</button>
|
||||||
{#if json_output.length > 0}
|
</div>
|
||||||
{#if opened_from === "OrgOverview"}
|
{/if}
|
||||||
<p>{$_("import__target-organization")}</p>
|
{#if json_output.length > 0}
|
||||||
<select
|
{#if opened_from === "OrgOverview"}
|
||||||
name="team"
|
<p>{$_("import__target-organization")}</p>
|
||||||
bind:value={selected_org}
|
<select
|
||||||
class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-neutral-800 rounded-md p-2"
|
name="team"
|
||||||
>
|
bind:value={selected_org}
|
||||||
{#each passed_orgs as o}
|
class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-neutral-800 rounded-md p-2"
|
||||||
<option value={o.id}>{o.name}</option>
|
>
|
||||||
{/each}
|
{#each passed_orgs as o}
|
||||||
</select>
|
<option value={o.id}>{o.name}</option>
|
||||||
<p>{$_("confirm-runner-import")}</p>
|
{/each}
|
||||||
{/if}
|
</select>
|
||||||
{#if opened_from === "RunnerOverview"}
|
<p>{$_("confirm-runner-import")}</p>
|
||||||
<p>{$_("group")}</p>
|
{/if}
|
||||||
<Select
|
{#if opened_from === "RunnerOverview"}
|
||||||
containerClasses="rounded-l-md mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-neutral-800 rounded-md p-2"
|
<p>{$_("group")}</p>
|
||||||
itemFilter={(label, filterText, option) =>
|
<select
|
||||||
label.toLowerCase().includes(filterText.toLowerCase()) ||
|
bind:value={selected_org_or_team}
|
||||||
option.id.value
|
class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-neutral-800 rounded-md p-2"
|
||||||
.toString()
|
>
|
||||||
.startsWith(filterText.toLowerCase())}
|
{#each groups as g}
|
||||||
items={groups}
|
<option value={g.value}>{g.label}</option>
|
||||||
showChevron={true}
|
{/each}
|
||||||
placeholder={$_(
|
</select>
|
||||||
"search-for-an-organization-or-team-by-name-or-id"
|
{/if}
|
||||||
)}
|
{#if opened_from === "OrgDetail"}
|
||||||
noOptionsMessage={$_("no-organization-or-team-found")}
|
<p>
|
||||||
on:select={(selectedValue) => {
|
{$_("runnerimport_verify_runners_org", {
|
||||||
selected_org_or_team = selectedValue.detail.value;
|
values: { org_name: passed_org.name },
|
||||||
}}
|
})}
|
||||||
on:clear={() => (selected_org_or_team = null)}
|
</p>
|
||||||
/>
|
{/if}
|
||||||
{/if}
|
<div class="relative w-full mt-4 mb-4">
|
||||||
{#if opened_from === "OrgDetail"}
|
<div class="w-full overflow-x-auto max-h-[50vh]">
|
||||||
<p>
|
<table class="divide-y divide-gray-200 w-full">
|
||||||
{$_("runnerimport_verify_runners_org", {
|
<thead class="bg-gray-50">
|
||||||
values: { org_name: passed_org.name },
|
<tr class="odd:bg-white even:bg-gray-100">
|
||||||
})}
|
<th
|
||||||
</p>
|
scope="col"
|
||||||
{/if}
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
||||||
<input
|
>
|
||||||
type="search"
|
{$_("csv_import__firstname")}
|
||||||
bind:value={searchvalue}
|
</th>
|
||||||
placeholder={$_("datatable.search")}
|
<th
|
||||||
aria-label={$_("datatable.search")}
|
scope="col"
|
||||||
class="p-2 w-full"
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
||||||
/>
|
>
|
||||||
<div class="relative w-full mt-4 mb-4">
|
{$_("csv_import__middlename")}
|
||||||
<div class="w-full overflow-x-auto">
|
</th>
|
||||||
<table class="divide-y divide-gray-200 w-full">
|
<th
|
||||||
<thead class="bg-gray-50">
|
scope="col"
|
||||||
<tr class="odd:bg-white even:bg-gray-100">
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
||||||
<th
|
>
|
||||||
scope="col"
|
{$_("csv_import__lastname")}
|
||||||
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
</th>
|
||||||
>
|
{#if (opened_from !== "TeamDetail" && opened_from !== "RunnerOverview") || (opened_from === "RunnerOverview" && selected_org_or_team.includes("ORG_"))}
|
||||||
{$_("csv_import__firstname")}
|
<th
|
||||||
</th>
|
scope="col"
|
||||||
<th
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
||||||
scope="col"
|
>
|
||||||
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
{$_("csv_import__team")}
|
||||||
>
|
</th>
|
||||||
{$_("csv_import__middlename")}
|
{/if}
|
||||||
</th>
|
</tr>
|
||||||
<th
|
</thead>
|
||||||
scope="col"
|
<tbody class="divide-y divide-gray-200">
|
||||||
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
{#each json_output as runner}
|
||||||
>
|
{#if Object.values(runner)
|
||||||
{$_("csv_import__lastname")}
|
.toString()
|
||||||
</th>
|
.toLowerCase()
|
||||||
{#if (opened_from !== "TeamDetail" && opened_from !== "RunnerOverview") || (opened_from === "RunnerOverview" && selected_org_or_team.includes("ORG_"))}
|
.includes(searchvalue)}
|
||||||
<th
|
<tr class="odd:bg-white even:bg-gray-100">
|
||||||
scope="col"
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
{runner[`${$_("csv_import__firstname")}`]}
|
||||||
>
|
</td>
|
||||||
{$_("csv_import__team")}
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
</th>
|
{runner[`${$_("csv_import__middlename")}`] || ""}
|
||||||
{/if}
|
</td>
|
||||||
</tr>
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
</thead>
|
{runner[`${$_("csv_import__lastname")}`]}
|
||||||
<tbody class="divide-y divide-gray-200">
|
</td>
|
||||||
{#each json_output as runner}
|
{#if (opened_from !== "TeamDetail" && opened_from !== "RunnerOverview") || (opened_from === "RunnerOverview" && selected_org_or_team.includes("ORG_"))}
|
||||||
{#if Object.values(runner)
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
.toString()
|
{runner[`${$_("csv_import__team")}`] ||
|
||||||
.toLowerCase()
|
runner[`${$_("csv_import__class")}`] ||
|
||||||
.includes(searchvalue)}
|
"---"}
|
||||||
<tr class="odd:bg-white even:bg-gray-100">
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
{/if}
|
||||||
{runner[`${$_("csv_import__firstname")}`]}
|
</tr>
|
||||||
</td>
|
{/if}
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
{/each}
|
||||||
{runner[`${$_("csv_import__middlename")}`] || ""}
|
</tbody>
|
||||||
</td>
|
</table>
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
</div>
|
||||||
{runner[`${$_("csv_import__lastname")}`]}
|
<button
|
||||||
</td>
|
disabled={!importButtonEnabled}
|
||||||
{#if (opened_from !== "TeamDetail" && opened_from !== "RunnerOverview") || (opened_from === "RunnerOverview" && selected_org_or_team.includes("ORG_"))}
|
class:opacity-50={!importButtonEnabled}
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
on:click={importAction}
|
||||||
{runner[`${$_("csv_import__team")}`] ||
|
type="button"
|
||||||
runner[`${$_("csv_import__class")}`] ||
|
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||||
"---"}
|
>
|
||||||
</td>
|
{$_("import-runners")}
|
||||||
{/if}
|
</button>
|
||||||
</tr>
|
<button
|
||||||
{/if}
|
on:click={() => {
|
||||||
{/each}
|
cancelModal();
|
||||||
</tbody>
|
}}
|
||||||
</table>
|
type="button"
|
||||||
</div>
|
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
|
||||||
<button
|
>
|
||||||
disabled={!importButtonEnabled}
|
{$_("cancel")}
|
||||||
class:opacity-50={!importButtonEnabled}
|
</button>
|
||||||
on:click={importAction}
|
</div>
|
||||||
type="button"
|
{/if}
|
||||||
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
</div>
|
||||||
>
|
</div>
|
||||||
{$_("import-runners")}
|
</div>
|
||||||
</button>
|
</div>
|
||||||
<button
|
</div>
|
||||||
on:click={() => {
|
|
||||||
cancelModal();
|
|
||||||
}}
|
|
||||||
type="button"
|
|
||||||
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
|
|
||||||
>
|
|
||||||
{$_("cancel")}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -180,6 +180,7 @@
|
|||||||
import store from "../../store";
|
import store from "../../store";
|
||||||
import AddRunnerModal from "./AddRunnerModal.svelte";
|
import AddRunnerModal from "./AddRunnerModal.svelte";
|
||||||
import ImportRunnerModal from "./ImportRunnerModal.svelte";
|
import ImportRunnerModal from "./ImportRunnerModal.svelte";
|
||||||
|
import toast from "svelte-french-toast";
|
||||||
$: current_runners = [];
|
$: current_runners = [];
|
||||||
export let modal_open = false;
|
export let modal_open = false;
|
||||||
export let import_modal_open = false;
|
export let import_modal_open = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user