From 806e4caf5a368026afe9db8bc8610ca95604bdab Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 31 Dec 2015 13:26:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E9=9A=90=E8=97=8F=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=A0=8F=E7=9B=AE=E5=8A=9F=E8=83=BD=EF=BC=9B2.?= =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E6=83=85=E5=86=B5=EF=BC=8C=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E9=83=A8=E5=88=86=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 10 ++ app/helpers/organizations_helper.rb | 11 ++- app/views/layouts/base_org.html.erb | 28 +++--- .../_org_left_subfield_list.html.erb | 57 ++++++----- .../organizations/_show_home_page.html.erb | 8 +- .../organizations/_subfield_list.html.erb | 95 +++++++++++-------- .../organizations/hide_org_subfield.js.erb | 2 + app/views/organizations/setting.html.erb | 3 +- app/views/organizations/show.html.erb | 2 +- .../organizations/show_org_subfield.js.erb | 2 + config/routes.rb | 2 + ...0151231023235_add_hide_to_org_subfields.rb | 5 + ...1231023610_add_records_to_org_subfields.rb | 9 ++ db/schema.rb | 8 +- 14 files changed, 153 insertions(+), 89 deletions(-) create mode 100644 app/views/organizations/hide_org_subfield.js.erb create mode 100644 app/views/organizations/show_org_subfield.js.erb create mode 100644 db/migrate/20151231023235_add_hide_to_org_subfields.rb create mode 100644 db/migrate/20151231023610_add_records_to_org_subfields.rb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 466fbd8e3..dabf45da8 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -281,4 +281,14 @@ class OrganizationsController < ApplicationController format.js end end + + def hide_org_subfield + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield.update_attribute(:hide, 1) + end + + def show_org_subfield + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield.update_attribute(:hide, 0) + end end diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 607d2af5c..69c355313 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -17,6 +17,15 @@ module OrganizationsHelper s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) end - + def get_default_name field + case field.name + when 'activity' then + return '动态' + when 'course' then + return '课程' + when 'project' then + return '项目' + end + end end diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 83bcb4dc9..8599ad750 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -120,19 +120,21 @@
-
- <%= link_to '文章', organization_org_document_comments_path(@organization) %>  - <% if User.current.logged? %> - ( - <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> - ) - <% end %> -  |  - <%= link_to '成员', members_organization_path(@organization.id) %>  - <% if User.current.logged? %> - (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) - <% end %> -
+ <% if User.current.logged? %> +
+ <%= link_to '文章', organization_org_document_comments_path(@organization) %>  + <% if User.current.logged? %> + ( + <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> + ) + <% end %> +  |  + <%= link_to '成员', members_organization_path(@organization.id) %>  + <% if User.current.logged? %> + (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) + <% end %> +
+ <% end %>
<%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index d11919927..42ebd240a 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -1,31 +1,38 @@ -
+<% org_activity_field = organization.org_subfields.where('field_type="default" and name="activity" and field_type="default"').first %> +<% org_course_field = organization.org_subfields.where('field_type="default" and name="course" and field_type="default"').first %> +<% org_project_field = organization.org_subfields.where('field_type="default" and name="project" and field_type="default"').first %> +
<%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
-
- 项目 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - <% end %> -
-
-
    - - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
-
-
- 课程 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <% end %> -
-
-
    - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
-
-<% organization.org_subfields.each do |field| %> +
+ 项目 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + <% end %> +
+
+
    + + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
+
+
+
+
+ 课程 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <% end %> +
+
+
    + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
+
+
+<% organization.org_subfields.where("field_type != 'default'").each do |field| %> +
<% if field.field_type == "Post" %> <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> diff --git a/app/views/organizations/_show_home_page.html.erb b/app/views/organizations/_show_home_page.html.erb index 76ee84e69..c80c52b2f 100644 --- a/app/views/organizations/_show_home_page.html.erb +++ b/app/views/organizations/_show_home_page.html.erb @@ -1,16 +1,16 @@ -
+
- + <% if User.current.logged? %>
<%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
- + <% end %> <% unless document.content.blank? %>
<%= document.content.html_safe %>
<% end %> - <% if params[:show_homepage].nil? %> + <% if params[:show_homepage].nil? and User.current.logged? %>
发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 642a5ffd0..8a092f7e2 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -1,47 +1,47 @@ +
    +
  • 已有栏目
  • +
  • 状态
  • +
  • 类型
  • +
    +
-
    -
  • 已有栏目
  • -
  • 状态
  • -
  • 类型
  • -
    -
-
    -
  • 动态
  • -
  • 默认
  • -
  • 默认
  • -
    -
