课程体系的超管页面调整

yslnewtiku
cxt 5 years ago
parent 7f9d258230
commit 7504d7b0c4

@ -20,7 +20,15 @@ class Admins::DisciplinesController < Admins::BaseController
name = params[:discipline][:name].to_s.strip name = params[:discipline][:name].to_s.strip
current_discipline.update_attributes!(name: name) current_discipline.update_attributes!(name: name)
else else
current_discipline.update_attributes!(setting_params) ActiveRecord::Base.transaction do
current_discipline.update_attributes!(setting_params)
current_discipline.sub_disciplines.each do |sub|
sub.tag_disciplines.each do |tag|
tag.update_attributes!(setting_params)
end
sub.update_attributes!(setting_params)
end
end
end end
@disciplines = Discipline.all @disciplines = Discipline.all
end end

@ -21,7 +21,12 @@ class Admins::SubDisciplinesController < Admins::BaseController
name = params[:sub_discipline][:name].to_s.strip name = params[:sub_discipline][:name].to_s.strip
current_sub_discipline.update_attributes!(name: name) current_sub_discipline.update_attributes!(name: name)
else else
current_sub_discipline.update_attributes!(setting_params) ActiveRecord::Base.transaction do
current_sub_discipline.update_attributes!(setting_params)
current_sub_discipline.tag_disciplines.each do |tag|
tag.update_attributes!(setting_params)
end
end
end end
@sub_disciplines = current_sub_discipline.discipline&.sub_disciplines @sub_disciplines = current_sub_discipline.discipline&.sub_disciplines
end end

@ -1,3 +1,7 @@
class TagDiscipline < ApplicationRecord class TagDiscipline < ApplicationRecord
belongs_to :sub_discipline belongs_to :sub_discipline
def discipline
sub_discipline&.discipline
end
end end

@ -17,9 +17,9 @@
<td class="text-left"> <td class="text-left">
<span><%= link_to sub.name, admins_tag_disciplines_path(sub_discipline_id: sub), :title => sub.name %></span> <span><%= link_to sub.name, admins_tag_disciplines_path(sub_discipline_id: sub), :title => sub.name %></span>
</td> </td>
<td><%= check_box_tag :subject,!sub.subject,sub.subject,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td> <td><%= check_box_tag :subject,!sub.subject,sub.subject,disabled:!sub.discipline&.subject,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
<td><%= check_box_tag :shixun,!sub.shixun,sub.shixun,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td> <td><%= check_box_tag :shixun,!sub.shixun,sub.shixun,disabled:!sub.discipline&.shixun,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
<td><%= check_box_tag :question,!sub.question,sub.question,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td> <td><%= check_box_tag :question,!sub.question,sub.question,disabled:!sub.discipline&.question,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
<td> <td>
<%= link_to '编辑', edit_admins_sub_discipline_path(sub), remote: true, class: 'action' %> <%= link_to '编辑', edit_admins_sub_discipline_path(sub), remote: true, class: 'action' %>
<%= delete_link '删除', admins_sub_discipline_path(sub, element: ".sub-discipline-item-#{sub.id}"), class: 'delete-sub-discipline-action' %> <%= delete_link '删除', admins_sub_discipline_path(sub, element: ".sub-discipline-item-#{sub.id}"), class: 'delete-sub-discipline-action' %>

@ -15,9 +15,18 @@
<tr class="tag-discipline-item tag-discipline-item-<%= tag.id %>"> <tr class="tag-discipline-item tag-discipline-item-<%= tag.id %>">
<td><%= index + 1 %></td> <td><%= index + 1 %></td>
<td class="text-left"><%= tag.name %></td> <td class="text-left"><%= tag.name %></td>
<td><%= check_box_tag :subject,!tag.subject,tag.subject,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %></td> <td>
<td><%= check_box_tag :shixun,!tag.shixun,tag.shixun,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %></td> <% disabled = !(tag.sub_discipline&.subject && tag.discipline&.subject) %>
<td><%= check_box_tag :question,!tag.question,tag.question,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %></td> <%= check_box_tag :subject,!tag.subject,tag.subject,disabled:disabled,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %>
</td>
<td>
<% disabled = !(tag.sub_discipline&.shixun && tag.discipline&.shixun) %>
<%= check_box_tag :shixun,!tag.shixun,tag.shixun,disabled:disabled,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %>
</td>
<td>
<% disabled = !(tag.sub_discipline&.question && tag.discipline&.question) %>
<%= check_box_tag :question,!tag.question,tag.question,disabled:disabled,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %>
</td>
<td> <td>
<%= link_to '编辑', edit_admins_tag_discipline_path(tag), remote: true, class: 'action' %> <%= link_to '编辑', edit_admins_tag_discipline_path(tag), remote: true, class: 'action' %>
<%= delete_link '删除', admins_tag_discipline_path(tag, element: ".tag-discipline-item-#{tag.id}"), class: 'delete-tag-discipline-action' %> <%= delete_link '删除', admins_tag_discipline_path(tag, element: ".tag-discipline-item-#{tag.id}"), class: 'delete-tag-discipline-action' %>

Loading…
Cancel
Save