reorganize stuff/app pages; Data component: make action configurable
This commit is contained in:
parent
ff47987b41
commit
1aa76a59c8
7 changed files with 47 additions and 31 deletions
|
@ -50,11 +50,12 @@ const appdata = {
|
||||||
|
|
||||||
// components
|
// components
|
||||||
|
|
||||||
function Data(name: string): object {
|
function Data(name: string, action: string): object {
|
||||||
const comp = {
|
const comp = {
|
||||||
name: name,
|
name: name, // matches/determines class of incoming/outgoing message
|
||||||
data: {},
|
action: action, // (default) action of outgoing message
|
||||||
save
|
data: {}, // model (2-way data store)
|
||||||
|
exec // default function to execute upon button click
|
||||||
}
|
}
|
||||||
appdata.components[name] = comp
|
appdata.components[name] = comp
|
||||||
return comp
|
return comp
|
||||||
|
@ -62,7 +63,7 @@ function Data(name: string): object {
|
||||||
|
|
||||||
// appdata and component method definitions
|
// appdata and component method definitions
|
||||||
|
|
||||||
function save() {
|
function exec() {
|
||||||
const data = this.data
|
const data = this.data
|
||||||
const conf = this.conf
|
const conf = this.conf
|
||||||
let value = ''
|
let value = ''
|
||||||
|
@ -70,8 +71,8 @@ function save() {
|
||||||
value += `${k}: ${data[k]}, `
|
value += `${k}: ${data[k]}, `
|
||||||
}
|
}
|
||||||
this.output += '\n' + value
|
this.output += '\n' + value
|
||||||
console.log('save:', value)
|
console.log('exec:', value)
|
||||||
sendMsg(conf, [conf.domain, 'data', this.name, data.id], data)
|
sendMsg(conf, [conf.domain, this.action, this.name, data.id], data)
|
||||||
}
|
}
|
||||||
|
|
||||||
function poll() {
|
function poll() {
|
||||||
|
@ -83,7 +84,7 @@ function handle(msg) {
|
||||||
const [ domain, action, class_, item ] = msg.path.split('/')
|
const [ domain, action, class_, item ] = msg.path.split('/')
|
||||||
//console.log('msgbase: ', domain, action, class_, item)
|
//console.log('msgbase: ', domain, action, class_, item)
|
||||||
// TODO: check message parts (using default values), select handler fct
|
// TODO: check message parts (using default values), select handler fct
|
||||||
Object.assign(this.components[class_].data, data)
|
Object.assign(this.components[class_ || 'data'].data, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// basic functions - move to api.ts
|
// basic functions - move to api.ts
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
baseurl: /
|
baseurl: /
|
||||||
DefaultContentLanguage: en
|
DefaultContentLanguage: en
|
||||||
title: cyberscopes example site
|
title: cyberscopes example site
|
||||||
|
summary: explore petite-vue in a Hugo-generated site.
|
||||||
paginate: 6
|
paginate: 6
|
||||||
theme:
|
theme:
|
||||||
- cyberscopes
|
- cyberscopes
|
||||||
|
@ -9,6 +10,9 @@ themesDir: themes
|
||||||
pygmentsUseClasses: true
|
pygmentsUseClasses: true
|
||||||
|
|
||||||
params:
|
params:
|
||||||
|
|
||||||
|
homeSection: app
|
||||||
|
|
||||||
#defaultImage: 9609-motor2.jpg
|
#defaultImage: 9609-motor2.jpg
|
||||||
logo: cc-logo.png
|
logo: cc-logo.png
|
||||||
favicon: icon-star-bl.png
|
favicon: icon-star-bl.png
|
||||||
|
@ -35,16 +39,12 @@ frontmatter:
|
||||||
related:
|
related:
|
||||||
_merge: shallow
|
_merge: shallow
|
||||||
|
|
||||||
taxonomies:
|
|
||||||
domain: domains
|
|
||||||
topic: topics
|
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
main:
|
main:
|
||||||
- identifier: home
|
- identifier: home
|
||||||
name: Home
|
name: Home
|
||||||
title: Home
|
title: Home
|
||||||
url: /app
|
url: /
|
||||||
weight: 10
|
weight: 10
|
||||||
- identifier: topics
|
- identifier: topics
|
||||||
name: Topics
|
name: Topics
|
||||||
|
|
|
@ -1,23 +1,15 @@
|
||||||
---
|
---
|
||||||
title: "example"
|
title: "cyberscopes"
|
||||||
summary: ""
|
|
||||||
img:
|
img:
|
||||||
pageid:
|
pageid: index
|
||||||
domains: []
|
domains: []
|
||||||
topics: []
|
topics: []
|
||||||
date: 2023-02-16
|
date: 2023-03-12
|
||||||
author: helmutm
|
author: helmutm
|
||||||
draft: false
|
draft: false
|
||||||
weight: 10
|
weight: 110
|
||||||
jsModule: main.ts
|
|
||||||
---
|
---
|
||||||
|
|
||||||
cyberscopes example site - use petite-vue in Hugo-generated sites.
|
cyberscopes example site - use petite-vue in Hugo-generated sites.
|
||||||
|
|
||||||
{{< pv/count >}}
|
|
||||||
|
|
||||||
{{< pv/count init="7" expr="count--" label="dec" >}}
|
|
||||||
|
|
||||||
{{< pv/count init="99" expr="save()" label="log" >}}
|
|
||||||
|
|
||||||
{{< pv/explore >}}
|
|
||||||
|
|
22
exampleSite/content/app/test0.md
Normal file
22
exampleSite/content/app/test0.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
title: "test0"
|
||||||
|
summary: "Explore petit-vue features"
|
||||||
|
img:
|
||||||
|
pageid: test0
|
||||||
|
domains: [App]
|
||||||
|
topics: [Examples]
|
||||||
|
date: 2023-03-12
|
||||||
|
author: helmutm
|
||||||
|
draft: false
|
||||||
|
weight: 110
|
||||||
|
---
|
||||||
|
|
||||||
|
cyberscopes example site - use petite-vue in Hugo-generated sites.
|
||||||
|
|
||||||
|
{{< pv/count >}}
|
||||||
|
|
||||||
|
{{< pv/count init="7" expr="count--" label="dec" >}}
|
||||||
|
|
||||||
|
{{< pv/count init="99" expr="save()" label="log" >}}
|
||||||
|
|
||||||
|
{{< pv/explore >}}
|
|
@ -1,14 +1,14 @@
|
||||||
---
|
---
|
||||||
title: "example"
|
title: "test1"
|
||||||
summary: "Test Page #1"
|
summary: "Test Page #1"
|
||||||
img:
|
img:
|
||||||
pageid: test1
|
pageid: test1
|
||||||
domains: [App]
|
domains: [App]
|
||||||
topics: [Examples]
|
topics: [Examples]
|
||||||
date: 2023-03-10
|
date: 2023-03-12
|
||||||
author: helmutm
|
author: helmutm
|
||||||
draft: false
|
draft: false
|
||||||
weight: 10
|
weight: 100
|
||||||
api:
|
api:
|
||||||
domain: test
|
domain: test
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{{- $type := .Get "type" | default "button" -}}
|
{{- $type := .Get "type" | default "button" -}}
|
||||||
{{- $name := .Get "name" | default "submit" -}}
|
{{- $name := .Get "name" | default "submit" -}}
|
||||||
{{- $label := .Get "label" | default (title $name) -}}
|
{{- $label := .Get "label" | default (title $name) -}}
|
||||||
{{- $action := .Get "action" | default "save" -}}
|
{{- $exec := .Get "exec" | default "exec" -}}
|
||||||
<div v-scope>
|
<div v-scope>
|
||||||
<button type="{{ $type }}" name="{{$name}}"
|
<button type="{{ $type }}" name="{{$name}}"
|
||||||
@click="{{ $action }}">{{$label}}</button>
|
@click="{{ $exec }}">{{$label}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{{- $name := .Get "name" | default "data" -}}
|
{{- $name := .Get "name" | default "data" -}}
|
||||||
|
{{- $action := .Get "action" | default "data" -}}
|
||||||
{{- $comp := .Get "component" | default "Data" -}}
|
{{- $comp := .Get "component" | default "Data" -}}
|
||||||
<div v-scope="{{ $comp }}('{{ $name }}')">
|
<div v-scope="{{ $comp }}('{{ $name }}', '{{ $action }}')">
|
||||||
{{ .Inner }}
|
{{ .Inner }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue