Skip to content

Commit

Permalink
$mol_view_tree2 refactor, hyoo-ru/mam_mol#646
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Dec 3, 2023
1 parent 6109542 commit b8507ca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion editor/editor.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $hyoo_sketch_editor $mol_page
<= Page_grid $hyoo_sketch_option
name @ \Grid
Control <= Grid $mol_switch
value? <=> grid?
value? <=> grid_str? \
options *
4 \4
8 \8
Expand Down
4 changes: 4 additions & 0 deletions editor/editor.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ namespace $.$$ {
return this.domain().element(id)
}

grid_str(next?: string) {
return String(this.grid(next === undefined ? next : Number(next)))
}

@ $mol_mem_key
Element(id: $mol_int62_string) {
const type = this.element(id).type()
Expand Down
9 changes: 9 additions & 0 deletions element/nav/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace $ {
export type $hyoo_sketch_element_nav_action_type = 'open' | 'close' | 'replace' | 'external'
export type $hyoo_sketch_element_nav_action_data = {
type: $hyoo_sketch_element_nav_action_type
source_page: string
target_page: string
target_link: string
}
}
2 changes: 2 additions & 0 deletions element/nav/nav.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ $hyoo_sketch_element_nav $hyoo_sketch_element_base
Element $mol_view
sub / \nav
nav_pages_param \demo
nav_click_handler null
nav_actions /$hyoo_sketch_element_nav_action_data
Options *
^
nav <= nav_options /
Expand Down
14 changes: 3 additions & 11 deletions element/nav/nav.view.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
namespace $.$$ {

type Action_type = 'open' | 'close' | 'replace' | 'external'
type Action = {
type: Action_type,
source_page: string,
target_page: string,
target_link: string,
}

export class $hyoo_sketch_element_nav extends $.$hyoo_sketch_element_nav {

@ $mol_mem
Expand Down Expand Up @@ -36,7 +28,7 @@ namespace $.$$ {
}

@ $mol_mem
nav_actions(next?: Action[]) {
nav_actions(next?: $hyoo_sketch_element_nav_action_data[]) {
return this.nav_actions_node().list(next) as Exclude<typeof next, undefined>
}

Expand All @@ -51,7 +43,7 @@ namespace $.$$ {
}

@ $mol_mem_key
nav_action_value<Key extends keyof Action>({ id, key } : { id: number, key: Key }, next?: string) {
nav_action_value<Key extends keyof $hyoo_sketch_element_nav_action_data>({ id, key } : { id: number, key: Key }, next?: string) {
const list = this.nav_actions()
const item = list[id] ?? {}

Expand All @@ -65,7 +57,7 @@ namespace $.$$ {
... list.slice( id + 1 ),
])

return next as Action[Key]
return next as $hyoo_sketch_element_nav_action_data[Key]
}

nav_action_type(id: number, next?: string) {
Expand Down
1 change: 1 addition & 0 deletions element/options/options.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $hyoo_sketch_element_options $hyoo_sketch_element_base
\two
\three
option_current? \
option_list /string
Options *
^
options <= options /
Expand Down

0 comments on commit b8507ca

Please sign in to comment.