Improve settings window and cleanup

This commit is contained in:
Eike Foken
2011-05-06 12:33:43 +02:00
parent 90c27d82cd
commit 6a1ae19983
9 changed files with 299 additions and 272 deletions

View File

@@ -36,3 +36,7 @@ a:hover {
.x-tree-node-icon {
height: 16px !important;
}
.x-form-display-field {
color: #777;
}

View File

@@ -3,94 +3,109 @@
*
* @class SettingsWindow
* @extends Ext.Window
* @author Eike Foken <kontakt@eikefoken.de>
*/
SettingsWindow = Ext.extend(Ext.Window, {
title: lang['settings_window_title'],
id: 'settings-window',
width: 400,
autoHeight: true,
closeAction: 'hide',
draggable: false,
resizable: false,
modal: true,
initComponent: function() {
this.items = [{
xtype: 'form',
id: 'settings-form',
url: BASE_URL + 'auth/settings',
method: 'POST',
border: false,
items: [{
xtype: 'tabpanel',
border: false,
activeTab: 0,
defaults: {
layout: 'form',
defaultType: 'textfield',
labelWidth: 170,
autoHeight: true,
bodyStyle: 'padding: 10px'
},
items: [{
xtype: 'panel',
id: 'password',
title: lang['settings_window_panel_password'],
items: [{
fieldLabel: lang['settings_window_old_password'],
name: 'old_password'
}, {
fieldLabel: lang['settings_window_new_password'],
name: 'new_password'
}, {
fieldLabel: lang['settings_window_new_password_confirm'],
name: 'new_password_confirm'
}]
}, {
xtype: 'panel',
title: lang['settings_window_panel_profile'],
items: [{
fieldLabel: lang['settings_window_firstname'],
name: 'firstname'
}, {
fieldLabel: lang['settings_window_lastname'],
name: 'lastname'
}, {
fieldLabel: lang['settings_window_institution'],
name: 'institution'
}, {
fieldLabel: lang['settings_window_phone'],
name: 'phone'
}, {
fieldLabel: lang['settings_window_email'],
name: 'email'
}]
}]
}],
buttons: [{
text: lang['settings_window_save'],
handler: function() {
Ext.getCmp('settings-form').getForm().submit();
}
}, {
text: lang['settings_window_close'],
handler: function() {
this.hide();
}
}]
}];
title: lang['settings_window_title'],
id: 'settings-window',
width: 400,
closeAction: 'hide',
draggable: false,
resizable: false,
modal: true,
initComponent: function() {
this.items = [{
xtype: 'form',
id: 'settings-form',
url: BASE_URL + 'auth/settings',
method: 'post',
border: false,
items: [{
xtype: 'tabpanel',
border: false,
activeTab: 0,
defaults: {
layout: 'form',
defaultType: 'textfield',
labelWidth: 170,
height: 150,
bodyStyle: 'padding: 10px'
},
items: [{
xtype: 'panel',
title: lang['settings_window_panel_profile'],
items: [{
fieldLabel: lang['settings_window_firstname'],
name: 'firstname'
}, {
fieldLabel: lang['settings_window_lastname'],
name: 'lastname'
}, {
fieldLabel: lang['settings_window_institution'],
name: 'institution'
}, {
fieldLabel: lang['settings_window_phone'],
name: 'phone'
}, {
fieldLabel: lang['settings_window_email'],
name: 'email'
}]
}, {
xtype: 'panel',
id: 'password',
title: lang['settings_window_panel_password'],
items: [{
fieldLabel: lang['settings_window_old_password'],
name: 'old_password',
inputType: 'password'
}, {
fieldLabel: lang['settings_window_new_password'],
name: 'new_password',
inputType: 'password'
}, {
fieldLabel: lang['settings_window_new_password_confirm'],
name: 'new_password_confirm',
inputType: 'password'
}, {
xtype: 'displayfield',
value: lang['settings_window_password_note'],
hideLabel: true
}]
}]
}],
buttons: [{
text: lang['settings_window_save'],
handler: function() {
var theForm = Ext.getCmp('settings-form').getForm();
// call parent
SettingsWindow.superclass.initComponent.apply(this);
},
beforeShow: function() {
Ext.getCmp('settings-form').load({
url : BASE_URL + 'auth/settings',
waitMsg: "Lade..."
});
if (theForm.isValid()) {
theForm.submit({
success: function() {
Ext.getCmp('settings-window').hide();
}
});
}
}
}, {
text: lang['settings_window_cancel'],
handler: function() {
Ext.getCmp('settings-window').hide();
}
}]
}];
// call parent
SettingsWindow.superclass.beforeShow.apply(this);
}
// call parent
SettingsWindow.superclass.initComponent.apply(this);
},
beforeShow: function() {
Ext.getCmp('settings-form').load({
url : BASE_URL + 'auth/settings',
waitMsg: "Lade..."
});
// call parent
SettingsWindow.superclass.beforeShow.apply(this);
}
});
// register xtype to allow for lazy initialization

View File

@@ -3,6 +3,7 @@
*
* @param {} title
* @param {} message
* @param {} icon
*/
var message = function(title, message, icon) {
Ext.Msg.show({
@@ -15,11 +16,26 @@ var message = function(title, message, icon) {
});
};
var settings = new SettingsWindow();
/**
* Logs the user out.
*/
var logout = function() {
Ext.Ajax.request({
url: BASE_URL + 'auth/logout',
method: 'post',
success: function(xhr) {
window.location = BASE_URL + 'auth/login';
}
});
};
/**
* Application main entry point
*/
Ext.onReady(function() {
Ext.QuickTips.init();
if (typeof(SettingsWindow) == "function") {
settings = new SettingsWindow();
}
});

View File

@@ -1,12 +1,13 @@
var lang = {
settings_window_title: "Settings",
settings_window_save: "Save",
settings_window_close: "Close",
settings_window_cancel: "Cancel",
settings_window_panel_password: "Password",
settings_window_panel_profile: "Profile",
settings_window_old_password: "Old password",
settings_window_old_password: "Current password",
settings_window_new_password: "New password",
settings_window_new_password_confirm: "Confirm new password",
settings_window_password_note: "If you want to change your password, please fill out these fields, otherwise leave it blank.",
settings_window_firstname: "Firstname",
settings_window_lastname: "Lastname",
settings_window_institution: "Company",

View File

@@ -1,12 +1,13 @@
var lang = {
settings_window_title: "Einstellungen",
settings_window_save: "Speichern",
settings_window_close: "Schließen",
settings_window_cancel: "Abbrechen",
settings_window_panel_password: "Passwort",
settings_window_panel_profile: "Profil",
settings_window_old_password: "Altes Passwort",
settings_window_old_password: "Aktuelles Passwort",
settings_window_new_password: "Neues Passwort",
settings_window_new_password_confirm: "Neues Passwort wiederholen",
settings_window_new_password_confirm: "Neues Passwort bestätigen",
settings_window_password_note: "Wenn Sie Ihr Passwort ändern möchten, füllen Sie bitte die obigen Felder aus, ansonsten lassen Sie sie einfach leer.",
settings_window_firstname: "Vorname",
settings_window_lastname: "Nachname",
settings_window_institution: "Institut",