IDEMPIERE-5491 Info Window - implement Select/DeSelect All buttons (FHCA-4016) (#1582)

This commit is contained in:
Carlos Ruiz 2022-11-27 09:19:26 +01:00 committed by GitHub
parent 5419b67762
commit a217e121fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 143 additions and 24 deletions

View File

@ -47,7 +47,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
<javascript-module name="org.idempiere.websocket" version="202205100600"/> <javascript-module name="org.idempiere.websocket" version="202205100600"/>
<javascript-module name="jawwa.atmosphere" version="202205100600"/> <javascript-module name="jawwa.atmosphere" version="202205100600"/>
<javascript-module name="adempiere.local.storage" version="202205100600"/> <javascript-module name="adempiere.local.storage" version="202205100600"/>
<javascript-moudle name="html2canvas" version="1.3.1"/> <javascript-module name="html2canvas" version="1.3.1"/>
<javascript-module name="org.idempiere.commons" version="202206300300"/> <javascript-module name="org.idempiere.commons" version="202206300300"/>
<javascript-module name="jquery.maskedinput" version="1.4.1" /> <javascript-module name="jquery.maskedinput" version="1.4.1" />
<javascript-module name="photobooth" version="0.7-rsd3" /> <javascript-module name="photobooth" version="0.7-rsd3" />
@ -57,6 +57,6 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
<!-- this js module doesn't actually exists and it is here for default theme version --> <!-- this js module doesn't actually exists and it is here for default theme version -->
<!-- since loading of js module is on demand, it doesn't cause any error as long as you don't try to load it --> <!-- since loading of js module is on demand, it doesn't cause any error as long as you don't try to load it -->
<javascript-module name="idempiere.theme.default" version="202210311430" /> <javascript-module name="idempiere.theme.default" version="202211251721" />
</language> </language>

View File

@ -137,8 +137,11 @@ import org.zkoss.zul.impl.InputElement;
* @contributor xolali IDEMPIERE-1045 Sub-Info Tabs (reviewed by red1) * @contributor xolali IDEMPIERE-1045 Sub-Info Tabs (reviewed by red1)
*/ */
public class InfoWindow extends InfoPanel implements ValueChangeListener, EventListener<Event> { public class InfoWindow extends InfoPanel implements ValueChangeListener, EventListener<Event> {
private static final long serialVersionUID = -5482739724937721227L; /**
*
*/
private static final long serialVersionUID = -2327249405074671115L;
private static final String ON_QUERY_AFTER_CHANGE = "onQueryAfterChange"; private static final String ON_QUERY_AFTER_CHANGE = "onQueryAfterChange";
protected Grid parameterGrid; protected Grid parameterGrid;
@ -279,7 +282,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
initInfoProcess(); initInfoProcess();
// when have a process, force multi select mode // when have a process, force multi select mode
if (haveProcess) if (haveProcess)
p_multipleSelection = true; setMultipleSelection(true);
} }
if (!isAutoComplete) if (!isAutoComplete)

View File

@ -127,20 +127,22 @@ import org.zkoss.zul.ext.Sortable;
*/ */
public abstract class InfoPanel extends Window implements EventListener<Event>, WTableModelListener, Sortable<Object>, IHelpContext public abstract class InfoPanel extends Window implements EventListener<Event>, WTableModelListener, Sortable<Object>, IHelpContext
{ {
/**
*
*/
private static final long serialVersionUID = -6216075383041481835L;
protected static final String ON_USER_QUERY_ATTR = "ON_USER_QUERY"; protected static final String ON_USER_QUERY_ATTR = "ON_USER_QUERY";
protected static final String INFO_QUERY_TIME_OUT_ERROR = "InfoQueryTimeOutError"; protected static final String INFO_QUERY_TIME_OUT_ERROR = "InfoQueryTimeOutError";
protected static final String COLUMN_VISIBLE_ORIGINAL = "column.visible.original"; protected static final String COLUMN_VISIBLE_ORIGINAL = "column.visible.original";
/**
*
*/
private static final long serialVersionUID = 5502211337030815819L;
private final static int DEFAULT_PAGE_SIZE = 100; private final static int DEFAULT_PAGE_SIZE = 100;
private final static int DEFAULT_PAGE_PRELOAD = 4; private final static int DEFAULT_PAGE_PRELOAD = 4;
protected List<Button> btProcessList = new ArrayList<Button>(); protected List<Button> btProcessList = new ArrayList<Button>();
protected Map<String, WEditor> editorMap = new HashMap<String, WEditor>(); protected Map<String, WEditor> editorMap = new HashMap<String, WEditor>();
protected final static String PROCESS_ID_KEY = "processId"; protected final static String PROCESS_ID_KEY = "processId";
protected final static String ON_RUN_PROCESS = "onRunProcess"; protected final static String ON_RUN_PROCESS = "onRunProcess";
protected final static String ON_SELECT_ALL_RECORDS = "onSelectAllRecords";
// attribute key of info process // attribute key of info process
protected final static String ATT_INFO_PROCESS_KEY = "INFO_PROCESS"; protected final static String ATT_INFO_PROCESS_KEY = "INFO_PROCESS";
protected int pageSize; protected int pageSize;
@ -212,6 +214,9 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
protected boolean m_lookup; protected boolean m_lookup;
protected int m_infoWindowID; protected int m_infoWindowID;
private boolean m_closeAfterExecutionOfProcess = false; private boolean m_closeAfterExecutionOfProcess = false;
private Button btnSelectAll;
private Button btnDeSelectAll;
/************************************************** /**************************************************
* Detail Constructor * Detail Constructor
@ -270,8 +275,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
{ {
parseQueryValue(); parseQueryValue();
} }
p_multipleSelection = multipleSelection; setMultipleSelection(multipleSelection);
m_lookup = lookup; m_lookup = lookup;
loadInfoWindowData(); loadInfoWindowData();
if (whereClause == null || whereClause.indexOf('@') == -1) if (whereClause == null || whereClause.indexOf('@') == -1)
@ -299,6 +304,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
addEventListener(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, this); addEventListener(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, this);
addEventListener(ON_RUN_PROCESS, this); addEventListener(ON_RUN_PROCESS, this);
addEventListener(ON_SELECT_ALL_RECORDS, this);
addEventListener(Events.ON_CLOSE, this); addEventListener(Events.ON_CLOSE, this);
addEventListener(Events.ON_CANCEL, e -> onCancel()); addEventListener(Events.ON_CANCEL, e -> onCancel());
} // InfoPanel } // InfoPanel
@ -379,6 +385,14 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
confirmPanel = new ConfirmPanel(true, true, true, true, true, true); // Elaine 2008/12/16 confirmPanel = new ConfirmPanel(true, true, true, true, true, true); // Elaine 2008/12/16
confirmPanel.addComponentsLeft(confirmPanel.createButton(ConfirmPanel.A_NEW)); confirmPanel.addComponentsLeft(confirmPanel.createButton(ConfirmPanel.A_NEW));
btnSelectAll = confirmPanel.createButton("SelectAll");
confirmPanel.addComponentsLeft(btnSelectAll);
btnSelectAll.setEnabled(false);
btnSelectAll.setVisible(p_multipleSelection);
btnDeSelectAll = confirmPanel.createButton("DeSelectAll");
confirmPanel.addComponentsLeft(btnDeSelectAll);
btnDeSelectAll.setEnabled(false);
btnDeSelectAll.setVisible(p_multipleSelection);
confirmPanel.addActionListener(Events.ON_CLICK, this); confirmPanel.addActionListener(Events.ON_CLICK, this);
ZKUpdateUtil.setHflex(confirmPanel, "1"); ZKUpdateUtil.setHflex(confirmPanel, "1");
if (ClientInfo.isMobile()) if (ClientInfo.isMobile())
@ -612,6 +626,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
String msg = Msg.getMsg(Env.getCtx(), "IWStatusSelected", new Object [] {String.valueOf(selectedCount)}); String msg = Msg.getMsg(Env.getCtx(), "IWStatusSelected", new Object [] {String.valueOf(selectedCount)});
statusBar.setSelectedRowNumber(msg); statusBar.setSelectedRowNumber(msg);
btnSelectAll.setEnabled(m_count > 0 && selectedCount != m_count);
btnDeSelectAll.setEnabled(selectedCount > 0);
} // setStatusDB } // setStatusDB
protected void prepareTable (ColumnInfo[] layout, protected void prepareTable (ColumnInfo[] layout,
@ -2024,6 +2040,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
} }
else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH))) else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH)))
{ {
recordSelectedData.clear();
onUserQuery(); onUserQuery();
} }
else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL))) else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL)))
@ -2031,6 +2048,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
onCancel(); onCancel();
} }
else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_RESET))) { else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_RESET))) {
recordSelectedData.clear();
resetParameters (); resetParameters ();
} }
// Elaine 2008/12/16 // Elaine 2008/12/16
@ -2062,6 +2080,19 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
{ {
newRecordAction (); newRecordAction ();
} }
else if (event.getTarget().equals(btnSelectAll))
{
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
Events.echoEvent(ON_SELECT_ALL_RECORDS, this, null);
}
else if (ON_SELECT_ALL_RECORDS.equals(event.getName()))
{
selectAllRecords();
}
else if (event.getTarget().equals(btnDeSelectAll))
{
deSelectAllRecords();
}
// IDEMPIERE-1334 handle event click into process button start // IDEMPIERE-1334 handle event click into process button start
else if (ON_RUN_PROCESS.equals(event.getName())){ else if (ON_RUN_PROCESS.equals(event.getName())){
// hand echo event after click button process // hand echo event after click button process
@ -2183,6 +2214,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
* Call query when user click to query button enter in parameter field * Call query when user click to query button enter in parameter field
*/ */
public void onUserQuery (){ public void onUserQuery (){
recordSelectedData.clear();
if (Executions.getCurrent().getAttribute(ON_USER_QUERY_ATTR) != null) if (Executions.getCurrent().getAttribute(ON_USER_QUERY_ATTR) != null)
return; return;
@ -2631,6 +2664,80 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
} }
} }
/**
* Select all records from all pages
*/
private void selectAllRecords() {
// select all
try {
if (paging != null) {
int currentPage = paging.getActivePage();
int pgCnt = paging.getPageCount();
for (int pgNo = 0; pgNo <= pgCnt-1; pgNo++) {
if (pgNo == currentPage)
continue; // will be done at the end
setAndLoadActivePage(pgNo);
}
setAndLoadActivePage(currentPage);
} else {
addAllCurrentContentPanelToSelected();
}
restoreSelectedInPage();
setStatusSelected();
btnSelectAll.setEnabled(false);
btnDeSelectAll.setEnabled(true);
} finally {
Clients.clearBusy();
}
}
/**
* Set and load the active page
* @param pgNo
*/
private void setAndLoadActivePage(int pgNo) {
paging.setActivePage(pgNo);
contentPanel.clearSelection();
pageNo = pgNo;
int start = pageNo * pageSize;
int end = getOverIntValue ((long)start + pageSize, extra_max_row);
if (end >= m_count)
end = m_count;
List<Object> subList = readLine(start, end);
model = new ListModelTable(subList);
model.setSorter(this);
model.addTableModelListener(this);
model.setMultiple(p_multipleSelection);
contentPanel.setData(model, null);
addAllCurrentContentPanelToSelected();
}
/**
* Add all the records from current content panel to selected records
*/
private void addAllCurrentContentPanelToSelected() {
for (int rowIndex = 0; rowIndex < contentPanel.getModel().getRowCount(); rowIndex++){
Integer keyCandidate = getColumnValue(rowIndex);
@SuppressWarnings("unchecked")
List<Object> candidateRecord = (List<Object>)contentPanel.getModel().get(rowIndex);
if (!recordSelectedData.containsKey(keyCandidate)) {
recordSelectedData.put(keyCandidate, candidateRecord);
}
}
}
/**
* De-Select all records from all pages
*/
private void deSelectAllRecords() {
// unselect all
recordSelectedData.clear();
restoreSelectedInPage();
setStatusSelected();
btnSelectAll.setEnabled(true);
btnDeSelectAll.setEnabled(false);
}
/** /**
* process action when user click to new button * process action when user click to new button
*/ */
@ -2825,4 +2932,13 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
public void setCloseAfterExecutionOfProcess(boolean closeAfterExecutionOfProcess) { public void setCloseAfterExecutionOfProcess(boolean closeAfterExecutionOfProcess) {
this.m_closeAfterExecutionOfProcess = closeAfterExecutionOfProcess; this.m_closeAfterExecutionOfProcess = closeAfterExecutionOfProcess;
} }
public void setMultipleSelection(boolean multipleSelection) {
p_multipleSelection = multipleSelection;
if (btnSelectAll != null)
btnSelectAll.setVisible(multipleSelection);
if (btnDeSelectAll != null)
btnDeSelectAll.setVisible(multipleSelection);
}
} // Info } // Info

