Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

refactoring...

  • Loading branch information...
commit 27fa2fa8f97fd55d446c08e05c3976e030cb91a8 1 parent 76555f0
angel ignacio colmenares laguado authored April 22, 2012
7  src/Aicl.DbToSS.CSharp/DotJs.Ext/Application.cs
@@ -8,18 +8,14 @@ public class Application
8 8
 	{
9 9
 		private string template=@"Ext.Loader.setConfig({{enabled: true}});
10 10
 Ext.Loader.setPath('{0}', '../app');
11  
-Ext.require(['Ext.tip.*']);
12  
-Ext.QuickTips.init();
13 11
     
14 12
 Ext.application({{
15 13
 name: '{0}',
16 14
 appFolder: '../app',
17  
-
18 15
 launch: function(){{
19 16
     Ext.create('Ext.form.Panel',{{
20 17
   	width:990,
21 18
     id:'panelModule',
22  
-    //baseCls:'x-plain',
23 19
     frame: true,
24 20
     renderTo: 'module',
25 21
     layout: {{
@@ -42,6 +38,9 @@ public class Application
42 38
 		}}
43 39
     ]
44 40
     }});
  41
+    var controller =this.getController('{2}');
  42
+    controller.get{2}Store().load();
  43
+    controller.refreshButtons();
45 44
 }},
46 45
     
47 46
 controllers: ['{2}']
117  src/Aicl.DbToSS.CSharp/DotJs.Ext/Controller.cs
@@ -9,20 +9,13 @@ public class Controller
9 9
 	{
10 10
 		private string template=@"Ext.define('{0}',{{
11 11
 	extend: '{1}',
12  
-    stores: [
13  
-        '{2}' 
14  
-    ],  
15  
-    models: [
16  
-    	'{2}'
17  
-    ],
18  
-    views: [
19  
-    	'{3}.List',
20  
-    	'{3}.Form'
21  
-    ],
  12
+    stores: ['{2}'],  
  13
+    models: ['{2}'],
  14
+    views:  ['{3}.List','{3}.Form' ],
22 15
     refs:[
23 16
     	{{ref: '{3}List',    	 selector: '{3}list' }},
24  
-    	{{ref: '{3}DeleteButton', selector: '{3}list button[action=delete]' 	}},
25  
-    	{{ref: '{3}NewButton',    selector: '{3}list button[action=new]' 	}},
  17
+    	{{ref: '{3}DeleteButton', selector: '{3}list button[action=delete]' }},
  18
+    	{{ref: '{3}NewButton',    selector: '{3}list button[action=new]' }},
26 19
     	{{ref: '{3}Form',    	 selector: '{3}form' }}, 
27 20
     	{{ref: '{3}SaveButton', 	 selector: '{3}form button[action=save]' }}
28 21
     ],
@@ -32,14 +25,7 @@ public class Controller
32 25
         this.control({{
33 26
             '{3}list': {{ 
34 27
                 selectionchange: function( sm,  selections,  eOpts){{
35  
-                	if (selections.length) {{
36  
-                		this.get{2}Form().getForm().loadRecord(selections[0]);
37  
-                		this.get{2}DeleteButton().setDisabled(false);
38  
-        				this.get{2}SaveButton().setText('Update');	          				
39  
-        			}}
40  
-        			else{{
41  
-        				this.reset{2}Form();
42  
-        			}}
  28
+                	this.refreshButtons(selections);
43 29
                 }}
44 30
             }},
45 31
             
@@ -47,49 +33,88 @@ public class Controller
47 33
                 click: function(button, event, options){{
48 34
                 	var grid = this.get{2}List();
49 35
                 	var record = grid.getSelectionModel().getSelection()[0];
50  
-        			grid.getStore().remove(record);
  36
+        			this.get{2}Store().remove(record);
51 37
                 }}
52 38
             }},
53 39
             
54 40
             '{3}list button[action=new]': {{
55 41
             	click:function(button, event, options){{
56  
-            		this.reset{2}Form();
  42
+            		this.get{2}List().getSelectionModel().deselectAll();
57 43
             	}}
58 44
             }},
59 45
             
60  
-            '{3}form button[action=save]':{{
  46
+            '{3}form button[action=save]':{{            	
61 47
             	click:function(button, event, options){{
  48
+            		var model = this.get{2}Store();
62 49
             		var record = this.get{2}Form().getForm().getFieldValues(true);
63  
-            		var store =this.get{2}Store();
64  
-        			if (record.Id ){{
65  
-           				var sr = store.getById(parseInt( record.Id) );
66  
-						sr.beginEdit();
67  
-						for( var r in record){{
68  
-							sr.set(r, record[r])
69  
-						}}
70  
-						sr.endEdit(); 
71  
-        			}}
72  
-        			else{{
73  
-          				var nr = Ext.ModelManager.create(record, this.get{2}Model().getName() );
74  
-						store.add(nr);
75  
-						this.get{2}List().getSelectionModel().doSingleSelect(nr,false);
76  
-        			}}
  50
+            		this.get{2}Store().save(record);
77 51
             	}}
78 52
             }}
79  
-            
80 53
         }});
81 54
     }},
82 55
     
83 56
     onLaunch: function(application){{
84  
-    	this.get{2}Store().load();
85  
-    	this.get{2}NewButton().setDisabled(false);
86  
-    	this.get{2}Form().setFocus();
  57
+    	this.get{2}Store().on('write', function(store, operation, eOpts ){{
  58
+    		var record =  operation.getRecords()[0];                                    
  59
+            if (operation.action != 'destroy') {{
  60
+               this.get{2}List().getSelectionModel().select(record,true,true);
  61
+               this.refreshButtons([record]);
  62
+            }}
  63
+    	}}, this);
87 64
     }},
88  
-    
89  
-    reset{2}Form: function(){{
90  
-        this.get{2}DeleteButton().setDisabled(true);
91  
-        this.get{2}Form().getForm().reset();            
92  
-        this.get{2}SaveButton().setText('Add');
  65
+        	
  66
+	refreshButtons: function(selections){{	
  67
+		selections=selections||[];
  68
+		if (selections.length){{
  69
+			this.get{2}NewButton().setDisabled(!this.get{2}Store().canCreate());
  70
+        	this.get{2}Form().getForm().loadRecord(selections[0]);
  71
+            this.get{2}SaveButton().setText('Update');
  72
+            this.get{2}DeleteButton().setDisabled(!this.get{2}Store().canDestroy());
  73
+            this.get{2}SaveButton().setDisabled(!this.get{2}Store().canUpdate());
  74
+        }}
  75
+        else{{
  76
+        	this.get{2}Form().getForm().reset();            
  77
+        	this.get{2}SaveButton().setText('Add');
  78
+        	this.get{2}DeleteButton().setDisabled(true);
  79
+        	this.get{2}NewButton().setDisabled(true);
  80
+        	this.get{2}SaveButton().setDisabled(!this.get{2}Store().canCreate());
  81
+        	this.get{2}Form().setFocus();
  82
+        }};
  83
+        this.enableAll();
  84
+	}},
  85
+	
  86
+	disableForm:function(){{
  87
+		this.get{2}Form().setDisabled(true);
  88
+	}},
  89
+	
  90
+	enableForm:function(){{
  91
+		this.get{2}Form().setDisabled(false);	
  92
+	}},
  93
+
  94
+	disableList:function(){{
  95
+		this.get{2}List().setDisabled(true);
  96
+	}},
  97
+	
  98
+	enableList:function(){{
  99
+		this.get{2}List().setDisabled(false);
  100
+	}},
  101
+	
  102
+	disableAll: function(){{
  103
+		this.get{2}List().setDisabled(true);
  104
+		this.get{2}Form().setDisabled(true);
  105
+	}},
  106
+	
  107
+	enableAll: function(){{
  108
+		this.get{2}List().setDisabled(false);
  109
+		this.get{2}Form().setDisabled(false);
  110
+	}},
  111
+	
  112
+	onselectionchange:function(fn, scope){{
  113
+		this.get{2}List().on('selectionchange', fn, scope);
  114
+	}},
  115
+	
  116
+	onwrite:function(fn, scope){{
  117
+		this.get{2}Store().on('write', fn, scope);
93 118
 	}}
94 119
 	
95 120
 }});
491  src/Aicl.DbToSS.CSharp/DotJs.Ext/ExtSolutionCreator.cs
@@ -156,7 +156,36 @@ public virtual void Write()
156 156
 				twp.Close();
157 157
 			}
158 158
 			
  159
+			string loginAppDir= Path.Combine(modulesDir,"login");
  160
+			if(! Directory.Exists(loginAppDir))
  161
+				Directory.CreateDirectory(loginAppDir);
  162
+			
  163
+			using (TextWriter twp = new StreamWriter(Path.Combine(loginAppDir,"app.js")))
  164
+			{
  165
+				twp.Write(string.Format(loginAppTemplate, AppName));				
  166
+				twp.Close();
  167
+			}
  168
+							
  169
+			string loginViewDir= Path.Combine( Path.Combine(modulesDir,"app"), "view");
  170
+			if(! Directory.Exists(loginViewDir))
  171
+				Directory.CreateDirectory(loginViewDir);
  172
+			
  173
+			using (TextWriter twp = new StreamWriter(Path.Combine(loginViewDir,"Login.js")))
  174
+			{
  175
+				twp.Write(string.Format(loginViewTemplate, AppName));				
  176
+				twp.Close();
  177
+			}
159 178
 	
  179
+			string loginControllerDir= Path.Combine( Path.Combine(modulesDir,"app"), "controller");
  180
+			if(! Directory.Exists(loginControllerDir))
  181
+				Directory.CreateDirectory(loginControllerDir);
  182
+			
  183
+			using (TextWriter twp = new StreamWriter(Path.Combine(loginControllerDir,"Login.js")))
  184
+			{
  185
+				twp.Write(string.Format(loginControllerTemplate, AppName));				
  186
+				twp.Close();
  187
+			}
  188
+			
160 189
 		}
161 190
 		
162 191
 		private string appTemplate=@"Ext.require(['*']);
@@ -362,7 +391,7 @@ public virtual void Write()
362 391
     <link rel=""stylesheet"" type=""text/css"" href=""resources/util.css""/>
363 392
 	<script type=""text/javascript"" src=""extjs/bootstrap.js""></script>
364 393
 	<script type=""text/javascript"" src=""resources/util.js""></script>
365  
-    <script type=""text/javascript"" src=""app.js"" ></script>
  394
+    <script type=""text/javascript"" src=""modules/login/app.js"" ></script>
366 395
 </head>
367 396
 <body></body>
368 397
 </html>";
@@ -370,13 +399,27 @@ public virtual void Write()
370 399
 		private string utilJsTemplate=@"(function(){{
371 400
 	Ext.ns('Aicl.Util');
372 401
 	Aicl.Util = {{}}; 
373  
-
  402
+	
374 403
 	var Util = Aicl.Util, 
375 404
 		_msgCt, 
376 405
 		_createBox= function (title, content){{
377 406
        		return '<div class=""msg""><h3>' + title + '</h3><p>' + content + '</p></div>';
378 407
     	}};
379  
-        
  408
+    	
  409
+    _registerSession=function(result){{
  410
+		sessionStorage[""authenticated""]= true;
  411
+		sessionStorage[""roles""]=Ext.encode(result.Roles);
  412
+		sessionStorage[""permissions""]=Ext.encode(result.Permissions);
  413
+		sessionStorage[""displayName""]=result.DisplayName;				
  414
+	}};
  415
+
  416
+	_clearSession=function(result){{
  417
+		sessionStorage[""authenticated""]= false;
  418
+		sessionStorage.removeItem(""roles"");
  419
+		sessionStorage.removeItem(""permissions"");
  420
+		sessionStorage.removeItem(""displayName"");
  421
+	}};
  422
+	        
380 423
     Ext.apply(Util,{{
381 424
     	
382 425
     	convertToDate: function (v){{
@@ -486,12 +529,14 @@ public virtual void Write()
486 529
 			for( p in params){{
487 530
 				s= Ext.String.urlAppend(s, Ext.String.format('{{0}}={{1}}', p, params[p]));
488 531
 			}};
489  
-			return s;			
  532
+			return s;
  533
+			
490 534
 		}},
491 535
 		
492 536
 		// proxies
493 537
 			
494 538
 		createRestProxy:function (config){{
  539
+			
495 540
 			config.format=config.format|| 'json';
496 541
 			config.type= config.type || 'rest';
497 542
 			
@@ -503,6 +548,7 @@ public virtual void Write()
503 548
 			config.url= config.url || Aicl.Util.getUrlApi()+'/' + config.storeId;
504 549
 			
505 550
 			return this.createProxy(config);
  551
+			
506 552
 		}},
507 553
 		
508 554
 		createAjaxProxy:function (config){{
@@ -578,17 +624,60 @@ public virtual void Write()
578 624
 		    }};
579 625
 		    return proxy;
580 626
 		}},
581  
-		
582  
-		// auth 
583  
-		setAuth:function (trueOrFalse){{
584  
-			 sessionStorage[""authenticated""]= trueOrFalse;
585  
-		}},
586  
-		
  627
+				
587 628
 		isAuth: function (){{
588 629
 			var v = sessionStorage[""authenticated""]
589 630
 			return v==undefined? false: Ext.decode(v);
590 631
 		}},
  632
+				
  633
+		login: function(config){{
  634
+			this.executeRestRequest({{
  635
+				url : Aicl.Util.getUrlLogin(),
  636
+				method : 'get',
  637
+				success : function(result) {{
  638
+					_registerSession(result);
  639
+					if(config.success) config.success(result);
  640
+				}},
  641
+				failure : config.failure,
  642
+				callback: config.callback,
  643
+				params : config.params
  644
+			}});
  645
+		}},
  646
+				
  647
+		logout: function(config){{
  648
+			config=config||{{}};
  649
+			this.executeRestRequest({{
  650
+				url : Aicl.Util.getUrlLogout()+'?format=json',
  651
+				method : 'delete',
  652
+				callback : function(result, success) {{
  653
+					_clearSession();
  654
+					if(config.callback) config.callback(result,success);
  655
+				}},
  656
+				failure : config.failure,
  657
+				success : config.success
  658
+			}});
  659
+		}},
  660
+				
  661
+		getRoles:function(){{
  662
+			return sessionStorage.roles? Ext.decode(sessionStorage.roles): [];		
  663
+		}},
  664
+		
  665
+		setUrlLogin: function (urlLogin){{
  666
+			sessionStorage[""urlLogin""]=urlLogin;
  667
+		}},
  668
+		
  669
+		getUrlLogin:function (){{
  670
+			return sessionStorage[""urlLogin""];
  671
+		}},
  672
+		
  673
+		setUrlLogout: function (urlLogout){{
  674
+			sessionStorage[""urlLogout""]=urlLogout;
  675
+		}},
591 676
 		
  677
+		getUrlLogout:function (){{
  678
+			return sessionStorage[""urlLogout""];
  679
+		}},
  680
+				
592 681
 		setUrlApi: function (urlApi){{
593 682
 			sessionStorage[""urlApi""]=urlApi;
594 683
 		}},
@@ -621,11 +710,20 @@ public virtual void Write()
621 710
 			return sessionStorage[""emptyImgUrl""];
622 711
 		}},
623 712
 		
624  
-		checkRole:function (role){{
625  
-			var a= sessionStorage.roles? Ext.decode(sessionStorage.roles): [];
626  
-			return a.indexOf(role)>0;
  713
+		hasRole:function (role){{
  714
+			var roles= this.getRoles();
  715
+			for(var r in roles){{
  716
+ 			  if (roles[r].Name==role) return true;
  717
+			}};
  718
+			return false;
627 719
 		}},
628  
-				
  720
+		
  721
+		hasPermission:function (permission){{
  722
+			var a= sessionStorage.permissions? Ext.decode(sessionStorage.permissions): [];
  723
+			return a.indexOf(permission)>=0;
  724
+		}},
  725
+		
  726
+		
629 727
 		//helpers
630 728
 		isValidEmail:function (email) {{
631 729
 			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{{2,4}})+$/;
@@ -665,7 +763,7 @@ public virtual void Write()
665 763
             write: (config.listeners && config.listeners.write)?
666 764
             config.listeners.write(store, operation, options):
667 765
             function(store, operation, options){{
668  
-            	console.log('store'+ this.storeId+ '  write arguments: ', arguments); 
  766
+            	//console.log('store'+ this.storeId+ '  write arguments: ', arguments); 
669 767
                 var record =  operation.getRecords()[0],
670 768
                     name = Ext.String.capitalize(operation.action),
671 769
                     verb;                                
@@ -675,10 +773,11 @@ public virtual void Write()
675 773
                 }} else {{
676 774
                     verb = name + 'd';
677 775
                 }}
678  
-                console.log('store'+ this.storeId +' write record: ', record);
  776
+                //console.log('store'+ this.storeId +' write record: ', record);
679 777
                 Aicl.Util.msg(name, Ext.String.format(""{{0}} {{1}}: {{2}}"", verb, this.storeId , record.getId()));
680 778
             }}
681 779
         }};
  780
+        
682 781
         this.callParent(arguments);
683 782
     }}
684 783
 }});  
@@ -697,7 +796,41 @@ public virtual void Write()
697 796
   		this.remove(this.getNewRecords());
698 797
    		//this.each(function(record) {{   		//	record.reject();  		//}}, this);
699 798
    		this.removed = [];
700  
-    }}
  799
+    }},
  800
+    //record={{somefield:'value', othefield:'value'}}
  801
+    save:function(record){{
  802
+		if (record.Id){{
  803
+			var keys = Ext.create( this.model.getName(),{{}}).fields.keys;
  804
+			var sr = this.getById(parseInt( record.Id) );
  805
+			sr.beginEdit();
  806
+			for( var r in record){{
  807
+				if( keys.indexOf(r)>0 )
  808
+					sr.set(r, record[r])
  809
+			}}
  810
+			sr.endEdit(); 
  811
+		}}
  812
+		else{{
  813
+			var nr = Ext.create( this.model.getName(),record );
  814
+			this.add(nr);
  815
+		}}			
  816
+	}},
  817
+	
  818
+	canCreate:function(){{
  819
+		 return Aicl.Util.hasPermission(Ext.String.format('{{0}}.create', this.storeId));
  820
+	}},
  821
+    canRead:function(){{
  822
+		 return Aicl.Util.hasPermission(Ext.String.format('{{0}}.read', this.storeId));
  823
+	}},
  824
+	canUpdate:function(){{
  825
+		 return Aicl.Util.hasPermission(Ext.String.format('{{0}}.update', this.storeId));
  826
+	}},
  827
+	canDestroy:function(){{
  828
+		 return Aicl.Util.hasPermission(Ext.String.format('{{0}}.destroy', this.storeId));
  829
+	}},
  830
+	canExecute:function(operation){{
  831
+		 return Aicl.Util.hasPermission(Ext.String.format('{{0}}.{{1}}', this.storeId,operation));
  832
+	}}
  833
+    
701 834
 }});
702 835
 
703 836
 Ext.form.Panel.implement({{
@@ -705,8 +838,8 @@ public virtual void Write()
705 838
     	var ff = item==undefined?this.items.items[1].name:Ext.isNumber(item)?this.items.items[item].name:item;
706 839
     	this.getForm().findField(ff).focus(false,10);
707 840
     }}
708  
-}});
709  
-";
  841
+}});";
  842
+		
710 843
 		private string utilCssTemplate=@"body {{
711 844
     padding:5px;
712 845
     padding-top:5px;
@@ -848,8 +981,58 @@ public virtual void Write()
848 981
 #module{{
849 982
 	margin-left:auto;
850 983
 	margin-right:auto;
851  
-	width: 70em;
  984
+	width: 75em;
852 985
 	text-align: left;
  986
+}}
  987
+
  988
+// Login form 
  989
+.form-login-icon-title {{
  990
+    background-image: url(""icons/silk/locked.png"")
  991
+}}
  992
+
  993
+.form-login-header {{
  994
+    background: transparent url(""icons/silk/lock.png"") no-repeat 97% 50%;
  995
+    font-size: 11px;
  996
+    font-weight: bold;
  997
+    padding: 10px 45px 10px 10px;
  998
+}}
  999
+
  1000
+.form-login-header .error {{
  1001
+    color: red;
  1002
+}}
  1003
+
  1004
+.form-login-icon-login {{
  1005
+    background-image: url(""icons/silk/login.png"")
  1006
+}}
  1007
+
  1008
+.form-login-icon-cancel {{
  1009
+    background-image: url(""icons/silk/close.png"")
  1010
+}}
  1011
+
  1012
+.form-login-warning {{
  1013
+    background: url(""icons/silk/warning.png"") no-repeat center left;
  1014
+    padding: 2px;
  1015
+    padding-left: 20px;
  1016
+    font-weight: bold;
  1017
+}}
  1018
+
  1019
+// Navigation 
  1020
+
  1021
+.expand {{
  1022
+    background-image: url('icons/silk/expand.png') !important;
  1023
+}}
  1024
+
  1025
+.collapse {{
  1026
+    background-image: url('icons/silk/collapse.png') !important;
  1027
+}}
  1028
+
  1029
+.datalink div{{
  1030
+   text-decoration: underline;
  1031
+    cursor: pointer;
  1032
+}}
  1033
+
  1034
+.logout {{
  1035
+    background-image: url('icons/silk/logout.png') !important;
853 1036
 }}";
854 1037
 		
855 1038
 		private string introTemplate=@"<html>
@@ -874,8 +1057,274 @@ public virtual void Write()
874 1057
 without even the implied warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF THIRD-PARTY INTELLECTUAL PROPERTY RIGHTS.
875 1058
 See the GNU General Public License for more details.";
876 1059
 
  1060
+		
  1061
+		private string loginAppTemplate=@"Ext.Loader.setConfig({{enabled: true}});
  1062
+Ext.Loader.setPath('{0}', 'modules/app');
  1063
+    
  1064
+Ext.application({{
  1065
+name: '{0}',
  1066
+appFolder: 'modules/app',
  1067
+
  1068
+launch: function(){{
  1069
+	Aicl.Util.setUrlApi(location.protocol + '//' + location.host + '/api');
  1070
+	Aicl.Util.setHttpUrlApi(location.protocol + '//' + location.host + '/api'+'/json/asynconeway')
  1071
+		
  1072
+	Aicl.Util.setUrlLogin(location.protocol + '//' + location.host + '/api/login');
  1073
+	Aicl.Util.setUrlLogout(location.protocol + '//' + location.host + '/api/logout');
  1074
+	
  1075
+	Aicl.Util.setPhotoDir(location.protocol + '//' + location.host +  '' + location.pathname+ 'photos');
  1076
+	Aicl.Util.setEmptyImgUrl('../../resources/icons/fam/user.png');
  1077
+    var loginWin = Ext.create('App.view.Login');
  1078
+    loginWin.show();
  1079
+}},
  1080
+    
  1081
+controllers: ['Login']
  1082
+    
  1083
+}});  
  1084
+";
  1085
+		private string loginViewTemplate=@"Ext.define('{0}.view.Login', {{
  1086
+    extend:'Ext.window.Window',
  1087
+    alias:'widget.login',
  1088
+    iconCls:'form-login-icon-title',
  1089
+    width:420,
  1090
+    height:210,
  1091
+    resizable:false,
  1092
+    closable:false,
  1093
+    draggable:false,
  1094
+    modal:true,
  1095
+    closeAction:'hide',
  1096
+    layout:'border',
  1097
+    title:'Login',
  1098
+
  1099
+    initComponent:function () {{
  1100
+
  1101
+        Ext.apply(this, {{
  1102
+            items:[
  1103
+                {{
  1104
+                    xtype:'panel',
  1105
+                    cls:'form-login-header',
  1106
+                    baseCls:'x-plain',
  1107
+                    //html:'intro',
  1108
+                    region:'north',
  1109
+                    height:60
  1110
+                }},
  1111
+                {{
  1112
+                    xtype:'form',
  1113
+                    baseCls:'x-plain',
  1114
+                    ui:'default-framed',
  1115
+                    bodyPadding:10,
  1116
+                    header:false,
  1117
+                    region:'center',
  1118
+                    border:false,
  1119
+                    waitMsgTarget:true,
  1120
+                    layout:{{
  1121
+                        type:'vbox',
  1122
+                        align:'stretch'
  1123
+                    }},
  1124
+                    defaults:{{
  1125
+                        labelWidth:85
  1126
+                    }},
  1127
+                    items:[
  1128
+                        {{
  1129
+                            itemId:'userName',
  1130
+                            xtype:'textfield',
  1131
+                            fieldLabel:'Username',
  1132
+                            name:'userName',
  1133
+                            allowBlank:false,
  1134
+                            anchor:'100%',
  1135
+                            validateOnBlur:false
  1136
+                        }},
  1137
+                        {{
  1138
+                            xtype:'textfield',
  1139
+                            fieldLabel:'Password',
  1140
+                            name:'password',
  1141
+                            allowBlank:false,
  1142
+                            inputType:'password',
  1143
+                            anchor:'100%',
  1144
+                            validateOnBlur:false,
  1145
+                            enableKeyEvents:true,
  1146
+                            listeners:{{
  1147
+                                render:{{
  1148
+                                    fn:function (field, eOpts) {{
  1149
+                                        field.capsWarningTooltip = Ext.create('Ext.tip.ToolTip', {{
  1150
+                                            target:field.bodyEl,
  1151
+                                            anchor:'top',
  1152
+                                            width:305,
  1153
+                                            html:'Caps lock warning'
  1154
+                                        }});
877 1155
 
  1156
+                                        // disable to tooltip from showing on mouseover
  1157
+                                        field.capsWarningTooltip.disable();
  1158
+                                    }},
  1159
+                                    scope:this
  1160
+                                }},
  1161
+
  1162
+                                keypress:{{
  1163
+                                    fn:function (field, e, eOpts) {{
  1164
+                                        var charCode = e.getCharCode();
  1165
+                                        if ((e.shiftKey && charCode >= 97 && charCode <= 122) ||
  1166
+                                            (!e.shiftKey && charCode >= 65 && charCode <= 90)) {{
  1167
+
  1168
+                                            field.capsWarningTooltip.enable();
  1169
+                                            field.capsWarningTooltip.show();
  1170
+                                        }}
  1171
+                                        else {{
  1172
+                                            if (field.capsWarningTooltip.hidden === false) {{
  1173
+                                                field.capsWarningTooltip.disable();
  1174
+                                                field.capsWarningTooltip.hide();
  1175
+                                            }}
  1176
+                                        }}
  1177
+                                    }},
  1178
+                                    scope:this
  1179
+                                }},
  1180
+
  1181
+                                blur:function (field) {{
  1182
+                                    if (field.capsWarningTooltip.hidden === false) {{
  1183
+                                        field.capsWarningTooltip.hide();
  1184
+                                    }}
  1185
+                                }}
  1186
+                            }}
  1187
+                        }}
  1188
+                    ]
  1189
+                }}
  1190
+            ],
  1191
+            buttons:[
  1192
+                {{
  1193
+                    action:""login"",
  1194
+                    formBind:true,
  1195
+                    text:'Login',
  1196
+                    iconCls:'form-login-icon-login',
  1197
+                    scale:'medium',
  1198
+                    width:90
  1199
+                }}
  1200
+            ]
  1201
+        }});
  1202
+        this.callParent(arguments);
  1203
+    }},
  1204
+    defaultFocus:'userName'
  1205
+}});
  1206
+";
  1207
+		
  1208
+		private string loginControllerTemplate=@"Ext.define('{0}.controller.Login',{{
  1209
+    extend:'Ext.app.Controller',
  1210
+    init:function () {{
  1211
+        this.control({{
  1212
+          
  1213
+            'login button[action=login]':{{
  1214
+                click:this.login
  1215
+            }},
  1216
+            'login textfield':{{
  1217
+                specialkey:this.keyenter
  1218
+            }}
  1219
+        }});
  1220
+    }},
  1221
+    views:[
  1222
+        'Login'
  1223
+    ],
  1224
+    refs:[
  1225
+         {{ref:'loginWindow', selector:'login'}},
  1226
+         {{ref:'loginForm', selector:'form'}}
  1227
+    ],
  1228
+    
  1229
+    login:function () {{
  1230
+    	var form = this.getLoginForm();
  1231
+    	if(!form.getForm().isValid()){{
  1232
+    		Aicl.Util.msg('Empty fields','please write username and password');
  1233
+    		return;
  1234
+    	}}
  1235
+        var me=this;
  1236
+    	var record = form.getValues();
  1237
+				Aicl.Util.login({{
  1238
+					success : function(result) {{
  1239
+						me.getLoginWindow().hide()
  1240
+						me.createMenu();
  1241
+					}},
  1242
+					failure : function(response, options) {{
  1243
+						console.log(arguments);
  1244
+					}},
  1245
+					params : record
  1246
+				}});
  1247
+    	
  1248
+    }},
  1249
+    
  1250
+    keyenter:function (item, event) {{
  1251
+        if (event.getKey() == event.ENTER) {{
  1252
+            this.login();
  1253
+        }}
  1254
+
  1255
+    }},
  1256
+    
  1257
+    createMenu: function(){{
  1258
+		var me = this;
  1259
+		var buttons=[];
  1260
+		var i=0;
  1261
+		var grupos = Aicl.Util.getRoles();
  1262
+		for(var grupo in grupos ){{
  1263
+			if(grupos[grupo].Directory){{
  1264
+				buttons[i]= Ext.create('Ext.Button', {{
  1265
+    				text    : grupos[grupo].Name,
  1266
+    				directory:grupos[grupo].Directory,
  1267
+    				scale   : 'small',
  1268
+    				handler	: function(){{
  1269
+    				Ext.getDom('iframe-win').src = 'modules/'+this.directory;
  1270
+    				}}
  1271
+				}});
  1272
+				i++;
  1273
+			}}
  1274
+		}};
  1275
+		
  1276
+		buttons[i]= Ext.create('Ext.Button', {{
  1277
+	    	text    : 'Salir',
  1278
+	    	scale   : 'small',
  1279
+	    	handler	: function(){{
  1280
+	    		Aicl.Util.logout({{
  1281
+	    			callback:function(result, success){{
  1282
+	    				vp.destroy();
  1283
+	    				me.getLoginWindow().show();
  1284
+	    			}}
  1285
+	    		}});
  1286
+	    	}}
  1287
+		}});
  1288
+		
  1289
+    	var vp=Ext.create('Ext.Viewport', {{
  1290
+        	layout: {{
  1291
+        		type: 'border',
  1292
+            	padding: 5
  1293
+        	}},
  1294
+        	defaults: {{
  1295
+            	split: true
  1296
+        	}},
  1297
+        	items: [{{
  1298
+            	region: 'west',
  1299
+            	layout:'fit',
  1300
+            	items:[{{
  1301
+            		layout: {{                        
  1302
+    	    			type: 'vbox',
  1303
+        				align:'stretch'
  1304
+    				}},
  1305
+    				defaults:{{margins:'5 5 5 5'}},
  1306
+        			items:buttons
  1307
+            	}}],
  1308
+            	collapsible: true,
  1309
+            	split: true,
  1310
+            	width: '20%'
  1311
+        	}},{{
  1312
+            	region: 'center',
  1313
+            	layout:'fit',
  1314
+            	items:[{{
  1315
+        			xtype : 'component',
  1316
+        			id    : 'iframe-win', 
  1317
+        			autoEl : {{
  1318
+	            		tag : 'iframe',
  1319
+            			src : 'intro.html'
  1320
+        			}}
  1321
+            	}}]
  1322
+        	}}]
  1323
+    	}});
  1324
+	}}
  1325
+    
  1326
+}});
  1327
+";
878 1328
 		
879 1329
 	}
880 1330
 }
881  
-
5  src/Aicl.DbToSS.CSharp/DotJs.Ext/Form.cs
@@ -156,7 +156,7 @@ public void Write()
156 156
 			if(ic==2) height=140;
157 157
 			else if (ic==3) height=150;
158 158
 			else if (ic==4) height=160;
159  
-			else if (ic>=5) height=35*ic;
  159
+			else if (ic>=5) height=40*ic;
160 160
 			if( height>350) height=350;
161 161
 			
162 162
 			string sItems= items.SerializeAndFormat().Replace("True","true").Replace("False","false");
@@ -184,8 +184,7 @@ public void Write()
184 184
 			
185 185
 			
186 186
 		}
187  
-		
188  
-		
  187
+			
189 188
 	}
190 189
 }
191 190
 
7  src/Aicl.DbToSS.CSharp/DotJs.Ext/List.cs
@@ -123,6 +123,13 @@ public List (Type type)
123 123
 				{
124 124
 					col.renderer="<FormatNumber/>";
125 125
 				}
  126
+				else if(pi.PropertyType== typeof(bool) || pi.PropertyType== typeof(bool?))
  127
+				{
  128
+					col.xtype="'booleancolumn'";
  129
+					col.trueText= "'Si'";
  130
+					col.falseText= "'No'";
  131
+					col.align="'center'";
  132
+				}
126 133
 				
127 134
 				cols.Add(col);
128 135
 			}
13  src/Aicl.DbToSS.CSharp/DotJs.Ext/ListColumn.cs
@@ -17,5 +17,18 @@ public ListColumn ()
17 17
 		
18 18
 		public object renderer { get; set;}
19 19
 		
  20
+		public string xtype {get; set;}
  21
+		
  22
+		public string trueText {get; set;}
  23
+		
  24
+		public string falseText {get; set;}
  25
+		
  26
+		public string align {get; set;}
20 27
 	}
  28
+	
21 29
 }
  30
+/*
  31
+ 
  32
+ {text: 'Department (Yrs)', xtype:'templatecolumn', tpl:'{dep} ({senority})'}
  33
+ 
  34
+ */ 

0 notes on commit 27fa2fa

Please sign in to comment.
Something went wrong with that request. Please try again.