Skip to content

Commit

Permalink
图标 & 评价学生界面
Browse files Browse the repository at this point in the history
  • Loading branch information
xEasy committed Mar 22, 2012
1 parent ac792ce commit 9a432cd
Show file tree
Hide file tree
Showing 28 changed files with 239 additions and 5 deletions.
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -3,6 +3,9 @@ class ApplicationController < ActionController::Base
#before_filter :authenticate_user! #before_filter :authenticate_user!
layout :render_by_login_session layout :render_by_login_session
protect_from_forgery protect_from_forgery

respond_to :html, :json

def render_by_login_session def render_by_login_session
is_a?(Devise::SessionsController) ? "login" : "application" is_a?(Devise::SessionsController) ? "login" : "application"
end end
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/homes_controller.rb
Expand Up @@ -18,4 +18,15 @@ def student_score
render_json Student.find(params[:s_id]).course_scores.collect &fields_provider render_json Student.find(params[:s_id]).course_scores.collect &fields_provider
end end


def comment_student
end

def comment_type_tree_nodes
render :json => CommentType.tree_nodes
end

def commets_by_type
render_json CommentType.find(params[:ct_id]).comments.collect &fields_provider
end

end end
1 change: 1 addition & 0 deletions app/models/comment.rb
@@ -1,3 +1,4 @@
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base
belongs_to :comment_type belongs_to :comment_type

end end
5 changes: 5 additions & 0 deletions app/models/comment_type.rb
@@ -1,3 +1,8 @@
class CommentType < ActiveRecord::Base class CommentType < ActiveRecord::Base
has_many :comments has_many :comments

def self.tree_nodes
all.inject([]) { |nodes, record| nodes << { :text => record.name, :id => record.id, :leaf => true } }
end

end end
8 changes: 8 additions & 0 deletions app/views/homes/comment_student.html.erb
@@ -0,0 +1,8 @@
<%= javascript_include_tag '/javascripts/PF/pages/comment_student.js' %>

<script language="javascript" type="text/javascript">
Ext.onReady(function() {
Pf.classes.commentStudent = new Pf.classes.commentStudent.MainPanel();
Pf.pages.currentInstance = Pf.classes.commentStudent;
});
</script>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -41,7 +41,7 @@
<div class="dock" id="dock2"> <div class="dock" id="dock2">
<div class="dock-container2"> <div class="dock-container2">
<a class="dock-item2" href="/homes"><span>主页</span><img src="../images/home.png" alt="home" /></a> <a class="dock-item2" href="/homes"><span>主页</span><img src="../images/home.png" alt="home" /></a>
<a class="dock-item2" href="#"><span>Contact</span><img src="../images/email.png" alt="contact" /></a> <a class="dock-item2" href="/homes/comment_student"><span>评价学生</span><img src="../images/email.png" alt="contact" /></a>
<a class="dock-item2" href="#"><span>Portfolio</span><img src="../images/portfolio.png" alt="portfolio" /></a> <a class="dock-item2" href="#"><span>Portfolio</span><img src="../images/portfolio.png" alt="portfolio" /></a>
<a class="dock-item2" href="#"><span>Music</span><img src="../images/music.png" alt="music" /></a> <a class="dock-item2" href="#"><span>Music</span><img src="../images/music.png" alt="music" /></a>
<a class="dock-item2" href="#"><span>Video</span><img src="../images/video.png" alt="video" /></a> <a class="dock-item2" href="#"><span>Video</span><img src="../images/video.png" alt="video" /></a>
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Expand Up @@ -6,6 +6,9 @@
get 'get_classes_students' get 'get_classes_students'
get 'student_detail' get 'student_detail'
get 'student_score' get 'student_score'
get 'comment_student'
post 'comment_type_tree_nodes'
get 'commets_by_type'
end end
end end
resources :settings do resources :settings do
Expand All @@ -20,7 +23,6 @@
end end







#可切换不同用户列表 #可切换不同用户列表
devise_for :users do devise_for :users do
Expand Down
1 change: 1 addition & 0 deletions files/.~lock.界面2.xlsx#
@@ -0,0 +1 @@
rice ,rice,rode,22.03.2012 15:44,file:///home/rice/.openoffice.org/3;
4 changes: 2 additions & 2 deletions lib/tasks/genrate_data.rake
Expand Up @@ -88,8 +88,8 @@ namespace :data do
Comment.destroy_all Comment.destroy_all
cms = Comment.create(cmses) cms = Comment.create(cmses)
cmtses = [ cmtses = [
{ :type => "思想德语" }, { :name => "思想德语" },
{ :type => "学风" }, { :name => "学风" },
] ]
CommentType.destroy_all CommentType.destroy_all
cmts = CommentType.create(cmtses) cmts = CommentType.create(cmtses)
Expand Down
Binary file modified public/images/Temp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/application_form_add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/cog_edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/cross.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/delete.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/find.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/form_edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/grid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/print.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/save.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/table_add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/tick.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/upload.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/user_add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/user_delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/icon/user_edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
189 changes: 189 additions & 0 deletions public/javascripts/PF/pages/comment_student.js
@@ -0,0 +1,189 @@
Ext.ns("Pf.classes.commentStudent");

Ext.onReady(function() {
Pf.classes.commentStudent = new Pf.classes.commentStudent.MainPanel();
Pf.pages.currentInstance = Pf.classes.commentStudent;
});

