Add Setting button

This commit is contained in:
sylor_huang@126.com 2020-10-16 16:26:15 +08:00 committed by Jasder
parent 63ae3fdea0
commit 248eadb918
6 changed files with 47 additions and 6 deletions

View File

@ -6,6 +6,12 @@ class Admins::LaboratoriesController < Admins::BaseController
@laboratories = paginate laboratories.preload(:laboratory_users)
end
def new
respond_to do |format|
format.js
end
end
def create
Admins::CreateLaboratoryService.call(create_params)
render_ok

View File

@ -1,4 +1,11 @@
class Admins::LaboratorySettingsController < Admins::BaseController
def new
respond_to do |format|
format.js
end
end
def show
@laboratory = current_laboratory
end

View File

@ -0,0 +1,12 @@
<tr>
<td><%= text_field_tag('navbar[][name]', "", id: nil, class: 'form-control', placeholder: "导航名称") %></td>
<td><%= text_field_tag('navbar[][link]', "", id: nil, class: 'form-control', placeholder: "导航链接") %></td>
<td class="text-center">
<%= check_box_tag('navbar[][hidden]', 0, false, id: nil, class: 'font-16') %>
</td>
<td class="text-center">
<div class="btn btn-primary btn-sm" onclick="destroy_tr(this)">
<i class='fa fa-trash'></i>
</div>
</td>
</tr>

View File

@ -0,0 +1 @@
$("#laboratories-show-content").append("<%= j render partial: "admins/laboratory_settings/add_tr" %>")

View File

@ -143,18 +143,23 @@
</div>
<div class="form-group px-2 setting-item">
<div class="setting-item-head"><h6>导航设置</h6></div>
<div class="setting-item-head">
<h6>导航设置
<%= link_to "<i class='fa fa-plus-circle'></i>".html_safe,new_admins_laboratory_laboratory_setting_path, remote: true, class: "btn btn-primary btn-sm"%>
</h6>
</div>
<div class="dropdown-divider"></div>
<div class="pl-0 py-3 setting-item-body">
<table class="table">
<thead class="thead-light">
<tr>
<th width="35%">导航名称</th>
<th width="30%">导航名称</th>
<th width="50%">导航链接</th>
<th width="15%" class="text-center">是否展示</th>
<th width="10%" class="text-center">是否展示</th>
<th width="10%" class="text-center">操作</th>
</tr>
</thead>
<tbody>
<tbody id="laboratories-show-content">
<% (setting.navbar || setting.default_navbar).each do |nav| %>
<tr>
<td><%= text_field_tag('navbar[][name]', nav['name'], id: nil, class: 'form-control') %></td>
@ -162,6 +167,11 @@
<td class="text-center">
<%= check_box_tag('navbar[][hidden]', 0, !nav['hidden'], id: nil, class: 'font-16') %>
</td>
<td class="text-center">
<div class="btn btn-primary btn-sm" onclick="destroy_tr(this)">
<i class='fa fa-trash'></i>
</div>
</td>
</tr>
<% end %>
</tbody>
@ -185,3 +195,8 @@
</div>
<% end %>
</div>
<script>
function destroy_tr(that) {
$(that).parent().parent("tr").remove()
}
</script>

View File

@ -567,7 +567,7 @@ Rails.application.routes.draw do
post :update_sync_course
end
resource :laboratory_setting, only: [:show, :update]
resource :laboratory_setting, only: [:show, :update, :new]
resource :laboratory_user, only: [:create, :destroy]
resources :carousels, only: [:index, :create, :update, :destroy] do