mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Patch for staged files only (#3730)
* Allow Hotkeys on helper object * Patch for staged files only * cleanup * fix linter * Fix: refresh on page patch keeps sel. files * Fix: Diff and Patch shd appear when only rem. Chg. * fix linter * clarify stage helper object in JS
This commit is contained in:
parent
17b6411cdb
commit
dfc19fe718
|
@ -319,6 +319,7 @@ RepoOverViewHelper.prototype.onPageLoad = function () {
|
||||||
function StageHelper(params) {
|
function StageHelper(params) {
|
||||||
this.pageSeed = params.seed;
|
this.pageSeed = params.seed;
|
||||||
this.formAction = params.formAction;
|
this.formAction = params.formAction;
|
||||||
|
this.patchAction = params.patchAction;
|
||||||
this.user = params.user;
|
this.user = params.user;
|
||||||
this.selectedCount = 0;
|
this.selectedCount = 0;
|
||||||
this.filteredCount = 0;
|
this.filteredCount = 0;
|
||||||
|
@ -330,6 +331,7 @@ function StageHelper(params) {
|
||||||
commitAllBtn: document.getElementById(params.ids.commitAllBtn),
|
commitAllBtn: document.getElementById(params.ids.commitAllBtn),
|
||||||
commitSelectedBtn: document.getElementById(params.ids.commitSelectedBtn),
|
commitSelectedBtn: document.getElementById(params.ids.commitSelectedBtn),
|
||||||
commitFilteredBtn: document.getElementById(params.ids.commitFilteredBtn),
|
commitFilteredBtn: document.getElementById(params.ids.commitFilteredBtn),
|
||||||
|
patchBtn: document.getElementById(params.ids.patchBtn),
|
||||||
objectSearch: document.getElementById(params.ids.objectSearch),
|
objectSearch: document.getElementById(params.ids.objectSearch),
|
||||||
selectedCounter: null,
|
selectedCounter: null,
|
||||||
filteredCounter: null,
|
filteredCounter: null,
|
||||||
|
@ -393,6 +395,7 @@ StageHelper.prototype.setHooks = function() {
|
||||||
this.dom.stageTab.onclick = this.onTableClick.bind(this);
|
this.dom.stageTab.onclick = this.onTableClick.bind(this);
|
||||||
this.dom.commitSelectedBtn.onclick = this.submit.bind(this);
|
this.dom.commitSelectedBtn.onclick = this.submit.bind(this);
|
||||||
this.dom.commitFilteredBtn.onclick = this.submitVisible.bind(this);
|
this.dom.commitFilteredBtn.onclick = this.submitVisible.bind(this);
|
||||||
|
this.dom.patchBtn.onclick = this.submitPatch.bind(this);
|
||||||
this.dom.objectSearch.oninput = this.onFilter.bind(this);
|
this.dom.objectSearch.oninput = this.onFilter.bind(this);
|
||||||
this.dom.objectSearch.onkeypress = this.onFilter.bind(this);
|
this.dom.objectSearch.onkeypress = this.onFilter.bind(this);
|
||||||
window.onbeforeunload = this.onPageUnload.bind(this);
|
window.onbeforeunload = this.onPageUnload.bind(this);
|
||||||
|
@ -613,6 +616,10 @@ StageHelper.prototype.submitVisible = function () {
|
||||||
submitSapeventForm(this.collectData(), this.formAction);
|
submitSapeventForm(this.collectData(), this.formAction);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StageHelper.prototype.submitPatch = function(){
|
||||||
|
submitSapeventForm(this.collectData(), this.patchAction);
|
||||||
|
};
|
||||||
|
|
||||||
// Extract data from the table
|
// Extract data from the table
|
||||||
StageHelper.prototype.collectData = function () {
|
StageHelper.prototype.collectData = function () {
|
||||||
var data = {};
|
var data = {};
|
||||||
|
@ -1288,12 +1295,21 @@ function Hotkeys(oKeyMap){
|
||||||
// the hotkey execution
|
// the hotkey execution
|
||||||
this.oKeyMap[sKey] = function(oEvent) {
|
this.oKeyMap[sKey] = function(oEvent) {
|
||||||
|
|
||||||
|
// gHelper is only valid for diff page
|
||||||
|
var diffHelper = (window.gHelper || {});
|
||||||
|
|
||||||
// We have either a js function on this
|
// We have either a js function on this
|
||||||
if (this[action]) {
|
if (this[action]) {
|
||||||
this[action].call(this);
|
this[action].call(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Or a method of the helper object for the diff page
|
||||||
|
if (diffHelper[action]){
|
||||||
|
diffHelper[action].call(diffHelper);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Or a global function
|
// Or a global function
|
||||||
if (window[action]) {
|
if (window[action]) {
|
||||||
window[action].call(this);
|
window[action].call(this);
|
||||||
|
|
|
@ -35,6 +35,7 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
|
||||||
!iv_key TYPE zif_abapgit_persistence=>ty_repo-key
|
!iv_key TYPE zif_abapgit_persistence=>ty_repo-key
|
||||||
!is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
!is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
||||||
!is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
!is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
||||||
|
!it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception.
|
zcx_abapgit_exception.
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
|
||||||
IMPORTING
|
IMPORTING
|
||||||
is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
||||||
is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
||||||
|
it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception,
|
zcx_abapgit_exception,
|
||||||
add_menu_begin
|
add_menu_begin
|
||||||
|
@ -185,12 +187,17 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
|
||||||
VALUE(ro_html) TYPE REF TO zcl_abapgit_html
|
VALUE(ro_html) TYPE REF TO zcl_abapgit_html
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception.
|
zcx_abapgit_exception.
|
||||||
|
METHODS filter_diff_by_files
|
||||||
|
IMPORTING
|
||||||
|
it_files TYPE zif_abapgit_definitions=>ty_stage_tt
|
||||||
|
CHANGING
|
||||||
|
ct_diff_files TYPE tt_file_diff.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD add_filter_sub_menu.
|
METHOD add_filter_sub_menu.
|
||||||
|
@ -426,6 +433,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
|
|
||||||
ELSE. " Diff for the whole repo
|
ELSE. " Diff for the whole repo
|
||||||
|
|
||||||
SORT lt_status BY
|
SORT lt_status BY
|
||||||
path ASCENDING
|
path ASCENDING
|
||||||
filename ASCENDING.
|
filename ASCENDING.
|
||||||
|
@ -437,6 +445,12 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
filter_diff_by_files(
|
||||||
|
EXPORTING
|
||||||
|
it_files = it_files
|
||||||
|
CHANGING
|
||||||
|
ct_diff_files = mt_diff_files ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,7 +471,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
||||||
|
|
||||||
calculate_diff(
|
calculate_diff(
|
||||||
is_file = is_file
|
is_file = is_file
|
||||||
is_object = is_object ).
|
is_object = is_object
|
||||||
|
it_files = it_files ).
|
||||||
|
|
||||||
IF lines( mt_diff_files ) = 0.
|
IF lines( mt_diff_files ) = 0.
|
||||||
zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ).
|
zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ).
|
||||||
|
@ -965,4 +980,26 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD filter_diff_by_files.
|
||||||
|
|
||||||
|
FIELD-SYMBOLS: <ls_diff_file> TYPE ty_file_diff.
|
||||||
|
|
||||||
|
IF lines( it_files ) = 0.
|
||||||
|
RETURN.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
" Diff only for specified files
|
||||||
|
LOOP AT ct_diff_files ASSIGNING <ls_diff_file>.
|
||||||
|
|
||||||
|
READ TABLE it_files TRANSPORTING NO FIELDS
|
||||||
|
WITH KEY file-filename = <ls_diff_file>-filename.
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
DELETE TABLE ct_diff_files FROM <ls_diff_file>.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDLOOP.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -12,6 +12,7 @@ CLASS zcl_abapgit_gui_page_patch DEFINITION
|
||||||
iv_key TYPE zif_abapgit_persistence=>ty_repo-key
|
iv_key TYPE zif_abapgit_persistence=>ty_repo-key
|
||||||
is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
||||||
is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
||||||
|
it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL
|
||||||
iv_patch_mode TYPE abap_bool OPTIONAL
|
iv_patch_mode TYPE abap_bool OPTIONAL
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception,
|
zcx_abapgit_exception,
|
||||||
|
@ -178,7 +179,7 @@ ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
CLASS zcl_abapgit_gui_page_patch IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD add_menu_begin.
|
METHOD add_menu_begin.
|
||||||
|
@ -384,7 +385,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
||||||
super->constructor(
|
super->constructor(
|
||||||
iv_key = iv_key
|
iv_key = iv_key
|
||||||
is_file = is_file
|
is_file = is_file
|
||||||
is_object = is_object ).
|
is_object = is_object
|
||||||
|
it_files = it_files ).
|
||||||
|
|
||||||
IF mo_repo->is_offline( ) = abap_true.
|
IF mo_repo->is_offline( ) = abap_true.
|
||||||
zcx_abapgit_exception=>raise( |Can't patch offline repos| ).
|
zcx_abapgit_exception=>raise( |Can't patch offline repos| ).
|
||||||
|
@ -504,7 +506,12 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
||||||
METHOD refresh.
|
METHOD refresh.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
lt_diff_files_old TYPE tt_file_diff.
|
lt_diff_files_old TYPE tt_file_diff,
|
||||||
|
lt_files TYPE zif_abapgit_definitions=>ty_stage_tt,
|
||||||
|
ls_file LIKE LINE OF lt_files.
|
||||||
|
|
||||||
|
FIELD-SYMBOLS: <ls_diff_file_old> TYPE zcl_abapgit_gui_page_diff=>ty_file_diff.
|
||||||
|
|
||||||
|
|
||||||
lt_diff_files_old = mt_diff_files.
|
lt_diff_files_old = mt_diff_files.
|
||||||
|
|
||||||
|
@ -517,7 +524,17 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
||||||
refresh_local_object( iv_action ).
|
refresh_local_object( iv_action ).
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
calculate_diff( ).
|
" We need to supply files again in calculate_diff. Because
|
||||||
|
" we only want to refresh the visible files. Otherwise all
|
||||||
|
" diff files would appear.
|
||||||
|
" Which is not wanted when we previously only selected particular files.
|
||||||
|
LOOP AT lt_diff_files_old ASSIGNING <ls_diff_file_old>.
|
||||||
|
CLEAR: ls_file.
|
||||||
|
MOVE-CORRESPONDING <ls_diff_file_old> TO ls_file-file.
|
||||||
|
INSERT ls_file INTO TABLE lt_files.
|
||||||
|
ENDLOOP.
|
||||||
|
|
||||||
|
calculate_diff( it_files = lt_files ).
|
||||||
restore_patch_flags( lt_diff_files_old ).
|
restore_patch_flags( lt_diff_files_old ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
|
@ -87,7 +87,7 @@ CLASS zcl_abapgit_gui_page_stage DEFINITION
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar .
|
VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar .
|
||||||
METHODS get_page_patch
|
METHODS get_page_patch
|
||||||
IMPORTING iv_getdata TYPE clike
|
IMPORTING io_stage TYPE REF TO zcl_abapgit_stage
|
||||||
RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable
|
RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable
|
||||||
RAISING zcx_abapgit_exception.
|
RAISING zcx_abapgit_exception.
|
||||||
METHODS render_master_language_warning
|
METHODS render_master_language_warning
|
||||||
|
@ -115,12 +115,14 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
||||||
|
|
||||||
CREATE OBJECT ro_menu.
|
CREATE OBJECT ro_menu.
|
||||||
|
|
||||||
IF lines( ms_files-local ) > 0.
|
IF lines( ms_files-local ) > 0
|
||||||
|
OR lines( ms_files-remote ) > 0.
|
||||||
ro_menu->add( iv_txt = |Diff|
|
ro_menu->add( iv_txt = |Diff|
|
||||||
iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mo_repo->get_key( ) }| ).
|
iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mo_repo->get_key( ) }| ).
|
||||||
|
|
||||||
ro_menu->add( iv_txt = |Patch|
|
ro_menu->add( iv_txt = |Patch|
|
||||||
iv_act = |{ zif_abapgit_definitions=>c_action-go_patch }?key={ mo_repo->get_key( ) }| ).
|
iv_typ = zif_abapgit_html=>c_action_type-onclick
|
||||||
|
iv_id = |patchBtn| ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -234,18 +236,20 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD get_page_patch.
|
METHOD get_page_patch.
|
||||||
|
|
||||||
DATA: lo_page TYPE REF TO zcl_abapgit_gui_page_patch,
|
DATA: lo_page TYPE REF TO zcl_abapgit_gui_page_patch,
|
||||||
lv_key TYPE zif_abapgit_persistence=>ty_repo-key.
|
lv_key TYPE zif_abapgit_persistence=>ty_repo-key,
|
||||||
|
lt_files TYPE zif_abapgit_definitions=>ty_stage_tt.
|
||||||
|
|
||||||
zcl_abapgit_html_action_utils=>file_obj_decode(
|
lv_key = mo_repo->get_key( ).
|
||||||
EXPORTING
|
lt_files = io_stage->get_all( ).
|
||||||
iv_string = iv_getdata
|
|
||||||
IMPORTING
|
DELETE lt_files WHERE method <> zif_abapgit_definitions=>c_method-add
|
||||||
ev_key = lv_key ).
|
AND method <> zif_abapgit_definitions=>c_method-rm.
|
||||||
|
|
||||||
CREATE OBJECT lo_page
|
CREATE OBJECT lo_page
|
||||||
EXPORTING
|
EXPORTING
|
||||||
iv_key = lv_key.
|
iv_key = lv_key
|
||||||
|
it_files = lt_files.
|
||||||
|
|
||||||
ri_page = lo_page.
|
ri_page = lo_page.
|
||||||
|
|
||||||
|
@ -513,12 +517,14 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
||||||
ro_html->add( | seed: "{ mv_seed }",| ). " Unique page id
|
ro_html->add( | seed: "{ mv_seed }",| ). " Unique page id
|
||||||
ro_html->add( | user: "{ to_lower( sy-uname ) }",| ).
|
ro_html->add( | user: "{ to_lower( sy-uname ) }",| ).
|
||||||
ro_html->add( ' formAction: "stage_commit",' ).
|
ro_html->add( ' formAction: "stage_commit",' ).
|
||||||
|
ro_html->add( | patchAction: "{ zif_abapgit_definitions=>c_action-go_patch }",| ).
|
||||||
|
|
||||||
ro_html->add( ' ids: {' ).
|
ro_html->add( ' ids: {' ).
|
||||||
ro_html->add( ' stageTab: "stageTab",' ).
|
ro_html->add( ' stageTab: "stageTab",' ).
|
||||||
ro_html->add( ' commitAllBtn: "commitAllButton",' ).
|
ro_html->add( ' commitAllBtn: "commitAllButton",' ).
|
||||||
ro_html->add( ' commitSelectedBtn: "commitSelectedButton",' ).
|
ro_html->add( ' commitSelectedBtn: "commitSelectedButton",' ).
|
||||||
ro_html->add( ' commitFilteredBtn: "commitFilteredButton",' ).
|
ro_html->add( ' commitFilteredBtn: "commitFilteredButton",' ).
|
||||||
|
ro_html->add( ' patchBtn: "patchBtn",' ).
|
||||||
ro_html->add( ' objectSearch: "objectSearch",' ).
|
ro_html->add( ' objectSearch: "objectSearch",' ).
|
||||||
ro_html->add( ' }' ).
|
ro_html->add( ' }' ).
|
||||||
|
|
||||||
|
@ -688,7 +694,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
||||||
|
|
||||||
WHEN zif_abapgit_definitions=>c_action-go_patch. " Go Patch page
|
WHEN zif_abapgit_definitions=>c_action-go_patch. " Go Patch page
|
||||||
|
|
||||||
ei_page = get_page_patch( iv_getdata ).
|
lo_stage = stage_selected( it_postdata ).
|
||||||
|
ei_page = get_page_patch( lo_stage ).
|
||||||
ev_state = zcl_abapgit_gui=>c_event_state-new_page.
|
ev_state = zcl_abapgit_gui=>c_event_state-new_page.
|
||||||
|
|
||||||
WHEN OTHERS.
|
WHEN OTHERS.
|
||||||
|
@ -711,7 +718,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
||||||
|
|
||||||
ls_hotkey_action-ui_component = 'Stage'.
|
ls_hotkey_action-ui_component = 'Stage'.
|
||||||
ls_hotkey_action-description = |Patch|.
|
ls_hotkey_action-description = |Patch|.
|
||||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_patch.
|
ls_hotkey_action-action = 'submitPatch'. " JS function in StageHelper
|
||||||
ls_hotkey_action-hotkey = |p|.
|
ls_hotkey_action-hotkey = |p|.
|
||||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user