diff --git a/assets/js/common.ts b/assets/js/common.ts index da9097c..d859236 100644 --- a/assets/js/common.ts +++ b/assets/js/common.ts @@ -48,6 +48,7 @@ const appdata = { conf: {} as Config, components: {}, output: '', // debug output space + register, handle, poll, Data @@ -55,6 +56,10 @@ const appdata = { // App (appdata) methods +function register(name: string, comp: any) { + this.components[name] = comp +} + function handle(msg) { const [ domain, action, class_, item ] = msg.path.split('/') const comp = this.components[class_ || 'data'] diff --git a/assets/js/comp-data.ts b/assets/js/comp-data.ts index 94bf90d..40c8ee7 100644 --- a/assets/js/comp-data.ts +++ b/assets/js/comp-data.ts @@ -1,6 +1,5 @@ // comp-data.ts - definition and methods of the Data component -import { reactive } from 'petite-vue' import { sendMsg } from './common' // Data component @@ -24,7 +23,7 @@ export function Data(name: string, conf: any): object { chmode, copynew } - this.components[name] = reactive(comp) + //this.components[name] = comp if (comp.state.id) { sendMsg(this.conf, [domain, 'query', name, comp.state.id], {}) } @@ -34,11 +33,11 @@ export function Data(name: string, conf: any): object { // Data methods function handle(parent: any, domain, action, class_, item, payload: string) { - if (action == 'data') { // && this.state.id - const data = JSON.parse(payload) + const data = JSON.parse(payload) + if (action == 'data') { // && this.state.id == item) { Object.assign(this.data, data) this.state.mode = 'view' - } else if (action == 'response') { + } else if (action == 'response') { // && data.rc == 3) { this.state.id = item window.location.hash = item sendMsg(parent.conf, [this.domain, 'query', this.name, item], {}) diff --git a/layouts/shortcodes/pv/fieldset.html b/layouts/shortcodes/pv/fieldset.html index 9833004..20bdac3 100644 --- a/layouts/shortcodes/pv/fieldset.html +++ b/layouts/shortcodes/pv/fieldset.html @@ -4,6 +4,7 @@ {{- $comp := .Get "component" | default "Data" -}} {{- $conf := merge $.Params (dict "domain" $domain "action" $action) | jsonify -}} -
+
{{ .Inner }}