diff --git a/src/z2ui5_cl_demo_app_178.clas.abap b/src/z2ui5_cl_demo_app_178.clas.abap
index ce7d6901..7ffd0dc5 100644
--- a/src/z2ui5_cl_demo_app_178.clas.abap
+++ b/src/z2ui5_cl_demo_app_178.clas.abap
@@ -1,54 +1,40 @@
-CLASS z2ui5_cl_demo_app_178 DEFINITION
- PUBLIC
- FINAL
- CREATE PUBLIC .
+class Z2UI5_CL_DEMO_APP_178 definition
+ public
+ final
+ create public .
- PUBLIC SECTION.
+public section.
- INTERFACES z2ui5_if_app.
+ interfaces IF_SERIALIZABLE_OBJECT .
+ interfaces Z2UI5_IF_APP .
- TYPES:
- BEGIN OF ty_prodh_node_level3,
+ types:
+ BEGIN OF ty_prodh_node_level3,
is_selected TYPE abap_bool,
text TYPE string,
prodh TYPE string,
END OF ty_prodh_node_level3 .
- TYPES:
- BEGIN OF ty_prodh_node_level2,
+ types:
+ BEGIN OF ty_prodh_node_level2,
is_selected TYPE abap_bool,
text TYPE string,
prodh TYPE string,
- expanded TYPE abap_bool,
nodes TYPE STANDARD TABLE OF ty_prodh_node_level3 WITH DEFAULT KEY,
END OF ty_prodh_node_level2 .
- TYPES:
- BEGIN OF ty_prodh_node_level1,
+ types:
+ BEGIN OF ty_prodh_node_level1,
is_selected TYPE abap_bool,
text TYPE string,
prodh TYPE string,
- expanded TYPE abap_bool,
nodes TYPE STANDARD TABLE OF ty_prodh_node_level2 WITH DEFAULT KEY,
END OF ty_prodh_node_level1 .
- TYPES:
- ty_prodh_nodes TYPE STANDARD TABLE OF ty_prodh_node_level1 WITH DEFAULT KEY .
- TYPES:
- BEGIN OF ty_prodh_node_level2_ex,
- expanded TYPE abap_bool,
- END OF ty_prodh_node_level2_ex .
- TYPES:
- BEGIN OF ty_prodh_node_level1_ex,
- expanded TYPE abap_bool,
- nodes TYPE STANDARD TABLE OF ty_prodh_node_level2_ex WITH DEFAULT KEY,
- END OF ty_prodh_node_level1_ex .
- TYPES:
- ty_prodh_nodes_ex TYPE STANDARD TABLE OF ty_prodh_node_level1_ex WITH DEFAULT KEY .
-
- DATA prodh_nodes TYPE ty_prodh_nodes .
- DATA prodh_nodes_ex TYPE ty_prodh_nodes_ex .
- DATA prodh_nodes_ex_tmp TYPE ty_prodh_nodes_ex .
- DATA is_initialized TYPE abap_bool .
-
- METHODS ui5_display_view .
+ types:
+ ty_prodh_nodes TYPE STANDARD TABLE OF ty_prodh_node_level1 WITH DEFAULT KEY .
+
+ data PRODH_NODES type TY_PRODH_NODES .
+ data IS_INITIALIZED type ABAP_BOOL .
+
+ methods UI5_DISPLAY_VIEW .
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
@@ -63,36 +49,15 @@ ENDCLASS.
CLASS Z2UI5_CL_DEMO_APP_178 IMPLEMENTATION.
- METHOD ui5_display_popup_tree_select.
-
- DATA(lv_js) = `debugger;` && |\n| &&
- `var tree_table = sap.z2ui5.oViewPopup.Fragment.byId("popupId","tree");` && |\n| &&
- `for (var i in sap.z2ui5.oResponse.OVIEWMODEL.XX.PRODH_NODES_EX) {` && |\n| &&
- ` if( sap.z2ui5.oResponse.OVIEWMODEL.XX.PRODH_NODES_EX[i].EXPANDED ) {` && |\n| &&
- ` tree_table.expand(parseInt(i));` && |\n| &&
- ` for (var j in sap.z2ui5.oResponse.OVIEWMODEL.XX.PRODH_NODES_EX[i].NODES) {` && |\n| &&
- ` if( sap.z2ui5.oResponse.OVIEWMODEL.XX.PRODH_NODES_EX[i].NODES[j].EXPANDED ) {` && |\n| &&
- ` tree_table.expand(parseInt(j+1));` && |\n| &&
- ` };` && |\n| &&
- ` };` && |\n| &&
- ` };` && |\n| &&
- `};` && |\n| &&
- `console.log(tree_table);`.
+ METHOD UI5_DISPLAY_POPUP_TREE_SELECT.
+
DATA(dialog) = z2ui5_cl_xml_view=>factory_popup(
- )->dialog( title = 'Choose Product here...' contentheight = '50%' contentwidth = '50%' ).
+ )->dialog( title = 'Choose Product here...' contentheight = '50%' contentwidth = '50%' beforeopen = `setState()` beforeclose = `saveState()` ).
dialog->tree(
id = `tree`
mode = 'SingleSelectMaster'
items = client->_bind_edit( prodh_nodes )
-* toggleopenstate = client->_event( val = 'TOGGLE_STATE' t_arg = VALUE #( ( `${$parameters>/itemIndex}` ) ( `${$parameters>/expanded}` ) ) )
- toggleopenstate = client->_event(
- val = 'TOGGLE_STATE'
- t_arg = VALUE #(
- ( `${$parameters>/itemContext/sPath}` )
- ( `${$parameters>/expanded}` ) )
- s_ctrl = value #( model_name = client->cs_view-main )
- )
)->items(
)->standard_tree_item( selected = '{IS_SELECTED}' title = '{TEXT}' ).
@@ -106,17 +71,33 @@ CLASS Z2UI5_CL_DEMO_APP_178 IMPLEMENTATION.
type = `Reject`
press = client->_event( 'CANCEL' ) ).
-* dialog->html( content = `` ).
-* dialog->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_js ).
client->popup_display( dialog->stringify( ) ).
ENDMETHOD.
- METHOD ui5_display_view.
- client->_bind_edit( val = prodh_nodes_ex view = client->cs_view-main ).
- DATA(page) = z2ui5_cl_xml_view=>factory( )->shell(
+ METHOD UI5_DISPLAY_VIEW.
+ DATA(lv_save_state_js) = `function saveState() {` && |\n| &&
+* ` debugger;` && |\n| &&
+ ` var treeTable = sap.z2ui5.oViewPopup.Fragment.byId("popupId","tree");` && |\n| &&
+ ` sap.z2ui5.treeState = treeTable.getBinding('items').getCurrentTreeState();` && |\n| &&
+ ` }; `.
+ DATA(lv_reset_state_js) = `function setState() { ` && |\n| &&
+* ` debugger;` && |\n| &&
+ ` var treeTable = sap.z2ui5.oViewPopup.Fragment.byId("popupId","tree");` && |\n| &&
+ ` if( sap.z2ui5.treeState == undefined ) {` && |\n| &&
+ ` sap.z2ui5.treeState = treeTable.getBinding('items').getCurrentTreeState();` && |\n| &&
+ ` } else {` && |\n| &&
+ ` treeTable.getBinding("items").setTreeState(sap.z2ui5.treeState);` && |\n| &&
+ ` treeTable.getBinding("items").refresh();` && |\n| &&
+ ` };` && |\n| &&
+ `};`.
+
+ DATA(view) = z2ui5_cl_xml_view=>factory( ).
+ view->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_save_state_js ).
+ view->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_reset_state_js ).
+ DATA(page) = view->shell(
)->page(
title = 'abap2UI5 - Popup Tree select Entry'
navbuttonpress = client->_event( 'BACK' )
@@ -127,7 +108,7 @@ CLASS Z2UI5_CL_DEMO_APP_178 IMPLEMENTATION.
ENDMETHOD.
- METHOD ui5_initialize.
+ METHOD UI5_INITIALIZE.
prodh_nodes =
VALUE #( ( text = 'Machines'
prodh = '00100'
@@ -152,22 +133,10 @@ CLASS Z2UI5_CL_DEMO_APP_178 IMPLEMENTATION.
) )
)
).
- prodh_nodes_ex =
- VALUE #( ( expanded = abap_false
- nodes = VALUE #(
- ( expanded = abap_false )
- )
- )
- ( expanded = abap_false
- nodes = VALUE #(
- ( expanded = abap_false )
- )
- )
- ).
ENDMETHOD.
- METHOD z2ui5_if_app~main.
+ METHOD Z2UI5_IF_APP~MAIN.
me->client = client.
@@ -179,41 +148,10 @@ CLASS Z2UI5_CL_DEMO_APP_178 IMPLEMENTATION.
CASE client->get( )-event.
- WHEN 'TOGGLE_STATE'.
- DATA(lt_arg) = client->get( )-t_event_arg.
- DATA(row) = lt_arg[ 1 ].
- DATA(expanded) = lt_arg[ 2 ].
-
-* IF prodh_nodes_ex_tmp IS INITIAL.
-* prodh_nodes_ex_tmp = prodh_nodes_ex.
-* ELSE.
-* prodh_nodes_ex = prodh_nodes_ex_tmp.
-* ENDIF.
-
-
- SPLIT row AT '/' INTO TABLE DATA(lt_indxs).
-
- IF row CS '/NODES/'.
- DATA(lv_node) = lt_indxs[ 4 ].
- DATA(lv_child_node) = lt_indxs[ 6 ].
- ASSIGN prodh_nodes_ex[ lv_node + 1 ]-nodes[ lv_child_node + 1 ]-expanded TO FIELD-SYMBOL().
- = expanded.
- ELSE.
- lv_node = lt_indxs[ 4 ].
- ASSIGN prodh_nodes_ex[ lv_node + 1 ]-expanded TO FIELD-SYMBOL().
- = expanded.
- ENDIF.
-
-* prodh_nodes_ex_tmp = prodh_nodes_ex.
-
-* client->popup_model_update( ).
- client->view_model_update( ).
-
WHEN 'BACK'.
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
WHEN 'POPUP_TREE'.
- CLEAR prodh_nodes_ex_tmp.
ui5_display_popup_tree_select( ).
WHEN 'CONTINUE'.