Skip to content

Commit

Permalink
guard against trailing non-widget fields in EditFoo.svelte template, …
Browse files Browse the repository at this point in the history
…take 2
  • Loading branch information
pdaoust authored and ThetaSinner committed Nov 10, 2023
1 parent fce5add commit 9a7286d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
10 changes: 0 additions & 10 deletions src/scaffold/entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ pub fn scaffold_entry_type(
}
};

let widget_fields = fields
.iter()
.map(|f| f.clone())
.filter(|f| match f.widget {
Some(_) => true,
None => false
})
.collect();

let reference_entry_hash = match maybe_reference_entry_hash {
Some(r) => r.clone(),
None => {
Expand Down Expand Up @@ -156,7 +147,6 @@ pub fn scaffold_entry_type(
let entry_def = EntryDefinition {
name: name.clone(),
fields,
widget_fields,
reference_entry_hash,
};

Expand Down
1 change: 0 additions & 1 deletion src/scaffold/entry_type/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ impl Referenceable {
pub struct EntryDefinition {
pub name: String,
pub fields: Vec<FieldDefinition>,
pub widget_fields: Vec<FieldDefinition>,
pub reference_entry_hash: bool,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let {{camel_case field_name}}: Array<{{> (concat field_type.type "/type")}} | un
let errorSnackbar: Snackbar;
$: {{#each entry_type.widget_fields}}{{camel_case field_name}}{{#unless @last}}, {{/unless}}{{/each}};
$: {{#each (filter entry_type.fields "widget")}}{{camel_case field_name}}{{#unless @last}}, {{/unless}}{{/each}};
$: is{{pascal_case entry_type.name}}Valid = true{{#each entry_type.fields}}{{#if widget}}{{#if (eq cardinality "single")}} && {{> (concat field_type.type "/" widget "/is-valid") variable_to_validate=(camel_case field_name) }}{{/if}}{{#if (eq cardinality "vector")}} && {{camel_case field_name}}.every(e => {{> (concat field_type.type "/" widget "/is-valid") variable_to_validate="e" }}){{/if}}{{/if}}{{/each}};
onMount(() => {
Expand Down

0 comments on commit 9a7286d

Please sign in to comment.