Browse Source

Add Setting button

tags/v1.0.0
sylor_huang@126.com Jasder 5 years ago
parent
commit
248eadb918
6 changed files with 47 additions and 6 deletions
  1. +6
    -0
      app/controllers/admins/laboratories_controller.rb
  2. +7
    -0
      app/controllers/admins/laboratory_settings_controller.rb
  3. +12
    -0
      app/views/admins/laboratory_settings/_add_tr.html.erb
  4. +1
    -0
      app/views/admins/laboratory_settings/new.js.erb
  5. +20
    -5
      app/views/admins/laboratory_settings/show.html.erb
  6. +1
    -1
      config/routes.rb

+ 6
- 0
app/controllers/admins/laboratories_controller.rb 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


+ 7
- 0
app/controllers/admins/laboratory_settings_controller.rb 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


+ 12
- 0
app/views/admins/laboratory_settings/_add_tr.html.erb 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>

+ 1
- 0
app/views/admins/laboratory_settings/new.js.erb View File

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

+ 20
- 5
app/views/admins/laboratory_settings/show.html.erb 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>
@@ -184,4 +194,9 @@
<%= link_to '取消', admins_laboratories_path, class: 'btn btn-secondary px-4' %>
</div>
<% end %>
</div>
</div>
<script>
function destroy_tr(that) {
$(that).parent().parent("tr").remove()
}
</script>

+ 1
- 1
config/routes.rb 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


Loading…
Cancel
Save