From b4d1b4417947b31574c94b9ff457fabf7e16e50f Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Mon, 4 Dec 2023 00:50:46 +0300 Subject: [PATCH] $mol_view_tree2 mixed args in right bind --- switch/switch.view.ts | 2 +- view/tree2/to/js/js.ts | 4 ++-- .../to/js/test/ex/right_hierarchy.view.tree | 3 +++ view/tree2/to/js/test/ex/right_hierarchy_bar.ts | 13 +++++++++---- view/tree2/to/js/test/js.right.test.ts | 17 ++++++++++++++++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/switch/switch.view.ts b/switch/switch.view.ts index 34799a1ff60..9768f2ce49c 100644 --- a/switch/switch.view.ts +++ b/switch/switch.view.ts @@ -6,7 +6,7 @@ namespace $.$$ { */ export class $mol_switch extends $.$mol_switch { - value( next? : any ) { + value( next? : string ) { return $mol_state_session.value( `${ this }.value()` , next ) ?? '' } diff --git a/view/tree2/to/js/js.ts b/view/tree2/to/js/js.ts index 1ddf4fd0137..d706768f3c2 100644 --- a/view/tree2/to/js/js.ts +++ b/view/tree2/to/js/js.ts @@ -81,7 +81,7 @@ namespace $ { ] ) } const op = prop.kids[0] - const is_delegate = op?.type === '<=' || op?.type === '<=>' + const is_delegate = op?.type === '<=' || op?.type === '<=>' || op?.type === '=' if( ! is_delegate && next ) addons.push( decorate() ) const val = prop.hack({ @@ -148,7 +148,7 @@ namespace $ { ] if( $mol_view_tree2_class_match( input ) ) { - if( !next ) addons.push( decorate() ) + if( ! next ) addons.push( decorate() ) const overrides = [] as $mol_tree2[] diff --git a/view/tree2/to/js/test/ex/right_hierarchy.view.tree b/view/tree2/to/js/test/ex/right_hierarchy.view.tree index 5564349e032..474b8382e48 100644 --- a/view/tree2/to/js/test/ex/right_hierarchy.view.tree +++ b/view/tree2/to/js/test/ex/right_hierarchy.view.tree @@ -1,4 +1,7 @@ $mol_view_tree2_to_js_test_ex_right_hierarchy_foo $mol_object + Indexed* $mol_view_tree2_to_js_test_ex_right_hierarchy_bar + title? => indexed_title*? + id <= indexed_id* 0 prj $mol_view_tree2_to_js_test_ex_right_hierarchy_bar domain* => prj_domain* user => prj_user* diff --git a/view/tree2/to/js/test/ex/right_hierarchy_bar.ts b/view/tree2/to/js/test/ex/right_hierarchy_bar.ts index 132e45c3bae..dd7f65b1cc8 100644 --- a/view/tree2/to/js/test/ex/right_hierarchy_bar.ts +++ b/view/tree2/to/js/test/ex/right_hierarchy_bar.ts @@ -1,15 +1,20 @@ namespace $ { export class $mol_view_tree2_to_js_test_ex_right_hierarchy_bar extends $mol_object { - title() { - return 123 + @ $mol_mem + title(next?: number) { + return 123 + (next ?? 0) + } + id() { + return 0 } - domain(id: string) { + @ $mol_mem_key + domain(id: number) { return { user() { return { id() { - return 1 + return 1 + id } } } diff --git a/view/tree2/to/js/test/js.right.test.ts b/view/tree2/to/js/test/js.right.test.ts index 4e2b1360ebf..fef9dd376a4 100644 --- a/view/tree2/to/js/test/js.right.test.ts +++ b/view/tree2/to/js/test/js.right.test.ts @@ -55,11 +55,26 @@ namespace $ { 'Right hierarchy'( $ ) { const _foo = $mol_view_tree2_to_js_test_ex_right_hierarchy_foo const foo = _foo.make({ $: _foo.$ }) + type prj_user_id_assert = $mol_type_assert, number > + type prj_domain_assert = $mol_type_assert, { + user: () => { id: () => number } + } > $mol_assert_like( foo.prj_user_id(1), - 1 + 2 ) + }, + + 'Right mixed args'( $ ) { + const _foo = $mol_view_tree2_to_js_test_ex_right_hierarchy_foo + const foo = _foo.make({ $: _foo.$ }) + foo.indexed_id = id => id + 25 + + $mol_assert_like( foo.indexed_title(1), 123 ) + $mol_assert_like( foo.Indexed(0).id(), 25 ) + $mol_assert_like( foo.Indexed(1).id(), 26 ) + $mol_assert_like( foo.indexed_title(0, 2), 125 ) } })