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
|
||||
|
@ -3344,4 +3344,25 @@ public final class MRole extends X_AD_Role
|
|||
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
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.adempiere.webui.theme.ThemeManager;
|
|||
import org.adempiere.webui.window.WFieldSuggestion;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.Lookup;
|
||||
import org.compiere.model.MFieldSuggestion;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.MZoomCondition;
|
||||
|
@ -289,6 +290,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
|||
}
|
||||
|
||||
public void addSuggestion(final GridField field) {
|
||||
if (!MRole.getDefault().isTableAccessExcluded(MFieldSuggestion.Table_ID)) {
|
||||
Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID"));
|
||||
if (ThemeManager.isUseFontIconForImage())
|
||||
editor.setIconSclass("z-icon-FieldSuggestion");
|
||||
|
@ -302,4 +304,5 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
|||
});
|
||||
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_Workflow;
|
||||
import org.compiere.model.MCtxHelpMsg;
|
||||
import org.compiere.model.MCtxHelpSuggestion;
|
||||
import org.compiere.model.MForm;
|
||||
import org.compiere.model.MInfoWindow;
|
||||
import org.compiere.model.MProcess;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTab;
|
||||
import org.compiere.model.MTask;
|
||||
import org.compiere.model.PO;
|
||||
|
@ -269,16 +271,19 @@ public class HelpController
|
|||
if (ctxHelpMsg != null)
|
||||
{
|
||||
sb.append(stripHtml(ctxHelpMsg.get_Translation(I_AD_CtxHelpMsg.COLUMNNAME_MsgText), false) + "<br>\n");
|
||||
|
||||
if (!MRole.getDefault().isTableAccessExcluded(MCtxHelpSuggestion.Table_ID)) {
|
||||
ContextHelpMenupopup popup = new ContextHelpMenupopup(ctxHelpMsg);
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder baseContent = new StringBuilder();
|
||||
StringBuilder translatedContent = new StringBuilder();
|
||||
ContextHelpMenupopup popup = null;
|
||||
|
||||
if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Tab))
|
||||
{
|
||||
MTab tab = new MTab(Env.getCtx(), recordId, null);
|
||||
|
@ -324,10 +329,7 @@ public class HelpController
|
|||
|
||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||
|
||||
popup = new ContextHelpMenupopup(tab, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
addContextHelpMenupopup(tab, baseContent, translatedContent);
|
||||
}
|
||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Process))
|
||||
{
|
||||
|
@ -375,10 +377,7 @@ public class HelpController
|
|||
|
||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||
|
||||
popup = new ContextHelpMenupopup(process, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
addContextHelpMenupopup(process, baseContent, translatedContent);
|
||||
}
|
||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Form))
|
||||
{
|
||||
|
@ -425,10 +424,7 @@ public class HelpController
|
|||
|
||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||
|
||||
popup = new ContextHelpMenupopup(form, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
addContextHelpMenupopup(form, baseContent, translatedContent);
|
||||
}
|
||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Info))
|
||||
{
|
||||
|
@ -474,10 +470,7 @@ public class HelpController
|
|||
|
||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||
|
||||
popup = new ContextHelpMenupopup(info, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
addContextHelpMenupopup(info, baseContent, translatedContent);
|
||||
}
|
||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Workflow))
|
||||
{
|
||||
|
@ -523,11 +516,7 @@ public class HelpController
|
|||
|
||||
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))
|
||||
{
|
||||
|
@ -575,10 +564,7 @@ public class HelpController
|
|||
|
||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||
|
||||
popup = new ContextHelpMenupopup(task, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
addContextHelpMenupopup(task, baseContent, translatedContent);
|
||||
}
|
||||
else if (ctxType.equals(X_AD_CtxHelp.CTXTYPE_Node))
|
||||
{
|
||||
|
@ -625,20 +611,15 @@ public class HelpController
|
|||
|
||||
sb.append(Util.isEmpty(translatedContent.toString()) ? baseContent.toString() : translatedContent.toString());
|
||||
|
||||
popup = new ContextHelpMenupopup(node, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
addContextHelpMenupopup(node, baseContent, translatedContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
translatedContent.append("<p><em>(" + Msg.getMsg(Env.getCtx(), "NotAvailable") + ")</em></p>");
|
||||
baseContent.append("<p><em>(" + Msg.getMsg(Language.getBaseAD_Language(), "NotAvailable") + ")</em></p>");
|
||||
sb.append(translatedContent.toString());
|
||||
popup = new ContextHelpMenupopup(null, baseContent.toString(), translatedContent.toString());
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
|
||||
addContextHelpMenupopup(null, baseContent, translatedContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,6 +628,15 @@ public class HelpController
|
|||
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) {
|
||||
if (gridTab == null) {
|
||||
pnlQuickInfo.setVisible(false);
|
||||
|
|
Loading…
Reference in New Issue