Commit d54f99d8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

old fashion methods removed

parent b392131d
......@@ -25,19 +25,21 @@ function UserPanel(params) {
}
});
self.getLoginButton().onclick = function(){
var loginButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON);
var logoutButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON);
loginButton.onclick = function(){
var login = self.getLoginText().value;
var password = self.getPasswordText().value;
ServerConnector.login(login, password).then(function(){
return ServerConnector.login(login, password).then(function(){
window.location.reload(false);
}).catch(function(problem){
GuiConnector.alert(problem);
});
};
self.getLogoutButton().onclick = function(){
ServerConnector.logout().then(function(){
logoutButton.onclick = function(){
return ServerConnector.logout().then(function(){
window.location.reload(false);
}).catch(function(problem){
GuiConnector.alert(problem);
......@@ -130,63 +132,33 @@ UserPanel.prototype._createUserDataTab = function() {
this.setControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON, logoutButton);
};
UserPanel.prototype.getUserLoginTab = function() {
return this.getElementByName(this.getElement(), "userLoginTab");
};
UserPanel.prototype.getPasswordText= function() {
return this.getElementByName(this.getElement(), "passwordText");
};
UserPanel.prototype.getLoginText = function() {
return this.getElementByName(this.getElement(), "loginText");
};
UserPanel.prototype.getUserDataTab = function() {
return this.getElementByName(this.getElement(), "userDataTab");
};
UserPanel.prototype.getLoginValue = function() {
return this.getElementByName(this.getElement(), "loginValue");
};
UserPanel.prototype.getLogoutButton = function() {
return this.getElementByName(this.getElement(), "logoutButton");
};
UserPanel.prototype.getLoginButton = function() {
return this.getElementByName(this.getElement(), "loginButton");
};
UserPanel.prototype.getNameValue = function() {
return this.getElementByName(this.getElement(), "nameValue");
};
UserPanel.prototype.getSurnameValue = function() {
return this.getElementByName(this.getElement(), "surnameValue");
};
UserPanel.prototype.getEmailValue = function() {
return this.getElementByName(this.getElement(), "emailValue");
};
UserPanel.prototype.showLoginPage = function() {
var self = this;
self.getUserLoginTab().style.display = "block";
var userLoginTabDiv = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_DIV);
var userDataTabDiv = self.getControlElement(PanelControlElementType.USER_TAB_USER_DIV);
self.getUserDataTab().style.display = "none";
userLoginTabDiv.style.display = "block";
userDataTabDiv.style.display = "none";
};
UserPanel.prototype.showUserProfilePage = function(user) {
var self = this;
self.getUserLoginTab().style.display = "none";
var userLoginTabDiv = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_DIV);
var userDataTabDiv = self.getControlElement(PanelControlElementType.USER_TAB_USER_DIV);
var loginText = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_TEXT);
var nameText = self.getControlElement(PanelControlElementType.USER_TAB_NAME_TEXT);
var surnameText = self.getControlElement(PanelControlElementType.USER_TAB_SURNAME_TEXT);
var emailText = self.getControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT);
userLoginTabDiv.style.display = "none";
self.getUserDataTab().style.display = "block";
userDataTabDiv.style.display = "block";
self.getLoginValue().innerHTML = user.getLogin();
self.getNameValue().innerHTML = user.getName();
self.getSurnameValue().innerHTML = user.getSurname();
self.getEmailValue().innerHTML = user.getEmail();
loginText.innerHTML = user.getLogin();
nameText.innerHTML = user.getName();
surnameText.innerHTML = user.getSurname();
emailText.innerHTML = user.getEmail();
};
module.exports = UserPanel;
......@@ -42,4 +42,17 @@ describe('UserPanel', function() {
var user = helper.createUser();
panel.showUserProfilePage(user);
});
it('show login page', function() {
var div = helper.createUserTab();
var map = helper.createCustomMap();
var panel = new UserPanel({
element : div,
customMap : map
});
panel.showLoginPage();
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment