From a2812ae4679fcbb108b36f77e33f9db4f69cb4b7 Mon Sep 17 00:00:00 2001 From: Collins Muriuki Date: Mon, 16 Dec 2024 19:31:46 +0300 Subject: [PATCH] feat: add u8 field type support (#433) * Add u8 field type * Represent Vec as a Uint8Array * Add u8 widgets * Fix misplaced lables * Fix svelte slider props * Ensure correct TS type is generated for Vec * Skip ui generation for Vec types --- src/scaffold/entry_type/definitions.rs | 20 ++++++++++++++----- src/scaffold/entry_type/fields.rs | 19 +++++++++++++----- templates/generic/field-types/Vec/type.hbs | 2 +- templates/generic/field-types/u8/default.hbs | 1 + templates/generic/field-types/u8/sample.hbs | 1 + templates/generic/field-types/u8/type.hbs | 1 + ...eate-{{kebab_case entry_type.name}}.ts.hbs | 12 ++++++++--- ...se entry_type.name}}.ts{{\302\241if}}.hbs" | 5 ++++- .../field-types/u8/Slider/detail/render.hbs | 1 + .../lit/field-types/u8/Slider/edit/render.hbs | 9 +++++++++ .../field-types/u8/Slider/initial-value.hbs | 1 + .../lit/field-types/u8/Slider/is-valid.hbs | 1 + ...ate{{pascal_case entry_type.name}}.tsx.hbs | 4 ++++ .../u8/NumberInput/detail/render.hbs | 1 + .../u8/NumberInput/edit/render.hbs | 2 ++ .../u8/NumberInput/initial-value.hbs | 1 + .../field-types/u8/NumberInput/is-valid.hbs | 1 + ...{{pascal_case entry_type.name}}.svelte.hbs | 8 ++++++++ ...ntry_type.name}}.svelte{{\302\241if}}.hbs" | 4 ++++ .../field-types/f32/Slider/edit/render.hbs | 2 +- .../field-types/i32/Slider/edit/render.hbs | 2 +- .../field-types/u32/Slider/edit/render.hbs | 2 +- .../field-types/u8/Slider/detail/render.hbs | 1 + .../field-types/u8/Slider/edit/render.hbs | 2 ++ .../field-types/u8/Slider/initial-value.hbs | 1 + .../svelte/field-types/u8/Slider/is-valid.hbs | 1 + ...ate{{pascal_case entry_type.name}}.vue.hbs | 6 +++++- ...e entry_type.name}}.vue{{\302\241if}}.hbs" | 4 ++++ .../field-types/f32/Slider/edit/render.hbs | 2 +- .../field-types/i32/Slider/edit/render.hbs | 2 +- .../field-types/u32/Slider/edit/render.hbs | 2 +- .../field-types/u8/Slider/detail/render.hbs | 1 + .../vue/field-types/u8/Slider/edit/render.hbs | 2 ++ .../field-types/u8/Slider/initial-value.hbs | 1 + .../vue/field-types/u8/Slider/is-valid.hbs | 1 + 35 files changed, 104 insertions(+), 22 deletions(-) create mode 100644 templates/generic/field-types/u8/default.hbs create mode 100644 templates/generic/field-types/u8/sample.hbs create mode 100644 templates/generic/field-types/u8/type.hbs create mode 100644 templates/ui-frameworks/lit/field-types/u8/Slider/detail/render.hbs create mode 100644 templates/ui-frameworks/lit/field-types/u8/Slider/edit/render.hbs create mode 100644 templates/ui-frameworks/lit/field-types/u8/Slider/initial-value.hbs create mode 100644 templates/ui-frameworks/lit/field-types/u8/Slider/is-valid.hbs create mode 100644 templates/ui-frameworks/react/field-types/u8/NumberInput/detail/render.hbs create mode 100644 templates/ui-frameworks/react/field-types/u8/NumberInput/edit/render.hbs create mode 100644 templates/ui-frameworks/react/field-types/u8/NumberInput/initial-value.hbs create mode 100644 templates/ui-frameworks/react/field-types/u8/NumberInput/is-valid.hbs create mode 100644 templates/ui-frameworks/svelte/field-types/u8/Slider/detail/render.hbs create mode 100644 templates/ui-frameworks/svelte/field-types/u8/Slider/edit/render.hbs create mode 100644 templates/ui-frameworks/svelte/field-types/u8/Slider/initial-value.hbs create mode 100644 templates/ui-frameworks/svelte/field-types/u8/Slider/is-valid.hbs create mode 100644 templates/ui-frameworks/vue/field-types/u8/Slider/detail/render.hbs create mode 100644 templates/ui-frameworks/vue/field-types/u8/Slider/edit/render.hbs create mode 100644 templates/ui-frameworks/vue/field-types/u8/Slider/initial-value.hbs create mode 100644 templates/ui-frameworks/vue/field-types/u8/Slider/is-valid.hbs diff --git a/src/scaffold/entry_type/definitions.rs b/src/scaffold/entry_type/definitions.rs index b3ea4be5e..66e58b104 100644 --- a/src/scaffold/entry_type/definitions.rs +++ b/src/scaffold/entry_type/definitions.rs @@ -20,6 +20,8 @@ pub enum FieldType { #[serde(rename = "bool")] Bool, String, + #[serde(rename = "u8")] + U8, #[serde(rename = "u32")] U32, #[serde(rename = "i32")] @@ -61,6 +63,7 @@ impl std::fmt::Display for FieldType { let str = match self { FieldType::Bool => "bool", FieldType::String => "String", + FieldType::U8 => "u8", FieldType::U32 => "u32", FieldType::I32 => "i32", FieldType::F32 => "f32", @@ -81,6 +84,7 @@ impl FieldType { vec![ FieldType::String, FieldType::Bool, + FieldType::U8, FieldType::U32, FieldType::I32, FieldType::F32, @@ -121,6 +125,7 @@ impl FieldType { match self { Bool => quote!(bool), String => quote!(String), + U8 => quote!(u8), U32 => quote!(u32), I32 => quote!(i32), F32 => quote!(f32), @@ -143,6 +148,7 @@ impl FieldType { match self { Bool => "boolean", String => "string", + U8 => "number", U32 => "number", I32 => "number", F32 => "number", @@ -515,11 +521,15 @@ impl EntryDefinition { ts_type ), Cardinality::Vector => { - format!( - " {}: Array<{}>;", - &field.field_name.to_case(Case::Snake), - ts_type - ) + if matches!(field.field_type, FieldType::U8) { + format!(" {}: Uint8Array;", &field.field_name.to_case(Case::Snake),) + } else { + format!( + " {}: Array<{}>;", + &field.field_name.to_case(Case::Snake), + ts_type + ) + } } }; ts_interface.push_str(&ts_field); diff --git a/src/scaffold/entry_type/fields.rs b/src/scaffold/entry_type/fields.rs index 3993665ac..e6a23306c 100644 --- a/src/scaffold/entry_type/fields.rs +++ b/src/scaffold/entry_type/fields.rs @@ -247,7 +247,7 @@ fn choose_field( } let widget = (!no_ui) - .then(|| choose_widget(&field_type, field_types_templates)) + .then(|| choose_widget(&field_type, &cardinality, field_types_templates)) .transpose()? .flatten(); @@ -338,7 +338,7 @@ fn choose_field( }; let widget = (!no_ui) - .then(|| choose_widget(&field_type, field_types_templates)) + .then(|| choose_widget(&field_type, &cardinality, field_types_templates)) .transpose()? .flatten(); @@ -347,6 +347,7 @@ fn choose_field( fn choose_widget( field_type: &FieldType, + cardinality: &Cardinality, field_types_templates: &FileTree, ) -> ScaffoldResult> { let path = PathBuf::new().join(field_type.to_string()); @@ -364,9 +365,17 @@ fn choose_widget( return Ok(None); } - let should_scaffold_ui = Confirm::with_theme(&ColorfulTheme::default()) - .with_prompt("Should UI be generated for this field?") - .interact()?; + let should_scaffold_ui = { + // Skip widget prompt for Vec field types + if matches!(field_type, FieldType::U8) && matches!(cardinality, Cardinality::Vector) + { + false + } else { + Confirm::with_theme(&ColorfulTheme::default()) + .with_prompt("Should UI be generated for this field?") + .interact()? + } + }; if !should_scaffold_ui { return Ok(None); diff --git a/templates/generic/field-types/Vec/type.hbs b/templates/generic/field-types/Vec/type.hbs index 44a00abfa..c3c9d97df 100644 --- a/templates/generic/field-types/Vec/type.hbs +++ b/templates/generic/field-types/Vec/type.hbs @@ -1 +1 @@ -Array<{{field_type.type}}> \ No newline at end of file +{{#if (eq field_type.type "u8")}}Uint8Array{{else}}Array<{{field_type.type}}>{{/if}} \ No newline at end of file diff --git a/templates/generic/field-types/u8/default.hbs b/templates/generic/field-types/u8/default.hbs new file mode 100644 index 000000000..16b2eb52b --- /dev/null +++ b/templates/generic/field-types/u8/default.hbs @@ -0,0 +1 @@ +{{#if (eq cardinality "vector")}}[]{{else}}0{{/if}} \ No newline at end of file diff --git a/templates/generic/field-types/u8/sample.hbs b/templates/generic/field-types/u8/sample.hbs new file mode 100644 index 000000000..9a037142a --- /dev/null +++ b/templates/generic/field-types/u8/sample.hbs @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/templates/generic/field-types/u8/type.hbs b/templates/generic/field-types/u8/type.hbs new file mode 100644 index 000000000..0dfad6f42 --- /dev/null +++ b/templates/generic/field-types/u8/type.hbs @@ -0,0 +1 @@ +number \ No newline at end of file diff --git a/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/create-{{kebab_case entry_type.name}}.ts.hbs b/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/create-{{kebab_case entry_type.name}}.ts.hbs index 7ef1c70b7..94053c5df 100644 --- a/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/create-{{kebab_case entry_type.name}}.ts.hbs +++ b/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/create-{{kebab_case entry_type.name}}.ts.hbs @@ -29,10 +29,13 @@ export class Create{{pascal_case entry_type.name}} extends LitElement { {{#if (eq cardinality "option")}} @property() {{camel_case field_name}}: {{> (concat field_type.type "/type") }} | undefined; - {{else}} @property() + {{else}} + {{#if (eq field_type.type "u8")}} + {{camel_case field_name}}!: Uint8Array; + {{else}} {{camel_case field_name}}!: Array<{{> (concat field_type.type "/type") }}>; - + {{/if}} {{/if}} {{/if}} {{/if}} @@ -46,8 +49,11 @@ export class Create{{pascal_case entry_type.name}} extends LitElement { {{else}} @state() + {{#if (eq field_type.type "u8")}} + _{{camel_case field_name}}: Uint8Array = [{{> (concat field_type.type "/" widget "/initial-value") field_type=field_type}}]; + {{else}} _{{camel_case field_name}}: Array<{{> (concat field_type.type "/type") }}> = [{{> (concat field_type.type "/" widget "/initial-value") field_type=field_type}}]; - + {{/if}} {{/if}} {{/if}} {{/each}} diff --git "a/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}edit-{{kebab_case entry_type.name}}.ts{{\302\241if}}.hbs" "b/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}edit-{{kebab_case entry_type.name}}.ts{{\302\241if}}.hbs" index e36cc741a..a0a6c665e 100644 --- "a/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}edit-{{kebab_case entry_type.name}}.ts{{\302\241if}}.hbs" +++ "b/templates/ui-frameworks/lit/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}edit-{{kebab_case entry_type.name}}.ts{{\302\241if}}.hbs" @@ -45,8 +45,11 @@ export class Edit{{pascal_case entry_type.name}} extends LitElement { {{else}} @state() + {{#if (eq field_type.type "u8")}} + _{{camel_case field_name}}: Uint8Array = this.current{{pascal_case ../entry_type.name}}.{{snake_case field_name}}; + {{else}} _{{camel_case field_name}}: Array<{{> (concat field_type.type "/type") }}> = this.current{{pascal_case ../entry_type.name}}.{{snake_case field_name}}; - + {{/if}} {{/if}} {{/if}} {{/each}} diff --git a/templates/ui-frameworks/lit/field-types/u8/Slider/detail/render.hbs b/templates/ui-frameworks/lit/field-types/u8/Slider/detail/render.hbs new file mode 100644 index 000000000..b82c4a0a1 --- /dev/null +++ b/templates/ui-frameworks/lit/field-types/u8/Slider/detail/render.hbs @@ -0,0 +1 @@ +${ {{variable_to_read}} } \ No newline at end of file diff --git a/templates/ui-frameworks/lit/field-types/u8/Slider/edit/render.hbs b/templates/ui-frameworks/lit/field-types/u8/Slider/edit/render.hbs new file mode 100644 index 000000000..399c92af9 --- /dev/null +++ b/templates/ui-frameworks/lit/field-types/u8/Slider/edit/render.hbs @@ -0,0 +1,9 @@ + + { {{variable_to_change}} = e.detail.value; } } +> \ No newline at end of file diff --git a/templates/ui-frameworks/lit/field-types/u8/Slider/initial-value.hbs b/templates/ui-frameworks/lit/field-types/u8/Slider/initial-value.hbs new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/templates/ui-frameworks/lit/field-types/u8/Slider/initial-value.hbs @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/templates/ui-frameworks/lit/field-types/u8/Slider/is-valid.hbs b/templates/ui-frameworks/lit/field-types/u8/Slider/is-valid.hbs new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/templates/ui-frameworks/lit/field-types/u8/Slider/is-valid.hbs @@ -0,0 +1 @@ +true diff --git a/templates/ui-frameworks/react/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.tsx.hbs b/templates/ui-frameworks/react/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.tsx.hbs index 3b5e80733..1d052a83c 100644 --- a/templates/ui-frameworks/react/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.tsx.hbs +++ b/templates/ui-frameworks/react/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.tsx.hbs @@ -76,7 +76,11 @@ interface Create{{pascal_case entry_type.name}}Props { {{#each entry_type.fields}} {{#if (not widget) }} {{#if (eq cardinality "vector")}} + {{#if (eq field_type.type "u8")}} + {{camel_case field_name}}: Uint8Array, + {{else}} {{camel_case field_name}}: {{> (concat field_type.type "/type") }}[], + {{/if}} {{else}} {{camel_case field_name}}{{#if (eq cardinality "single")}}{{/if}}: {{> (concat field_type.type "/type") }}{{#if (eq cardinality "option")}} | undefined{{/if}}, {{/if}} diff --git a/templates/ui-frameworks/react/field-types/u8/NumberInput/detail/render.hbs b/templates/ui-frameworks/react/field-types/u8/NumberInput/detail/render.hbs new file mode 100644 index 000000000..defd9c7a6 --- /dev/null +++ b/templates/ui-frameworks/react/field-types/u8/NumberInput/detail/render.hbs @@ -0,0 +1 @@ +{ {{variable_to_read}} } diff --git a/templates/ui-frameworks/react/field-types/u8/NumberInput/edit/render.hbs b/templates/ui-frameworks/react/field-types/u8/NumberInput/edit/render.hbs new file mode 100644 index 000000000..91d1346cc --- /dev/null +++ b/templates/ui-frameworks/react/field-types/u8/NumberInput/edit/render.hbs @@ -0,0 +1,2 @@ + + set{{pascal_case variable_to_change}}(parseInt(e.target.value))} min="0" max="255" /> \ No newline at end of file diff --git a/templates/ui-frameworks/react/field-types/u8/NumberInput/initial-value.hbs b/templates/ui-frameworks/react/field-types/u8/NumberInput/initial-value.hbs new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/templates/ui-frameworks/react/field-types/u8/NumberInput/initial-value.hbs @@ -0,0 +1 @@ +0 diff --git a/templates/ui-frameworks/react/field-types/u8/NumberInput/is-valid.hbs b/templates/ui-frameworks/react/field-types/u8/NumberInput/is-valid.hbs new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/templates/ui-frameworks/react/field-types/u8/NumberInput/is-valid.hbs @@ -0,0 +1 @@ +true diff --git a/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs b/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs index a0c7a6edf..d80c1a73d 100644 --- a/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs +++ b/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs @@ -21,7 +21,11 @@ const appClientContext = getContext(clientContext); {{#if (not (eq cardinality "vector" ) )}} let {{camel_case field_name}}: {{> (concat field_type.type "/type") }}{{#if (eq cardinality "option")}} | undefined{{/if}} = {{> (concat field_type.type "/" widget "/initial-value") field_type=field_type}}; {{else}} + {{#if (eq field_type.type "u8")}} +let {{camel_case field_name}}: Uint8Array = [{{> (concat field_type.type "/" widget "/initial-value") field_type=field_type}}]; + {{else}} let {{camel_case field_name}}: Array<{{> (concat field_type.type "/type")}}> = [{{> (concat field_type.type "/" widget "/initial-value") field_type=field_type}}]; + {{/if}} {{/if}} {{/if}} {{/each}} @@ -29,7 +33,11 @@ let {{camel_case field_name}}: Array<{{> (concat field_type.type "/type")}}> = [ {{#each entry_type.fields}} {{#if (not widget) }} {{#if (eq cardinality "vector")}} + {{#if (eq field_type.type "u8")}} +export let {{camel_case field_name}}!: Uint8Array; + {{else}} export let {{camel_case field_name}}!: Array<{{> (concat field_type.type "/type") }}>; + {{/if}} {{else}} export let {{camel_case field_name}}{{#if (eq cardinality "single")}}!{{/if}}: {{> (concat field_type.type "/type") }}{{#if (eq cardinality "option")}} | undefined{{/if}}; {{/if}} diff --git "a/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.svelte{{\302\241if}}.hbs" "b/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.svelte{{\302\241if}}.hbs" index e3649462c..c578663a4 100644 --- "a/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.svelte{{\302\241if}}.hbs" +++ "b/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.svelte{{\302\241if}}.hbs" @@ -28,7 +28,11 @@ let current{{pascal_case entry_type.name}}: {{pascal_case entry_type.name}} = de {{#if (not (eq cardinality "vector" ) )}} let {{camel_case field_name}}: {{> (concat field_type.type "/type")}} | undefined = current{{pascal_case ../entry_type.name}}.{{snake_case field_name}}; {{else}} + {{#if (eq field_type.type "u8")}} +let {{camel_case field_name}}: Uint8Array | undefined> = current{{pascal_case ../entry_type.name}}.{{snake_case field_name}}; + {{else}} let {{camel_case field_name}}: Array<{{> (concat field_type.type "/type")}} | undefined> = current{{pascal_case ../entry_type.name}}.{{snake_case field_name}}; + {{/if}} {{/if}} {{/if}} {{/each}} diff --git a/templates/ui-frameworks/svelte/field-types/f32/Slider/edit/render.hbs b/templates/ui-frameworks/svelte/field-types/f32/Slider/edit/render.hbs index 1f2d832d7..38f1d68ca 100644 --- a/templates/ui-frameworks/svelte/field-types/f32/Slider/edit/render.hbs +++ b/templates/ui-frameworks/svelte/field-types/f32/Slider/edit/render.hbs @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/ui-frameworks/svelte/field-types/i32/Slider/edit/render.hbs b/templates/ui-frameworks/svelte/field-types/i32/Slider/edit/render.hbs index c400e82db..d6faa9f4d 100644 --- a/templates/ui-frameworks/svelte/field-types/i32/Slider/edit/render.hbs +++ b/templates/ui-frameworks/svelte/field-types/i32/Slider/edit/render.hbs @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/ui-frameworks/svelte/field-types/u32/Slider/edit/render.hbs b/templates/ui-frameworks/svelte/field-types/u32/Slider/edit/render.hbs index cf48cd881..38f1d68ca 100644 --- a/templates/ui-frameworks/svelte/field-types/u32/Slider/edit/render.hbs +++ b/templates/ui-frameworks/svelte/field-types/u32/Slider/edit/render.hbs @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/ui-frameworks/svelte/field-types/u8/Slider/detail/render.hbs b/templates/ui-frameworks/svelte/field-types/u8/Slider/detail/render.hbs new file mode 100644 index 000000000..defd9c7a6 --- /dev/null +++ b/templates/ui-frameworks/svelte/field-types/u8/Slider/detail/render.hbs @@ -0,0 +1 @@ +{ {{variable_to_read}} } diff --git a/templates/ui-frameworks/svelte/field-types/u8/Slider/edit/render.hbs b/templates/ui-frameworks/svelte/field-types/u8/Slider/edit/render.hbs new file mode 100644 index 000000000..f54711c14 --- /dev/null +++ b/templates/ui-frameworks/svelte/field-types/u8/Slider/edit/render.hbs @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/templates/ui-frameworks/svelte/field-types/u8/Slider/initial-value.hbs b/templates/ui-frameworks/svelte/field-types/u8/Slider/initial-value.hbs new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/templates/ui-frameworks/svelte/field-types/u8/Slider/initial-value.hbs @@ -0,0 +1 @@ +0 diff --git a/templates/ui-frameworks/svelte/field-types/u8/Slider/is-valid.hbs b/templates/ui-frameworks/svelte/field-types/u8/Slider/is-valid.hbs new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/templates/ui-frameworks/svelte/field-types/u8/Slider/is-valid.hbs @@ -0,0 +1 @@ +true diff --git a/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.vue.hbs b/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.vue.hbs index fd09891c3..7070a616e 100644 --- a/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.vue.hbs +++ b/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.vue.hbs @@ -40,8 +40,12 @@ export default defineComponent({ {{#if (not (eq cardinality "vector" ) )}} {{camel_case field_name}}: {{> (concat field_type.type "/type")}}{{#if (eq cardinality "option")}}| undefined{{/if}}; {{else}} + {{#if (eq field_type.type "u8")}} + {{camel_case field_name}}: Uint8Array; + {{else}} {{camel_case field_name}}: Array<{{> (concat field_type.type "/type")}}>; {{/if}} + {{/if}} {{/if}} {{/each}} } { @@ -102,7 +106,7 @@ export default defineComponent({ {{#if (eq cardinality "single") }} {{snake_case field_name}}: this.{{camel_case field_name}}!, {{else}} - {{snake_case field_name}}: this.{{camel_case field_name}}{{#if (eq cardinality "vector") }} as Array<{{> (concat field_type.type "/type") }}>{{/if}}, + {{snake_case field_name}}: this.{{camel_case field_name}}{{#if (eq cardinality "vector") }}{{#if field_type.type "u8"}} as Uint8Array{{else}}as Array<{{> (concat field_type.type "/type") }}>{{/if}}{{/if}}, {{/if}} {{/each}} }; diff --git "a/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.vue{{\302\241if}}.hbs" "b/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.vue{{\302\241if}}.hbs" index cca770035..855cd1183 100644 --- "a/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.vue{{\302\241if}}.hbs" +++ "b/templates/ui-frameworks/vue/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if crud.update}}Edit{{pascal_case entry_type.name}}.vue{{\302\241if}}.hbs" @@ -43,7 +43,11 @@ export default defineComponent({ {{#if (not (eq cardinality "vector" ) )}} {{camel_case field_name}}: {{> (concat field_type.type "/type")}}; {{else}} + {{#if (eq field_type.type "u8")}} + {{camel_case field_name}}: Uint8Array; + {{else}} {{camel_case field_name}}: Array<{{> (concat field_type.type "/type")}}>; + {{/if}} {{/if}} {{/if}} {{/each}} diff --git a/templates/ui-frameworks/vue/field-types/f32/Slider/edit/render.hbs b/templates/ui-frameworks/vue/field-types/f32/Slider/edit/render.hbs index d63288e75..486a56496 100644 --- a/templates/ui-frameworks/vue/field-types/f32/Slider/edit/render.hbs +++ b/templates/ui-frameworks/vue/field-types/f32/Slider/edit/render.hbs @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/ui-frameworks/vue/field-types/i32/Slider/edit/render.hbs b/templates/ui-frameworks/vue/field-types/i32/Slider/edit/render.hbs index 02b9636ab..a8ec98161 100644 --- a/templates/ui-frameworks/vue/field-types/i32/Slider/edit/render.hbs +++ b/templates/ui-frameworks/vue/field-types/i32/Slider/edit/render.hbs @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/ui-frameworks/vue/field-types/u32/Slider/edit/render.hbs b/templates/ui-frameworks/vue/field-types/u32/Slider/edit/render.hbs index d63288e75..486a56496 100644 --- a/templates/ui-frameworks/vue/field-types/u32/Slider/edit/render.hbs +++ b/templates/ui-frameworks/vue/field-types/u32/Slider/edit/render.hbs @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/ui-frameworks/vue/field-types/u8/Slider/detail/render.hbs b/templates/ui-frameworks/vue/field-types/u8/Slider/detail/render.hbs new file mode 100644 index 000000000..1d0a09daf --- /dev/null +++ b/templates/ui-frameworks/vue/field-types/u8/Slider/detail/render.hbs @@ -0,0 +1 @@ +{{{{raw}}}} {{ {{{{/raw}}}} {{variable_to_read}} {{{{raw}}}} }} {{{{/raw}}}} \ No newline at end of file diff --git a/templates/ui-frameworks/vue/field-types/u8/Slider/edit/render.hbs b/templates/ui-frameworks/vue/field-types/u8/Slider/edit/render.hbs new file mode 100644 index 000000000..b53495028 --- /dev/null +++ b/templates/ui-frameworks/vue/field-types/u8/Slider/edit/render.hbs @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/templates/ui-frameworks/vue/field-types/u8/Slider/initial-value.hbs b/templates/ui-frameworks/vue/field-types/u8/Slider/initial-value.hbs new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/templates/ui-frameworks/vue/field-types/u8/Slider/initial-value.hbs @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/templates/ui-frameworks/vue/field-types/u8/Slider/is-valid.hbs b/templates/ui-frameworks/vue/field-types/u8/Slider/is-valid.hbs new file mode 100644 index 000000000..f32a5804e --- /dev/null +++ b/templates/ui-frameworks/vue/field-types/u8/Slider/is-valid.hbs @@ -0,0 +1 @@ +true \ No newline at end of file