Pf.classes.commentStudent.MainPanel = Ext.extend(Ext.Panel, {
autoScroll : true,
region : 'center',
layout : 'border',

initComponent : function () {
this.addDefaultComponents();
Pf.classes.commentStudent.MainPanel.superclass.initComponent.call(this);
},

addDefaultComponents : function(){
this.tree = this.createTree();
this.commentGrid = this.createCommentGrid();
this.studentForm = this.createForm();
this.items = [ {
region : 'center',
layout : 'border',
items : [
this.tree,
this.commentGrid,
new Ext.FormPanel({
region: 'south',
frame : true,
height : 180,
labelAlign : 'top',
items: [ { xtype : 'textarea',fieldLabel: "评语", id : 's-comment', width : "100%", height : 145 } ],
}),
]},
this.studentForm
]

},

createTree : function () {
root = new Ext.tree.AsyncTreeNode({ text: '类型', expanded: true,nodeType: 'async' });
var tree = new Ext.tree.TreePanel({
autoScroll: true,
containerScroll: true,
region: "west",
title: "评价类型",
width: 130,
split: true,
frame : true,
collapseMode: 'mini',
loader: new Ext.tree.TreeLoader({ dataUrl: '/homes/comment_type_tree_nodes.json', requestMethod: 'POST', preloadChildren: false }),
root: root,
listeners: {
click : function (node) {
if(node.isLeaf){
var store = Ext.getCmp('comment-grid').getStore();
store.removeAll();
store.load({ params : { ct_id : node.attributes.id } });
}
}
}
});
return tree;
},

createCommentGrid : function () {
var scope = this;
var store = new Pf.util.FieldsJsonStore({
root : 'root',
url : '/homes/commets_by_type.joson',
fields : ["id",'content']
});
var cm = new Ext.grid.ColumnModel({
columns: [
{ header: '评价详情' , dataIndex: 'content' },
],
defaults: { menuDisabled : true, sortable : true }
});
var grid = new Ext.grid.EditorGridPanel({
id : 'comment-grid',
region : 'center',
store: store,
border: false,
title : '评价详细',
stripeRows: true,
loadMask : true,
viewConfig: { forceFit: true },
bbar : new Pf.util.Bbar({ store : store }),
cm : cm,
sm : new Ext.grid.RowSelectionModel({ }),
listeners: {
celldblclick : function(grid,rowIndex,columnIndex) {
var content = grid.getStore().getAt(rowIndex).get("content");
scope.addComment(content,false);
}
}
});
return grid;
},

createForm : function () {
var scope = this;
var classCombox = new Ext.form.ComboBox({
fieldLabel : '班级',
triggerAction : 'all',
displayField : 'name',
mode : 'remote',
autoSelect : true,
width : 130,
forceSelection : true,
store : new Pf.util.FieldsJsonStore({
url : '/homes/get_classes.json',
fields : ["id", "name"],
autoLoad: false
}),
listeners : {
select : function(combo, record, index) {
}
}
});

var form = new Ext.FormPanel({
region : 'east',
title : '学生信息',
frame : true,
autoScroll : true,
width : 280,
lableWidth: 55,
labelAlign : 'top',
bodyStyle: 'padding:5px 15px 0',
defaults : { anchor : '95%' },
defaultType : 'textfield',
layout: 'form',
items: [
new Ext.form.FieldSet({
title : '头像',
layout : 'fit',
height : 140,
items :[{
html : '<span id="image"><img src="/images/Temp.png" height=110px width=120px alt="图片" /></span>'
}]
}),
classCombox
,{
fieldLabel: '学号',
name: 'number',
},{
fieldLabel: '姓名',
name: 'name',
},{
fieldLabel: '性别',
name: 'sex',
},{
fieldLabel: '班级',
name: 'classes/name',
}, {
fieldLabel: '总分',
name: 'total_score',
}, {
fieldLabel: '评级',
name: 'grade',
}
],
buttonAlign: 'center',
buttons: [
{ text : '保存', handler : function() { scope.saveComment() } },
{ text : '清除', handler : function() { scope.addComment("",true) } },
{ text : '重置', handler : function() { scope.addComment(currentStu.get('comment'), true)} }
]
});
return form;
},

addComment : function (content, clear) {
var commentArea = Ext.getCmp('s-comment');
if (clear) {
commentArea.setValue(content);
}else{
commentArea.setValue(commentArea.getValue() + content);
};
},

saveComment : function () {

}

});

2 changes: 1 addition & 1 deletion public/javascripts/PF/pages/home_index.js
Expand Up @@ -21,7 +21,7 @@ Pf.classes.homeIndex.MainPanel = Ext.extend(Ext.Panel, {
tbar : new Ext.Toolbar({ tbar : new Ext.Toolbar({
id : 'form-tbar', id : 'form-tbar',
items : [ items : [
{ id : 'update-btn', text: '打印', handler: Pf.util.scope(this.printHandler,this) }, { id : 'update-btn', text: '打印', handler: Pf.util.scope(this.printHandler,this), icon : Pf.Icon.Print },
] ]
}), }),
items : [ this.form ] items : [ this.form ]
Expand Down
14 changes: 14 additions & 0 deletions public/javascripts/PF/public/init.js
@@ -1 +1,15 @@
Ext.ns("Pf.classes","Pf.pages","Pf.widgets","Pf.util","Pf.settings"); Ext.ns("Pf.classes","Pf.pages","Pf.widgets","Pf.util","Pf.settings");

Pf.Icon = {
Print : '/images/icon/print.png',
Edi : '/images/icon/table_edit.png',
CEdi : '/images/icon/cog_edit.png',
Show : '/images/icon/grid.png',
Cancel: '/images/icon/cross.gif',
Des : '/images/icon/delete.gif',
Add : '/images/icon/add.png',
Save : '/images/icon/save.gif',
Up : '/images/icon/upload.gif',
Ue : '/images/icon/user_edit.png',
AUe : '/images/icon/user_add.png',
}

0 comments on commit 9a432cd

Please sign in to comment.