diff --git a/src/components/teams/TeamDetail.svelte b/src/components/teams/TeamDetail.svelte index 78381d14..3c1ea30f 100644 --- a/src/components/teams/TeamDetail.svelte +++ b/src/components/teams/TeamDetail.svelte @@ -7,7 +7,7 @@ import { getLocaleFromNavigator, _ } from "svelte-i18n"; import Toastify from "toastify-js"; import store from "../../store"; - import Select from "svelte-select" + import Select from "svelte-select"; import ImportRunnerModal from "../runners/ImportRunnerModal.svelte"; import PromiseError from "../base/PromiseError.svelte"; import ConfirmTeamDeletion from "./ConfirmTeamDeletion.svelte"; @@ -27,15 +27,12 @@ $: data_changed = JSON.stringify(teamdata) === JSON.stringify(original); $: sponsoring_contracts_download_open = false; // + const getContactLabel = (option) => + option.firstname + " " + (option.middlename || "") + " " + option.lastname; const promise = RunnerTeamService.runnerTeamControllerGetOne( params.teamid ).then((value) => { data_loaded = true; - if (value.contact) { - if (value.contact !== "null") { - value.contact = value.contact.id; - } - } teamdata = Object.assign(teamdata, value); original = Object.assign(original, value); }); @@ -76,13 +73,11 @@ }).showToast(); let postdata = teamdata; postdata.parentGroup = teamdata.parentGroup.id; - postdata.contact = postdata.contact === "null" ? null : postdata.contact; + postdata.contact = teamdata.contact?.id; RunnerTeamService.runnerTeamControllerPut(original.id, postdata) .then((resp) => { Object.assign(original, teamdata); - original = teamdata; - Object.assign(original, teamdata); - // + original = original; Toastify({ text: "updated team", duration: 2500, @@ -344,37 +339,45 @@ - + {return option.name}} - getOptionLabel={(option) => {return option.name}} - itemFilter={(label, filterText, option) => - label.toLowerCase().includes(filterText.toLowerCase()) || - option.id.toString().startsWith(filterText.toLowerCase())} + getSelectionLabel={(option) => { + return option.name; + }} + getOptionLabel={(option) => { + return option.name; + }} + itemFilter={(label, filterText, option) => label + .toLowerCase() + .includes( + filterText.toLowerCase() + ) || option.id.toString().startsWith(filterText.toLowerCase())} items={orgs} showChevron={true} placeholder={$_('search-for-an-organization-by-name-or-id')} noOptionsMessage={$_('no-organizations-found')} bind:selectedValue={teamdata.parentGroup} - on:clear={()=>(teamdata.parentGroup = null)} /> + on:clear={() => (teamdata.parentGroup = null)} /> {:else} diff --git a/src/locales/en.json b/src/locales/en.json index bf5d964d..455f52f0 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -314,5 +314,7 @@ "no-runners-found": "No runners found", "search-for-an-organization-by-name-or-id": "Search for an organization (by name or id)", "no-organizations-found": "No organizations found", - "you-have-to-provide-an-organization": "You have to provide an organization" + "you-have-to-provide-an-organization": "You have to provide an organization", + "no-contact-found": "No contact found", + "no-contact-selected": "No contact selected" }