Skip to content

Commit

Permalink
Added StudentInfo and Student controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ups-tla committed Jan 13, 2012
1 parent ba75bec commit f8f7d13
Show file tree
Hide file tree
Showing 20 changed files with 349 additions and 36 deletions.
5 changes: 4 additions & 1 deletion app/app.js
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();
}
});
36 changes: 36 additions & 0 deletions app/controllers/student/Student.js
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();
}
});
18 changes: 18 additions & 0 deletions app/models/StudentInfo.js
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'
}
]

})
4 changes: 4 additions & 0 deletions app/stores/StudentInfo.js
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
})
24 changes: 16 additions & 8 deletions app/views/SelectUserType.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
UPSApp.views.SelectUserType = Ext.extend(Ext.Panel, {
id:'selectusertype',
layout:'card',
items:[
{
Expand All @@ -10,16 +11,18 @@ UPSApp.views.SelectUserType = Ext.extend(Ext.Panel, {
defaults: {
xtype: 'button',
ui: 'maroon',
style: { marginBottom:'1%'}
},
items:[
{
xtype:'panel',
height:32,
align:'center',
html:"How are you affiliated with UPS?"
html:"How are you affiliated with UPS?",
},
{
text:"I'm a Parent",
html:'<div><img src="sencha/resources/upsstyle/images/icons/studentparent.png"/><div>Parent</div></div>',
cls:'imageButton',
flex: 1,
width:"96%",
handler:function() {
Expand All @@ -28,20 +31,25 @@ UPSApp.views.SelectUserType = Ext.extend(Ext.Panel, {
}
}, {
cls:'imageButton',
html:'<div><div>Student</div><img src="gradcap.png"/></div>',
html:'<div><img src="sencha/resources/upsstyle/images/icons/gradcap.png"/><div>Student</div></div>',
flex: 1,
width:"96%"
width:"96%",
handler:function() {
User.SetUserType('student');
UPSApp.views.viewport.setActiveItem('studentlogin');
}

}, {
cls:'btn-imastudent',
cls:'imageButton',
html:'<div><img src="sencha/resources/upsstyle/images/icons/scroll.png"/><div>Alumnus</div></div>',
flex: 1,
width:"96%",
text:"I'm an Alumnus"
width:"96%"
}]
}
],
initComponent: function() {


UPSApp.views.Viewport.superclass.initComponent.apply(this, arguments);
UPSApp.views.SelectUserType.superclass.initComponent.apply(this, arguments);
}
});
53 changes: 36 additions & 17 deletions app/views/Viewport.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var User;

UPSApp.views.Viewport = Ext.extend(Ext.Panel, {
fullscreen:true,
layout: 'card',
cardSwitchAnimation:'pop',
align:'stretch',
scroll:false,
dockedItems:[
Expand All @@ -20,31 +17,53 @@ UPSApp.views.Viewport = Ext.extend(Ext.Panel, {
]
})
],
items:[],
items:[
{
xtype:'panel',
html:'Loading...'
}
],
activeItem:0,
onStart: function() {

UPSApp.views.selectUserType = new UPSApp.views.SelectUserType();
UPSApp.views.parentHome = new UPSApp.views.ParentHome();
UPSApp.views.studentLogin = new UPSApp.views.StudentLogin();
UPSApp.views.studentInfo = new UPSApp.views.StudentInfo();
UPSApp.views.studentHome = new UPSApp.views.StudentHome();

this.add(UPSApp.views.selectUserType);
this.add(UPSApp.views.parentHome);
this.add(UPSApp.views.studentLogin);
this.add(UPSApp.views.studentInfo);
this.add(UPSApp.views.studentHome);

if(User.GetUserType() == "none") // Go to the select user type panel
this.setActiveItem('selectusertype');
else if(User.GetUserType() == "parent") // DEBUG: just reset to none, otherwise we will probably go to school website
{
User.SetUserType("none");
this.setActiveItem('selectusertype');
}
else if(User.GetUserType() == "student") // Log in
Ext.dispatch({
controller: 'Student',
action:'login'
});
},
initComponent: function() {

User = new UPSUser();


UPSApp.views.toolbar = new Ext.Toolbar({
title:'University of Puget Sound'
});

this.dockedItems[1] = UPSApp.views.toolbar;

UPSApp.views.selectUserType = new UPSApp.views.SelectUserType();
UPSApp.views.parentHome = new UPSApp.views.ParentHome();

this.items[0] = UPSApp.views.selectUserType;
this.items[1] = UPSApp.views.parentHome;

if(User.GetUserType() == "none")
Ext.apply(this, {
activeItem:0
})
else if(User.GetUserType() == "parent")
User.SetUserType("none");


UPSApp.views.Viewport.superclass.initComponent.apply(this, arguments);

}
});
52 changes: 52 additions & 0 deletions app/views/student/StudentHome.js
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);
}
});
71 changes: 71 additions & 0 deletions app/views/student/StudentInfo.js
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);
}
});*/
49 changes: 49 additions & 0 deletions app/views/student/StudentLogin.js
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() {

}
});
Loading

0 comments on commit f8f7d13

Please sign in to comment.