Skip to content

update #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 37 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"transpile": "rm -rf output && cp test/*.abap downport && abap_transpile abap_transpile.json",
"express": "node test/express.mjs",
"downport": "rm -rf downport && cp -r src downport && abaplint --fix abaplint-downport.jsonc",
"unit": "npm run downport && npm run transpile && node output/index.mjs",
"test": "npm run downport && npm run transpile && npm run express"
},
"repository": {
Expand All @@ -20,10 +21,10 @@
},
"homepage": "https://github.com/oblomov-dev/abap2UI5#readme",
"devDependencies": {
"@abaplint/cli": "^2.97.17",
"@abaplint/runtime": "^2.6.35",
"@abaplint/database-sqlite": "^2.6.0",
"@abaplint/cli": "^2.100.3",
"@abaplint/runtime": "^2.7.1",
"@abaplint/database-sqlite": "^2.7.0",
"express": "^4.18.2",
"@abaplint/transpiler-cli": "^2.6.35"
"@abaplint/transpiler-cli": "^2.7.1"
}
}
2 changes: 1 addition & 1 deletion src/00/z2ui5_cl_app_demo_09.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ CLASS Z2UI5_CL_APP_DEMO_09 IMPLEMENTATION.

METHOD z2ui5_on_rendering.

DATA(page) = Z2UI5_CL_XML_VIEW=>factory(
DATA(page) = Z2UI5_CL_XML_VIEW=>factory( )->shell(
)->page(
title = 'abap2UI5 - Value Help Examples'
navbuttonpress = client->_event( 'BACK' )
Expand Down
2 changes: 1 addition & 1 deletion src/00/z2ui5_cl_app_demo_10.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CLASS Z2UI5_CL_APP_DEMO_10 IMPLEMENTATION.
client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ).
ENDCASE.

DATA(page) = Z2UI5_CL_XML_VIEW=>factory(
DATA(page) = Z2UI5_CL_XML_VIEW=>factory( )->shell(
)->page(
title = 'abap2UI5 - Demo Layout'
navbuttonpress = client->_event( 'BACK' )
Expand Down
38 changes: 23 additions & 15 deletions src/00/z2ui5_cl_app_demo_22.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ ENDCLASS.



CLASS Z2UI5_CL_APP_DEMO_22 IMPLEMENTATION.
CLASS z2ui5_cl_app_demo_22 IMPLEMENTATION.


METHOD z2ui5_if_app~main.

app-client = client.
app-s_get = client->get( ).
app-view_popup = ``.

IF app-check_initialized = abap_false.
app-check_initialized = abap_true.
Expand All @@ -60,6 +59,11 @@ CLASS Z2UI5_CL_APP_DEMO_22 IMPLEMENTATION.

ENDIF.

app-s_next-t_scroll_pos = VALUE #(
( name = 'id_page' )
( name = 'id_text3' )
).

CASE client->get( )-event.

WHEN 'BUTTON_SCROLL_TOP'.
Expand All @@ -68,15 +72,16 @@ CLASS Z2UI5_CL_APP_DEMO_22 IMPLEMENTATION.
WHEN 'BUTTON_SCROLL_BOTTOM'.
app-s_next-t_scroll_pos = VALUE #( ( name = 'id_page' value = '99999' ) ).

" WHEN 'BUTTON_SCROLL_UP'.
" DATA(lv_pos) = client->get( )-page_scroll_pos - 500.
" client->set( page_scroll_pos = COND #( WHEN lv_pos < 0 THEN 0 ELSE lv_pos ) ).
WHEN 'BUTTON_SCROLL_UP'.
DATA(lv_pos) = CONV i( app-s_get-t_scroll_pos[ name = `id_page` ]-value ) - 500.
app-s_next-t_scroll_pos = VALUE #( ( name = 'id_page' value = lv_pos ) ).

" WHEN 'BUTTON_SCROLL_DOWN'.
" client->set( page_scroll_pos = client->get( )-page_scroll_pos + 500 ).
WHEN 'BUTTON_SCROLL_DOWN'.
lv_pos = CONV i( app-s_get-t_scroll_pos[ name = `id_page` ]-value ) + 500.
app-s_next-t_scroll_pos = VALUE #( ( name = 'id_page' value = lv_pos ) ).

" WHEN 'BUTTON_SCROLL_HOLD'.
" client->set( page_scroll_pos = client->get( )-page_scroll_pos ).
WHEN 'BUTTON_SCROLL_HOLD'.
app-s_next-t_scroll_pos = app-s_get-t_scroll_pos.

WHEN 'BUTTON_FOCUS_FIRST'.
app-s_next-s_cursor_pos = VALUE #( id = 'id_text1' cursorpos = '3' selectionstart = '3' selectionend = '3' ).
Expand All @@ -100,15 +105,15 @@ CLASS Z2UI5_CL_APP_DEMO_22 IMPLEMENTATION.
ENDCASE.


DATA(view) = Z2UI5_CL_XML_VIEW=>factory( )->shell( ).
DATA(view) = z2ui5_cl_xml_view=>factory( )->shell( ).
DATA(page) = view->page(
id = 'id_page'
title = 'abap2ui5 - Scrolling and Cursor (use the browser Chrome to avoid incompatibilities)'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = abap_true
).

page->header_content( )->link( text = 'Source_Code' target = '_blank' href = Z2UI5_CL_XML_VIEW=>hlp_get_source_code_url( app = me get = client->get( ) ) ).
page->header_content( )->link( text = 'Source_Code' target = '_blank' href = z2ui5_cl_xml_view=>hlp_get_source_code_url( app = me get = client->get( ) ) ).


page->input(
Expand Down Expand Up @@ -147,15 +152,18 @@ CLASS Z2UI5_CL_APP_DEMO_22 IMPLEMENTATION.

page->footer( )->overflow_toolbar(
)->button( text = 'Scroll Top' press = client->_event( 'BUTTON_SCROLL_TOP' )
" )->button( text = 'Scroll 500 up' press = view->_event( 'BUTTON_SCROLL_UP' )
" )->button( text = 'Scroll 500 down' press = view->_event( 'BUTTON_SCROLL_DOWN' )
)->button( text = 'Scroll 500 up' press = client->_event( 'BUTTON_SCROLL_UP' )
)->button( text = 'Scroll 500 down' press = client->_event( 'BUTTON_SCROLL_DOWN' )
)->button( text = 'Scroll Bottom' press = client->_event( 'BUTTON_SCROLL_BOTTOM' )
" )->toolbar_spacer(
" )->button( text = 'Server Event and hold position' press = view->_event( 'BUTTON_SCROLL_HOLD' )
)->toolbar_spacer(
)->button( text = 'Server Event and hold position' press = client->_event( 'BUTTON_SCROLL_HOLD' )
).

app-s_next-xml_main = page->get_root( )->xml_get( ).
client->set_next( app-s_next ).

app-view_popup = ``.
CLEAR app-s_next.

ENDMETHOD.
ENDCLASS.
51 changes: 30 additions & 21 deletions src/z2ui5_cl_http_handler.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,23 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION.
` var oView = this.getView();` && |\n| &&
` try {` && |\n| &&
` if (sap.z2ui5.oResponse.oCursor) {` && |\n| &&
` var ofocus = oView.byId(sap.z2ui5.oResponse.oCursor.id).getFocusInfo();` && |\n| &&
` ofocus.cursorPos = sap.z2ui5.oResponse.oCursor.cursorPos;` && |\n| &&
` ofocus.selectionStart = sap.z2ui5.oResponse.oCursor.selectionStart;` && |\n| &&
` ofocus.selectionEnd = sap.z2ui5.oResponse.oCursor.selectionEnd;` && |\n| &&
` var ofocus = oView.byId(sap.z2ui5.oResponse.oCursor.ID).getFocusInfo();` && |\n| &&
` ofocus.cursorPos = parseInt( sap.z2ui5.oResponse.oCursor.CURSORPOS );` && |\n| &&
` ofocus.selectionStart = parseInt( sap.z2ui5.oResponse.oCursor.SELECTIONSTART );` && |\n| &&
` ofocus.selectionEnd = parseInt( sap.z2ui5.oResponse.oCursor.SELECTIONEND );` && |\n| &&
` }` && |\n| &&
` oView.byId(sap.z2ui5.oResponse.oCursor.id).applyFocusInfo(ofocus);` && |\n| &&
` oView.byId(sap.z2ui5.oResponse.oCursor.ID).applyFocusInfo(ofocus);` && |\n| &&
` } catch (error) { };` && |\n| &&
` try {` && |\n| &&
` // oView.getContent()[0].getApp().scrollTo(sap.z2ui5.oResponse.PAGE_SCROLL_POS);` && |\n| &&
` } catch (error) { };` && |\n| &&
` //todo` && |\n| &&
` if (sap.z2ui5.oResponse.oScroll) {` && |\n| &&
` sap.z2ui5.oResponse.oScroll.forEach(item => Object.keys(item).forEach(function (key, index) {` && |\n| &&
` try {` && |\n| &&
` oView.byId(key).scrollTo(item[key]);` && |\n| &&
` } catch (e) {` && |\n| &&
` var ele = '#' + oView.byId(key).getId() + '-inner';` && |\n| &&
` $(ele).scrollTop(item[key]);` && |\n| &&
` }` && |\n| &&
` // index: the ordinal position of the key within the object ` && |\n| &&
` }));` && |\n| &&
` sap.z2ui5.oResponse.oScroll.forEach(` && |\n| &&
` item => { try { oView.byId(item.NAME).scrollTo( parseInt( item.VALUE ) ); ` && |\n| &&
` } catch (e) {` && |\n| &&
` var ele = '#' + oView.byId(item.NAME).getId() + '-inner';` && |\n| &&
` $(ele).scrollTop(item.VALUE); ` && |\n| &&
` } ` && |\n| &&
` } );` && |\n| &&
` }` && |\n| &&
` if (sap.z2ui5.oResponse.vViewPopup) {` && |\n| &&
` ` && |\n| &&
Expand All @@ -163,9 +159,9 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION.
` }` && |\n| &&
` if (sap.z2ui5.oResponse.oTimer){ ` && |\n| &&
` var oEvent = { 'EVENT' : 'BUTTON_CHECK', 'METHOD' : 'UPDATE' };` && |\n| &&
` oEvent.EVENT = sap.z2ui5.oResponse.oTimer.eventFinished;` && |\n| &&
` oEvent.EVENT = sap.z2ui5.oResponse.oTimer.EVENT_FINISHED;` && |\n| &&
` sap.z2ui5.checkTimerActive = true;` && |\n| &&
` setTimeout( ( ) => { if ( sap.z2ui5.checkTimerActive ) { sap.z2ui5.oView.getController().onEvent( oEvent ); } }, sap.z2ui5.oResponse.oTimer.intervalMs, oEvent );` && |\n| &&
` setTimeout( ( ) => { if ( sap.z2ui5.checkTimerActive ) { sap.z2ui5.oView.getController().onEvent( oEvent ); } }, parseInt( sap.z2ui5.oResponse.oTimer.INTERVAL_MS ) , oEvent );` && |\n| &&
` }` && |\n| &&
` sap.ui.core.BusyIndicator.hide();` && |\n| &&
` },` && |\n| &&
Expand Down Expand Up @@ -203,6 +199,19 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION.
` this.oBody.oUpdate = sap.z2ui5.oView.getModel().oData.oUpdate;` && |\n| &&
` }` && |\n| &&
|\n| &&
` if (sap.z2ui5.oResponse.oScroll) {` && |\n| &&
` this.oBody.oScroll = sap.z2ui5.oResponse.oScroll; ` && |\n| &&
` this.oBody.oScroll .forEach(` && |\n| &&
` item => { try { ` && |\n| &&
` item.VALUE = this.getView().byId( item.NAME ).getScrollDelegate().getScrollTop(); ` && |\n| &&
` } catch (e) {` && |\n| &&
` var ele = '#' + this.getView( ).byId(item.NAME).getId() + '-inner';` && |\n| &&
` item.VALUE = $(ele).scrollTop(); ` && |\n| &&
` } ` && |\n| &&
` } );` && |\n| &&
` }` && |\n| &&


` this.oBody.oSystem = sap.z2ui5.oResponse.oSystem;` && |\n| &&
` this.oBody.oEvent = oEvent;` && |\n| &&
` this.oBody.oEvent.vData = vData;` && |\n| &&
Expand Down Expand Up @@ -251,9 +260,9 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION.
` }` && |\n| &&
` }` && |\n| &&
|\n| &&
` if (sap.z2ui5.oResponse.oAfter) {` && |\n| &&
` sap.z2ui5.oResponse.oAfter.forEach(item => sap.m[item[0]][item[1]](item[2]));` && |\n| &&
` }` && |\n| &&
` if (sap.z2ui5.oResponse.oMessage) {` && |\n| &&
` sap.m[sap.z2ui5.oResponse.oMessage.CONTROL][sap.z2ui5.oResponse.oMessage.TYPE](sap.z2ui5.oResponse.oMessage.TEXT);` && |\n| &&
` }` && |\n| &&
|\n| &&
` if (sap.z2ui5.oResponse.vView) {` && |\n| &&
` var oModel = new sap.ui.model.json.JSONModel(sap.z2ui5.oResponse.oViewModel);` && |\n| &&
Expand Down
Loading