From a067f6db7f5fa917a283970ce049a99722fe75cd Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 25 Mar 2023 17:11:06 +0100 Subject: [PATCH] fix 'new' processing; remove obsolete parent from handle() method --- assets/js/common.ts | 2 +- assets/js/comp-data.ts | 10 +++++----- assets/js/comp-list.ts | 2 +- layouts/shortcodes/pv/list.html | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/assets/js/common.ts b/assets/js/common.ts index d859236..18d5733 100644 --- a/assets/js/common.ts +++ b/assets/js/common.ts @@ -67,7 +67,7 @@ function handle(msg) { return } if (comp) { - comp.handle(this, domain, action, class_, item, msg.payload) + comp.handle(domain, action, class_, item, msg.payload) } } diff --git a/assets/js/comp-data.ts b/assets/js/comp-data.ts index 40c8ee7..0cbb164 100644 --- a/assets/js/comp-data.ts +++ b/assets/js/comp-data.ts @@ -32,15 +32,15 @@ export function Data(name: string, conf: any): object { // Data methods -function handle(parent: any, domain, action, class_, item, payload: string) { +function handle(domain, action, class_, item, payload: string) { const data = JSON.parse(payload) - if (action == 'data') { // && this.state.id == item) { + if (action === 'data') { // && this.state.id == item) { Object.assign(this.data, data) this.state.mode = 'view' - } else if (action == 'response') { // && data.rc == 3) { + } else if (action === 'response') { // && data.rc == 3) { this.state.id = item window.location.hash = item - sendMsg(parent.conf, [this.domain, 'query', this.name, item], {}) + sendMsg(this.conf, [this.domain, 'query', this.name, item], {}) } } @@ -55,7 +55,7 @@ function exec(action: string) { this.output += '\n' + value console.log('exec:', value) const msgbase = [this.domain, action, this.name] - if (this.mode != 'new') { + if (this.state.mode !== 'new') { msgbase.push(this.state.id) } sendMsg(conf, msgbase, data) diff --git a/assets/js/comp-list.ts b/assets/js/comp-list.ts index 194369b..360cb5f 100644 --- a/assets/js/comp-list.ts +++ b/assets/js/comp-list.ts @@ -27,7 +27,7 @@ export function List(name: string, conf: any): object { // Data methods -function handle(parent: any, domain, action, class_, item: string, payload) { +function handle(domain, action, class_, item: string, payload) { if (action == 'list') { const rows = payload.split('\n') this.data.length = 0 diff --git a/layouts/shortcodes/pv/list.html b/layouts/shortcodes/pv/list.html index 51b1599..163cbd8 100644 --- a/layouts/shortcodes/pv/list.html +++ b/layouts/shortcodes/pv/list.html @@ -5,7 +5,8 @@ {{- $conf := merge $.Params (dict "domain" $domain "action" $action) | jsonify -}} + v-scope="{{ $comp }}('{{ $name }}', {{ $conf }})" + @vue:mounted="register('{{ $name }}', valueOf())"> {{- .Inner -}}