Add `title` prop to forms (hides title if none entered)

This commit is contained in:
Michael Shanks 2020-07-06 10:17:23 +01:00
parent 9936471dca
commit fbdd159c56
4 changed files with 22 additions and 8 deletions

View File

@ -335,6 +335,11 @@ export default {
key: "model", key: "model",
control: ModelSelect, control: ModelSelect,
}, },
{
label: "Title",
key: "title",
control: Input,
},
], ],
}, },
template: { template: {
@ -355,6 +360,11 @@ export default {
key: "model", key: "model",
control: ModelSelect, control: ModelSelect,
}, },
{
label: "Title",
key: "title",
control: Input,
},
], ],
}, },
}, },

View File

@ -206,14 +206,16 @@
"description": "an HTML table that fetches data from a table or view and displays it.", "description": "an HTML table that fetches data from a table or view and displays it.",
"data": true, "data": true,
"props": { "props": {
"model": "models" "model": "models",
"title": "string"
} }
}, },
"dataformwide": { "dataformwide": {
"description": "an HTML table that fetches data from a table or view and displays it.", "description": "an HTML table that fetches data from a table or view and displays it.",
"data": true, "data": true,
"props": { "props": {
"model": "models" "model": "models",
"title": "string"
} }
}, },
"datalist": { "datalist": {

View File

@ -3,6 +3,7 @@
export let _bb export let _bb
export let model export let model
export let title
const TYPE_MAP = { const TYPE_MAP = {
string: "text", string: "text",
@ -10,8 +11,6 @@
number: "number", number: "number",
} }
let username
let password
let newModel = { let newModel = {
modelId: model, modelId: model,
} }
@ -64,7 +63,9 @@
</script> </script>
<form class="form" on:submit|preventDefault> <form class="form" on:submit|preventDefault>
<h1>{modelDef.name} Form</h1> {#if title}
<h1>{title}</h1>
{/if}
<hr /> <hr />
<div class="form-content"> <div class="form-content">
{#each fields as field} {#each fields as field}

View File

@ -2,6 +2,7 @@
import { onMount } from "svelte" import { onMount } from "svelte"
export let _bb export let _bb
export let model export let model
export let title
const TYPE_MAP = { const TYPE_MAP = {
string: "text", string: "text",
@ -9,8 +10,6 @@
number: "number", number: "number",
} }
let username
let password
let newModel = { let newModel = {
modelId: model, modelId: model,
} }
@ -54,7 +53,9 @@
</script> </script>
<form class="form" on:submit|preventDefault> <form class="form" on:submit|preventDefault>
<h1>{modelDef.name} Form</h1> {#if title}
<h1>{title}</h1>
{/if}
<hr /> <hr />
<div class="form-content"> <div class="form-content">
{#each fields as field} {#each fields as field}