IDEMPIERE-4460 : User suggestions for field/context help : check perm… (#257)
* IDEMPIERE-4460 : User suggestions for field/context help : check permission new method to check exclusion of a table for current role, used to determine if popups should be displayed or not * IDEMPIERE-4460 : User suggestions for field/context help : check permission Following @globalqss's recommandations : rename the method + add more controls inside Co-Authored-By: Carlos Ruiz <carg67@gmail.com> Co-authored-by: Carlos Ruiz <carg67@gmail.com>
This commit is contained in:
parent
dede5bd506
commit
9509d95c7c
|
@ -63,7 +63,7 @@ public final class MRole extends X_AD_Role
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4649095180532036099L;
|
private static final long serialVersionUID = 8041397465891798378L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Default (Client) Role
|
* Get Default (Client) Role
|
||||||
|
@ -3344,4 +3344,25 @@ public final class MRole extends X_AD_Role
|
||||||
return access;
|
return access;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the table is excluded for current role (this method doesn't check the level of the table, use isTableAccess for this purpose)
|
||||||
|
* @param tableID ID of the table
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isTableAccessExcluded(int tableID)
|
||||||
|
{
|
||||||
|
loadTableAccess(false);
|
||||||
|
|
||||||
|
for (int i = 0; i < m_tableAccess.length; i++) {
|
||||||
|
if ( m_tableAccess[i].isExclude()
|
||||||
|
&& m_tableAccess[i].getAD_Table_ID() == tableID
|
||||||
|
&& ! m_tableAccess[i].isReadOnly()
|
||||||
|
&& MTableAccess.ACCESSTYPERULE_Accessing.equals(m_tableAccess[i].getAccessTypeRule())
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // isTableAccessExcluded
|
||||||
|
|
||||||
} // MRole
|
} // MRole
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.adempiere.webui.window.WFieldSuggestion;
|
import org.adempiere.webui.window.WFieldSuggestion;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.Lookup;
|
import org.compiere.model.Lookup;
|
||||||
|
import org.compiere.model.MFieldSuggestion;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.MZoomCondition;
|
import org.compiere.model.MZoomCondition;
|
||||||
|
@ -289,17 +290,19 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSuggestion(final GridField field) {
|
public void addSuggestion(final GridField field) {
|
||||||
Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID"));
|
if (!MRole.getDefault().isTableAccessExcluded(MFieldSuggestion.Table_ID)) {
|
||||||
if (ThemeManager.isUseFontIconForImage())
|
Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID"));
|
||||||
editor.setIconSclass("z-icon-FieldSuggestion");
|
if (ThemeManager.isUseFontIconForImage())
|
||||||
editor.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
editor.setIconSclass("z-icon-FieldSuggestion");
|
||||||
@Override
|
editor.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||||
public void onEvent(Event event) throws Exception {
|
@Override
|
||||||
WFieldSuggestion fieldSuggestion = new WFieldSuggestion(field.getAD_Field_ID());
|
public void onEvent(Event event) throws Exception {
|
||||||
fieldSuggestion.setPage(WEditorPopupMenu.this.getPage());
|
WFieldSuggestion fieldSuggestion = new WFieldSuggestion(field.getAD_Field_ID());
|
||||||
fieldSuggestion.doHighlighted();
|
fieldSuggestion.setPage(WEditorPopupMenu.this.getPage());
|
||||||
}
|
fieldSuggestion.doHighlighted();
|
||||||
});
|
}
|
||||||
appendChild(editor);
|
});
|
||||||
|
appendChild(editor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,12 @@ import org.compiere.model.I_AD_InfoWindow;
|
||||||
import org.compiere.model.I_AD_WF_Node;
|
import org.compiere.model.I_AD_WF_Node;
|
||||||
import org.compiere.model.I_AD_Workflow;
|
import org.compiere.model.I_AD_Workflow;
|
||||||
import org.compiere.model.MCtxHelpMsg;
|
import org.compiere.model.MCtxHelpMsg;
|
||||||
|
import org.compiere.model.MCtxHelpSuggestion;
|
||||||
import org.compiere.model.MForm;
|
import org.compiere.model.MForm;
|
||||||
import org.compiere.model.MInfoWindow;
|
import org.compiere.model.MInfoWindow;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MTab;
|
import org.compiere.model.MTab;
|
||||||
import org.compiere.model.MTask;
|
import org.compiere.model.MTask;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
|
@ -269,16 +271,19 @@ public class HelpController
|
||||||
if (ctxHelpMsg != null)
|
if (ctxHelpMsg != null)
|
||||||
{
|
{
|
||||||
sb.append(stripHtml(ctxHelpMsg.get_Translation(I_AD_CtxHelpMsg.COLUMNNAME_MsgText), false) + "<br>\n");
|
sb.append(stripHtml(ctxHelpMsg.get_Translation(I_AD_CtxHelpMsg.COLUMNNAME_MsgText), false) + "<br>\n");
|
||||||
ContextHelpMenupopup popup = new ContextHelpMenupopup(ctxHelpMsg);
|
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
if (!MRole.getDefault().isTableAccessExcluded(MCtxHelpSuggestion.Table_ID)) {
|
||||||
pnlContextHelp.setContext(popup);
|
ContextHelpMenupopup popup = new ContextHelpMenupopup(ctxHelpMsg);
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||||
|
pnlContextHelp.setContext(popup);
|
||||||
|
popup.setPage(pnlContextHelp.getPage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder baseContent = new StringBuilder();
|
StringBuilder baseContent = new StringBuilder();
|
||||||
StringBuilder translatedContent = new StringBuilder();
|
StringBuilder translatedContent = new StringBuilder();
|
||||||
ContextHelpMenupopup popup = null;
|
|
||||||
if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Tab))
|
if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Tab))
|
||||||
{
|
{
|
||||||
MTab tab = new MTab(Env.getCtx(), recordId, null);
|
MTab tab = new MTab(Env.getCtx(), recordId, null);
|
||||||
|
@ -323,11 +328,8 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(tab, baseContent.toString(), translatedContent.toString());
|
addContextHelpMenupopup(tab, baseContent, translatedContent);
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Process))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Process))
|
||||||
{
|
{
|
||||||
|
@ -374,11 +376,8 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(process, baseContent.toString(), translatedContent.toString());
|
addContextHelpMenupopup(process, baseContent, translatedContent);
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Form))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Form))
|
||||||
{
|
{
|
||||||
|
@ -424,11 +423,8 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(form, baseContent.toString(), translatedContent.toString());
|
addContextHelpMenupopup(form, baseContent, translatedContent);
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Info))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Info))
|
||||||
{
|
{
|
||||||
|
@ -473,11 +469,8 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(info, baseContent.toString(), translatedContent.toString());
|
addContextHelpMenupopup(info, baseContent, translatedContent);
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Workflow))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Workflow))
|
||||||
{
|
{
|
||||||
|
@ -522,12 +515,8 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(workflow, baseContent.toString(), translatedContent.toString());
|
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
|
|
||||||
|
addContextHelpMenupopup(workflow, baseContent, translatedContent);
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Task))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Task))
|
||||||
{
|
{
|
||||||
|
@ -574,11 +563,8 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(task, baseContent.toString(), translatedContent.toString());
|
addContextHelpMenupopup(task, baseContent, translatedContent);
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Node))
|
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Node))
|
||||||
{
|
{
|
||||||
|
@ -624,21 +610,16 @@ public class HelpController
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||||
|
|
||||||
popup = new ContextHelpMenupopup(node, baseContent.toString(), translatedContent.toString());
|
addContextHelpMenupopup(node, baseContent, translatedContent);
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
translatedContent.append("<p><em>(" + Msg.getMsg(Env.getCtx(), "NotAvailable") + ")</em></p>");
|
translatedContent.append("<p><em>(" + Msg.getMsg(Env.getCtx(), "NotAvailable") + ")</em></p>");
|
||||||
baseContent.append("<p><em>(" + Msg.getMsg(Language.getBaseAD_Language(), "NotAvailable") + ")</em></p>");
|
baseContent.append("<p><em>(" + Msg.getMsg(Language.getBaseAD_Language(), "NotAvailable") + ")</em></p>");
|
||||||
sb.append(translatedContent.toString());
|
sb.append(translatedContent.toString());
|
||||||
popup = new ContextHelpMenupopup(null, baseContent.toString(), translatedContent.toString());
|
|
||||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
addContextHelpMenupopup(null, baseContent, translatedContent);
|
||||||
pnlContextHelp.setContext(popup);
|
|
||||||
popup.setPage(pnlContextHelp.getPage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +627,16 @@ public class HelpController
|
||||||
|
|
||||||
htmlContextHelp.setContent(sb.toString());
|
htmlContextHelp.setContent(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addContextHelpMenupopup(PO po, StringBuilder baseContent, StringBuilder translatedContent) {
|
||||||
|
if (!MRole.getDefault().isTableAccessExcluded(MCtxHelpSuggestion.Table_ID)) {
|
||||||
|
ContextHelpMenupopup popup = new ContextHelpMenupopup(po, baseContent.toString(), translatedContent.toString());
|
||||||
|
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||||
|
pnlContextHelp.setContext(popup);
|
||||||
|
popup.setPage(pnlContextHelp.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void renderQuickInfo(GridTab gridTab) {
|
public void renderQuickInfo(GridTab gridTab) {
|
||||||
if (gridTab == null) {
|
if (gridTab == null) {
|
||||||
pnlQuickInfo.setVisible(false);
|
pnlQuickInfo.setVisible(false);
|
||||||
|
|
Loading…
Reference in New Issue