Compare commits

..

No commits in common. "652e55e80e9e7a6c14e7dbeb0ccf6259f11f9368" and "3834079481d36a38fbb6d61a56c56320c075d59d" have entirely different histories.

5 changed files with 41 additions and 288 deletions

View File

@ -31,7 +31,7 @@
isEmailValid && isEmailValid &&
isPhoneValidOrEmpty && isPhoneValidOrEmpty &&
((isAddress1Valid && iszipcodevalid && iscityvalid) || ((isAddress1Valid && iszipcodevalid && iscityvalid) ||
editable.address_checked === false); address_checked === false);
const promise = GroupContactService.groupContactControllerGetOne( const promise = GroupContactService.groupContactControllerGetOne(
params.contact params.contact
).then((data) => { ).then((data) => {
@ -42,15 +42,6 @@
original_data.groups = original_data.groups.map((g) => g.id); original_data.groups = original_data.groups.map((g) => g.id);
editable.address_checked = editable.address.address1 !== null; editable.address_checked = editable.address.address1 !== null;
original_data.address_checked = editable.address.address1 !== null; original_data.address_checked = editable.address.address1 !== null;
if(editable.address_checked===false){
editable.address = {
address1: "",
address2: "",
city: "",
postalcode: "",
country: ""
}
}
}); });
RunnerOrganizationService.runnerOrganizationControllerGetAll().then((val) => { RunnerOrganizationService.runnerOrganizationControllerGetAll().then((val) => {
orgs = val; orgs = val;
@ -73,7 +64,7 @@
}).showToast(); }).showToast();
editable.address.country = "DE"; editable.address.country = "DE";
if (editable.address_checked === false) { if (editable.address_checked === false) {
editable.address = null; editable.address = {};
} }
if (editable.email) editable.email = editable.email; if (editable.email) editable.email = editable.email;
if (editable.phone) editable.phone = editable.phone; if (editable.phone) editable.phone = editable.phone;

View File

