IDEMPIERE-354 Implement 'Select Role' checkbox on first login screen to skip second login screen
Thanks to Juliana Corredor - peer reviewed by Carlos Ruiz - sponsored by Trek Global
This commit is contained in:
parent
4a2a4af7c8
commit
facd2b358a
|
@ -0,0 +1,14 @@
|
|||
-- Aug 1, 2012 4:43:04 PM COT
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Select Role',200009,'D','15bdd556-85d4-4518-87e9-4ab298c49bb0','SelectRole','Y',TO_DATE('2012-08-01 16:43:01','YYYY-MM-DD HH24:MI:SS'),0,0,0,0,TO_DATE('2012-08-01 16:43:01','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Aug 1, 2012 4:43:04 PM COT
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200009 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
UPDATE AD_System
|
||||
SET LastMigrationScriptApplied='859_IDEMPIERE-354.sql'
|
||||
WHERE LastMigrationScriptApplied<'859_IDEMPIERE-354.sql'
|
||||
OR LastMigrationScriptApplied IS NULL
|
||||
;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
-- Aug 1, 2012 4:43:04 PM COT
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Select Role',200009,'D','15bdd556-85d4-4518-87e9-4ab298c49bb0','SelectRole','Y',TO_TIMESTAMP('2012-08-01 16:43:01','YYYY-MM-DD HH24:MI:SS'),0,0,0,0,TO_TIMESTAMP('2012-08-01 16:43:01','YYYY-MM-DD HH24:MI:SS'))
|
||||
;
|
||||
|
||||
-- Aug 1, 2012 4:43:04 PM COT
|
||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200009 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||
;
|
||||
|
||||
UPDATE AD_System
|
||||
SET LastMigrationScriptApplied='859_IDEMPIERE-354.sql'
|
||||
WHERE LastMigrationScriptApplied<'859_IDEMPIERE-354.sql'
|
||||
OR LastMigrationScriptApplied IS NULL
|
||||
;
|
||||
|
|
@ -68,7 +68,6 @@ import org.zkoss.zhtml.Td;
|
|||
import org.zkoss.zhtml.Tr;
|
||||
import org.zkoss.zk.au.out.AuFocus;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.fn.ZkFns;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.Session;
|
||||
|
@ -109,6 +108,7 @@ public class LoginPanel extends Window implements EventListener
|
|||
private Combobox lstLanguage;
|
||||
private LoginWindow wndLogin;
|
||||
private Checkbox chkRememberMe;
|
||||
private Checkbox chkSelectRole;
|
||||
|
||||
public LoginPanel(Properties ctx, LoginWindow loginWindow)
|
||||
{
|
||||
|
@ -200,6 +200,17 @@ public class LoginPanel extends Window implements EventListener
|
|||
td.setSclass(ITheme.LOGIN_FIELD_CLASS);
|
||||
tr.appendChild(td);
|
||||
td.appendChild(chkRememberMe);
|
||||
tr = new Tr();
|
||||
tr.setId("rowSelectRole");
|
||||
table.appendChild(tr);
|
||||
td = new Td();
|
||||
tr.appendChild(td);
|
||||
td.setSclass(ITheme.LOGIN_LABEL_CLASS);
|
||||
td.appendChild(new Label(""));
|
||||
td = new Td();
|
||||
td.setSclass(ITheme.LOGIN_FIELD_CLASS);
|
||||
tr.appendChild(td);
|
||||
td.appendChild(chkSelectRole);
|
||||
}
|
||||
|
||||
div = new Div();
|
||||
|
@ -240,6 +251,7 @@ public class LoginPanel extends Window implements EventListener
|
|||
txtPassword.setAttribute("user.token.hash", token);
|
||||
txtPassword.setAttribute("user.token.sid", AD_Session_ID);
|
||||
}
|
||||
chkSelectRole.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -305,6 +317,8 @@ public class LoginPanel extends Window implements EventListener
|
|||
|
||||
chkRememberMe = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "RememberMe"));
|
||||
|
||||
chkSelectRole = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "SelectRole"));
|
||||
|
||||
// Make the default language the language of client System
|
||||
String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
|
||||
for(int i = 0; i < lstLanguage.getItemCount(); i++)
|
||||
|
@ -393,6 +407,8 @@ public class LoginPanel extends Window implements EventListener
|
|||
lblPassword.setValue(res.getString("Password"));
|
||||
lblLanguage.setValue(res.getString("Language"));
|
||||
chkRememberMe.setLabel(Msg.getMsg(language, "RememberMe"));
|
||||
chkSelectRole.setLabel(Msg.getMsg(language, "SelectRole"));
|
||||
|
||||
}
|
||||
|
||||
private Language findLanguage(String langName) {
|
||||
|
@ -431,6 +447,8 @@ public class LoginPanel extends Window implements EventListener
|
|||
}
|
||||
}
|
||||
|
||||
Env.setContext(ctx, BrowserToken.REMEMBER_ME, chkRememberMe.isChecked());
|
||||
|
||||
Session currSess = Executions.getCurrent().getDesktop().getSession();
|
||||
|
||||
KeyNamePair rolesKNPairs[] = login.getRoles(userId, userPassword);
|
||||
|
@ -445,10 +463,10 @@ public class LoginPanel extends Window implements EventListener
|
|||
else
|
||||
langName = Language.getBaseLanguage().getName();
|
||||
Language language = findLanguage(langName);
|
||||
wndLogin.loginOk(userId, userPassword);
|
||||
|
||||
Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName()); // Elaine 2009/02/06
|
||||
|
||||
wndLogin.loginOk(userId, userPassword, chkSelectRole.isChecked());
|
||||
|
||||
Locale locale = language.getLocale();
|
||||
currSess.setAttribute(Attributes.PREFERRED_LOCALE, locale);
|
||||
try {
|
||||
|
@ -470,8 +488,6 @@ public class LoginPanel extends Window implements EventListener
|
|||
currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx));
|
||||
// End of temporary code for [ adempiere-ZK Web Client-2832968 ] User context lost?
|
||||
|
||||
Env.setContext(ctx, BrowserToken.REMEMBER_ME, chkRememberMe.isChecked());
|
||||
|
||||
/* Check DB version */
|
||||
String version = DB.getSQLValueString(null, "SELECT Version FROM AD_System");
|
||||
// Identical DB version
|
||||
|
|
|
@ -97,11 +97,14 @@ public class RolePanel extends Window implements EventListener, Deferrable
|
|||
/** Password */
|
||||
private String m_password;
|
||||
|
||||
public RolePanel(Properties ctx, LoginWindow loginWindow, String userName, String password) {
|
||||
private boolean m_show = true;
|
||||
|
||||
public RolePanel(Properties ctx, LoginWindow loginWindow, String userName, String password, boolean show) {
|
||||
this.wndLogin = loginWindow;
|
||||
m_ctx = ctx;
|
||||
m_userName = userName;
|
||||
m_password = password; login = new Login(ctx);
|
||||
m_show = show;
|
||||
rolesKNPairs = login.getRoles(userName, password);
|
||||
if(rolesKNPairs == null)
|
||||
throw new ApplicationException("Login is invalid, UserName: " + userName + " and Password:" + password);
|
||||
|
@ -110,8 +113,12 @@ public class RolePanel extends Window implements EventListener, Deferrable
|
|||
init();
|
||||
this.setId("rolePanel");
|
||||
|
||||
AuFocus auf = new AuFocus(lstRole);
|
||||
Clients.response(auf);
|
||||
if (m_show) {
|
||||
AuFocus auf = new AuFocus(lstRole);
|
||||
Clients.response(auf);
|
||||
} else {
|
||||
validateRoles();
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
|
@ -298,8 +305,10 @@ public class RolePanel extends Window implements EventListener, Deferrable
|
|||
if(rolesKNPairs[i].getID().equals(initDefault))
|
||||
lstRole.setSelectedItem(ci);
|
||||
}
|
||||
if (lstRole.getSelectedIndex() == -1 && lstRole.getItemCount() > 0)
|
||||
if (lstRole.getSelectedIndex() == -1 && lstRole.getItemCount() > 0) {
|
||||
m_show = true; // didn't find default role
|
||||
lstRole.setSelectedIndex(0);
|
||||
}
|
||||
//
|
||||
|
||||
// If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94
|
||||
|
@ -338,8 +347,10 @@ public class RolePanel extends Window implements EventListener, Deferrable
|
|||
if(clientKNPairs[i].getID().equals(initDefault))
|
||||
lstClient.setSelectedItem(ci);
|
||||
}
|
||||
if (lstClient.getSelectedIndex() == -1 && lstClient.getItemCount() > 0)
|
||||
if (lstClient.getSelectedIndex() == -1 && lstClient.getItemCount() > 0) {
|
||||
m_show = true; // didn't find default client
|
||||
lstClient.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
|
@ -372,8 +383,10 @@ public class RolePanel extends Window implements EventListener, Deferrable
|
|||
lstOrganisation.setSelectedItem(ci);
|
||||
|
||||
}
|
||||
if (lstOrganisation.getSelectedIndex() == -1 && lstOrganisation.getItemCount() > 0)
|
||||
if (lstOrganisation.getSelectedIndex() == -1 && lstOrganisation.getItemCount() > 0) {
|
||||
m_show = true; // didn't find default organisation
|
||||
lstOrganisation.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
//
|
||||
}
|
||||
|
@ -401,8 +414,10 @@ public class RolePanel extends Window implements EventListener, Deferrable
|
|||
if(warehouseKNPairs[i].getID().equals(initDefault))
|
||||
lstWarehouse.setSelectedItem(ci);
|
||||
}
|
||||
if (lstWarehouse.getSelectedIndex() == -1 && lstWarehouse.getItemCount() > 0)
|
||||
if (lstWarehouse.getSelectedIndex() == -1 && lstWarehouse.getItemCount() > 0) {
|
||||
m_show = true; // didn't find default warehouse
|
||||
lstWarehouse.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
//
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ public class LoginWindow extends FWindow implements EventListener
|
|||
pnlLogin = new LoginPanel(ctx, this);
|
||||
}
|
||||
|
||||
public void loginOk(String userName, String password)
|
||||
public void loginOk(String userName, String password, boolean show)
|
||||
{
|
||||
pnlRole = new RolePanel(ctx, this, userName, password);
|
||||
pnlRole = new RolePanel(ctx, this, userName, password, show);
|
||||
this.getChildren().clear();
|
||||
this.appendChild(pnlRole);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue