mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 04:36:49 +08:00
Page Stage: Preserve filter value
On page stage the filter value is preserved while navigating to diff or commit page and navigate back.
This commit is contained in:
parent
3c86342bef
commit
2b4ff9529b
|
@ -9,6 +9,7 @@ CLASS zcl_abapgit_gui_page_stage DEFINITION
|
|||
CONSTANTS: BEGIN OF c_action,
|
||||
stage_all TYPE string VALUE 'stage_all',
|
||||
stage_commit TYPE string VALUE 'stage_commit',
|
||||
stage_filter TYPE string VALUE 'stage_filter',
|
||||
END OF c_action.
|
||||
|
||||
METHODS:
|
||||
|
@ -36,7 +37,8 @@ CLASS zcl_abapgit_gui_page_stage DEFINITION
|
|||
|
||||
DATA mo_repo TYPE REF TO zcl_abapgit_repo_online .
|
||||
DATA ms_files TYPE zif_abapgit_definitions=>ty_stage_files .
|
||||
DATA mv_seed TYPE string . " Unique page id to bind JS sessionStorage
|
||||
DATA mv_seed TYPE string . " Unique page id to bind JS sessionStorage
|
||||
DATA mv_filter_value TYPE string.
|
||||
|
||||
METHODS find_changed_by
|
||||
IMPORTING
|
||||
|
@ -227,7 +229,8 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION.
|
|||
" Filter bar
|
||||
ro_html->add( '<td class="right">' ).
|
||||
ro_html->add( '<input class="stage-filter" id="objectSearch"' &&
|
||||
' type="search" placeholder="Filter objects">' ).
|
||||
' type="search" placeholder="Filter objects"' &&
|
||||
| value={ mv_filter_value }>| ).
|
||||
ro_html->add( '</td>' ).
|
||||
|
||||
ro_html->add( '</tr>' ).
|
||||
|
@ -399,7 +402,9 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION.
|
|||
|
||||
METHOD zif_abapgit_gui_page~on_event.
|
||||
|
||||
DATA lo_stage TYPE REF TO zcl_abapgit_stage.
|
||||
DATA: lo_stage TYPE REF TO zcl_abapgit_stage,
|
||||
lv_string TYPE string,
|
||||
lt_fields TYPE tihttpnvp.
|
||||
|
||||
FIELD-SYMBOLS: <ls_file> LIKE LINE OF ms_files-local.
|
||||
|
||||
|
@ -435,6 +440,18 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION.
|
|||
io_stage = lo_stage.
|
||||
ev_state = zif_abapgit_definitions=>c_event_state-new_page.
|
||||
|
||||
WHEN c_action-stage_filter.
|
||||
|
||||
CONCATENATE LINES OF it_postdata INTO lv_string.
|
||||
|
||||
lt_fields = zcl_abapgit_html_action_utils=>parse_fields( lv_string ).
|
||||
|
||||
zcl_abapgit_html_action_utils=>get_field( EXPORTING iv_name = 'filterValue'
|
||||
it_field = lt_fields
|
||||
CHANGING cg_field = mv_filter_value ).
|
||||
|
||||
ev_state = zif_abapgit_definitions=>c_event_state-no_more_act.
|
||||
|
||||
WHEN zif_abapgit_definitions=>c_action-go_patch. " Go Patch page
|
||||
|
||||
ei_page = get_page_patch(
|
||||
|
|
|
@ -180,7 +180,7 @@ function StageHelper(params) {
|
|||
this.pageSeed = params.seed;
|
||||
this.formAction = params.formAction;
|
||||
this.choiseCount = 0;
|
||||
this.lastSearchValue = "";
|
||||
this.lastFilterValue = "";
|
||||
|
||||
// DOM nodes
|
||||
this.dom = {
|
||||
|
@ -218,8 +218,8 @@ function StageHelper(params) {
|
|||
StageHelper.prototype.setHooks = function() {
|
||||
this.dom.stageTab.onclick = this.onTableClick.bind(this);
|
||||
this.dom.commitBtn.onclick = this.submit.bind(this);
|
||||
this.dom.objectSearch.oninput = this.onSearch.bind(this);
|
||||
this.dom.objectSearch.onkeypress = this.onSearch.bind(this);
|
||||
this.dom.objectSearch.oninput = this.onFilter.bind(this);
|
||||
this.dom.objectSearch.onkeypress = this.onFilter.bind(this);
|
||||
window.onbeforeunload = this.onPageUnload.bind(this);
|
||||
window.onload = this.onPageLoad.bind(this);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ StageHelper.prototype.onPageUnload = function() {
|
|||
|
||||
var data = this.collectData();
|
||||
window.sessionStorage.setItem(this.pageSeed, JSON.stringify(data));
|
||||
}
|
||||
};
|
||||
|
||||
// Re-store table state on entering the page
|
||||
StageHelper.prototype.onPageLoad = function() {
|
||||
|
@ -254,8 +254,11 @@ StageHelper.prototype.onPageLoad = function() {
|
|||
});
|
||||
|
||||
this.updateMenu();
|
||||
if (this.dom.objectSearch.value) {
|
||||
this.applyFilterValue(this.dom.objectSearch.value);
|
||||
}
|
||||
debugOutput("StageHelper.onPageLoad: " + ((data) ? "from Storage" : "initial state"));
|
||||
}
|
||||
};
|
||||
|
||||
// Table event handler, change status
|
||||
StageHelper.prototype.onTableClick = function (event) {
|
||||
|
@ -292,15 +295,22 @@ StageHelper.prototype.onTableClick = function (event) {
|
|||
};
|
||||
|
||||
// Search object
|
||||
StageHelper.prototype.onSearch = function (e) {
|
||||
StageHelper.prototype.onFilter = function (e) {
|
||||
if ( // Enter hit or clear, IE SUCKS !
|
||||
e.type === "input" && !e.target.value && this.lastSearchValue
|
||||
e.type === "input" && !e.target.value && this.lastFilterValue
|
||||
|| e.type === "keypress" && e.which === 13 ) {
|
||||
|
||||
this.lastSearchValue = e.target.value;
|
||||
this.iterateStageTab(true, this.applyFilterToRow, e.target.value);
|
||||
this.applyFilterValue(e.target.value);
|
||||
submitSapeventForm({ 'filterValue': e.target.value }, "stage_filter", "post");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
StageHelper.prototype.applyFilterValue = function(sFilterValue) {
|
||||
|
||||
this.lastFilterValue = sFilterValue;
|
||||
this.iterateStageTab(true, this.applyFilterToRow, sFilterValue);
|
||||
|
||||
};
|
||||
|
||||
// Apply filter to a single stage line - hide or show
|
||||
StageHelper.prototype.applyFilterToRow = function (row, filter) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user