-
    -
  • 项目
  • -
  • 默认
  • -
  • 默认
  • -
    -
-
    -
  • 课程
  • -
  • 默认
  • -
  • 默认
  • -
    -
- <% subfields.each do |field| %> +<% default_fields.each do |field| %> + <% name = get_default_name(field) %>
    -
  • <%= field.name %>
  • -
  • 新增
  • -
  • <%= field.field_type == "Post" ? "帖子":"资源" %>
  • - <%= link_to "删除",org_subfield_path(field), :method => 'delete',:remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr5" %> - 编辑 -
    +
  • <%= name %>
  • +
  • 默认
  • +
  • 默认
  • + <%= field.hide==0?"设为隐藏":"设为显示" %> +
- <% end %> +<% end %> - \ No newline at end of file + } + + function hide(content, id){ + if (content.text() == '设为隐藏') + $.ajax({ + url: "/organizations/hide_org_subfield?org_subfield_id=" + id, + type: "post" + }); + else + $.ajax({ + url: "/organizations/show_org_subfield?org_subfield_id=" + id, + type: "post" + }); + } + \ No newline at end of file diff --git a/app/views/organizations/hide_org_subfield.js.erb b/app/views/organizations/hide_org_subfield.js.erb new file mode 100644 index 000000000..09ed3c280 --- /dev/null +++ b/app/views/organizations/hide_org_subfield.js.erb @@ -0,0 +1,2 @@ +$("#hide_<%= @org_subfield.id %>").text("设为显示"); +$("#org_subfield_<%= @org_subfield.id %>").css("display", "none"); \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 4fc20653a..3058d03a8 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -107,7 +107,8 @@
- <%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields } %> + <%= render :partial => 'organizations/subfield_list', :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), + :subfields => @organization.org_subfields.where("field_type != 'default'") } %>
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index a79271add..78fb12279 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -16,7 +16,7 @@ .homepagePostReplyInputContainer .ke-inline-block {display: none;} .homepagePostReplyInputContainer .ke-container {float: left;} -<% if params[:show_homepage].nil? %> +<% if params[:show_homepage].nil? and User.current.logged? %>
<%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %>
<% if params[:org_subfield_id].nil? %> diff --git a/app/views/organizations/show_org_subfield.js.erb b/app/views/organizations/show_org_subfield.js.erb new file mode 100644 index 000000000..165b07afd --- /dev/null +++ b/app/views/organizations/show_org_subfield.js.erb @@ -0,0 +1,2 @@ +$("#hide_<%= @org_subfield.id %>").text("设为隐藏"); +$("#org_subfield_<%= @org_subfield.id %>").css("display", "block"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9326ac61e..2d195f0d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,8 @@ RedmineApp::Application.routes.draw do collection do get 'check_uniq' get 'autocomplete_search' + post 'hide_org_subfield' + post 'show_org_subfield' end resources :org_document_comments do member do diff --git a/db/migrate/20151231023235_add_hide_to_org_subfields.rb b/db/migrate/20151231023235_add_hide_to_org_subfields.rb new file mode 100644 index 000000000..57dd5cb68 --- /dev/null +++ b/db/migrate/20151231023235_add_hide_to_org_subfields.rb @@ -0,0 +1,5 @@ +class AddHideToOrgSubfields < ActiveRecord::Migration + def change + add_column :org_subfields, :hide, :integer, :default => 0 + end +end diff --git a/db/migrate/20151231023610_add_records_to_org_subfields.rb b/db/migrate/20151231023610_add_records_to_org_subfields.rb new file mode 100644 index 000000000..61fb760da --- /dev/null +++ b/db/migrate/20151231023610_add_records_to_org_subfields.rb @@ -0,0 +1,9 @@ +class AddRecordsToOrgSubfields < ActiveRecord::Migration + def change + Organization.all.each do |org| + OrgSubfield.create(:organization_id => org.id, :name => 'activity', :field_type => 'default') + OrgSubfield.create(:organization_id => org.id, :name => 'course', :field_type => 'default') + OrgSubfield.create(:organization_id => org.id, :name => 'project', :field_type => 'default') + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 72ca3c649..6e3a62182 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151229022049) do +ActiveRecord::Schema.define(:version => 20151231023610) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -198,6 +198,7 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.integer "last_message_id" t.integer "parent_id" t.integer "course_id" + t.integer "org_subfield_id" end add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" @@ -1209,9 +1210,10 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.integer "organization_id" t.integer "priority" t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "field_type" + t.integer "hide", :default => 0 end create_table "organizations", :force => true do |t|