diff --git a/app/assets/javascripts/admins/competition_settings/index.js b/app/assets/javascripts/admins/competition_settings/index.js
index cd10aeb4f..4804ae16e 100644
--- a/app/assets/javascripts/admins/competition_settings/index.js
+++ b/app/assets/javascripts/admins/competition_settings/index.js
@@ -9,7 +9,7 @@ $(document).on('turbolinks:load', function(){
};
var timeOptions = {
- autoclose: true,
+ // autoclose: true,
language: 'zh-CN',
format: 'yyyy-mm-dd hh:ii:ss',
minuteStep: 30
@@ -24,17 +24,20 @@ $(document).on('turbolinks:load', function(){
});
};
- // var defineTimeRangeSelect = function (element) {
- // var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, timeOptions);
- // $(element).datetimepicker(options);
- //
- // $(element).find('.start-date').datetimepicker().on('changeDate', function (e) {
- // $(element).find('.end-date').datetimepicker('setStartDate', e.date);
- // });
- // };
+ var defineTimeRangeSelect = function (element) {
+ // var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, timeOptions);
+ $(".start-date").datetimepicker(timeOptions);
+
+ $(element).find('.start-date').datetimepicker().on('changeDate', function (e) {
+ $(element).find('.end-date').datetimepicker('setStartDate', e.date);
+ });
+ };
+ $(".competition-start-end-date .start-date").datetimepicker();
+
+ $(".competition-start-end-date .end-date").datetimepicker();
defineDateRangeSelect('.teaching-mode-date');
- defineDateRangeSelect('.competition-start-end-date');
+ // defineTimeRangeSelect('.competition-start-end-date');
var $basicForm = $('form.basic-setting-form');
@@ -133,8 +136,8 @@ $(function () {
//链接
- $("#linkForm").on("click",".add_linkBtn",function () {
- var length=$("#linkForm").find(".linkFormItem").length + 1;
+ $(".nav-setting-form").on("click",".add_linkBtn",function () {
+ var length=$(".nav-setting-form").find(".linkFormItem").length + 1;
var html='
\n' +
'
'
- $("#linkForm").append(html)
- })
- $("#linkForm").on("click",".del_linkBtn",function () {
+ '
';
+ $(this).parents(".lineFromItem").insertAfter(html);
+ });
+
+ $(".nav-setting-form").on("click",".del_linkBtn",function () {
$(this).parents(".lineFromItem").remove();
- })
+ });
//有关报名要求
$("#addRequireBtn").on("click",function () {
@@ -192,9 +196,18 @@ $(function () {
' \n' +
' ';
$("#requireForm").append(html);
- })
+ });
$("#requireForm").on("click",".delRequrieBtn",function () {
$(this).parents(".requireForm_item").remove();
+ });
+
+ $('.competition-staff-settings').on('click', '.mutiple-limited-radio', function(){
+ var radio = $(this);
+ if (radio.is(':checked')) {
+ radio.parent().parent().siblings().find('.mutiple-limited-radio').attr('checked', false)
+ } else {
+ radio.parent().parent().siblings().find('.mutiple-limited-radio').attr('checked', true)
+ }
})
-})
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/app/controllers/admins/competition_settings_controller.rb b/app/controllers/admins/competition_settings_controller.rb
index 9fee83c3e..c905c4644 100644
--- a/app/controllers/admins/competition_settings_controller.rb
+++ b/app/controllers/admins/competition_settings_controller.rb
@@ -24,6 +24,6 @@ class Admins::CompetitionSettingsController < Admins::BaseController
end
def nav_form_params
- params.permit(:enroll_end_time, competition_staffs: %i[category minimum maximum mutiple_limited], nav_module: %i[module_type name hidden position url])
+ params.permit(:enroll_end_time, competition_staffs: %i[category minimum maximum mutiple_limited], navbar: %i[module_type name hidden position url])
end
end
\ No newline at end of file
diff --git a/app/services/admins/competition_nav_setting_service.rb b/app/services/admins/competition_nav_setting_service.rb
index 13b58a799..9b68450f7 100644
--- a/app/services/admins/competition_nav_setting_service.rb
+++ b/app/services/admins/competition_nav_setting_service.rb
@@ -13,7 +13,7 @@ class Admins::CompetitionNavSettingService < ApplicationService
# hidden_module_type = competition.all_module_types - params[:module_type]
# competition.competition_modules.where(module_type: hidden_module_type).update_all(hidden: 1)
- params[:nav_module].each do |nav|
+ params[:navbar].each do |nav|
module_type = nav["module_type"]
if competition.all_module_types.include?(module_type)
com_module = competition.competition_modules.find_by(module_type: module_type)
@@ -23,6 +23,7 @@ class Admins::CompetitionNavSettingService < ApplicationService
com_module.update_attributes!(hidden: nav["hidden"] ? 0 : 1, position: nav["position"], name: nav["name"], url: nav["url"])
end
+ competition.update_attributes!(enroll_end_time: params[:enroll_end_time])
if params[:competition_staffs].present?
competition.competition_staffs.delete_all
params[:competition_staffs].each_with_index do |staff_params, index|
diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb
index 7133b7254..c2fdabbad 100644
--- a/app/views/admins/competition_settings/index.html.erb
+++ b/app/views/admins/competition_settings/index.html.erb
@@ -35,8 +35,8 @@
起止时间
- <%= text_field_tag :start_time, @competition.start_time&.strftime('%Y-%m-%d'), autocomplete: 'off', class: 'form-control start-date mx-0 mr-2', placeholder: '竞赛开始时间' %>
- <%= text_field_tag :end_time, @competition.end_time&.strftime('%Y-%m-%d'), autocomplete: 'off', class: 'form-control end-date mx-0', placeholder: '竞赛截止时间' %>
+ <%= text_field_tag :start_time, @competition.start_time&.strftime('%Y-%m-%d %H:%M:%S'), autocomplete: 'off', class: 'form-control start-date mx-0 mr-2', placeholder: '竞赛开始时间' %>
+ <%= text_field_tag :end_time, @competition.end_time&.strftime('%Y-%m-%d %H:%M:%S'), autocomplete: 'off', class: 'form-control end-date mx-0', placeholder: '竞赛截止时间' %>
@@ -151,134 +151,161 @@
导航设置
-
- <% @competition.competition_modules.each do |com_module| %>
- <% case com_module.module_type %>
+ <%= form_tag(nav_setting_admins_competition_competition_settings_path(@competition), method: :post, class: 'nav-setting-form flex-1', remote: true) do %>
+
+ <% @competition.competition_modules.each do |com_module| %>
+ <% case com_module.module_type %>
<% when 'home' %>
-
-
+
+
+
+
+
+
+ <%= text_field_tag('navbar[][name]', com_module.name, id: nil, class: 'form-control', placeholder: '首页') %>
+
+
+
+ <%= text_field_tag('navbar[][position]', com_module.position, id: nil, class: 'form-control', placeholder: '位置') %>
+
+
+
+ <% when 'enroll' %>
+
-
- <%= text_field_tag('navbar[][name]', com_module.name, id: nil, class: 'form-control', placeholder: '首页') %>
+
+
+ 报名
-
- <%= text_field_tag('navbar[][position]', com_module.position, id: nil, class: 'form-control', placeholder: '位置') %>
+
+
+
+
+ 报名截止时间
+
+
+ <%= text_field_tag :enroll_end_time, @competition.enroll_end_time&.strftime('%Y-%m-%d'), autocomplete: 'off', class: 'form-control enroll_end_time', placeholder: '报名截止时间' %>
+
+
+
-
- <% end %>
- <% end %>
-
-
-
-
-
+ <% when 'inform', 'chart', 'resource' %>
+
+
+
+
+
+
+
+ <%= com_module.name %>
+
+
+ <%= text_field_tag('navbar[][position]', com_module.position, id: nil, class: 'form-control', placeholder: '位置') %>
+
+ <% if com_module.module_type == "resource" %>
+
+ <%= text_field_tag('navbar[][url]', com_module.url, id: nil, class: 'form-control', placeholder: '请输入资料下载地址') %>
+
+
+ <% end %>
+
+ <% else %>
+
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
+
+
-
-
+ <% end %>
diff --git a/app/views/competitions/competition_teams/index.json.jbuilder b/app/views/competitions/competition_teams/index.json.jbuilder
index 70651b4ae..3e5dc4d16 100644
--- a/app/views/competitions/competition_teams/index.json.jbuilder
+++ b/app/views/competitions/competition_teams/index.json.jbuilder
@@ -1,5 +1,6 @@
json.count @all_count
json.personal @personal
+json.competition_name @competition.name
json.competition_teams do
json.array! @all_teams&.each do |team|
json.extract! team, :id, :name, :invite_code
diff --git a/config/routes.rb b/config/routes.rb
index 80e1298cc..8bad9a889 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1025,6 +1025,7 @@ Rails.application.routes.draw do
resources :competition_settings, only: [:index] do
post :basic_setting, on: :collection
+ post :nav_setting, on: :collection
end
resources :enroll_lists, only: [:index] do
diff --git a/db/migrate/20191023074837_migrate_competition_module_type.rb b/db/migrate/20191023074837_migrate_competition_module_type.rb
index 009b65cc9..c98c5797d 100644
--- a/db/migrate/20191023074837_migrate_competition_module_type.rb
+++ b/db/migrate/20191023074837_migrate_competition_module_type.rb
@@ -16,7 +16,7 @@ class MigrateCompetitionModuleType < ActiveRecord::Migration[5.2]
mod_type = "manual"
when '排行榜'
mod_type = "chart"
- when '资料下载 '
+ when '资料下载'
mod_type = "resource"
else
mod_type = "md"
diff --git a/db/migrate/20191024055404_migrate_com_module_resource.rb b/db/migrate/20191024055404_migrate_com_module_resource.rb
new file mode 100644
index 000000000..f8625b2bc
--- /dev/null
+++ b/db/migrate/20191024055404_migrate_com_module_resource.rb
@@ -0,0 +1,26 @@
+class MigrateComModuleResource < ActiveRecord::Migration[5.2]
+ def change
+ Competition.all.each do |competition|
+ competition.competition_modules.each do |com_module|
+ mod_type = ""
+ case com_module.name.strip
+ when '首页'
+ mod_type = "home"
+ when '报名'
+ mod_type = "enroll"
+ when '通知公告'
+ mod_type = "inform"
+ when '参赛手册'
+ mod_type = "manual"
+ when '排行榜'
+ mod_type = "chart"
+ when '资料下载'
+ mod_type = "resource"
+ else
+ mod_type = "md"
+ end
+ com_module.update_attributes!(module_type: mod_type)
+ end
+ end
+ end
+end