Skip to content
Snippets Groups Projects
Commit d54f99d8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

old fashion methods removed

parent b392131d
No related branches found
No related tags found
1 merge request!5Frontend refactor
...@@ -25,19 +25,21 @@ function UserPanel(params) { ...@@ -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 login = self.getLoginText().value;
var password = self.getPasswordText().value; var password = self.getPasswordText().value;
ServerConnector.login(login, password).then(function(){ return ServerConnector.login(login, password).then(function(){
window.location.reload(false); window.location.reload(false);
}).catch(function(problem){ }).catch(function(problem){
GuiConnector.alert(problem); GuiConnector.alert(problem);
}); });
}; };
self.getLogoutButton().onclick = function(){ logoutButton.onclick = function(){
ServerConnector.logout().then(function(){ return ServerConnector.logout().then(function(){
window.location.reload(false); window.location.reload(false);
}).catch(function(problem){ }).catch(function(problem){
GuiConnector.alert(problem); GuiConnector.alert(problem);
...@@ -130,63 +132,33 @@ UserPanel.prototype._createUserDataTab = function() { ...@@ -130,63 +132,33 @@ UserPanel.prototype._createUserDataTab = function() {
this.setControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON, logoutButton); 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() { UserPanel.prototype.showLoginPage = function() {
var self = this; 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) { UserPanel.prototype.showUserProfilePage = function(user) {
var self = this; 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(); loginText.innerHTML = user.getLogin();
self.getNameValue().innerHTML = user.getName(); nameText.innerHTML = user.getName();
self.getSurnameValue().innerHTML = user.getSurname(); surnameText.innerHTML = user.getSurname();
self.getEmailValue().innerHTML = user.getEmail(); emailText.innerHTML = user.getEmail();
}; };
module.exports = UserPanel; module.exports = UserPanel;
...@@ -42,4 +42,17 @@ describe('UserPanel', function() { ...@@ -42,4 +42,17 @@ describe('UserPanel', function() {
var user = helper.createUser(); var user = helper.createUser();
panel.showUserProfilePage(user); 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();
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment