From 084844941f0d766c2f54f64d624db05e92b5a6d2 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 18 Dec 2015 15:22:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82=20=E8=81=9A=E7=84=A6=E5=B0=B1?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=89=80=E6=9C=89=E7=9A=84=E5=AD=A6=E6=A0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/school_controller.rb | 5 +- app/views/my/account.html.erb | 78 ++++++++++++++-------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index d20a58b75..e0aff6254 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -120,15 +120,16 @@ class SchoolController < ApplicationController condition.scan(/./).each_with_index do |char,index| if char =~ /[a-zA-Z0-9]/ pinyin << char + elsif char =~ /\'/ else chinese << char end end if(condition == '') - @school = School.page((params[:page].to_i || 1) - 1).per(100) + @school = School.reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100) @school_count = School.count else - @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").page((params[:page].to_i || 1) - 1).per(100) + @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100) @school_count = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count end diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 604953ad9..30072777e 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -642,45 +642,45 @@ $("#hint").hide(); } }); -// $("input[name='province']").on('focus', function (e) { -// if($(e.target).val() == ''){ // -// return; -// } -// if( $("input[name='occupation']").val() != ''){ //如果已经有id了。肯定存在,不用去找了。 -// return; -// } -// -// $.ajax({ -// url: '<%#= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value, -// type: 'post', -// success: function (data) { -// if(data.length != undefined && data.length != 0) { -// var i = 0; -// $("#search_school_result_list").html(''); -// for (; i < data.length; i++) { -// link = '' + data[i].school.name + '
'; -// $("#search_school_result_list").append(link); -// } -// $("#search_school_result_list").css('left', $(e.target).offset().left); -// $("#search_school_result_list").css('top', $(e.target).offset().top + 28); -// $("#search_school_result_list").css("position", "absolute"); -// $("#search_school_result_list").show(); -// if ($(e.target).val().trim() != '') { -// str = e.target.value.length > 8 ? e.target.value.substr(0, 6) + "..." : e.target.value; -// $("#hint").html('找到了' + data.length + '个包含"' + str + '"的高校'); -// $("#hint").show(); -// } else { -// $("#hint").hide(); -// } -// }else { -// $("#search_school_result_list").html(''); -// str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value; -// $("#hint").html('没有找到包含"'+str+'"的高校,创建高校'); -// $("#hint").show(); -// } -// } -// }); -// }); + $("input[name='province']").on('focus', function (e) { + if( $("input[name='occupation']").val() != ''){ //如果已经有id了。肯定存在,不用去找了。 + return; + } + + $.ajax({ + url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value+'&page='+page, + type: 'post', + success: function (data) { + schoolsResult = data.schools; + count = data.count; + maxPage = Math.ceil(count/100) //最大页码值 + if(schoolsResult.length != undefined && schoolsResult.length != 0) { + var i = 0; + $("#search_school_result_list").html(''); + for (; i < schoolsResult.length; i++) { + link = '' + schoolsResult[i].school.name + '
'; + $("#search_school_result_list").append(link); + } + $("#search_school_result_list").css('left', $(e.target).offset().left); + $("#search_school_result_list").css('top', $(e.target).offset().top + 28); + $("#search_school_result_list").css("position", "absolute"); + $("#search_school_result_list").show(); + if($(e.target).val().trim() != '') { + str = e.target.value.length > 8 ? e.target.value.substr(0, 6)+"..." : e.target.value; + $("#hint").html('找到了' + count + '个包含"' + str + '"的高校'); + $("#hint").show(); + }else{ + $("#hint").hide(); + } + }else{ + $("#search_school_result_list").html(''); + str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value; + $("#hint").html('没有找到包含"'+str+'"的高校,创建高校'); + $("#hint").show(); + } + } + }); + }); // $("#province").leanModal({top: 100, closeButton: ".modal_close"}); From 793a98ade12e33b93fe824a06785d3e5eb8363bf Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 18 Dec 2015 15:51:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?forge=5Factivities=E9=82=A3=E4=B8=AA?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=8A=A8=E6=80=81=E8=84=9A=E6=9C=AC=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...18022014_batch_delete_project_journal_activities.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/migrate/20151218022014_batch_delete_project_journal_activities.rb b/db/migrate/20151218022014_batch_delete_project_journal_activities.rb index 95d6a39c5..6752b5b30 100644 --- a/db/migrate/20151218022014_batch_delete_project_journal_activities.rb +++ b/db/migrate/20151218022014_batch_delete_project_journal_activities.rb @@ -1,7 +1,15 @@ # encoding: utf-8 class BatchDeleteProjectJournalActivities < ActiveRecord::Migration def up - ForgeActivity.where('forge_act_type = \'Journal\'').destroy_all #需要触发回调 + #ForgeActivity.where('forge_act_type = \'Journal\'').destroy_all #需要触发回调 + count = ForgeActivity.where('forge_act_type = \'Journal\'').count / 30 + 2 + transaction do + for i in 1 ... count do i + ForgeActivity.where('forge_act_type = \'Journal\'').page(i).per(30).each do |activity| + activity.destroy + end + end + end end def down From c38191eb424e722182bda8eeb24a28aa3977004a Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 18 Dec 2015 16:25:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=9B=9E=E5=A4=8Dat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 115a70e7a..fd6171f18 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -18,7 +18,7 @@ } $(function () { - init_activity_KindEditor_data(<%= issue.id%>, null, "87%"); + init_activity_KindEditor_data(<%= issue.id%>, null, "87%", "<%= issue.class.name %>"); showNormalImage('activity_description_<%= issue.id %>'); if ($("#intro_content_<%= issue.id %>").height() > 360) { $("#intro_content_show_<%= issue.id %>").show();