IDEMPIERE-1362 Implement support to register/unregister available dashboard content. Fixed double click on item doesn't work. Fixed changes on list doesn't always saved. Fixed gadget being display on side and center pane. Fixed dashboard preference being stored as ad_user_id+ad_role_id+ad_org_id instead of ad_user_id+ad_role_id
This commit is contained in:
parent
f8c42adcb7
commit
bba389c81c
|
@ -56,7 +56,7 @@ public class MDashboardContent extends X_PA_DashboardContent
|
||||||
|
|
||||||
return new Query(ctx, Table_Name, whereClause.toString(), null)
|
return new Query(ctx, Table_Name, whereClause.toString(), null)
|
||||||
.setParameters(parameters)
|
.setParameters(parameters)
|
||||||
.setOnlyActiveRecords(false)
|
.setOnlyActiveRecords(true)
|
||||||
.setApplyAccessFilter(true, false)
|
.setApplyAccessFilter(true, false)
|
||||||
.setOrderBy(COLUMNNAME_ColumnNo+","+COLUMNNAME_AD_Client_ID+","+COLUMNNAME_Line);
|
.setOrderBy(COLUMNNAME_ColumnNo+","+COLUMNNAME_AD_Client_ID+","+COLUMNNAME_Line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,9 @@ public class MDashboardPreference extends X_PA_DashboardPreference
|
||||||
|
|
||||||
public static int getForSessionColumnCount(boolean isShowInDashboard, int AD_User_ID, int AD_Role_ID)
|
public static int getForSessionColumnCount(boolean isShowInDashboard, int AD_User_ID, int AD_Role_ID)
|
||||||
{
|
{
|
||||||
int noOfCols = getForSessionQuery(isShowInDashboard, AD_User_ID, AD_Role_ID).aggregate("DISTINCT "+COLUMNNAME_ColumnNo, Query.AGGREGATE_COUNT, Integer.class);
|
int noOfCols = getForSessionQuery(isShowInDashboard, AD_User_ID, AD_Role_ID)
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.aggregate("DISTINCT "+COLUMNNAME_ColumnNo, Query.AGGREGATE_COUNT, Integer.class);
|
||||||
return noOfCols;
|
return noOfCols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +53,9 @@ public class MDashboardPreference extends X_PA_DashboardPreference
|
||||||
|
|
||||||
StringBuilder whereClause = new StringBuilder(COLUMNNAME_IsShowInDashboard).append("=?")
|
StringBuilder whereClause = new StringBuilder(COLUMNNAME_IsShowInDashboard).append("=?")
|
||||||
.append(" AND ").append(COLUMNNAME_AD_Role_ID).append("=?")
|
.append(" AND ").append(COLUMNNAME_AD_Role_ID).append("=?")
|
||||||
.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?");
|
.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?")
|
||||||
|
.append(" AND ").append(COLUMNNAME_AD_Org_ID).append("=0");
|
||||||
|
|
||||||
|
|
||||||
List<Object> parameters = new ArrayList<Object>();
|
List<Object> parameters = new ArrayList<Object>();
|
||||||
parameters.add(isShowInDashboard);
|
parameters.add(isShowInDashboard);
|
||||||
|
@ -60,7 +64,7 @@ public class MDashboardPreference extends X_PA_DashboardPreference
|
||||||
|
|
||||||
return new Query(ctx, Table_Name, whereClause.toString(), null)
|
return new Query(ctx, Table_Name, whereClause.toString(), null)
|
||||||
.setParameters(parameters)
|
.setParameters(parameters)
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(false)
|
||||||
.setApplyAccessFilter(true, false)
|
.setApplyAccessFilter(true, false)
|
||||||
.setOrderBy(COLUMNNAME_ColumnNo+","+COLUMNNAME_AD_Client_ID+","+COLUMNNAME_Line);
|
.setOrderBy(COLUMNNAME_ColumnNo+","+COLUMNNAME_AD_Client_ID+","+COLUMNNAME_Line);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +81,8 @@ public class MDashboardPreference extends X_PA_DashboardPreference
|
||||||
|
|
||||||
StringBuilder whereClause = new StringBuilder()
|
StringBuilder whereClause = new StringBuilder()
|
||||||
.append(COLUMNNAME_AD_Role_ID).append("=?")
|
.append(COLUMNNAME_AD_Role_ID).append("=?")
|
||||||
.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?");
|
.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?")
|
||||||
|
.append(" AND ").append(COLUMNNAME_AD_Org_ID).append("=0");
|
||||||
|
|
||||||
List<Object> parameters = new ArrayList<Object>();
|
List<Object> parameters = new ArrayList<Object>();
|
||||||
parameters.add(AD_Role_ID);
|
parameters.add(AD_Role_ID);
|
||||||
|
|
|
@ -129,16 +129,16 @@ public class DashboardController implements EventListener<Event> {
|
||||||
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
|
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
|
||||||
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
||||||
|
|
||||||
MDashboardPreference[] dps = MDashboardPreference.getForSession(isShowInDashboard,AD_User_ID, AD_Role_ID);
|
MDashboardPreference[] dps = MDashboardPreference.getForSession(AD_User_ID, AD_Role_ID);
|
||||||
MDashboardContent [] dcs = MDashboardContentAccess.get(Env.getCtx(), AD_Role_ID, AD_User_ID, null,isShowInDashboard);
|
MDashboardContent [] dcs = MDashboardContentAccess.get(Env.getCtx(), AD_Role_ID, AD_User_ID, null,isShowInDashboard);
|
||||||
|
|
||||||
if(dps.length == 0){
|
if(dps.length == 0){
|
||||||
createDashboardPreference(AD_User_ID, AD_Role_ID,isShowInDashboard);
|
createDashboardPreference(AD_User_ID, AD_Role_ID,true);
|
||||||
dps = MDashboardPreference.getForSession(isShowInDashboard,AD_User_ID, AD_Role_ID);
|
createDashboardPreference(AD_User_ID, AD_Role_ID,false);
|
||||||
|
dps = MDashboardPreference.getForSession(AD_User_ID, AD_Role_ID);
|
||||||
}else{
|
}else{
|
||||||
if(dps.length < dcs.length){
|
if(updatePreferences(dps, dcs,Env.getCtx())){
|
||||||
updatePreferences(dps, dcs,Env.getCtx());
|
dps = MDashboardPreference.getForSession(AD_User_ID, AD_Role_ID);
|
||||||
dps = MDashboardPreference.getForSession(isShowInDashboard,AD_User_ID, AD_Role_ID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +149,12 @@ public class DashboardController implements EventListener<Event> {
|
||||||
int extraWidth = 100 - (noOfCols <= 0 ? dashboardWidth : width * noOfCols) - (100 - dashboardWidth - 1);
|
int extraWidth = 100 - (noOfCols <= 0 ? dashboardWidth : width * noOfCols) - (100 - dashboardWidth - 1);
|
||||||
for (final MDashboardPreference dp : dps)
|
for (final MDashboardPreference dp : dps)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!dp.isActive())
|
if(!dp.isActive())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (dp.isShowInDashboard() != isShowInDashboard)
|
||||||
|
continue;
|
||||||
|
|
||||||
MDashboardContent dc = new MDashboardContent(dp.getCtx(), dp.getPA_DashboardContent_ID(), dp.get_TrxName());
|
MDashboardContent dc = new MDashboardContent(dp.getCtx(), dp.getPA_DashboardContent_ID(), dp.get_TrxName());
|
||||||
|
|
||||||
int columnNo = dp.getColumnNo();
|
int columnNo = dp.getColumnNo();
|
||||||
|
@ -524,7 +526,7 @@ public class DashboardController implements EventListener<Event> {
|
||||||
for (MDashboardContent dc : dcs)
|
for (MDashboardContent dc : dcs)
|
||||||
{
|
{
|
||||||
MDashboardPreference preference = new MDashboardPreference(Env.getCtx(), 0, null);
|
MDashboardPreference preference = new MDashboardPreference(Env.getCtx(), 0, null);
|
||||||
preference.setAD_Org_ID(Env.getAD_Org_ID(Env.getCtx()));
|
preference.setAD_Org_ID(0);
|
||||||
preference.setAD_Role_ID(AD_Role_ID);
|
preference.setAD_Role_ID(AD_Role_ID);
|
||||||
preference.set_ValueNoCheck("AD_User_ID", AD_User_ID);
|
preference.set_ValueNoCheck("AD_User_ID", AD_User_ID);
|
||||||
preference.setColumnNo(dc.getColumnNo());
|
preference.setColumnNo(dc.getColumnNo());
|
||||||
|
@ -539,7 +541,8 @@ public class DashboardController implements EventListener<Event> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updatePreferences(MDashboardPreference[] dps,MDashboardContent[] dcs, Properties ctx) {
|
private boolean updatePreferences(MDashboardPreference[] dps,MDashboardContent[] dcs, Properties ctx) {
|
||||||
|
boolean change = false;
|
||||||
for (int i = 0; i < dcs.length; i++) {
|
for (int i = 0; i < dcs.length; i++) {
|
||||||
boolean isNew = true;
|
boolean isNew = true;
|
||||||
for (int j = 0; j < dps.length; j++) {
|
for (int j = 0; j < dps.length; j++) {
|
||||||
|
@ -549,7 +552,7 @@ public class DashboardController implements EventListener<Event> {
|
||||||
}
|
}
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
MDashboardPreference preference = new MDashboardPreference(ctx,0, null);
|
MDashboardPreference preference = new MDashboardPreference(ctx,0, null);
|
||||||
preference.setAD_Org_ID(Env.getAD_Org_ID(Env.getCtx()));
|
preference.setAD_Org_ID(0);
|
||||||
preference.setAD_Role_ID(Env.getAD_Role_ID(ctx));
|
preference.setAD_Role_ID(Env.getAD_Role_ID(ctx));
|
||||||
preference.set_ValueNoCheck("AD_User_ID",Env.getAD_User_ID(ctx));
|
preference.set_ValueNoCheck("AD_User_ID",Env.getAD_User_ID(ctx));
|
||||||
preference.setColumnNo(dcs[i].getColumnNo());
|
preference.setColumnNo(dcs[i].getColumnNo());
|
||||||
|
@ -559,9 +562,10 @@ public class DashboardController implements EventListener<Event> {
|
||||||
preference.setPA_DashboardContent_ID(dcs[i].getPA_DashboardContent_ID());
|
preference.setPA_DashboardContent_ID(dcs[i].getPA_DashboardContent_ID());
|
||||||
|
|
||||||
preference.saveEx();
|
preference.saveEx();
|
||||||
|
if (!change) change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDashboardPreference(Vlayout layout)
|
private void saveDashboardPreference(Vlayout layout)
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.zkoss.zk.ui.event.DropEvent;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zk.ui.event.MouseEvent;
|
||||||
import org.zkoss.zk.ui.util.Clients;
|
import org.zkoss.zk.ui.util.Clients;
|
||||||
import org.zkoss.zul.Hlayout;
|
import org.zkoss.zul.Hlayout;
|
||||||
import org.zkoss.zul.Vbox;
|
import org.zkoss.zul.Vbox;
|
||||||
|
@ -158,15 +159,17 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
bRemove.setImage(ThemeManager.getThemeResource("images/Previous24.png"));
|
bRemove.setImage(ThemeManager.getThemeResource("images/Previous24.png"));
|
||||||
bRemove.addEventListener(Events.ON_CLICK, actionListener);
|
bRemove.addEventListener(Events.ON_CLICK, actionListener);
|
||||||
|
|
||||||
final EventListener<Event> crossListMouseListener = new DragListener();
|
final EventListener<Event> moveListener = new MoveListener();
|
||||||
yesList.addOnDropListener(crossListMouseListener);
|
yesList.addOnDropListener(moveListener);
|
||||||
noList.addOnDropListener(crossListMouseListener);
|
yesList.addDoubleClickListener(moveListener);
|
||||||
|
noList.addOnDropListener(moveListener);
|
||||||
|
noList.addDoubleClickListener(moveListener);
|
||||||
yesList.setItemDraggable(true);
|
yesList.setItemDraggable(true);
|
||||||
yesList.setDroppable("true");
|
yesList.setDroppable("true");
|
||||||
yesList.addEventListener(Events.ON_DROP, new EventListener<Event>() {
|
yesList.addEventListener(Events.ON_DROP, new EventListener<Event>() {
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
crossListMouseListener.onEvent(event);
|
moveListener.onEvent(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
noList.setItemDraggable(true);
|
noList.setItemDraggable(true);
|
||||||
|
@ -174,7 +177,7 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
noList.addEventListener(Events.ON_DROP, new EventListener<Event>() {
|
noList.addEventListener(Events.ON_DROP, new EventListener<Event>() {
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
crossListMouseListener.onEvent(event);
|
moveListener.onEvent(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -236,12 +239,14 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
String query = " SELECT ct.PA_DashboardContent_ID, ct.Name "
|
String query = " SELECT ct.PA_DashboardContent_ID, ct.Name "
|
||||||
+" FROM PA_DashboardContent ct"
|
+" FROM PA_DashboardContent ct"
|
||||||
+" WHERE ct.AD_Client_ID IN (0,?)"
|
+" WHERE ct.AD_Client_ID IN (0,?)"
|
||||||
|
+" AND ct.IsActive='Y'"
|
||||||
+" AND ct.PA_DashboardContent_ID NOT IN ("
|
+" AND ct.PA_DashboardContent_ID NOT IN ("
|
||||||
+" SELECT pre.PA_DashboardContent_ID"
|
+" SELECT pre.PA_DashboardContent_ID"
|
||||||
+" FROM PA_DashboardPreference pre"
|
+" FROM PA_DashboardPreference pre"
|
||||||
+" WHERE pre.AD_Client_ID IN (0,?)"
|
+" WHERE pre.AD_Client_ID IN (0,?)"
|
||||||
+" AND pre.AD_Role_ID = ?"
|
+" AND pre.AD_Role_ID = ?"
|
||||||
+" AND pre.AD_User_ID = ?"
|
+" AND pre.AD_User_ID = ?"
|
||||||
|
+" AND pre.AD_Org_ID=0 "
|
||||||
+" AND pre.IsActive='Y') ";
|
+" AND pre.IsActive='Y') ";
|
||||||
|
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
@ -272,6 +277,7 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
String where=" AD_User_ID=?"
|
String where=" AD_User_ID=?"
|
||||||
+" AND AD_Role_ID=?"
|
+" AND AD_Role_ID=?"
|
||||||
+" AND AD_Client_ID=?"
|
+" AND AD_Client_ID=?"
|
||||||
|
+" AND AD_Org_ID=0"
|
||||||
+" AND IsActive='Y'";
|
+" AND IsActive='Y'";
|
||||||
|
|
||||||
Query query1 =new Query(ctx,MDashboardPreference.Table_Name, where, null);
|
Query query1 =new Query(ctx,MDashboardPreference.Table_Name, where, null);
|
||||||
|
@ -282,11 +288,13 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
for(int i = 0; i < preference.size() ; i++){
|
for(int i = 0; i < preference.size() ; i++){
|
||||||
int ID = preference.get(i).getPA_DashboardContent_ID();
|
int ID = preference.get(i).getPA_DashboardContent_ID();
|
||||||
MDashboardContent content = new MDashboardContent(ctx, ID, null);
|
MDashboardContent content = new MDashboardContent(ctx, ID, null);
|
||||||
|
if (content.isActive()) {
|
||||||
if (!dirtyList.containsKey(content.getPA_DashboardContent_ID())) {
|
if (!dirtyList.containsKey(content.getPA_DashboardContent_ID())) {
|
||||||
yesItems.add(content);
|
yesItems.add(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(MDashboardPreference pre : dirtyList.values()) {
|
for(MDashboardPreference pre : dirtyList.values()) {
|
||||||
MDashboardContent content = (MDashboardContent) pre.getPA_DashboardContent();
|
MDashboardContent content = (MDashboardContent) pre.getPA_DashboardContent();
|
||||||
|
@ -338,9 +346,10 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
|
|
||||||
MDashboardContent content = new MDashboardContent(Env.getCtx(),selObject.m_key, null);
|
MDashboardContent content = new MDashboardContent(Env.getCtx(),selObject.m_key, null);
|
||||||
String where=" AD_Client_ID=?"
|
String where=" AD_Client_ID=?"
|
||||||
+" AND PA_DashboardContent_ID=?";
|
+" AND PA_DashboardContent_ID=?"
|
||||||
|
+" AND AD_Role_ID=? AND AD_User_ID=? AND AD_Org_ID=0";
|
||||||
Query query = new Query(ctx, MDashboardPreference.Table_Name, where, null);
|
Query query = new Query(ctx, MDashboardPreference.Table_Name, where, null);
|
||||||
query.setParameters(new Object[]{AD_Client_ID, content.getPA_DashboardContent_ID()});
|
query.setParameters(AD_Client_ID, content.getPA_DashboardContent_ID(), AD_Role_ID, AD_User_ID);
|
||||||
|
|
||||||
MDashboardPreference pre = query.setOnlyActiveRecords(false).first();
|
MDashboardPreference pre = query.setOnlyActiveRecords(false).first();
|
||||||
|
|
||||||
|
@ -350,7 +359,7 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
pre.setIsShowInDashboard(content.isShowInDashboard());
|
pre.setIsShowInDashboard(content.isShowInDashboard());
|
||||||
}else{
|
}else{
|
||||||
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
||||||
pre.setAD_Org_ID(Env.getAD_Org_ID(Env.getCtx()));
|
pre.setAD_Org_ID(0);
|
||||||
pre.setAD_Role_ID(AD_Role_ID);
|
pre.setAD_Role_ID(AD_Role_ID);
|
||||||
pre.set_ValueNoCheck("AD_User_ID",AD_User_ID);
|
pre.set_ValueNoCheck("AD_User_ID",AD_User_ID);
|
||||||
pre.setColumnNo(content.getColumnNo());
|
pre.setColumnNo(content.getColumnNo());
|
||||||
|
@ -363,8 +372,19 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
}else{
|
}else{
|
||||||
if(pre != null){
|
if(pre != null){
|
||||||
pre.setIsActive(false);
|
pre.setIsActive(false);
|
||||||
dirtyList.put(pre.getPA_DashboardContent_ID(), pre);
|
}else{
|
||||||
|
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
||||||
|
pre.setAD_Org_ID(0);
|
||||||
|
pre.setAD_Role_ID(AD_Role_ID);
|
||||||
|
pre.set_ValueNoCheck("AD_User_ID",AD_User_ID);
|
||||||
|
pre.setColumnNo(content.getColumnNo());
|
||||||
|
pre.setIsCollapsedByDefault(content.isCollapsedByDefault());
|
||||||
|
pre.setIsShowInDashboard(content.isShowInDashboard());
|
||||||
|
pre.setLine(content.getLine());
|
||||||
|
pre.setPA_DashboardContent_ID(content.getPA_DashboardContent_ID());
|
||||||
|
pre.setIsActive(false);
|
||||||
}
|
}
|
||||||
|
dirtyList.put(pre.getPA_DashboardContent_ID(), pre);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -491,13 +511,13 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
* @author eslatis
|
* @author eslatis
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private class DragListener implements EventListener<Event>
|
private class MoveListener implements EventListener<Event>
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ADSortTab.DragListener.
|
* Creates a ADSortTab.DragListener.
|
||||||
*/
|
*/
|
||||||
public DragListener()
|
public MoveListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +546,7 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
|
|
||||||
if (listFrom != listTo)
|
if (listFrom != listTo)
|
||||||
{
|
{
|
||||||
migrateLists (listFrom,listTo); //,endIndex);
|
migrateLists (listFrom,listTo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -534,6 +554,20 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event instanceof MouseEvent)
|
||||||
|
{
|
||||||
|
Listbox listFrom = null;
|
||||||
|
Listbox listTo = null;
|
||||||
|
|
||||||
|
ListItem fromItem = (ListItem) event.getTarget();
|
||||||
|
listFrom = (Listbox) fromItem.getListbox();
|
||||||
|
listTo = listFrom==yesList ? noList : yesList;
|
||||||
|
|
||||||
|
if (!fromItem.isSelected())
|
||||||
|
fromItem.setSelected(true);
|
||||||
|
|
||||||
|
migrateLists (listFrom,listTo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue