Skip to content

Commit

Permalink
Merge pull request #11 from gdi-be/services-section
Browse files Browse the repository at this point in the history
Prepare Service form
  • Loading branch information
KaiVolland authored Jan 16, 2025
2 parents ba8c099 + 21f2674 commit 24267c0
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/Form/Checkmark.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" />
</svg>

<style lang="less">
<style lang="scss">
.checkmark {
--check-color: white;
--background: var(--mdc-theme-primary, green);
Expand Down
23 changes: 10 additions & 13 deletions src/lib/components/Form/Form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import TechnicalDescription_60 from "./Field/TechnicalDescription_60.svelte";
import Lineage_32 from "./Field/Lineage_32.svelte";
import AdditionalInformation_39 from "./Field/AdditionalInformation_39.svelte";
import ServicesSection from "./service/ServicesSection.svelte";
type FormProps = {
metadata?: Record<string, unknown>;
Expand All @@ -72,11 +73,8 @@
section: 'additional',
label: 'Weitere Angaben'
}, {
section: 'display_services',
label: 'Darstellungsdienste'
}, {
section: 'download_services',
label: 'Downloaddienste'
section: 'services',
label: 'Dienste'
}];
initializeFormContext();
Expand Down Expand Up @@ -197,12 +195,9 @@
<AdditionalInformation_39 />
</section>
{/if}
{#if activeSection === "display_services"}
<section id="display_services" transition:fade >
</section>
{/if}
{#if activeSection === "download_services"}
<section id="download_services" transition:fade >
{#if activeSection === "services"}
<section id="services" transition:fade >
<ServicesSection />
</section>
{/if}
</form>
Expand Down Expand Up @@ -233,7 +228,8 @@
nav.tabs {
position: relative;
display: flex;
padding-bottom: 0.25rem;
padding: 0 2em 0.25em 2em;
margin-bottom: 1em;
button.section-button {
display: flex;
Expand Down Expand Up @@ -267,7 +263,7 @@
display: flex;
overflow-y: scroll;
flex: 1;
padding: 2em 0;
position: relative;
form {
flex: 2;
Expand All @@ -280,6 +276,7 @@
top: 0;
display: flex;
flex-direction: column;
padding: 1em 0 2em 0;
gap: 1em;
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/lib/components/Form/FormContext.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function toggleActiveHelp(key: FieldKey) {
}
}

export type Section = 'basedata' | 'classification' | 'temp_and_spatial' | 'additional' | 'display_services' | 'download_services';
export type Section = 'basedata' | 'classification' | 'temp_and_spatial' | 'additional' | 'services';

type Progress = {
total: number;
Expand Down Expand Up @@ -225,11 +225,7 @@ const formValidators: FormValidators = {
validator: (val) => val !== undefined && val !== null && val !== ''
}]
},
display_services: {
required: [],
optional: []
},
download_services: {
services: {
required: [],
optional: []
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Form/Inputs/SelectInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let element = $state();
type InputProps = {
onChange?: (value: string | undefined) => void;
onChange?: (value: string) => void;
value?: string;
key: string;
label: string;
Expand Down
30 changes: 17 additions & 13 deletions src/lib/components/Form/Inputs/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@
label: string;
maxlength?: number;
value?: string;
wrapperClass?: string;
} & ComponentProps<typeof Textfield>;
let {
key,
label,
maxlength,
value = $bindable(""),
wrapperClass,
...restProps
}: InputProps = $props();
</script>

<Textfield
{label}
input$name={key}
input$maxlength={maxlength}
bind:value
{...restProps}
>
{#snippet helper()}
{#if maxlength}
<CharacterCounter />
{/if}
{/snippet}
</Textfield>
<div class={['text-input', wrapperClass]} >
<Textfield
{label}
input$name={key}
input$maxlength={maxlength}
bind:value
{...restProps}
>
{#snippet helper()}
{#if maxlength}
<CharacterCounter />
{/if}
{/snippet}
</Textfield>
</div>
134 changes: 134 additions & 0 deletions src/lib/components/Form/service/ServiceForm.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<script lang="ts">
import type { Service } from "$lib/models/metadata";
import Paper from "@smui/paper";
import TextAreaInput from "../Inputs/TextAreaInput.svelte";
import TextInput from "../Inputs/TextInput.svelte";
import SelectInput from "../Inputs/SelectInput.svelte";
import { setNestedValue } from "../../../util";
import NumberInput from "../Inputs/NumberInput.svelte";
export type ServiceFormProps = {
service: Service;
onChange?: (service: Service) => void;
};
let {
service,
onChange = () => {}
}: ServiceFormProps = $props();
// let isDownloadService = $derived(service.serviceType === 'WFS' || service.serviceType === 'ATOM');
let isDisplayService = $derived(service.serviceType === 'WMS' || service.serviceType === 'WMTS');
function setByEvent(key: string, e: Event) {
const target = e.target as HTMLInputElement;
const value = target.value;
set(key, value);
}
function set(key: string, value: string) {
service = setNestedValue(service, key, value);
onChange(service);
}
</script>

<div class="service-form">
<Paper>
<!-- serviceType [57] -->
<SelectInput
label="Typ"
key="type"
value={service.serviceType}
options={[{
key: 'ATOM',
label: '🗃️ ATOM'
}, {
key: 'WFS',
label: '🗃️ WFS'
}, {
key: 'WMS',
label: '🗺️ WMS'
}, {
key: 'WMTS',
label: '🗺️ WMTS'
}]}
onChange={(value: string) => set("type", value)}
/>
</Paper>
<Paper>
<!-- title [58] -->
<TextInput
label="Titel"
key="title"
value={service.title}
maxlength={100}
onchange={(e: Event) => setByEvent("title", e)}
/>
</Paper>
<!-- shortDescription [59] -->
<TextAreaInput
label="Kurzbeschreibung"
key="shortDescription"
value={service.shortDescription}
maxlength={500}
onchange={(e: Event) => setByEvent("shortDescription", e)}
/>
{#if isDisplayService}
<!-- legendImage [53] -->
<fieldset class="legend-fieldset">
<legend>Gesamtlegende</legend>
<div class="legend-text-fields">
<TextInput
label="Format"
value={service.legendImage?.format}
maxlength={100}
onchange={(e: Event) => setByEvent("legendImage.format", e)}
/>
<TextInput
label="Url"
value={service.legendImage?.url}
maxlength={100}
onchange={(e: Event) => setByEvent("legendImage.url", e)}
/>
</div>
<fieldset>
<NumberInput
label="Breite"
value={service.legendImage?.width}
onchange={(e: Event) => setByEvent("legendImage.width", e)}
/>
<NumberInput
label="Höhe"
value={service.legendImage?.height}
onchange={(e: Event) => setByEvent("legendImage.height", e)}
/>
</fieldset>
</fieldset>
{/if}
</div>

<style lang="scss">
.service-form {
display: flex;
flex-direction: column;
gap: 1em;
.legend-fieldset {
display: flex;
gap: 1em;
div.legend-text-fields {
flex: 1;
}
}
:global(label.mdc-text-field),
:global(.select-input) {
width: 100%;
}
}
</style>
Loading

0 comments on commit 24267c0

Please sign in to comment.