components, fields: use explicit parameters (no more '... merge ... jsonify')

This commit is contained in:
Helmut Merz 2023-04-05 11:18:49 +02:00
parent f7144f7b2a
commit 2f73690ec5
5 changed files with 20 additions and 14 deletions

View file

@ -4,7 +4,7 @@
{{- $exec := .Get "exec" | default "exec" -}}
{{- $action := .Get "action" | default "" -}}
{{- $mode := .Get "mode" -}}
<button type="{{ $type }}" name="{{ $name }}"
{{- with $mode }}v-show="hasmode('{{ . }}')"{{ end -}}
@click="{{ $exec }}('{{ $action }}')">{{$label}}</button>
{{- $params := dict "type" $type "name" $name "label" $label
"exec" $exec "action" $action "mode" $mode -}}
{{ partial "button" $params }}

View file

@ -1,11 +1,13 @@
{{- $type := .Get "type" | default "text" -}}
{{- $name := .Get "name" | default "textline" -}}
{{- $meta := merge $.Params (dict "name" $name "type" $type) | jsonify -}}
<div>
<input type="{{ $type }}" name="{{ $name }}"
{{- with .Get "attrs" }} {{ . }}{{ end }}
:readonly="state.mode == 'view' || meta['{{ $name }}'].readonly ? '' : null"
:readonly="hasmode('view') || meta['{{ $name }}'].readonly ? '' : null"
v-model="data.{{ $name }}"
@vue:mounted="initField('{{ $name }}', {{ $meta }})"
@vue:mounted="initField('{{ $name }}', {
type: '{{ $type }}',
default: '{{ .Get "default" }}'
})"
{{- with .Get "onchange" }} @change="{{ . }}"{{ end }} />
</div>

View file

@ -2,9 +2,10 @@
{{- $action := .Get "action" | default "data" -}}
{{- $domain := .Get "domain" | default $.Page.Params.api.domain -}}
{{- $comp := .Get "component" | default "Data" -}}
{{- $conf := merge $.Params (dict "domain" $domain "action" $action)
| jsonify -}}
<div v-scope="{{ $comp }}('{{ $name }}', {{ $conf }})"
<div v-scope="{{ $comp }}('{{ $name }}', {
action: '{{ $action }}',
domain: '{{ $domain }}'
})"
@vue:mounted="register('{{ $name }}', valueOf())">
{{ .Inner }}
</div>

View file

@ -1,4 +1,6 @@
{{- $name := .Get "name" | default "column" -}}
{{- $label := .Get "label" | default "Column" -}}
{{- $meta := $.Params | jsonify -}}
<th @vue:mounted="initField('{{ $name }}', {{ $meta }})">{{ $label }}</th>
<th @vue:mounted="initField('{{ $name }}', {
default: '{{ .Get "default" }}'
})">{{ $label }}</th>

View file

@ -2,10 +2,11 @@
{{- $action := .Get "action" | default "query" -}}
{{- $domain := .Get "domain" | default $.Page.Params.api.domain -}}
{{- $comp := .Get "component" | default "List" -}}
{{- $conf := merge $.Params (dict "domain" $domain "action" $action)
| jsonify -}}
<table class="table"
v-scope="{{ $comp }}('{{ $name }}', {{ $conf }})"
v-scope="{{ $comp }}('{{ $name }}', {
action: '{{ $action }}',
domain: '{{ $domain }}'
})"
@vue:mounted="register('{{ $name }}', valueOf())">
<tr>{{- .Inner -}}</tr>
<tr v-for="item in data" :key="item._item">