From b884c2ae1e4ba21a426558118f6d21c7a97a4dc3 Mon Sep 17 00:00:00 2001 From: oblomov-dev <102328295+oblomov-dev@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:34:56 +0100 Subject: [PATCH] Tree (#1621) * tree * Update App.controller.js * update * update * update --- app/webapp/controller/App.controller.js | 28 +++++++++++++++++++++ src/01/03/z2ui5_cl_app_app_js.clas.abap | 33 +++++++++++++++++++++++-- src/02/z2ui5_cl_xml_view.clas.abap | 32 +++++++++++++++++++++--- src/02/z2ui5_cl_xml_view_cc.clas.abap | 21 ++++++++++++++-- 4 files changed, 107 insertions(+), 7 deletions(-) diff --git a/app/webapp/controller/App.controller.js b/app/webapp/controller/App.controller.js index bba211f1..498be1ae 100644 --- a/app/webapp/controller/App.controller.js +++ b/app/webapp/controller/App.controller.js @@ -187,6 +187,34 @@ sap.ui.define("z2ui5/History", ["sap/ui/core/Control"], (Control) => { } ); +sap.ui.define("z2ui5/Tree", ["sap/ui/core/Control"], (Control) => { + "use strict"; + + return Control.extend("z2ui5.Tree", { + metadata: { + properties: { + tree_id: { + type: "string" + } + } + }, + + setBackend() { + z2ui5.treeState = z2ui5.oView.byId( this.getProperty("tree_id") ).getBinding('items').getCurrentTreeState(); + }, + + init() { + z2ui5.onBeforeRoundtrip.push(this.setBackend.bind(this)); + }, + + renderer(oRm, oControl) { + setTimeout(() => { + z2ui5.oView.byId( this.getProperty("tree_id") ).setTreeState( z2ui5.treeState ); + }, 100); + } + }); +}); + sap.ui.define("z2ui5/Scrolling", ["sap/ui/core/Control"], (Control) => { "use strict"; diff --git a/src/01/03/z2ui5_cl_app_app_js.clas.abap b/src/01/03/z2ui5_cl_app_app_js.clas.abap index 182c9c9f..4f66edcf 100644 --- a/src/01/03/z2ui5_cl_app_app_js.clas.abap +++ b/src/01/03/z2ui5_cl_app_app_js.clas.abap @@ -207,6 +207,35 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION. `}` && |\n| && `);` && |\n| && `` && |\n| && + `sap.ui.define("z2ui5/Tree", ["sap/ui/core/Control"], (Control) => {` && |\n| && + ` "use strict";` && |\n| && + `` && |\n| && + ` return Control.extend("z2ui5.Tree", {` && |\n| && + ` metadata: {` && |\n| && + ` properties: {` && |\n| && + ` tree_id: {` && |\n| && + ` type: "string"` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` },` && |\n| && + `` && |\n| && + ` setBackend() {` && |\n| && + ` z2ui5.treeState = z2ui5.oView.byId( this.getProperty("tree_id") ).getBinding('items').getCurrentTreeState();` && |\n| && + ` },` && |\n| && + `` && |\n| && + ` init() {` && |\n| && + ` z2ui5.onBeforeRoundtrip.push(this.setBackend.bind(this));` && |\n| && + ` },` && |\n| && + `` && |\n| && + ` renderer(oRm, oControl) {` && |\n| && + ` if (!z2ui5.treeState) return;` && |\n| && + ` setTimeout((id) => {` && |\n| && + ` z2ui5.oView.byId( id ).getBinding('items').setTreeState( z2ui5.treeState );` && |\n| && + ` }, 100, oControl.getProperty("tree_id") );` && |\n| && + ` }` && |\n| && + ` });` && |\n| && + `});` && |\n| && + `` && |\n| && `sap.ui.define("z2ui5/Scrolling", ["sap/ui/core/Control"], (Control) => {` && |\n| && ` "use strict";` && |\n| && `` && |\n| && @@ -490,6 +519,8 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION. ` defaultValue: true` && |\n| && ` },` && |\n| && ` checkDirectUpload: {` && |\n| && + |\n|. + result = result && ` type: "boolean",` && |\n| && ` defaultValue: false` && |\n| && ` }` && |\n| && @@ -518,8 +549,6 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION. ` var file = z2ui5.oUpload.oFileUpload.files[0];` && |\n| && ` var reader = new FileReader();` && |\n| && `` && |\n| && - |\n|. - result = result && ` reader.onload = function (evt) {` && |\n| && ` var vContent = evt.currentTarget.result;` && |\n| && ` this.setProperty("value", vContent);` && |\n| && diff --git a/src/02/z2ui5_cl_xml_view.clas.abap b/src/02/z2ui5_cl_xml_view.clas.abap index 2fe17ff0..a091a1cd 100644 --- a/src/02/z2ui5_cl_xml_view.clas.abap +++ b/src/02/z2ui5_cl_xml_view.clas.abap @@ -2579,6 +2579,7 @@ CLASS z2ui5_cl_xml_view DEFINITION multiselectmode TYPE clike OPTIONAL nodatatext TYPE clike OPTIONAL shownodata TYPE clike OPTIONAL + PREFERRED PARAMETER items RETURNING VALUE(result) TYPE REF TO z2ui5_cl_xml_view. @@ -4450,8 +4451,20 @@ CLASS z2ui5_cl_xml_view DEFINITION IMPORTING sourceAggregation TYPE clike OPTIONAL RETURNING VALUE(result) TYPE REF TO z2ui5_cl_xml_view. + METHODS Drag_Drop_Info + IMPORTING + sourceAggregation TYPE clike OPTIONAL + targetAggregation TYPE clike OPTIONAL + dragStart TYPE clike OPTIONAL + drop TYPE clike OPTIONAL + RETURNING + VALUE(result) TYPE REF TO z2ui5_cl_xml_view. + METHODS drag_drop_config - RETURNING VALUE(result) TYPE REF TO z2ui5_cl_xml_view. + IMPORTING + ns TYPE clike DEFAULT `f` + RETURNING + VALUE(result) TYPE REF TO z2ui5_cl_xml_view. METHODS html_map IMPORTING @@ -6127,6 +6140,18 @@ CLASS z2ui5_cl_xml_view IMPLEMENTATION. ( n = `visible` v = z2ui5_cl_util=>boolean_abap_2_json( visible ) ) ) ). ENDMETHOD. + METHOD Drag_Drop_Info. + result = me. + _generic( name = `DragDropInfo` + ns = `dnd` + t_prop = VALUE #( + ( n = `sourceAggregation` v = sourceAggregation ) + ( n = `targetAggregation` v = targetAggregation ) + ( n = `dragStart` v = dragStart ) + ( n = `drop` v = drop ) + ) ). + ENDMETHOD. + METHOD drag_info. result = me. _generic( name = `DragInfo` @@ -6136,7 +6161,8 @@ CLASS z2ui5_cl_xml_view IMPLEMENTATION. METHOD drag_drop_config. result = _generic( name = `dragDropConfig` - ns = `f` ). + ns = ns + ). ENDMETHOD. METHOD dynamic_page. @@ -10906,7 +10932,7 @@ CLASS z2ui5_cl_xml_view IMPLEMENTATION. METHOD viz_frame. - data(lv_vizproperties) = ``. + DATA(lv_vizproperties) = ``. IF vizproperties IS INITIAL. lv_vizproperties = `{` && |\n| && `"plotArea": {` && |\n| && diff --git a/src/02/z2ui5_cl_xml_view_cc.clas.abap b/src/02/z2ui5_cl_xml_view_cc.clas.abap index 3a172dfb..4ae901d0 100644 --- a/src/02/z2ui5_cl_xml_view_cc.clas.abap +++ b/src/02/z2ui5_cl_xml_view_cc.clas.abap @@ -50,7 +50,7 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION selectionstart TYPE clike OPTIONAL selectionend TYPE clike OPTIONAL setupdate TYPE clike OPTIONAL - PREFERRED PARAMETER focusid + PREFERRED PARAMETER focusid RETURNING VALUE(result) TYPE REF TO z2ui5_cl_xml_view. @@ -159,6 +159,12 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION RETURNING VALUE(result) TYPE REF TO z2ui5_cl_xml_view. + METHODS tree + IMPORTING + tree_id TYPE clike OPTIONAL + RETURNING + VALUE(result) TYPE REF TO z2ui5_cl_xml_view. + METHODS timer IMPORTING finished TYPE clike OPTIONAL @@ -303,7 +309,8 @@ CLASS z2ui5_cl_xml_view_cc IMPLEMENTATION. DATA(lv_class) = 'Z2UI5_CL_CC_DEMO_OUT'. CALL METHOD (lv_class)=>('GET_STYLE') - RECEIVING result = lv_style. + RECEIVING + result = lv_style. result = mo_view->_cc_plain_xml( lv_style )->html( val ). ENDMETHOD. @@ -435,6 +442,16 @@ CLASS z2ui5_cl_xml_view_cc IMPLEMENTATION. ENDMETHOD. + METHOD tree. + + result = mo_view. + mo_view->_generic( name = `Tree` + ns = `z2ui5` + t_prop = VALUE #( ( n = `tree_id` v = tree_id ) + ) ). + + ENDMETHOD. + METHOD scrolling. result = mo_view.