mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-06-22 12:21:31 +00:00
window/Language Edit: use view controller
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
7029d72ad2
commit
eb23099741
@ -2,6 +2,29 @@ Ext.define('Proxmox.window.LanguageEditWindow', {
|
|||||||
extend: 'Ext.window.Window',
|
extend: 'Ext.window.Window',
|
||||||
alias: 'widget.pmxLanguageEditWindow',
|
alias: 'widget.pmxLanguageEditWindow',
|
||||||
|
|
||||||
|
viewModel: {
|
||||||
|
parent: null,
|
||||||
|
data: {
|
||||||
|
language: '__default__',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
controller: {
|
||||||
|
xclass: 'Ext.app.ViewController',
|
||||||
|
init: function(view) {
|
||||||
|
let language = Ext.util.Cookies.get(view.cookieName) || '__default__';
|
||||||
|
this.getViewModel().set('language', language);
|
||||||
|
},
|
||||||
|
applyLanguage: function(button) {
|
||||||
|
let view = this.getView();
|
||||||
|
let vm = this.getViewModel();
|
||||||
|
|
||||||
|
let expire = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
|
||||||
|
Ext.util.Cookies.set(view.cookieName, vm.get('language'), expire);
|
||||||
|
view.mask(gettext('Please wait...'), 'x-mask-loading');
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
cookieName: 'PVELangCookie',
|
cookieName: 'PVELangCookie',
|
||||||
|
|
||||||
title: gettext('Language'),
|
title: gettext('Language'),
|
||||||
@ -11,33 +34,15 @@ Ext.define('Proxmox.window.LanguageEditWindow', {
|
|||||||
{
|
{
|
||||||
xtype: 'proxmoxLanguageSelector',
|
xtype: 'proxmoxLanguageSelector',
|
||||||
fieldLabel: gettext('Language'),
|
fieldLabel: gettext('Language'),
|
||||||
|
bind: {
|
||||||
|
value: '{language}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
text: gettext('OK'),
|
text: gettext('Apply'),
|
||||||
handler: function() {
|
handler: 'applyLanguage',
|
||||||
let me = this;
|
|
||||||
let win = this.up('window');
|
|
||||||
let value = win.down('proxmoxLanguageSelector').getValue();
|
|
||||||
let dt = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
|
|
||||||
Ext.util.Cookies.set(win.cookieName, value, dt);
|
|
||||||
win.mask(gettext('Please wait...'), 'x-mask-loading');
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
initComponent: function() {
|
|
||||||
let me = this;
|
|
||||||
|
|
||||||
if (!me.cookieName) {
|
|
||||||
throw "no cookie name given";
|
|
||||||
}
|
|
||||||
|
|
||||||
me.callParent();
|
|
||||||
me.down('proxmoxLanguageSelector')
|
|
||||||
.setValue(Ext.util.Cookies.get(me.cookieName) || '__default__');
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user