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

View file

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

View file

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

View file

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