@ -13,24 +13,7 @@
$: name = ""; $: name = "";
$: processed_last_submit = true; $: processed_last_submit = true;
$: isOrgnameValid = name.trim().length !== 0; $: isOrgnameValid = name.trim().length !== 0;
$: isAddress1Valid = address_input1_value.trim().length !== 0; $: createbtnenabled = isOrgnameValid;
$: iszipcodevalid = address_zipcode_value.trim().length !== 0;
$: iscityvalid = address_city_value.trim().length !== 0;
$: createbtnenabled =
isOrgnameValid &&
((isAddress1Valid && iszipcodevalid && iscityvalid) ||
address_checked === false);
$: address_input1_value = "";
$: address_input2_value = "";
$: address_zipcode_value = "";
$: address_city_value = "";
$: address_checked = true;
let address_input1;
let address_input2;
let address_zipcode;
let address_city;
(() => { (() => {
document.onkeydown = (e) => { document.onkeydown = (e) => {
e = e || window.event; e = e || window.event;
@ -52,19 +35,9 @@
text: "Organization is being added...", text: "Organization is being added...",
duration: -1, duration: -1,
}).showToast(); }).showToast();
let address = {};
if (address_checked === true) {
address = {
address1: address_input1_value,
address2: address_input2_value || "",
postalcode: address_zipcode_value,
city: address_city_value,
country: "DE",
};
}
RunnerOrganizationService.runnerOrganizationControllerPost({ RunnerOrganizationService.runnerOrganizationControllerPost({
name, name,
address: address, address: undefined,
contact: undefined, contact: undefined,
}) })
.then((result) => { .then((result) => {
@ -160,105 +133,7 @@
</span> </span>
{/if} {/if}
</div> </div>
<div class="flex items-start"> </div>
<div class="flex items-center h-5">
<input
bind:checked={address_checked}
id="comments"
name="comments"
type="checkbox"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" />
</div>
<div class="ml-3 text-sm">
<label
for="comments"
class="font-medium text-gray-700">Address</label>
</div>
</div>
{#if address_checked === true}
<div class="col-span-6">
<label
for="address1"
class="block text-sm font-medium text-gray-700">Address</label>
<input
autocomplete="off"
placeholder="Address"
class:border-red-500={!isAddress1Valid}
class:focus:border-red-500={!isAddress1Valid}
class:focus:ring-red-500={!isAddress1Valid}
bind:value={address_input1_value}
bind:this={address_input1}
type="text"
name="address1"
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-gray-500 rounded-md p-2" />
{#if !isAddress1Valid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
Address is required
</span>
{/if}
</div>
<div class="col-span-6">
<label
for="address2"
class="block text-sm font-medium text-gray-700">Apartment,
suite, etc.</label>
<input
autocomplete="off"
placeholder="Apartment, suite, etc."
bind:value={address_input2_value}
bind:this={address_input2}
type="text"
name="address2"
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-gray-500 rounded-md p-2" />
</div>
<div class="col-span-6">
<label
for="zipcode"
class="block text-sm font-medium text-gray-700">ZIP/ postal
code</label>
<input
autocomplete="off"
placeholder="ZIP/ postal code"
class:border-red-500={!iszipcodevalid}
class:focus:border-red-500={!iszipcodevalid}
class:focus:ring-red-500={!iszipcodevalid}
bind:value={address_zipcode_value}
bind:this={address_zipcode}
type="text"
name="zipcode"
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-gray-500 rounded-md p-2" />
{#if !iszipcodevalid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
Valid zipcode/ postal code is required
</span>
{/if}
</div>
<div class="col-span-6">
<label
for="city"
class="block text-sm font-medium text-gray-700">City</label>
<input
autocomplete="off"
placeholder="City"
class:border-red-500={!iscityvalid}
class:focus:border-red-500={!iscityvalid}
class:focus:ring-red-500={!iscityvalid}
bind:value={address_city_value}
bind:this={address_city}
type="text"
name="city"
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-gray-500 rounded-md p-2" />
{#if !iscityvalid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
Valid city is required
</span>
{/if}
</div>
{/if}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -10,21 +10,13 @@
import ImportRunnerModal from "../runners/ImportRunnerModal.svelte"; import ImportRunnerModal from "../runners/ImportRunnerModal.svelte";
import PromiseError from "../base/PromiseError.svelte"; import PromiseError from "../base/PromiseError.svelte";
$: delete_triggered = false; $: delete_triggered = false;
$: address_valid_or_none = $: save_enabled = !data_changed;
(isAddress1Valid && iszipcodevalid && iscityvalid) ||
editable.address_checked === false;
$: save_enabled = data_changed && address_valid_or_none;
let original = "";
let original_object = {};
let contacts = [];
export let params; export let params;
$: editable = {}; let orgdata = {};
let original = {};
let contacts = [];
$: data_loaded = false; $: data_loaded = false;
$: data_changed = !(JSON.stringify(editable) === original); $: data_changed = JSON.stringify(orgdata) === JSON.stringify(original);
$: isAddress1Valid = editable.address?.address1?.trim().length !== 0;
$: iszipcodevalid = editable.address?.postalcode?.trim().length !== 0;
$: iscityvalid = editable.address?.city?.trim().length !== 0;
const promise = RunnerOrganizationService.runnerOrganizationControllerGetOne( const promise = RunnerOrganizationService.runnerOrganizationControllerGetOne(
params.orgid params.orgid
).then((value) => { ).then((value) => {
@ -34,20 +26,8 @@
value.contact = value.contact.id; value.contact = value.contact.id;
} }
} }
value.address_checked = value.address.address1 !== null; orgdata = Object.assign(orgdata, value);
if(value.address_checked===false){ original = Object.assign(original, value);
value.address = {
address1: "",
address2: "",
city: "",
postalcode: "",
country: ""
}
}
editable = Object.assign(editable, value);
editable = editable;
original_object = Object.assign(editable, value);
original = JSON.stringify(value);
}); });
GroupContactService.groupContactControllerGetAll().then((val) => { GroupContactService.groupContactControllerGetAll().then((val) => {
contacts = val; contacts = val;
@ -56,7 +36,7 @@
let delete_org = {}; let delete_org = {};
function deleteOrganization() { function deleteOrganization() {
RunnerOrganizationService.runnerOrganizationControllerRemove( RunnerOrganizationService.runnerOrganizationControllerRemove(
original_object.id, original.id,
false false
) )
.then((resp) => { .then((resp) => {
@ -68,9 +48,9 @@
location.replace("./"); location.replace("./");
}) })
.catch((err) => { .catch((err) => {
modal_open = true; modal_open = true;
delete_org = original_object; delete_org = original;
}); });
} }
function submit() { function submit() {
if (data_loaded === true && save_enabled) { if (data_loaded === true && save_enabled) {
@ -78,18 +58,17 @@
text: "updating organization", text: "updating organization",
duration: 2500, duration: 2500,
}).showToast(); }).showToast();
let postdata = Object.assign({}, editable); let postdata = orgdata;
if (postdata.address_checked === false) {
postdata.address = null;
}
console.log(postdata)
postdata.contact = postdata.contact === "null" ? null : postdata.contact; postdata.contact = postdata.contact === "null" ? null : postdata.contact;
RunnerOrganizationService.runnerOrganizationControllerPut( RunnerOrganizationService.runnerOrganizationControllerPut(
original_object.id, original.id,
postdata postdata
) )
.then((resp) => { .then((resp) => {
original = JSON.stringify(editable); Object.assign(original, orgdata);
original = orgdata;
Object.assign(original, orgdata);
//
Toastify({ Toastify({
text: "updated organization", text: "updated organization",
duration: 2500, duration: 2500,
@ -110,15 +89,15 @@
current_runners={[]} current_runners={[]}
passed_team={{}} passed_team={{}}
passed_orgs={[]} passed_orgs={[]}
passed_org={editable} passed_org={orgdata}
opened_from="OrgDetail" opened_from="OrgDetail"
bind:import_modal_open /> bind:import_modal_open />
<ConfirmOrgDeletion bind:modal_open bind:delete_org /> <ConfirmOrgDeletion bind:modal_open bind:delete_org />
{#if data_loaded} {#if data_loaded}
<section class="container p-5"> <section class="container p-5">
<div class="mb-8 text-3xl font-extrabold leading-tight"> <div class="mb-8 text-3xl font-extrabold leading-tight">
{original_object.name} {original.name}
<span data-id="org_actions_${editable.id}"> <span data-id="org_actions_${orgdata.id}">
{#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')} {#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')}
<button <button
on:click={() => { on:click={() => {
@ -236,7 +215,7 @@
autocomplete="off" autocomplete="off"
placeholder="Name" placeholder="Name"
type="text" type="text"
bind:value={editable.name} bind:value={orgdata.name}
name="name" name="name"
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-gray-500 rounded-md p-2" /> 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-gray-500 rounded-md p-2" />
</div> </div>
@ -246,7 +225,7 @@
class="font-medium text-gray-700">{$_('contact')}</label> class="font-medium text-gray-700">{$_('contact')}</label>
<select <select
name="contact" name="contact"
bind:value={editable.contact} bind:value={orgdata.contact}
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-gray-500 rounded-md p-2"> 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-gray-500 rounded-md p-2">
<option value="null">no contact</option> <option value="null">no contact</option>
{#each contacts as c} {#each contacts as c}
@ -258,99 +237,18 @@
{/each} {/each}
</select> </select>
</div> </div>
<!-- --> <div class="text-sm w-full">
<div class="flex items-start mt-2"> <label
<div class="flex items-center h-5"> for="address"
<input class="font-medium text-gray-700">{$_('address')}</label>
bind:checked={editable.address_checked} <input
id="comments" autocomplete="off"
name="comments" placeholder={$_('address')}
type="checkbox" type="text"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" /> bind:value={orgdata.address}
</div> name="address"
<div class="ml-3 text-sm"> 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-gray-500 rounded-md p-2" />
<label
for="comments"
class="font-medium text-gray-700">{$_('address')}</label>
</div>
</div> </div>
{#if editable.address_checked === true}
<div class="col-span-6">
<label
for="address1"
class="block text-sm font-medium text-gray-700">{$_('address')}</label>
<input
autocomplete="off"
placeholder="Address"
class:border-red-500={!isAddress1Valid}
class:focus:border-red-500={!isAddress1Valid}
class:focus:ring-red-500={!isAddress1Valid}
bind:value={editable.address.address1}
type="text"
name="address1"
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-gray-500 rounded-md p-2" />
{#if !isAddress1Valid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
{$_('address-is-required')}
</span>
{/if}
</div>
<div class="col-span-6">
<label
for="address2"
class="block text-sm font-medium text-gray-700">{$_('apartment-suite-etc')}</label>
<input
autocomplete="off"
placeholder={$_('apartment-suite-etc')}
bind:value={editable.address.address2}
type="text"
name="address2"
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-gray-500 rounded-md p-2" />
</div>
<div class="col-span-6">
<label
for="zipcode"
class="block text-sm font-medium text-gray-700">{$_('zip-postal-code')}</label>
<input
autocomplete="off"
placeholder={$_('zip-postal-code')}
class:border-red-500={!iszipcodevalid}
class:focus:border-red-500={!iszipcodevalid}
class:focus:ring-red-500={!iszipcodevalid}
bind:value={editable.address.postalcode}
type="text"
name="zipcode"
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-gray-500 rounded-md p-2" />
{#if !iszipcodevalid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
{$_('valid-zipcode-postal-code-is-required')}
</span>
{/if}
</div>
<div class="col-span-6">
<label
for="city"
class="block text-sm font-medium text-gray-700">{$_('city')}</label>
<input
autocomplete="off"
placeholder={$_('city')}
class:border-red-500={!iscityvalid}
class:focus:border-red-500={!iscityvalid}
class:focus:ring-red-500={!iscityvalid}
bind:value={editable.address.city}
type="text"
name="city"
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-gray-500 rounded-md p-2" />
{#if !iscityvalid}
<span
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
{$_('valid-city-is-required')}
</span>
{/if}
</div>
{/if}
</section> </section>
{:else} {:else}
{#await promise} {#await promise}

View File

@ -88,13 +88,9 @@
<div class="flex items-center"> <div class="flex items-center">
<div class="ml-4"> <div class="ml-4">
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
{#if o.address.address1 !== null} {#if o.address}
{o.address.address1}<br /> {JSON.stringify(o.address)}
{o.address.address2 || ''}<br /> {:else}no address specified{/if}
{o.address.postalcode}
{o.address.city}
{o.address.country}
{/if}
</div> </div>
</div> </div>
</div> </div>

View File

@ -115,13 +115,6 @@
{#if runner.phone} {#if runner.phone}
<div class="text-sm text-gray-500">{runner.phone}</div> <div class="text-sm text-gray-500">{runner.phone}</div>
{/if} {/if}
{#if runner.address.address1 !== null}
{runner.address.address1}<br />
{runner.address.address2 || ''}<br />
{runner.address.postalcode}
{runner.address.city}
{runner.address.country}
{/if}
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
{#if runner.group.responseType === 'RUNNERTEAM'} {#if runner.group.responseType === 'RUNNERTEAM'}