add setting navbar index for new

This commit is contained in:
呱呱呱 2023-09-27 09:43:35 +08:00
parent 3367d748b6
commit 19c8587723
3 changed files with 4 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class SettingsController < ApplicationController
private
def get_navbar
@navbar = default_laboratory.navbar.sort_by{|e| e["index"]}
@navbar = default_laboratory.navbar.sort_by{|e| e["index"].to_i }
# 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

@ -1,6 +1,7 @@
<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><%= number_field_tag('navbar[][index]', "", id: nil, class: 'form-control', placeholder: "顺序") %></td>
<td class="text-center">
<%= check_box_tag('navbar[][hidden]', 0, false, id: nil, class: 'font-16') %>
</td>

View File

@ -165,11 +165,11 @@
</tr>
</thead>
<tbody id="laboratories-show-content">
<% (setting.navbar || setting.default_navbar).sort_by{|e| e["index"]}.each do |nav| %>
<% (setting.navbar || setting.default_navbar).sort_by{|e| e["index"].to_i }.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><%= number_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>