From 248eadb918889d6d8930b6522bcc117a7fa0395c Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 16 Oct 2020 16:26:15 +0800 Subject: [PATCH] Add Setting button --- .../admins/laboratories_controller.rb | 6 +++++ .../admins/laboratory_settings_controller.rb | 7 ++++++ .../laboratory_settings/_add_tr.html.erb | 12 +++++++++ .../admins/laboratory_settings/new.js.erb | 1 + .../admins/laboratory_settings/show.html.erb | 25 +++++++++++++++---- config/routes.rb | 2 +- 6 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 app/views/admins/laboratory_settings/_add_tr.html.erb create mode 100644 app/views/admins/laboratory_settings/new.js.erb diff --git a/app/controllers/admins/laboratories_controller.rb b/app/controllers/admins/laboratories_controller.rb index 1c314edeb..f397b0f34 100644 --- a/app/controllers/admins/laboratories_controller.rb +++ b/app/controllers/admins/laboratories_controller.rb @@ -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 diff --git a/app/controllers/admins/laboratory_settings_controller.rb b/app/controllers/admins/laboratory_settings_controller.rb index 283afc175..861db50c6 100644 --- a/app/controllers/admins/laboratory_settings_controller.rb +++ b/app/controllers/admins/laboratory_settings_controller.rb @@ -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 diff --git a/app/views/admins/laboratory_settings/_add_tr.html.erb b/app/views/admins/laboratory_settings/_add_tr.html.erb new file mode 100644 index 000000000..2d6ff25d5 --- /dev/null +++ b/app/views/admins/laboratory_settings/_add_tr.html.erb @@ -0,0 +1,12 @@ + + <%= text_field_tag('navbar[][name]', "", id: nil, class: 'form-control', placeholder: "导航名称") %> + <%= text_field_tag('navbar[][link]', "", id: nil, class: 'form-control', placeholder: "导航链接") %> + + <%= check_box_tag('navbar[][hidden]', 0, false, id: nil, class: 'font-16') %> + + +
+ +
+ + \ No newline at end of file diff --git a/app/views/admins/laboratory_settings/new.js.erb b/app/views/admins/laboratory_settings/new.js.erb new file mode 100644 index 000000000..47eb5aa38 --- /dev/null +++ b/app/views/admins/laboratory_settings/new.js.erb @@ -0,0 +1 @@ +$("#laboratories-show-content").append("<%= j render partial: "admins/laboratory_settings/add_tr" %>") \ No newline at end of file diff --git a/app/views/admins/laboratory_settings/show.html.erb b/app/views/admins/laboratory_settings/show.html.erb index ee9880fbb..67536af24 100644 --- a/app/views/admins/laboratory_settings/show.html.erb +++ b/app/views/admins/laboratory_settings/show.html.erb @@ -143,18 +143,23 @@
-
导航设置
+
+
导航设置 + <%= link_to "".html_safe,new_admins_laboratory_laboratory_setting_path, remote: true, class: "btn btn-primary btn-sm"%> +
+
- + - + + - + <% (setting.navbar || setting.default_navbar).each do |nav| %> @@ -162,6 +167,11 @@ + <% end %> @@ -184,4 +194,9 @@ <%= link_to '取消', admins_laboratories_path, class: 'btn btn-secondary px-4' %> <% end %> - \ No newline at end of file + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6c7f5d80c..3cc95eb02 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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
导航名称导航名称 导航链接是否展示是否展示操作
<%= text_field_tag('navbar[][name]', nav['name'], id: nil, class: 'form-control') %> <%= check_box_tag('navbar[][hidden]', 0, !nav['hidden'], id: nil, class: 'font-16') %> +
+ +
+