-
-
-
- {{#if crud.update}}
- { this._editing = true; } }>
- {{/if}}
- {{#if crud.delete}}
- this.delete{{pascal_case entry_type.name}}()}>
- {{/if}}
-
-
+ return html`
+
{{#each entry_type.fields}}
{{#if widget}}
{{#if (not (eq cardinality "vector") )}}
-
-
{{title_case field_name}}:
-
{{> (concat field_type.type "/" widget "/detail/render") variable_to_read=(concat (camel_case ../entry_type.name) "." (snake_case field_name) ) }}
+
+ {{title_case field_name}}:
+ {{> (concat field_type.type "/" widget "/detail/render") variable_to_read=(concat (camel_case ../entry_type.name) "." (snake_case field_name) ) }}
{{else}}
{{> Vec/detail/render variable_to_read=(concat (camel_case ../entry_type.name) "." (snake_case field_name) ) field_name=field_name field_type=field_type widget=widget }}
{{/if}}
-
{{/if}}
{{/each}}
-
+
+
+{{#if crud.update}}
+
+{{/if}}
+{{#if crud.delete}}
+
+{{/if}}
+
+
`;
}
render{{pascal_case entry_type.name}}(record: Record | undefined) {
- if (!record) return html`
The requested {{lower_case entry_type.name}} was not found.`;
-
+ if (!record) return html`
The requested {{lower_case entry_type.name}} was not found.
`;
{{#if crud.update}}
if (this._editing) {
- return html`
{
- this._editing = false;
- await this._fetchRecord.run();
- } }
- @edit-canceled=${() => { this._editing = false; } }
- style="display: flex; flex: 1;"
- >`;
+ return html`
+
{
+ this._editing = false;
+ await this._fetchRecord.run();
+ } }
+ @edit-canceled=${() => { this._editing = false; } }
+ >
+ `;
}
-
{{/if}}
return this.renderDetail(record);
}
render() {
return this._fetchRecord.render({
- pending: () => html`
-
-
`,
+ pending: () => html`
`,
complete: (record) => this.render{{pascal_case entry_type.name}}(record),
- error: (e: any) => html`
Error fetching the {{lower_case entry_type.name}}: ${e.message}`
+ error: (e: any) => html`
Error fetching the {{lower_case entry_type.name}}: ${e.message}
`
});
}
-}
+
+ static styles = sharedStyles;
+}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/example.instructions.hbs b/templates/custom-template/custom-template/template/example.instructions.hbs
index 3ac12f06d..cfdf10efd 100644
--- a/templates/custom-template/custom-template/template/example.instructions.hbs
+++ b/templates/custom-template/custom-template/template/example.instructions.hbs
@@ -1,6 +1,10 @@
Run the example app with:
cd {{example}}
- nix develop
- npm install
- npm start
+ nix develop
+ {{(package_manager_command package_manager "install" null)}}
+ {{(package_manager_command package_manager "start" null)}}
+
+Generated ui code might also need to be reformatted:
+
+ {{(package_manager_command package_manager "format" "ui")}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/example/ui/src/holochain-app.ts.hbs b/templates/custom-template/custom-template/template/example/ui/src/holochain-app.ts.hbs
index fb9c9c9b4..58eee306c 100644
--- a/templates/custom-template/custom-template/template/example/ui/src/holochain-app.ts.hbs
+++ b/templates/custom-template/custom-template/template/example/ui/src/holochain-app.ts.hbs
@@ -1,75 +1,43 @@
-import { LitElement, css, html } from 'lit';
+import { LitElement, html, css, unsafeCSS } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { AppClient, AppWebsocket } from '@holochain/client';
import { provide } from '@lit-labs/context';
+import sharedStyles from './index.css';
import { clientContext } from './contexts';
import './forum/posts/all-posts';
-import { AllPosts } from './forum/posts/all-posts';
import './forum/posts/create-post';
@customElement('holochain-app')
export class HolochainApp extends LitElement {
- @state() loading = true;
-
- @state() result: string | undefined;
+ @state() loading = false;
@provide({ context: clientContext })
@property({ type: Object })
client!: AppClient;
async firstUpdated() {
- this.client = await AppWebsocket.connect();
-
- this.loading = false;
+ this.loading = true;
+ try {
+ this.client = await AppWebsocket.connect();
+ } catch(e) {
+ console.error(e)
+ } finally {
+ this.loading = false;
+ }
}
render() {
- if (this.loading)
- return html`
-
- `;
-
+ if (this.loading) return html`
`;
return html`
-
- Forum
-
-
-
+
+
Welcome to the Forum hApp
+
+
+
`;
}
- static styles = css`
- :host {
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: flex-start;
- font-size: calc(10px + 2vmin);
- color: #1a2b42;
- max-width: 960px;
- margin: 0 auto;
- text-align: center;
- background-color: var(--lit-element-background-color);
- }
-
- main {
- flex-grow: 1;
- }
-
- .app-footer {
- font-size: calc(12px + 0.5vmin);
- align-items: center;
- }
-
- .app-footer a {
- margin-left: 5px;
- }
- `;
-}
+ static styles = css`${unsafeCSS(sharedStyles)}`;
+}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/ActionHash/sample.hbs b/templates/custom-template/custom-template/template/field-types/ActionHash/sample.hbs
index 62bb9db14..3d318bd7c 100644
--- a/templates/custom-template/custom-template/template/field-types/ActionHash/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/ActionHash/sample.hbs
@@ -1 +1 @@
-(await fakeActionHash())
+(await fakeActionHash())
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/ActionHash/type.hbs b/templates/custom-template/custom-template/template/field-types/ActionHash/type.hbs
index a00d2d429..339425a42 100644
--- a/templates/custom-template/custom-template/template/field-types/ActionHash/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/ActionHash/type.hbs
@@ -1 +1 @@
-ActionHash
+ActionHash
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/AgentPubKey/sample.hbs b/templates/custom-template/custom-template/template/field-types/AgentPubKey/sample.hbs
index 98a2ed787..2ad640d28 100644
--- a/templates/custom-template/custom-template/template/field-types/AgentPubKey/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/AgentPubKey/sample.hbs
@@ -1 +1 @@
-(await fakeAgentPubKey())
+(await fakeAgentPubKey())
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/AgentPubKey/type.hbs b/templates/custom-template/custom-template/template/field-types/AgentPubKey/type.hbs
index f25075ccb..fe408746c 100644
--- a/templates/custom-template/custom-template/template/field-types/AgentPubKey/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/AgentPubKey/type.hbs
@@ -1 +1 @@
-AgentPubKey
+AgentPubKey
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/DnaHash/sample.hbs b/templates/custom-template/custom-template/template/field-types/DnaHash/sample.hbs
index 9369d2e2b..19e7efd04 100644
--- a/templates/custom-template/custom-template/template/field-types/DnaHash/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/DnaHash/sample.hbs
@@ -1 +1 @@
-(await fakeDnaHash())
+(await fakeDnaHash())
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/DnaHash/type.hbs b/templates/custom-template/custom-template/template/field-types/DnaHash/type.hbs
index c0e9d7168..3551c1f2c 100644
--- a/templates/custom-template/custom-template/template/field-types/DnaHash/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/DnaHash/type.hbs
@@ -1 +1 @@
-DnaHash
+DnaHash
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/EntryHash/sample.hbs b/templates/custom-template/custom-template/template/field-types/EntryHash/sample.hbs
index 5f7895b86..f1f27ff28 100644
--- a/templates/custom-template/custom-template/template/field-types/EntryHash/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/EntryHash/sample.hbs
@@ -1 +1 @@
-(await fakeEntryHash())
+(await fakeEntryHash())
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/EntryHash/type.hbs b/templates/custom-template/custom-template/template/field-types/EntryHash/type.hbs
index b97d6b80e..9a4e496c5 100644
--- a/templates/custom-template/custom-template/template/field-types/EntryHash/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/EntryHash/type.hbs
@@ -1 +1 @@
-EntryHash
+EntryHash
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/Select/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/Enum/Select/detail/render.hbs
index bfaf687c2..2bdebc1aa 100644
--- a/templates/custom-template/custom-template/template/field-types/Enum/Select/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Enum/Select/detail/render.hbs
@@ -1 +1 @@
-${ {{#each field_type.variants}}{{#unless @last}} {{../variable_to_read}}.type === '{{pascal_case this}}' ?{{/unless}} `{{title_case this}}`{{#unless @last}} :{{/unless}} {{/each}} }
+${ {{#each field_type.variants}}{{#unless @last}} {{../variable_to_read}}.type === '{{pascal_case this}}' ?{{/unless}} `{{title_case this}}`{{#unless @last}} :{{/unless}} {{/each}} }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/imports.hbs
deleted file mode 100644
index 171161339..000000000
--- a/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@material/mwc-select';
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/render.hbs
index c1f8d52f4..81534064b 100644
--- a/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Enum/Select/edit/render.hbs
@@ -1,5 +1,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/Select/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/Enum/Select/initial-value.hbs
index 560b9ff7e..214893c2e 100644
--- a/templates/custom-template/custom-template/template/field-types/Enum/Select/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Enum/Select/initial-value.hbs
@@ -1 +1 @@
-{ type: '{{lookup field_type.variants 0}}' }
+{ type: '{{lookup field_type.variants 0}}' }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/Select/is-valid.hbs b/templates/custom-template/custom-template/template/field-types/Enum/Select/is-valid.hbs
index 27ba77dda..f32a5804e 100644
--- a/templates/custom-template/custom-template/template/field-types/Enum/Select/is-valid.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Enum/Select/is-valid.hbs
@@ -1 +1 @@
-true
+true
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/default.hbs b/templates/custom-template/custom-template/template/field-types/Enum/default.hbs
new file mode 100644
index 000000000..214893c2e
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/Enum/default.hbs
@@ -0,0 +1 @@
+{ type: '{{lookup field_type.variants 0}}' }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/sample.hbs b/templates/custom-template/custom-template/template/field-types/Enum/sample.hbs
index 560b9ff7e..214893c2e 100644
--- a/templates/custom-template/custom-template/template/field-types/Enum/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Enum/sample.hbs
@@ -1 +1 @@
-{ type: '{{lookup field_type.variants 0}}' }
+{ type: '{{lookup field_type.variants 0}}' }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Enum/type.hbs b/templates/custom-template/custom-template/template/field-types/Enum/type.hbs
index e9b80fff9..798c93ded 100644
--- a/templates/custom-template/custom-template/template/field-types/Enum/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Enum/type.hbs
@@ -1 +1 @@
-{{pascal_case field_type.label}}
+{{pascal_case field_type.label}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextArea/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/String/TextArea/detail/render.hbs
index 433f42b69..b82c4a0a1 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextArea/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextArea/detail/render.hbs
@@ -1 +1 @@
-${ {{variable_to_read}} }
+${ {{variable_to_read}} }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/imports.hbs
deleted file mode 100644
index 01d0786c1..000000000
--- a/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@material/mwc-textarea';
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/render.hbs
index cd25d12f4..5823114e1 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextArea/edit/render.hbs
@@ -1 +1,11 @@
-
{ {{variable_to_change}} = (e.target as any).value;} } {{#if required}}required{{/if}}>
+
+
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextArea/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/String/TextArea/initial-value.hbs
index a614936fa..942309095 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextArea/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextArea/initial-value.hbs
@@ -1 +1 @@
-''
+''
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextArea/is-valid.hbs b/templates/custom-template/custom-template/template/field-types/String/TextArea/is-valid.hbs
index a9e6c9814..e3891233e 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextArea/is-valid.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextArea/is-valid.hbs
@@ -1 +1 @@
-{{variable_to_validate}} !== ''
+{{variable_to_validate}} !== ''
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextField/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/String/TextField/detail/render.hbs
index 433f42b69..b82c4a0a1 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextField/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextField/detail/render.hbs
@@ -1 +1 @@
-${ {{variable_to_read}} }
+${ {{variable_to_read}} }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextField/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/String/TextField/edit/imports.hbs
deleted file mode 100644
index 0572528d4..000000000
--- a/templates/custom-template/custom-template/template/field-types/String/TextField/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@material/mwc-textfield';
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextField/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/String/TextField/edit/render.hbs
index 38869aa15..5311bf73b 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextField/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextField/edit/render.hbs
@@ -1 +1,11 @@
-
{ {{variable_to_change}} = (e.target as any).value; } } {{#if required}}required{{/if}}>
+
+
{ {{variable_to_change}} = (e.target as any).value; } }
+ {{#if required}}
+ required
+ {{/if}}
+>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextField/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/String/TextField/initial-value.hbs
index a614936fa..942309095 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextField/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextField/initial-value.hbs
@@ -1 +1 @@
-''
+''
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/TextField/is-valid.hbs b/templates/custom-template/custom-template/template/field-types/String/TextField/is-valid.hbs
index a9e6c9814..e3891233e 100644
--- a/templates/custom-template/custom-template/template/field-types/String/TextField/is-valid.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/TextField/is-valid.hbs
@@ -1 +1 @@
-{{variable_to_validate}} !== ''
+{{variable_to_validate}} !== ''
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/default.hbs b/templates/custom-template/custom-template/template/field-types/String/default.hbs
new file mode 100644
index 000000000..5de6da439
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/String/default.hbs
@@ -0,0 +1 @@
+{{#if (eq cardinality "vector")}}[]{{else}}""{{/if}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/sample.hbs b/templates/custom-template/custom-template/template/field-types/String/sample.hbs
index 56b4c51a6..f128f21fd 100644
--- a/templates/custom-template/custom-template/template/field-types/String/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/sample.hbs
@@ -1 +1 @@
-"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
+"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/String/type.hbs b/templates/custom-template/custom-template/template/field-types/String/type.hbs
index ee8a39c38..ec186f1f3 100644
--- a/templates/custom-template/custom-template/template/field-types/String/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/String/type.hbs
@@ -1 +1 @@
-string
+string
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/detail/render.hbs
index 537195405..322138be4 100644
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/detail/render.hbs
@@ -1 +1 @@
-${new Date({{variable_to_read}} / 1000).toLocaleString() }
+${new Date({{variable_to_read}} / 1000).toLocaleString() }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/imports.hbs
deleted file mode 100644
index f8705a0ed..000000000
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@vaadin/date-time-picker/theme/material/vaadin-date-time-picker.js';
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/render.hbs
index 6197e2383..97e59e87e 100644
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/edit/render.hbs
@@ -1 +1,12 @@
-
{ {{variable_to_change}} = new Date((e.target as any).value).valueOf() * 1000;} } {{#if required}}required{{/if}}>
\ No newline at end of file
+
+
{ {{variable_to_change}} = Math.floor(new Date(e.target.value).getTime() / 1000); } }
+ {{#if required}}
+ required
+ {{/if}}
+>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/initial-value.hbs
index 56bfef5d4..e32bcd5fd 100644
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/initial-value.hbs
@@ -1 +1 @@
-Date.now()
+Date.now()
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/is-valid.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/is-valid.hbs
index 27ba77dda..f32a5804e 100644
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/is-valid.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/DateTimePicker/is-valid.hbs
@@ -1 +1 @@
-true
+true
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/default.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/default.hbs
new file mode 100644
index 000000000..1b4b0c67a
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/default.hbs
@@ -0,0 +1 @@
+Date.now() * 1000
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/sample.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/sample.hbs
index ed20776b5..e82254249 100644
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/sample.hbs
@@ -1 +1 @@
-1674053334548000
+1674053334548000
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Timestamp/type.hbs b/templates/custom-template/custom-template/template/field-types/Timestamp/type.hbs
index b67e17aeb..0dfad6f42 100644
--- a/templates/custom-template/custom-template/template/field-types/Timestamp/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Timestamp/type.hbs
@@ -1 +1 @@
-number
+number
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Vec/default.hbs b/templates/custom-template/custom-template/template/field-types/Vec/default.hbs
new file mode 100644
index 000000000..0637a088a
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/Vec/default.hbs
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Vec/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/Vec/detail/render.hbs
deleted file mode 100644
index 6b1b24b2b..000000000
--- a/templates/custom-template/custom-template/template/field-types/Vec/detail/render.hbs
+++ /dev/null
@@ -1,4 +0,0 @@
-
- {{title_case field_name}}
- ${ {{variable_to_read}}.map(el => html`{{> (concat field_type.type "/" widget "/detail/render") variable_to_read="el"}}`)}
-
diff --git a/templates/custom-template/custom-template/template/field-types/Vec/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/Vec/edit/render.hbs
deleted file mode 100644
index 96ec1f455..000000000
--- a/templates/custom-template/custom-template/template/field-types/Vec/edit/render.hbs
+++ /dev/null
@@ -1,6 +0,0 @@
-
this.requestUpdate()} @change=${() => this.requestUpdate()}>
- {{title_case field_name}}
-
- ${this._{{camel_case field_name}}.map((el, i) => html`{{> (concat field_type.type "/" widget "/edit/render") label="" variable_to_read="el" variable_to_change=(concat "this._" (camel_case field_name) "[i]" ) }} }`)}
- { this._{{camel_case field_name}} = [...this._{{camel_case field_name}}, {{> (concat field_type.type "/" widget "/initial-value") field_type=field_type}}]; } }>
-
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Vec/sample.hbs b/templates/custom-template/custom-template/template/field-types/Vec/sample.hbs
new file mode 100644
index 000000000..0637a088a
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/Vec/sample.hbs
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/Vec/type.hbs b/templates/custom-template/custom-template/template/field-types/Vec/type.hbs
index 1f1899cec..44a00abfa 100644
--- a/templates/custom-template/custom-template/template/field-types/Vec/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/Vec/type.hbs
@@ -1 +1 @@
-Array<{{field_type.type}}>
+Array<{{field_type.type}}>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/detail/render.hbs
index 725742854..dda2fe9b1 100644
--- a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/detail/render.hbs
@@ -1 +1 @@
-${ {{variable_to_read}} ? 'Yes' : 'No' }
+${ {{variable_to_read}} ? 'Yes' : 'No' }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/imports.hbs
deleted file mode 100644
index a8312f198..000000000
--- a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/imports.hbs
+++ /dev/null
@@ -1,2 +0,0 @@
-import '@material/mwc-checkbox';
-import '@material/mwc-formfield';
diff --git a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/render.hbs
index c1a1625fe..3fb668d2b 100644
--- a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/edit/render.hbs
@@ -1,3 +1,7 @@
-
- { {{variable_to_change}} = (e.target as any).checked;} }>
-
\ No newline at end of file
+
+
{ {{variable_to_change}} = (e.target as any).checked;} }
+>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/initial-value.hbs
index 27ba77dda..02e4a84d6 100644
--- a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/initial-value.hbs
@@ -1 +1 @@
-true
+false
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/is-valid.hbs b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/is-valid.hbs
index 27ba77dda..f32a5804e 100644
--- a/templates/custom-template/custom-template/template/field-types/bool/Checkbox/is-valid.hbs
+++ b/templates/custom-template/custom-template/template/field-types/bool/Checkbox/is-valid.hbs
@@ -1 +1 @@
-true
+true
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/default.hbs b/templates/custom-template/custom-template/template/field-types/bool/default.hbs
new file mode 100644
index 000000000..51b676e7a
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/bool/default.hbs
@@ -0,0 +1 @@
+{{#if (eq cardinality "vector")}}[]{{else}}false{{/if}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/sample.hbs b/templates/custom-template/custom-template/template/field-types/bool/sample.hbs
index 27ba77dda..02e4a84d6 100644
--- a/templates/custom-template/custom-template/template/field-types/bool/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/bool/sample.hbs
@@ -1 +1 @@
-true
+false
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/bool/type.hbs b/templates/custom-template/custom-template/template/field-types/bool/type.hbs
index 7b19ee8df..535368032 100644
--- a/templates/custom-template/custom-template/template/field-types/bool/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/bool/type.hbs
@@ -1 +1 @@
-boolean
+boolean
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/Slider/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/f32/Slider/detail/render.hbs
index 433f42b69..b82c4a0a1 100644
--- a/templates/custom-template/custom-template/template/field-types/f32/Slider/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/f32/Slider/detail/render.hbs
@@ -1 +1 @@
-${ {{variable_to_read}} }
+${ {{variable_to_read}} }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/imports.hbs
deleted file mode 100644
index 9c37e9323..000000000
--- a/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@material/mwc-slider';
diff --git a/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/render.hbs
index 364300128..99547a15a 100644
--- a/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/f32/Slider/edit/render.hbs
@@ -1,5 +1,8 @@
-
- {{label}}
-
- { {{variable_to_change}} = e.detail.value; } }>
-
+
+
{ {{variable_to_change}} = e.detail.value; } }
+>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/Slider/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/f32/Slider/initial-value.hbs
index ba66466c2..171538eb0 100644
--- a/templates/custom-template/custom-template/template/field-types/f32/Slider/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/f32/Slider/initial-value.hbs
@@ -1 +1 @@
-0.0
+0.0
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/Slider/is-valid.hbs b/templates/custom-template/custom-template/template/field-types/f32/Slider/is-valid.hbs
index 27ba77dda..f32a5804e 100644
--- a/templates/custom-template/custom-template/template/field-types/f32/Slider/is-valid.hbs
+++ b/templates/custom-template/custom-template/template/field-types/f32/Slider/is-valid.hbs
@@ -1 +1 @@
-true
+true
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/default.hbs b/templates/custom-template/custom-template/template/field-types/f32/default.hbs
new file mode 100644
index 000000000..0039c80a1
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/f32/default.hbs
@@ -0,0 +1 @@
+{{#if (eq cardinality "vector")}}[]{{else}}0.0{{/if}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/sample.hbs b/templates/custom-template/custom-template/template/field-types/f32/sample.hbs
index 2eb3c4fe4..ea2303bc0 100644
--- a/templates/custom-template/custom-template/template/field-types/f32/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/f32/sample.hbs
@@ -1 +1 @@
-0.5
+0.5
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/f32/type.hbs b/templates/custom-template/custom-template/template/field-types/f32/type.hbs
index b67e17aeb..0dfad6f42 100644
--- a/templates/custom-template/custom-template/template/field-types/f32/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/f32/type.hbs
@@ -1 +1 @@
-number
+number
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/i32/Slider/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/i32/Slider/detail/render.hbs
index 433f42b69..b82c4a0a1 100644
--- a/templates/custom-template/custom-template/template/field-types/i32/Slider/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/i32/Slider/detail/render.hbs
@@ -1 +1 @@
-${ {{variable_to_read}} }
+${ {{variable_to_read}} }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/imports.hbs
deleted file mode 100644
index 9c37e9323..000000000
--- a/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@material/mwc-slider';
diff --git a/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/render.hbs
index 136a70331..7ba55ca89 100644
--- a/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/i32/Slider/edit/render.hbs
@@ -1,5 +1,7 @@
-
- {{label}}
-
- { {{variable_to_change}} = e.detail.value; } } discrete>
-
+
+
{ {{variable_to_change}} = e.detail.value; } }
+>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/i32/default.hbs b/templates/custom-template/custom-template/template/field-types/i32/default.hbs
new file mode 100644
index 000000000..16b2eb52b
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/i32/default.hbs
@@ -0,0 +1 @@
+{{#if (eq cardinality "vector")}}[]{{else}}0{{/if}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/i32/sample.hbs b/templates/custom-template/custom-template/template/field-types/i32/sample.hbs
index 291670352..46b71d470 100644
--- a/templates/custom-template/custom-template/template/field-types/i32/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/i32/sample.hbs
@@ -1 +1 @@
--10
+-10
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/i32/type.hbs b/templates/custom-template/custom-template/template/field-types/i32/type.hbs
index b67e17aeb..0dfad6f42 100644
--- a/templates/custom-template/custom-template/template/field-types/i32/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/i32/type.hbs
@@ -1 +1 @@
-number
+number
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/u32/Slider/detail/render.hbs b/templates/custom-template/custom-template/template/field-types/u32/Slider/detail/render.hbs
index 433f42b69..b82c4a0a1 100644
--- a/templates/custom-template/custom-template/template/field-types/u32/Slider/detail/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/u32/Slider/detail/render.hbs
@@ -1 +1 @@
-${ {{variable_to_read}} }
+${ {{variable_to_read}} }
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/imports.hbs b/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/imports.hbs
deleted file mode 100644
index 9c37e9323..000000000
--- a/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/imports.hbs
+++ /dev/null
@@ -1 +0,0 @@
-import '@material/mwc-slider';
diff --git a/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/render.hbs b/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/render.hbs
index 136a70331..99547a15a 100644
--- a/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/render.hbs
+++ b/templates/custom-template/custom-template/template/field-types/u32/Slider/edit/render.hbs
@@ -1,5 +1,8 @@
-
- {{label}}
-
- { {{variable_to_change}} = e.detail.value; } } discrete>
-
+
+
{ {{variable_to_change}} = e.detail.value; } }
+>
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/u32/Slider/initial-value.hbs b/templates/custom-template/custom-template/template/field-types/u32/Slider/initial-value.hbs
index 573541ac9..c22708346 100644
--- a/templates/custom-template/custom-template/template/field-types/u32/Slider/initial-value.hbs
+++ b/templates/custom-template/custom-template/template/field-types/u32/Slider/initial-value.hbs
@@ -1 +1 @@
-0
+0
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/u32/default.hbs b/templates/custom-template/custom-template/template/field-types/u32/default.hbs
new file mode 100644
index 000000000..16b2eb52b
--- /dev/null
+++ b/templates/custom-template/custom-template/template/field-types/u32/default.hbs
@@ -0,0 +1 @@
+{{#if (eq cardinality "vector")}}[]{{else}}0{{/if}}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/u32/sample.hbs b/templates/custom-template/custom-template/template/field-types/u32/sample.hbs
index f599e28b8..9a037142a 100644
--- a/templates/custom-template/custom-template/template/field-types/u32/sample.hbs
+++ b/templates/custom-template/custom-template/template/field-types/u32/sample.hbs
@@ -1 +1 @@
-10
+10
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/field-types/u32/type.hbs b/templates/custom-template/custom-template/template/field-types/u32/type.hbs
index b67e17aeb..0dfad6f42 100644
--- a/templates/custom-template/custom-template/template/field-types/u32/type.hbs
+++ b/templates/custom-template/custom-template/template/field-types/u32/type.hbs
@@ -1 +1 @@
-number
+number
\ No newline at end of file
diff --git "a/templates/custom-template/custom-template/template/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" "b/templates/custom-template/custom-template/template/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs"
index 902aebe29..84e12c27f 100644
--- "a/templates/custom-template/custom-template/template/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs"
+++ "b/templates/custom-template/custom-template/template/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs"
@@ -1,7 +1,19 @@
import { assert, test } from "vitest";
import { runScenario, dhtSync, CallableCell } from '@holochain/tryorama';
-import { NewEntryAction, ActionHash, Record, Link, SignedActionHashed, CreateLink, DeleteLink, AppBundleSource, fakeActionHash, fakeAgentPubKey, fakeEntryHash } from '@holochain/client';
+import {
+ NewEntryAction,
+ ActionHash,
+ Record,
+ Link,
+ CreateLink,
+ DeleteLink,
+ SignedActionHashed,
+ AppBundleSource,
+ fakeActionHash,
+ fakeAgentPubKey,
+ fakeEntryHash
+} from '@holochain/client';
import { decode } from '@msgpack/msgpack';
{{#if (ne from_referenceable.hash_type "AgentPubKey")}}
diff --git "a/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and bidireccional (and to_referenceable (ne from_referenceable.hash_type 'AgentPubKey')))}}{{kebab_case (plural from_referenceable.name)}}-for-{{kebab_case to_referenceable.name}}.ts{{\302\241if}}.hbs" "b/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and bidireccional (and to_referenceable (ne from_referenceable.hash_type 'AgentPubKey')))}}{{kebab_case (plural from_referenceable.name)}}-for-{{kebab_case to_referenceable.name}}.ts{{\302\241if}}.hbs"
index 6341cf723..1ddb2555a 100644
--- "a/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and bidireccional (and to_referenceable (ne from_referenceable.hash_type 'AgentPubKey')))}}{{kebab_case (plural from_referenceable.name)}}-for-{{kebab_case to_referenceable.name}}.ts{{\302\241if}}.hbs"
+++ "b/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and bidireccional (and to_referenceable (ne from_referenceable.hash_type 'AgentPubKey')))}}{{kebab_case (plural from_referenceable.name)}}-for-{{kebab_case to_referenceable.name}}.ts{{\302\241if}}.hbs"
@@ -3,6 +3,8 @@ import { state, property, customElement } from 'lit/decorators.js';
import { AgentPubKey, Link, EntryHash, ActionHash, Record, AppClient, NewEntryAction, SignalType } from '@holochain/client';
import { consume } from '@lit-labs/context';
import { Task } from '@lit-labs/task';
+
+import { sharedStyles } from '../../shared-styles';
import { clientContext } from '../../contexts';
import { {{pascal_case coordinator_zome_manifest.name}}Signal } from './types';
@@ -18,7 +20,7 @@ export class {{pascal_case (plural from_referenceable.name)}}For{{pascal_case to
})
{{camel_case to_referenceable.singular_arg}}!: {{to_referenceable.hash_type}};
- _fetch{{pascal_case (plural from_referenceable.name)}} = new Task(this, ([{{camel_case to_referenceable.singular_arg}}]) => this.client.callZome({
+ _fetch{{pascal_case (plural from_referenceable.name)}} = new Task(this, ([{{camel_case to_referenceable.singular_arg}}]: Array<{{to_referenceable.hash_type}}>) => this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
@@ -30,12 +32,12 @@ export class {{pascal_case (plural from_referenceable.name)}}For{{pascal_case to
signaledHashes: Array<{{from_referenceable.hash_type}}> = [];
firstUpdated() {
- if (this.{{camel_case to_referenceable.singular_arg}} === undefined) {
+ if (!this.{{camel_case to_referenceable.singular_arg}}) {
throw new Error(`The {{camel_case to_referenceable.singular_arg}} property is required for the {{kebab_case (plural from_referenceable.name)}}-for-{{kebab_case to_referenceable.name}} element`);
}
- this.client.on('signal', signal => {
- if (!(SignalType.App in signal)) return
+ this.client?.on('signal', signal => {
+ if (!(SignalType.App in signal)) return;
if (signal.App.zome_name !== '{{coordinator_zome_manifest.name}}') return;
const payload = signal.App.payload as {{pascal_case coordinator_zome_manifest.name}}Signal;
if (payload.type !== 'LinkCreated') return;
@@ -46,10 +48,10 @@ export class {{pascal_case (plural from_referenceable.name)}}For{{pascal_case to
}
renderList(hashes: Array<{{to_referenceable.hash_type}}>) {
- if (hashes.length === 0) return html`
No {{lower_case (plural from_referenceable.name)}} found for this {{lower_case to_referenceable.name}}`;
+ if (!hashes.length) return html`
No {{lower_case (plural from_referenceable.name)}} found for this {{lower_case to_referenceable.name}}
`;
return html`
-
+
${hashes.map(hash =>
html`<{{kebab_case from_referenceable.name}}-detail .{{camel_case from_referenceable.name}}Hash=${hash} style="margin-bottom: 16px;">{{kebab_case from_referenceable.name}}-detail>`
)}
@@ -59,11 +61,11 @@ export class {{pascal_case (plural from_referenceable.name)}}For{{pascal_case to
render() {
return this._fetch{{pascal_case (plural from_referenceable.name)}}.render({
- pending: () => html`
-
-
`,
+ pending: () => html`
`,
complete: (links) => this.renderList([...this.signaledHashes, ...links.map(l => l.target)]),
- error: (e: any) => html`
Error fetching the {{lower_case (plural from_referenceable.name)}}: ${e.message}.`
+ error: (e: any) => html`
Error fetching the {{lower_case (plural from_referenceable.name)}}: ${e.message}.
`
});
}
+
+ static styles = sharedStyles;
}
diff --git "a/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and to_referenceable (ne to_referenceable.hash_type 'AgentPubKey'))}}{{kebab_case (plural to_referenceable.name)}}-for-{{kebab_case from_referenceable.name}}.ts{{\302\241if}}.hbs" "b/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and to_referenceable (ne to_referenceable.hash_type 'AgentPubKey'))}}{{kebab_case (plural to_referenceable.name)}}-for-{{kebab_case from_referenceable.name}}.ts{{\302\241if}}.hbs"
index c943123ce..b751dbd6a 100644
--- "a/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and to_referenceable (ne to_referenceable.hash_type 'AgentPubKey'))}}{{kebab_case (plural to_referenceable.name)}}-for-{{kebab_case from_referenceable.name}}.ts{{\302\241if}}.hbs"
+++ "b/templates/custom-template/custom-template/template/link-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if (and to_referenceable (ne to_referenceable.hash_type 'AgentPubKey'))}}{{kebab_case (plural to_referenceable.name)}}-for-{{kebab_case from_referenceable.name}}.ts{{\302\241if}}.hbs"
@@ -4,10 +4,12 @@ import { AgentPubKey, Link, EntryHash, ActionHash, Record, AppClient, NewEntryAc
import { consume } from '@lit-labs/context';
import { Task } from '@lit-labs/task';
+import { sharedStyles } from '../../shared-styles';
import { clientContext } from '../../contexts';
-import './{{kebab_case to_referenceable.name}}-detail';
import { {{pascal_case coordinator_zome_manifest.name}}Signal } from './types';
+import './{{kebab_case to_referenceable.name}}-detail';
+
@customElement('{{kebab_case (plural to_referenceable.name)}}-for-{{kebab_case from_referenceable.name}}')
export class {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from_referenceable.name}} extends LitElement {
@consume({ context: clientContext })
@@ -21,7 +23,7 @@ export class {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from
@state()
signaledHashes: Array<{{to_referenceable.hash_type}}> = [];
- _fetch{{pascal_case (plural to_referenceable.name)}} = new Task(this, ([{{camel_case from_referenceable.singular_arg}}]) => this.client.callZome({
+ _fetch{{pascal_case (plural to_referenceable.name)}} = new Task(this, ([{{camel_case from_referenceable.singular_arg}}]: Array<{{from_referenceable.hash_type}}>) => this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
@@ -30,12 +32,12 @@ export class {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from
}) as Promise
>, () => [this.{{camel_case from_referenceable.singular_arg}}]);
firstUpdated() {
- if (this.{{camel_case from_referenceable.singular_arg}} === undefined) {
+ if (!this.{{camel_case from_referenceable.singular_arg}}) {
throw new Error(`The {{camel_case from_referenceable.singular_arg}} property is required for the {{kebab_case (plural to_referenceable.name)}}-for-{{kebab_case from_referenceable.name}} element`);
}
- this.client.on('signal', signal => {
- if (!(SignalType.App in signal)) return;
+ this.client?.on('signal', signal => {
+ if (!(SignalType.App in signal)) return
if (signal.App.zome_name !== '{{coordinator_zome_manifest.name}}') return;
const payload = signal.App.payload as {{pascal_case coordinator_zome_manifest.name}}Signal;
if (payload.type !== 'LinkCreated') return;
@@ -46,10 +48,10 @@ export class {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from
}
renderList(hashes: Array<{{to_referenceable.hash_type}}>) {
- if (hashes.length === 0) return html`No {{lower_case (plural to_referenceable.name)}} found for this {{lower_case from_referenceable.name}}`;
+ if (!hashes.length) return html`No {{lower_case (plural to_referenceable.name)}} found for this {{lower_case from_referenceable.name}}
`;
return html`
-
+
${hashes.map(hash =>
html`<{{kebab_case to_referenceable.name}}-detail .{{camel_case to_referenceable.name}}Hash=${hash} style="margin-bottom: 16px;">{{kebab_case to_referenceable.name}}-detail>`
)}
@@ -59,11 +61,11 @@ export class {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from
render() {
return this._fetch{{pascal_case (plural to_referenceable.name)}}.render({
- pending: () => html`
-
-
`,
+ pending: () => html`
`,
complete: (links) => this.renderList([...this.signaledHashes, ...links.map(l => l.target)]),
- error: (e: any) => html`
Error fetching the {{lower_case (plural to_referenceable.name)}}: ${e.message}.`
+ error: (e: any) => html`
Error fetching the {{lower_case (plural to_referenceable.name)}}: ${e.message}.
`
});
}
-}
+
+ static styles = sharedStyles;
+}
\ No newline at end of file
diff --git a/templates/custom-template/custom-template/template/web-app/.github/workflows/test.yaml.hbs b/templates/custom-template/custom-template/template/web-app/.github/workflows/test.yaml.hbs
index 5c88e3c50..08bccaa26 100644
--- a/templates/custom-template/custom-template/template/web-app/.github/workflows/test.yaml.hbs
+++ b/templates/custom-template/custom-template/template/web-app/.github/workflows/test.yaml.hbs
@@ -1,6 +1,6 @@
name: "test"
on:
- push:
+ push:
branches: [ main ]
pull_request:
branches: [ main ]
@@ -22,4 +22,4 @@ jobs:
- name: Install and test
run: |
- nix develop --command bash -c "npm i && npm t"
+ nix develop --command bash -c "{{(package_manager_command package_manager "install" null)}} && {{(package_manager_command package_manager "test" null)}}"
diff --git a/templates/custom-template/custom-template/template/web-app/README.md.hbs b/templates/custom-template/custom-template/template/web-app/README.md.hbs
index 5274b8049..0164034bc 100644
--- a/templates/custom-template/custom-template/template/web-app/README.md.hbs
+++ b/templates/custom-template/custom-template/template/web-app/README.md.hbs
@@ -8,7 +8,7 @@ Enter the nix shell by running this in the root folder of the repository:
```bash
nix develop
-npm install
+{{(package_manager_command package_manager "install" null)}}
```
**Run all the other instructions in this README from inside this nix shell, otherwise they won't work**.
@@ -16,7 +16,7 @@ npm install
## Running 2 agents
```bash
-npm start
+{{(package_manager_command package_manager "start" null)}}
```
This will create a network of 2 nodes connected to each other and their respective UIs.
@@ -25,7 +25,7 @@ It will also bring up the Holochain Playground for advanced introspection of the
## Running the backend tests
```bash
-npm test
+{{(package_manager_command package_manager "test" null)}}
```
## Bootstrapping a network
@@ -33,7 +33,7 @@ npm test
Create a custom network of nodes connected to each other and their respective UIs with:
```bash
-AGENTS=3 npm run network
+AGENTS=3 {{(package_manager_command package_manager "network" null)}}
```
Substitute the "3" for the number of nodes that you want to bootstrap in your network.
@@ -43,7 +43,7 @@ This will also bring up the Holochain Playground for advanced introspection of t
To package the web happ:
``` bash
-npm run package
+{{(package_manager_command package_manager "package" null)}}
```
You'll have the `{{app_name}}.webhapp` in `workdir`. This is what you should distribute so that the Holochain Launcher can install it.
diff --git a/templates/custom-template/custom-template/template/web-app/flake.nix.hbs b/templates/custom-template/custom-template/template/web-app/flake.nix.hbs
deleted file mode 100644
index 155c7c0ff..000000000
--- a/templates/custom-template/custom-template/template/web-app/flake.nix.hbs
+++ /dev/null
@@ -1,17 +0,0 @@
-{{#merge previous_file_content}}
- {{#match_scope "inputs = {"}}
- {{previous_scope_content}}
-
- scaffolding.url = "github:
";
- {{/match_scope}}
- {{#match_scope "devShells.default = pkgs.mkShell {"}}
-
- inputsFrom = [ inputs'.holochain-flake.devShells.holonix ];
-
- packages = with pkgs; [
- nodejs_20
- ] ++ [
- inputs'.scaffolding.packages.hc-scaffold-custom-template
- ];
- {{/match_scope}}
-{{/merge}}
diff --git a/templates/custom-template/custom-template/template/web-app/package.json.hbs b/templates/custom-template/custom-template/template/web-app/package.json.hbs
index 8503102b0..19ec6e52f 100644
--- a/templates/custom-template/custom-template/template/web-app/package.json.hbs
+++ b/templates/custom-template/custom-template/template/web-app/package.json.hbs
@@ -6,33 +6,35 @@
"tests"
],
"scripts": {
- "start": "AGENTS=2 BOOTSTRAP_PORT=$(port) SIGNAL_PORT=$(port) npm run network",
- "network": "hc sandbox clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run launch:happ\" \"holochain-playground\"",
- "test": "npm run build:zomes && hc app pack workdir --recursive && npm t -w tests",
+ "start": "AGENTS=${AGENTS:-2} BOOTSTRAP_PORT=$(get-port) SIGNAL_PORT=$(get-port) {{(package_manager_command package_manager "network" null)}}",
+ "network": "hc sandbox clean && {{(package_manager_command package_manager "build:happ" null)}} && UI_PORT=$(get-port) concurrently \"{{(package_manager_command package_manager "start" "ui")}}\" \"{{(package_manager_command package_manager "launch:happ" null)}}\" \"holochain-playground\"",
+ "test": "{{(package_manager_command package_manager "build:zomes" null)}} && hc app pack workdir --recursive && {{(package_manager_command package_manager "test" "tests")}}",
"launch:happ": "hc-spin -n $AGENTS --ui-port $UI_PORT workdir/{{app_name}}.happ",
- "start:tauri": "AGENTS=2 BOOTSTRAP_PORT=$(port) SIGNAL_PORT=$(port) npm run network:tauri",
- "network:tauri": "hc sandbox clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run launch:tauri\" \"holochain-playground\"",
+ "start:tauri": "AGENTS=${AGENTS:-2} BOOTSTRAP_PORT=$(get-port) SIGNAL_PORT=$(get-port) {{(package_manager_command package_manager "network:tauri" null)}}",
+ "network:tauri": "hc sandbox clean && {{(package_manager_command package_manager "build:happ" null)}} && UI_PORT=$(get-port) concurrently \"{{(package_manager_command package_manager "start" "ui")}}\" \"{{(package_manager_command package_manager "launch:tauri" null)}}\" \"holochain-playground\"",
"launch:tauri": "concurrently \"hc run-local-services --bootstrap-port $BOOTSTRAP_PORT --signal-port $SIGNAL_PORT\" \"echo pass | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/{{app_name}}.happ --ui-port $UI_PORT network --bootstrap http://127.0.0.1:\"$BOOTSTRAP_PORT\" webrtc ws://127.0.0.1:\"$SIGNAL_PORT\"\"",
{{#if holo_enabled}}
- "start:holo": "AGENTS=2 npm run network:holo",
- "network:holo": "npm run build:happ && UI_PORT=8888 concurrently \"npm run launch:holo-dev-server\" \"holochain-playground ws://localhost:4444\" \"concurrently-repeat 'VITE_APP_CHAPERONE_URL=http://localhost:24274 VITE_APP_IS_HOLO=true npm start -w ui' $AGENTS\"",
+ "start:holo": "AGENTS=${AGENTS:-2} {{(package_manager_command package_manager "network:holo" null)}}",
+ "network:holo": "{{(package_manager_command package_manager "build:happ" null)}} && UI_PORT=$(get-port) concurrently \"{{(package_manager_command package_manager "launch:holo-dev-server" null)}}\" \"holochain-playground ws://localhost:4444\" \"concurrently-repeat 'VITE_APP_CHAPERONE_URL=http://localhost:24274 VITE_APP_IS_HOLO=true {{(package_manager_command package_manager "start" "ui")}}' $AGENTS\"",
"launch:holo-dev-server": "holo-dev-server workdir/{{app_name}}.happ",
{{/if}}
- "package": "npm run build:happ && npm run package -w ui && hc web-app pack workdir --recursive",
- "build:happ": "npm run build:zomes && hc app pack workdir --recursive",
- "build:zomes": "RUSTFLAGS='' CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown"
+ {{#if (eq package_manager "pnpm")}}
+ "postinstall": "node ./node_modules/.pnpm/node_modules/electron/install.js",
+ {{/if}}
+ "package": "{{(package_manager_command package_manager "build:happ" null)}} && {{(package_manager_command package_manager "package" "ui")}} && hc web-app pack workdir --recursive",
+ "build:happ": "{{(package_manager_command package_manager "build:zomes" null)}} && hc app pack workdir --recursive",
+ "build:zomes": "cargo build --release --target wasm32-unknown-unknown"
},
"devDependencies": {
"@holochain-playground/cli": "{{holochain_playground_cli_version}}",
"@holochain/hc-spin": "{{hc_spin_version}}",
"concurrently": "^6.2.1",
- "rimraf": "^5.0.7",
{{#if holo_enabled}}
"concurrently-repeat": "^0.0.1",
{{/if}}
- "new-port-cli": "^1.0.0"
+ "get-port-cli": "^3.0.0"
},
"engines": {
- "npm": ">=7.0.0"
+ "node": ">=16.0.0"
}
}
diff --git a/templates/custom-template/custom-template/template/web-app/tests/package.json.hbs b/templates/custom-template/custom-template/template/web-app/tests/package.json.hbs
index 8821314bc..59bce775a 100644
--- a/templates/custom-template/custom-template/template/web-app/tests/package.json.hbs
+++ b/templates/custom-template/custom-template/template/web-app/tests/package.json.hbs
@@ -1,5 +1,6 @@
{
"name": "tests",
+ "version": "0.1.0",
"private": true,
"scripts": {
"test": "vitest run"
diff --git a/templates/custom-template/custom-template/template/web-app/tests/vitest.config.ts.hbs b/templates/custom-template/custom-template/template/web-app/tests/vitest.config.ts.hbs
index 7737dbd2a..ed926ca6b 100644
--- a/templates/custom-template/custom-template/template/web-app/tests/vitest.config.ts.hbs
+++ b/templates/custom-template/custom-template/template/web-app/tests/vitest.config.ts.hbs
@@ -6,4 +6,3 @@ export default defineConfig({
testTimeout: 60*1000*3 // 3 mins
},
})
-
diff --git a/templates/custom-template/custom-template/template/web-app/ui/index.html.hbs b/templates/custom-template/custom-template/template/web-app/ui/index.html.hbs
index dc24b0de7..f38b7af12 100644
--- a/templates/custom-template/custom-template/template/web-app/ui/index.html.hbs
+++ b/templates/custom-template/custom-template/template/web-app/ui/index.html.hbs
@@ -8,30 +8,10 @@
/>
-
-
-
-
{{title_case app_name}}
-
-