Replaced css class based state verification to a data attribute based

approach
This commit is contained in:
Benjamin Barth committed 2016-03-09 11:17:17 +01:00
1 parent 63333e5cbe
commit 1428a836cc
3 files changed
+13 -8

No files matched your search

@@ -33,7 +33,6 @@ public class SAPHeaderWithAuthentication extends SAPHeader {
rightWithAuthentication.addStyleName(res.css().header_right_wrapper());
Anchor authenticationMenu = new Anchor();
authenticationMenu.ensureDebugId("authenticationMenu");
authenticationMenu.addStyleName(res.css().usermanagement_icon());
rightWithAuthentication.add(authenticationMenu);
authenticationMenuView = new AuthenticationMenuViewImpl(authenticationMenu, res.css().usermanagement_loggedin(), res.css().usermanagement_open());
@@ -1,5 +1,6 @@
package com.sap.sse.security.ui.authentication.view;
import com.google.gwt.debug.client.DebugInfo;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Anchor;
@@ -35,6 +36,7 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView {
presenter.toggleFlyout();
}
});
this.anchor.ensureDebugId("authenticationMenu");
}
@Override
@@ -50,11 +52,19 @@ public class AuthenticationMenuViewImpl implements AuthenticationMenuView {
@Override
public void setAuthenticated(boolean authenticated) {
anchor.setStyleName(loggedInStyle, authenticated);
setDebugDataAttribute("data-auth", authenticated);
}
@Override
public void setOpen(boolean open) {
anchor.setStyleName(openStyle, open);
setDebugDataAttribute("data-open", open);
}
private void setDebugDataAttribute(String name, boolean value) {
if (DebugInfo.isDebugIdEnabled()) {
anchor.getElement().setAttribute(name, String.valueOf(value));
}
}
}