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,17 +290,19 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
|||
}
|
||||
|
||||
public void addSuggestion(final GridField field) {
|
||||
Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID"));
|
||||
if (ThemeManager.isUseFontIconForImage())
|
||||
editor.setIconSclass("z-icon-FieldSuggestion");
|
||||
editor.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
WFieldSuggestion fieldSuggestion = new WFieldSuggestion(field.getAD_Field_ID());
|
||||
fieldSuggestion.setPage(WEditorPopupMenu.this.getPage());
|
||||
fieldSuggestion.doHighlighted();
|
||||
}
|
||||
});
|
||||
appendChild(editor);
|
||||
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");
|
||||
editor.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
WFieldSuggestion fieldSuggestion = new WFieldSuggestion(field.getAD_Field_ID());
|
||||
fieldSuggestion.setPage(WEditorPopupMenu.this.getPage());
|
||||
fieldSuggestion.doHighlighted();
|
||||
}
|
||||
});
|
||||
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");
|
||||
ContextHelpMenupopup popup = new ContextHelpMenupopup(ctxHelpMsg);
|
||||
pnlContextHelp.setAttribute("contextMenu", popup);
|
||||
pnlContextHelp.setContext(popup);
|
||||
popup.setPage(pnlContextHelp.getPage());
|
||||
|
||||
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);
|
||||
|
@ -323,11 +328,8 @@ 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))
|
||||
{
|
||||
|
@ -374,11 +376,8 @@ 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))
|
||||
{
|
||||
|
@ -424,11 +423,8 @@ 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))
|
||||
{
|
||||
|
@ -473,11 +469,8 @@ 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))
|
||||
{
|
||||
|
@ -522,12 +515,8 @@ 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))
|
||||
{
|
||||
|
@ -574,11 +563,8 @@ 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))
|
||||
{
|
||||
|
@ -624,21 +610,16 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,7 +627,16 @@ 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