增加 welcome-file 以支持 Tomcat 7 下根路径可以被 map 到 LoginServlet。
[jibu.git] / jibu-web / jibu-core-extjs / src / main / webapp / js / system / setting.js
blob45c8c1455bc770934901ae028c3ce20be3453454
1 Ext.ns('jibu.security.setting');
2 jibu.security.setting.Form =
3 Ext.extend(Ext.form.FormPanel,{
4 fullName : 'Full Name',
5 email : 'E-mail',
6 userName: 'User Name',
7 password: 'New Password',
8 passwordRepeat: 'Re-enter New Password',
9 userInformation:'Account Information',
10 settings: 'Preference Settings',
11 theme : 'Theme',
12 language : 'Language',
13 fl_layout : 'Layout',
14 confirmPassword: 'Passwords do not match',
15 passwordInfo: 'Password',
16 oldPassword: 'Current Password',
17 submitText: 'Submit',
18 waitMsgText: 'Submitting...',
19 initComponent:function() {
20 var config = {
21 labelWidth: 150,
22 frame : true,
23 monitorValid:true,
24 style:'padding:1px',
25 items: [{
26 xtype:'fieldset',
27 title: this.userInformation,
28 collapsible: true,
29 autoHeight:true,
30 defaults: {width: 210},
31 defaultType: 'textfield',
32 items :[{
33 name: 'User.id',
34 xtype:'hidden'
35 },{
36 fieldLabel: this.fullName,
37 name: 'User.fullname',
38 allowBlank:false
39 },{
40 fieldLabel: this.email,
41 name: 'User.emailaddress',
42 vtype:'email'
43 },{
44 fieldLabel: this.userName,
45 name: 'User.username',
46 allowBlank:false,
47 disabled:true
50 },{
51 xtype:'fieldset',
52 title: this.passwordInfo,
53 collapsible: true,
54 autoHeight:true,
55 defaults: {width: 210},
56 defaultType: 'textfield',
57 items :[{
58 fieldLabel: this.oldPassword,
59 name: 'oldpassword',
60 allowBlank:false,
61 inputType: 'password'
62 }, {
63 fieldLabel: this.password,
64 id :'setting_newpassword',
65 name: 'User.password',
66 inputType: 'password'
67 }, {
68 fieldLabel: this.passwordRepeat,
69 name: 'passwordAgain',
70 inputType: 'password',
71 vtype: 'passwordAgain'
74 },{
75 xtype:'fieldset',
76 title: this.settings,
77 collapsible: true,
78 autoHeight:true,
79 defaults: {width: 210},
80 defaultType: 'textfield',
81 items :[
82 new Ext.form.ComboBox({
83 store:new Ext.data.JsonStore({
84 fields:[{name:'id', type:'int'},
85 {name:'value', type:'string'}],
86 url:'Setting.y?ci=settingLoad',
87 root:'settings',
88 baseParams:{'settings.name' :'language'}
89 }),
90 displayField:'value',
91 valueField:'id',
92 id:'setting_language',
93 hiddenId :'h_setting_language',
94 hiddenName:'settings.id',
95 triggerAction:'all',
96 fieldLabel: this.language,
97 selectOnFocus:true
98 }),
99 new Ext.form.ComboBox({
100 store:new Ext.data.JsonStore({
101 fields:[{name:'id', type:'int'},
102 {name:'value', type:'string'}],
103 url:'Setting.y?ci=settingLoad',
104 root:'settings',
105 baseParams:{'settings.name' :'layout'}
107 displayField:'value',
108 valueField:'id',
109 id:'setting_layout',
110 hiddenId :'h_setting_layout',
111 hiddenName:'settings.id',
112 triggerAction:'all',
113 fieldLabel: this.fl_layout,
114 selectOnFocus:true
116 new Ext.form.ComboBox({
117 store:new Ext.data.JsonStore({
118 fields:[{name:'id', type:'int'},
119 {name:'value', type:'string'}],
120 url:'Setting.y?ci=settingLoad',
121 root:'settings',
122 baseParams:{
123 'settings.name' :'theme'
126 displayField:'value',
127 valueField:'id',
128 id:'setting_theme',
129 hiddenId :'h_setting_theme',
130 hiddenName:'settings.id',
131 triggerAction:'all',
132 fieldLabel:this.theme,
133 selectOnFocus:true
137 buttonAlign:'center',
138 buttons: [{
139 id:'setting_submitBtn',
140 text: this.submitText,
141 scope:this,
142 formBind:true,
143 handler:function() {
144 this.getForm().submit({
145 url: 'Setting.y?ci=settingUpdate',
146 method: 'POST',
147 waitMsg: this.waitMsgText,
148 success: function(form, action) {
150 failure: function(form, action) {
156 listeners:{
157 render:function(){
158 this.form.load(
160 url: 'Setting.y?ci=formLoad',
161 success:function(f,a){
162 var settings = a.result.settings;
163 // f.setValues() 会把显示值和实际值都置为 settings[i].value
164 // 需要 Ext.fly 将实际值置为 settings[i].id,而且必须在 f.setValues() 之后
165 for (var i=0;i<settings.length;i++) {
166 f.setValues([{id:'setting_'+settings[i].name,value:settings[i].value}]);
167 Ext.fly('h_setting_'+settings[i].name).dom.value=settings[i].id;
173 }; // eof config object
174 // apply config
175 Ext.apply(this, Ext.apply(this.initialConfig, config));
176 // call parent
177 jibu.security.setting.Form.superclass.initComponent.apply(this, arguments);
179 // “再次录入密码”校验器
180 Ext.apply(Ext.form.VTypes, {
181 passwordAgain: function(val, field) {
182 var password = Ext.getCmp("setting_newpassword").getValue();
183 if (val != password) {
184 Ext.getCmp("setting_submitBtn").disable();
185 return false;
186 } else {
187 Ext.getCmp("setting_submitBtn").enable();
188 return true;
193 // 处理“再次录入密码”校验未通过时显示的提示信息
194 Ext.apply(Ext.form.VTypes, {
195 passwordAgainText: this.confirmPassword
197 }// eo funtion initComponent
200 Ext.reg('system.setting', jibu.security.setting.Form);