add setting navbar index

This commit is contained in:
呱呱呱 2023-09-27 09:29:50 +08:00
parent 412ac22998
commit 3367d748b6
4 changed files with 11 additions and 8 deletions

View File

@ -25,6 +25,6 @@ class Admins::LaboratorySettingsController < Admins::BaseController
params.permit(:identifier, :name,
:nav_logo, :login_logo, :tab_logo, :oj_banner,
:subject_banner, :course_banner, :competition_banner, :moop_cases_banner,
:footer, navbar: %i[name link hidden])
:footer, navbar: %i[name link hidden index])
end
end

View File

@ -28,7 +28,7 @@ class SettingsController < ApplicationController
private
def get_navbar
@navbar = default_laboratory.navbar
@navbar = default_laboratory.navbar.sort_by{|e| e["index"]}
# if User.current.logged?
# pernal_index = {"name"=>"个人主页", "link"=>get_site_url("url", "#{Rails.application.config_for(:configuration)['platform_url']}/current_user"), "hidden"=>false}
# @navbar << pernal_index

View File

@ -30,6 +30,7 @@ class Admins::SaveLaboratorySettingService < ApplicationService
hash = {}
hash[:name] = strip nav[:name]
hash[:link] = strip nav[:link]
hash[:index] = strip nav[:index]
hash[:hidden] = nav[:hidden].to_s != '0'
hash
end

View File

@ -16,9 +16,9 @@
<span class="input-group-text">https://</span>
</div>
<%= text_field_tag :identifier, @laboratory.identifier,
maxlength: 15, class: 'form-control font-16',
'onKeyUp': 'value=value.replace(/[^\w\-\/]/ig,"").toLowerCase()',
style: 'text-transform:lowercase'%>
maxlength: 15, class: 'form-control font-16',
'onKeyUp': 'value=value.replace(/[^\w\-\/]/ig,"").toLowerCase()',
style: 'text-transform:lowercase'%>
<div class="input-group-append">
<% rails_env = EduSetting.get('rails_env') %>
<span class="input-group-text font-14" id="site-prefix"><%= rails_env && rails_env != 'production' ? ".#{rails_env}.gitlink.org.cn" : '.gitlink.org.cn' %></span>
@ -159,15 +159,17 @@
<tr>
<th width="30%">导航名称</th>
<th width="50%">导航链接</th>
<th width="10%" class="text-center">是否展示</th>
<th width="5%">顺序</th>
<th width="5%" class="text-center">是否展示</th>
<th width="10%" class="text-center">操作</th>
</tr>
</thead>
<tbody id="laboratories-show-content">
<% (setting.navbar || setting.default_navbar).each do |nav| %>
<tbody id="laboratories-show-content">
<% (setting.navbar || setting.default_navbar).sort_by{|e| e["index"]}.each do |nav| %>
<tr>
<td><%= text_field_tag('navbar[][name]', nav['name'], id: nil, class: 'form-control') %></td>
<td><%= text_field_tag('navbar[][link]', nav['link'], id: nil, class: 'form-control') %></td>
<td><%= text_field_tag('navbar[][index]', nav['index'], id: nil, class: 'form-control') %></td>
<td class="text-center">
<%= check_box_tag('navbar[][hidden]', 0, !nav['hidden'], id: nil, class: 'font-16') %>
</td>