Skip to content

Commit

Permalink
show required attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
psubram3 committed Jan 3, 2025
1 parent 074e5ef commit efc7a1d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/external-events/ExternalEventForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
let externalEventType: ExternalEventType | undefined = undefined;
let externalEventTypeParametersMap: ParametersMap = {};
let startTimeField: FieldStore<string>;
let requiredAttributes: string[] = [];
$: externalEventType = $externalEventTypes.find(eventType => eventType.name === externalEvent.pkey.event_type_name);
$: externalEventAttributes = translateJsonSchemaArgumentsToValueSchema(externalEvent.attributes);
Expand All @@ -44,6 +45,11 @@
},
{} as ParametersMap,
);
// Get the set of required attribute names
requiredAttributes =
$externalEventTypes.find(eventType => eventType.name === externalEvent?.pkey.event_type_name)?.attribute_schema
.required ?? [];
}
$: startTimeField = field<string>(`${formatDate(new Date(externalEvent.start_time), $plugins.time.primary.format)}`);
Expand Down Expand Up @@ -101,7 +107,11 @@
<Parameters
disabled={true}
expanded={false}
formParameters={getFormParameters(externalEventTypeParametersMap, externalEventAttributes, [])}
formParameters={getFormParameters(
externalEventTypeParametersMap,
externalEventAttributes,
requiredAttributes,
)}
/>
</div>
</Collapse>
Expand Down
10 changes: 9 additions & 1 deletion src/components/parameters/ParameterInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
let leaveTimeout: NodeJS.Timeout | null = null;
let source: ValueSource;
let unit: string | undefined = undefined;
let required: boolean = true;
let externalEvent: boolean = false;
$: if (formParameter) {
source = formParameter.valueSource;
unit = formParameter.schema?.metadata?.unit?.value;
externalEvent = formParameter.externalEvent ?? false;
required = formParameter.required ?? true;
}
function leaveCallback() {
Expand Down Expand Up @@ -75,7 +79,7 @@
}
</script>

{#if unit || source !== 'none'}
{#if externalEvent || unit || source !== 'none'}
<div class="parameter-info-container" role="contentinfo" on:mouseenter={onIconOver} on:mouseleave={onIconOut}>
<div><InfoIcon /></div>
<ContextMenu hideAfterClick={false} bind:this={contextMenu}>
Expand All @@ -92,6 +96,10 @@
<ValueSourceBadge {disabled} isCompact={false} {source} on:reset={onReset} />
</div>
{/if}
{#if externalEvent}
<div class="parameter-info-label">Required</div>
<div class="parameter-info-value"><i>{required}</i></div>
{/if}
</div>
</div>
</ContextMenu>
Expand Down
1 change: 1 addition & 0 deletions src/types/parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type EffectiveArguments = {

export type FormParameter<T = ValueSchema> = {
errors: string[] | null;
externalEvent?: boolean;
file?: File;
index?: number;
key?: string;
Expand Down
1 change: 1 addition & 0 deletions src/utilities/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function getFormParameters(

const formParameter: FormParameter = {
errors: null,
externalEvent: true,
name,
order,
required,
Expand Down

0 comments on commit efc7a1d

Please sign in to comment.