diff --git a/assets/js/comp-data.ts b/assets/js/comp-data.ts index a39c4b4..34dca93 100644 --- a/assets/js/comp-data.ts +++ b/assets/js/comp-data.ts @@ -4,12 +4,13 @@ import { sendMsg } from './common' // Data component -export function Data(name, action, domain: string): object { - domain = domain || this.conf.domain +//export function Data(name, action, domain: string): object { +export function Data(name: string, conf: any): object { + const domain = conf.domain || this.conf.domain const comp = { id: this.conf.itemid, name: name, // also used as class of incoming/outgoing message - action: action, // (default) action of outgoing message + action: conf.action, // (default) action of outgoing message domain: domain, // domain of incoming/outgoing message data: {}, // model (2-way data store) data_bak: {}, // backup copy when leaving view or edit mode diff --git a/assets/js/comp-list.ts b/assets/js/comp-list.ts index 0d6d9e7..33d216b 100644 --- a/assets/js/comp-list.ts +++ b/assets/js/comp-list.ts @@ -4,12 +4,13 @@ import { sendMsg } from './common' // List component -export function List(name, action, domain: string): object { - domain = domain || this.conf.domain +//export function List(name, action, domain: string): object { +export function List(name: string, conf: any): object { + const domain = conf.domain || this.conf.domain const comp = { id: this.conf.itemid, name: name, // also used as class of incoming/outgoing message - action: action, // (default) action of outgoing message + action: conf.action, // (default) action of outgoing message domain: domain, // domain of incoming/outgoing message data: [], // model = list of rows meta: {}, // metadata (params) for each field (table column) @@ -26,7 +27,7 @@ export function List(name, action, domain: string): object { function handle(domain, action, class_, item: string, payload) { if (action == 'list') { const rows = payload.split('\n') - //this.data = [] + this.data.length = 0 for (const row of rows) { this.data.push(JSON.parse(row)) } diff --git a/exampleSite/content/app/person-list.md b/exampleSite/content/app/person-list.md index 60132d0..25e018e 100644 --- a/exampleSite/content/app/person-list.md +++ b/exampleSite/content/app/person-list.md @@ -17,5 +17,6 @@ cyberscopes example site - list person (user) data. {{< pv/list-column name="firstname" label="First Name" >}} {{< pv/list-column name="lastname" label="Last Name" >}} + {{< pv/list-column name="email" label="Email Address" >}} {{< /pv/list >}} diff --git a/layouts/shortcodes/pv/fieldset.html b/layouts/shortcodes/pv/fieldset.html index 16b5c20..9833004 100644 --- a/layouts/shortcodes/pv/fieldset.html +++ b/layouts/shortcodes/pv/fieldset.html @@ -2,6 +2,8 @@ {{- $action := .Get "action" | default "data" -}} {{- $domain := .Get "domain" | default $.Page.Params.api.domain -}} {{- $comp := .Get "component" | default "Data" -}} -
- {| item[col.name] |} + | + {| item[fname] |} |