View File

@ -57,7 +57,7 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
/** /**
* *
*/ */
private static final long serialVersionUID = -3262889055635240201L; private static final long serialVersionUID = 1217160210065925924L;
private static final String POPUP_INFO_BACKGROUND_STYLE = "background-color: #262626; -moz-border-radius: 3px; -webkit-border-radius: 3px; border: 1px solid #262626; border-radius: 3px; "; private static final String POPUP_INFO_BACKGROUND_STYLE = "background-color: #262626; -moz-border-radius: 3px; -webkit-border-radius: 3px; border: 1px solid #262626; border-radius: 3px; ";
private static final String POPUP_ERROR_BACKGROUND_STYLE = "background-color: #8B0000; -moz-border-radius: 3px; -webkit-border-radius: 3px; border: 1px solid #8B0000; border-radius: 3px; "; private static final String POPUP_ERROR_BACKGROUND_STYLE = "background-color: #8B0000; -moz-border-radius: 3px; -webkit-border-radius: 3px; border: 1px solid #8B0000; border-radius: 3px; ";
@ -112,17 +112,10 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
East east = new East(); East east = new East();
statusBar.appendChild(east); statusBar.appendChild(east);
Hbox selectedLineHbox = new Hbox();
selectedLineHbox.appendChild(selectedLine);
LayoutUtils.addSclass("status-selected", selectedLine); LayoutUtils.addSclass("status-selected", selectedLine);
selectedLine.setVisible(false); west.appendChild(selectedLine);
west.appendChild(selectedLineHbox);
statusBar.appendChild(west);
Hbox statusLineHbox = new Hbox(); center.appendChild(statusLine);
statusLineHbox.appendChild(statusLine);
center.appendChild(statusLineHbox);
statusBar.appendChild(center);
Hbox statusDbHbox = new Hbox(); Hbox statusDbHbox = new Hbox();
statusDbHbox.appendChild(infoLine); statusDbHbox.appendChild(infoLine);
@ -132,7 +125,7 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
LayoutUtils.addSclass("status-db", statusDB); LayoutUtils.addSclass("status-db", statusDB);
east.appendChild(statusDbHbox); east.appendChild(statusDbHbox);
east.setStyle("text-align: left; "); east.setStyle("text-align: left; ");
statusBar.appendChild(east); ZKUpdateUtil.setWidth(east, "50px");
this.appendChild(statusBar); this.appendChild(statusBar);
@ -170,6 +163,7 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
m_text = text; m_text = text;
m_dse = dse; m_dse = dse;
invalidate();
} }
/** /**
@ -234,6 +228,7 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
AuScript aus = new AuScript(popup, script); AuScript aus = new AuScript(popup, script);
Clients.response("statusPopupFade", aus); Clients.response("statusPopupFade", aus);
} }
invalidate();
} }
/** /**
@ -299,6 +294,7 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
infoLine.setVisible(false); infoLine.setVisible(false);
else else
infoLine.setVisible(true); infoLine.setVisible(true);
invalidate();
} // setInfo } // setInfo
public void setSelectedRowNumber (String rowNum){ public void setSelectedRowNumber (String rowNum){
@ -306,6 +302,7 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
if (rowNum != null){ if (rowNum != null){
selectedLine.setValue(rowNum); selectedLine.setValue(rowNum);
} }
invalidate();
} }
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {

View File

@ -45,6 +45,9 @@
font-weight: bold; font-weight: bold;
content: "\f068"; content: "\f068";
} }
.z-icon-DeSelectAll:before {
content: "\f248";
}
.z-icon-Detail:before { .z-icon-Detail:before {
content: "\f0d7"; content: "\f0d7";
} }
@ -275,7 +278,7 @@
content: "\f144"; content: "\f144";
} }
.z-icon-Reset:before { .z-icon-Reset:before {
content: "\f0e2"; content: "\f12d";
} }
.z-icon-Save:before { .z-icon-Save:before {
content: "\f0c7"; content: "\f0c7";
@ -287,7 +290,7 @@
content: "\f002"; content: "\f002";
} }
.z-icon-SelectAll:before { .z-icon-SelectAll:before {
content: "\f248"; content: "\f247";
} }
.z-icon-SendMail:before { .z-icon-SendMail:before {
content: "\f003"; content: "\f003";

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB