-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added StudentInfo and Student controller
- Loading branch information
Showing
20 changed files
with
349 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
var User; | ||
|
||
Ext.regApplication('UPSApp', { | ||
defaultTarget:'viewport', | ||
name:'UPSApp', | ||
launch: function() { | ||
|
||
User = new UPSUser(); | ||
// The Ext.regApplication call automatically creates our 'views' namespace | ||
this.views.viewport = new this.views.Viewport(); | ||
|
||
this.views.viewport.onStart(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Ext.regController('Student', { | ||
info: function() { | ||
// Just show the info pane | ||
UPSApp.views.viewport.setActiveItem('studentinfo'); | ||
}, | ||
login: function(params) { | ||
|
||
// TODO: Attempt to login and store a session cookie | ||
// For now, we just create some fake user info | ||
|
||
if(!params) | ||
console.log("No username or password passed to login, assuming we're resuming session"); | ||
else | ||
console.log("Username and password supplied \"logging in\""); | ||
|
||
if(!UPSApp.stores.studentinfo.first()) | ||
UPSApp.stores.studentinfo.add({username:''}); | ||
|
||
var student = UPSApp.stores.studentinfo.first(); | ||
|
||
student.set("username", 'TestUsername'); | ||
student.set("name","Test T. Testington"); | ||
student.set("dinerdollars","100.00"); | ||
student.set("paymentdue","1000"); | ||
|
||
|
||
// Update the student info panel | ||
console.log(UPSApp.stores.studentinfo.first()); | ||
UPSApp.views.studentInfo.update(UPSApp.stores.studentinfo.first().data); | ||
UPSApp.views.studentInfo.doLayout(); | ||
|
||
// Switch to StudentHome panel | ||
UPSApp.views.viewport.setActiveItem('studenthome'); | ||
UPSApp.views.studentInfo.doLayout(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
UPSApp.models.StudentInfo = Ext.regModel('StudentInfo', { | ||
fields: [ | ||
{ | ||
name:'username', | ||
type:'string' | ||
} , { | ||
name:'name', | ||
type:'string' | ||
}, { | ||
name:'dinerdollars', | ||
type:'string' | ||
}, { | ||
name:'paymentdue', | ||
type:'string' | ||
} | ||
] | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
UPSApp.stores.studentinfo = new Ext.data.Store({ | ||
model:'StudentInfo', | ||
autoLoad:false | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
UPSApp.views.StudentHome = Ext.extend(Ext.Panel, { | ||
id:'studenthome', | ||
layout:'card', | ||
items:[ ], | ||
initComponent: function() { | ||
var header = { | ||
xtype:'panel', | ||
html:'<span>Student Home</span>', | ||
height:25 | ||
}; | ||
|
||
var elements = [ | ||
{xtype:'button',text:'Student Info',handler:function(){Ext.dispatch({controller: 'Student',action:'info'});}}, | ||
{xtype:'button',text:'News'}, | ||
{xtype:'button',text:'Events'}, | ||
{xtype:'button',text:'Finances'}, | ||
{xtype:'button',text:'Fifth element'} | ||
]; | ||
|
||
var idx = 0; var hboxes = [header]; | ||
for(var i = 1; i <= Math.ceil(elements.length / 2); i++) | ||
{ | ||
var temp = [] | ||
temp[0] = elements[idx++]; | ||
|
||
if(elements[idx]) | ||
temp[1] = elements[idx++]; | ||
hboxes[i] = { | ||
flex:1, | ||
xtype:'container', | ||
layout:{type:'hbox',align:'stretch',pack:'stretch',}, | ||
defaults:{flex:1,marginBottom:'1%'}, | ||
items:temp | ||
} | ||
} | ||
|
||
|
||
var vbox = { | ||
xtype: 'container', | ||
layout: { | ||
type: 'vbox', | ||
align: 'stretch', | ||
pack: 'stretch', | ||
}, | ||
items:hboxes | ||
} | ||
|
||
Ext.apply(this, {items:vbox}); | ||
|
||
UPSApp.views.StudentInfo.superclass.initComponent.apply(this, arguments); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
UPSApp.views.StudentInfo = Ext.extend(Ext.Panel, { | ||
id:'studentinfo', | ||
width:'100%', | ||
tpl:'<div class="student-info">' + | ||
'<p>' + | ||
'Hello, <b class="small">{name}</b>.' + | ||
'<hr />' + | ||
'You have <b class="large">{dinerdollars}</b> diner dollars.' + | ||
'<hr />' + | ||
'Your next payment due is <b class="medium">${paymentdue}</b> on <b class="small">January 25th</b>' + | ||
'</p>' + | ||
'</div>', | ||
|
||
items:[], | ||
initComponent: function() { | ||
|
||
|
||
UPSApp.views.StudentInfo.superclass.initComponent.apply(this, arguments); | ||
} | ||
}); | ||
|
||
/*UPSApp.views.StudentInfo = Ext.extend(Ext.form.FormPanel, { | ||
id:'studentinfo', | ||
layout: | ||
{ | ||
type:'vbox', | ||
align:'stretch', | ||
pack:'stretch' | ||
}, | ||
width:'100%', | ||
items:[ | ||
{ | ||
xtype:'fieldset', | ||
layout: | ||
{ | ||
type:'fit', | ||
align:'stretch', | ||
pack:'stretch' | ||
}, | ||
title:'Student Info', | ||
width:"100%", | ||
instructions:'Your current student info', | ||
defaults: { | ||
xtype:'textfield', | ||
useClearIcon:false, | ||
autoCapitalize:false, | ||
cls:'readonlyform', | ||
disabled:true | ||
}, | ||
items: [ | ||
{ | ||
name:'username', | ||
label:'username' | ||
}, | ||
{ | ||
name:'dinerdollars', | ||
label:'Diner Dollars' | ||
}, | ||
{ | ||
name:'paymentdue', | ||
label:'Payment Due' | ||
} | ||
] | ||
} | ||
], | ||
initComponent: function() { | ||
UPSApp.views.StudentInfo.superclass.initComponent.apply(this, arguments); | ||
} | ||
});*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
UPSApp.views.StudentLogin = Ext.extend(Ext.form.FormPanel, { | ||
id:'studentlogin', | ||
layout:'vbox', | ||
items:[ | ||
{ | ||
xtype:'fieldset', | ||
title:'Student Login', | ||
instructions:'Enter your student account info.', | ||
defaults: { | ||
xtype:'textfield', | ||
required:true, | ||
useClearIcon:true, | ||
autoCapitalize:false | ||
}, | ||
items: [ | ||
{ | ||
name:'username', | ||
label:'username' | ||
}, | ||
{ | ||
xtype:'passwordfield', | ||
name:'password', | ||
label:'password' | ||
} | ||
] | ||
}, | ||
{ | ||
ui:'action', | ||
xtype:'button', | ||
text:'Login', | ||
handler:function() | ||
{ | ||
Ext.dispatch({ | ||
controller: 'Student', | ||
action:'login', | ||
data: this.ownerCt.getValues() | ||
}); | ||
} | ||
} | ||
], | ||
initComponent: function() { | ||
|
||
|
||
UPSApp.views.StudentLogin.superclass.initComponent.apply(this, arguments); | ||
}, | ||
onLoginAction: function() { | ||
|
||
} | ||
}); |
Oops, something went wrong.