Permalink
Browse files

图标 & 评价学生界面

  • Loading branch information...
1 parent ac792ce commit 9a432cd9afe50ca7e453d42474fdf1149f388722 @xEasy xEasy committed Mar 22, 2012
View
3 app/controllers/application_controller.rb
@@ -3,6 +3,9 @@ class ApplicationController < ActionController::Base
#before_filter :authenticate_user!
layout :render_by_login_session
protect_from_forgery
+
+ respond_to :html, :json
+
def render_by_login_session
is_a?(Devise::SessionsController) ? "login" : "application"
end
View
11 app/controllers/homes_controller.rb
@@ -18,4 +18,15 @@ def student_score
render_json Student.find(params[:s_id]).course_scores.collect &fields_provider
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
View
1 app/models/comment.rb
@@ -1,3 +1,4 @@
class Comment < ActiveRecord::Base
belongs_to :comment_type
+
end
View
5 app/models/comment_type.rb
@@ -1,3 +1,8 @@
class CommentType < ActiveRecord::Base
has_many :comments
+
+ def self.tree_nodes
+ all.inject([]) { |nodes, record| nodes << { :text => record.name, :id => record.id, :leaf => true } }
+ end
+
end
View
8 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>
View
2 app/views/layouts/application.html.erb
@@ -41,7 +41,7 @@
<div class="dock" id="dock2">
<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="#"><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>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>
View
4 config/routes.rb
@@ -6,6 +6,9 @@
get 'get_classes_students'
get 'student_detail'
get 'student_score'
+ get 'comment_student'
+ post 'comment_type_tree_nodes'
+ get 'commets_by_type'
end
end
resources :settings do
@@ -20,7 +23,6 @@
end
-
#可切换不同用户列表
devise_for :users do
View
1 files/.~lock.界面2.xlsx#
@@ -0,0 +1 @@
+rice ,rice,rode,22.03.2012 15:44,file:///home/rice/.openoffice.org/3;
View
4 lib/tasks/genrate_data.rake
@@ -88,8 +88,8 @@ namespace :data do
Comment.destroy_all
cms = Comment.create(cmses)
cmtses = [
- { :type => "思想德语" },
- { :type => "学风" },
+ { :name => "思想德语" },
+ { :name => "学风" },
]
CommentType.destroy_all
cmts = CommentType.create(cmtses)
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
BIN 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.
View
189 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 () {
+
+ }
+
+});
+
View
2 public/javascripts/PF/pages/home_index.js
@@ -21,7 +21,7 @@ Pf.classes.homeIndex.MainPanel = Ext.extend(Ext.Panel, {
tbar : new Ext.Toolbar({
id : 'form-tbar',
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 ]
View
14 public/javascripts/PF/public/init.js
@@ -1 +1,15 @@
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.