课程配置加上小程序选项

sso
jingquan huang 5 years ago
parent c517b10cc7
commit af0b7aa1a6

@ -29,6 +29,23 @@ $(document).on('turbolinks:load', function () {
}
});
$(".action-container").on("change", '.subject-mobile-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
json[s_name] = s_value;
json["page_no"] = s_index;
$.ajax({
url: "/admins/subject_settings/update_mobile_show?subject_id=" + s_id,
type: "POST",
dataType:'script',
data: json
});
});
$(".subject-setting-list-container").on("change", '.subject-setting-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();

@ -8,6 +8,12 @@ class Admins::SubjectSettingsController < Admins::BaseController
end
def update
# 为了复用代码
if params["show_moblie"]
subject.find(params[:id]).update_attributes(:show_moblie => params[:show_moblie])
return
end
sub_discipline_ids = params[:sub_disciplines] || []
sub_ids = sub_discipline_ids.reject(&:blank?).map(&:to_i)
old_sub_ids = current_subject.sub_discipline_containers.pluck(:sub_discipline_id)
@ -20,6 +26,11 @@ class Admins::SubjectSettingsController < Admins::BaseController
end
end
def update_mobile_show
subject = Subject.find(params[:subject_id])
subject.update_attributes(:show_mobile => params[:show_mobile])
end
private
def current_subject

@ -1,14 +1,14 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="4%">序号</th>
<th width="25%" class="text-left">名称</th>
<th width="12%">技术体系</th>
<th width="10%">等级体系</th>
<th width="5%">序号</th>
<th width="23%" class="text-left">名称</th>
<th width="10%">老版技术体系</th>
<th width="10%">状态</th>
<th width="25%">课程体系</th>
<th width="10%">封面</th>
<th width="8%">开课人数</th>
<th width="6%">操作</th>
<th width="5%">开课人数</th>
<th width="12%">操作</th>
</tr>
</thead>
<tbody>

@ -5,7 +5,7 @@
<span class="badge badge-pill badge-info excellent-badge" style="<%= subject.excellent? ? '' : 'display:none' %>">金课</span>
</td>
<td><%= display_text subject.repertoire&.name %></td>
<td><%= display_text subject.subject_level_system&.name %></td>
<td><%= display_text subject.status == 2 ? "已发布" : "未发布" %></td>
<td>
<%= select_tag(:sub_disciplines, options_for_select(@sub_disciplines, subject.sub_disciplines.pluck(:id)),multiple:true,class:"form-control subject-setting-form",data:{id:subject.id},id:"tags-chosen-#{subject.id}") %>
</td>
@ -16,6 +16,8 @@
</td>
<td><%= subject.student_count %></td>
<td class="action-container">
<%= check_box_tag :show_mobile, !subject.show_mobile, subject.show_mobile, remote: true,
data: {id: subject.id, toggle: "tooltip", placement: "top"}, class: "subject-mobile-form mr10", title: "小程序端显示" %>
<%= link_to('编辑', edit_admins_subject_path(subject), remote: true, class: 'edit-action') %>
</td>

@ -0,0 +1 @@
$.notify({ message: '更新成功' });

@ -1328,7 +1328,9 @@ Rails.application.routes.draw do
post :drag, on: :collection
end
resources :subject_settings, only: [:index, :update]
resources :subject_settings, only: [:index, :update] do
post :update_mobile_show, on: :collection
end
resources :subjects, only: [:index, :edit, :update, :destroy] do
member do

@ -0,0 +1,5 @@
class AddShowMoblieToSubjects < ActiveRecord::Migration[5.2]
def change
add_column :subjects, :show_mobile, :boolean, :default => false
end
end
Loading…
Cancel
Save