diff --git a/app/assets/javascripts/olympiamanagement.js b/app/assets/javascripts/olympiamanagement.js new file mode 100644 index 0000000..cf2cbbb --- /dev/null +++ b/app/assets/javascripts/olympiamanagement.js @@ -0,0 +1,43 @@ +$(document).ready(function(){ + $('.class_setting_block input[type="reset"]').off('click').on('click',function(){ + $('.col_input').val(''); + }); + $('.class_setting_block input[type="submit"]').off('click').on('click',function(){ + var class_number_range = []; + class_number_range.push(Number($('.class_setting_block .col_input[name="MinClass"]').val())); + class_number_range.push(Number($('.class_setting_block .col_input[name="MaxClass"]').val())); + var enrollment_available = $('.class_setting_block .col_input#Person').val(); + class_number_range.sort(); + var params_array = (window.location.search.substring(1)=="") ? [] : window.location.search.substring(1).split('&').map(function(el){return el.split('=')}); + var params = {}; + params_array.forEach(function(el){params[el[0]] = el[1]}); + var params_to_send = {'type':'class_setting','class_number_range':class_number_range,'enrollment_available':enrollment_available}; + params_to_send = Object.assign(params,params_to_send); + var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send); + post_data.done(function(){ + window.location.search=""; + }); + }); + $('.fieldset_block input[type="submit"]').click(function(){ + $el = $('.fieldset_block li.required'); + for(var i = 0; i< $el.length ; i++){ + if($el.eq(i).siblings('.col_r').find('.required').val() == ""){ + $el.eq(i).addClass('errFld'); + if($el.eq(i).siblings('.col_r').find('.errMsg').length == 0) + $el.eq(i).siblings('.col_r').append('
'+((I18n.locale == "en") ? 'Required field': '必填欄位')+'
'); + }else{ + $el.eq(i).removeClass('errFld'); + $el.eq(i).siblings('.col_r').find('.errMsg').remove(); + }; + }; + if($('.fieldset_block .required.errFld').length != 0) + return false; + else + return true; + }) + var $el = $('.fieldset_block select'); + for(var i = 0 ; i < $el.length ; i++) + if($el.eq(i).attr('value') != "" && $el.eq(i).attr('value') != undefined) + $el.eq(i).find('option[value='+$el.eq(i).attr('value')+']').attr('selected','selected'); + CKEDITOR.replaceAll(); +}); \ No newline at end of file diff --git a/app/controllers/olympiamanagements_controller.rb b/app/controllers/olympiamanagements_controller.rb index 9febd3b..88992cd 100644 --- a/app/controllers/olympiamanagements_controller.rb +++ b/app/controllers/olympiamanagements_controller.rb @@ -1,6 +1,40 @@ class OlympiamanagementsController < ApplicationController + def initialize + super + @app_title = "olympiamanagement" + end def index + uid = OrbitHelper.params[:uid] rescue "" + tags = OrbitHelper.widget_tags + categories = OrbitHelper.widget_categories || [] + @sign_up_setting = SignUpSetting.last + @olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s + @sign_up_setting.attributes.to_h.each do |key,value| + @olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s) + end + { + "olympiamanagement" => [], + "extras"=>{"instructions"=> @olympiamanagement_instruction} + } end def widget + uid = OrbitHelper.params[:uid] rescue "" + tags = OrbitHelper.widget_tags + categories = OrbitHelper.widget_categories || [] + @sign_up_setting = SignUpSetting.last + @olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s + @sign_up_setting.attributes.to_h.each do |key,value| + @olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s) + end + { + "olympiamanagement" => [], + "extras"=>{"instructions"=> @olympiamanagement_instruction} + } + end + def updata_school_data + #render :html => '123' + end + def updata_student_data + #render :html => '123' end end \ No newline at end of file diff --git a/app/views/olympiamanagements/_olympia_managements_widget.html.erb b/app/views/olympiamanagements/_olympia_managements_widget.html.erb new file mode 100644 index 0000000..4203a62 --- /dev/null +++ b/app/views/olympiamanagements/_olympia_managements_widget.html.erb @@ -0,0 +1,7 @@ + + + +{{table}} + + + \ No newline at end of file diff --git a/app/views/olympiamanagements/info.json b/app/views/olympiamanagements/info.json new file mode 100644 index 0000000..ae9f1e4 --- /dev/null +++ b/app/views/olympiamanagements/info.json @@ -0,0 +1,30 @@ +{ + "frontend": [ + { + "filename" : "olympia_managements_index", + "name" : { + "zh_tw" : "1. 初選線上報名", + "en" : "1. Primary online registration" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "olympia_managements_instructions_index", + "name" : { + "zh_tw" : "2. 線上報名說明", + "en" : "1. Online registration instructions " + }, + "thumbnail" : "thumb.png" + } + ], + "widgets" : [ + { + "filename" : "olympia_managements_widget", + "name" : { + "zh_tw" : "1. 初選線上報名", + "en" : "1. Primary online registration" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/app/views/olympiamanagements/olympia_managements_index.html.erb b/app/views/olympiamanagements/olympia_managements_index.html.erb new file mode 100644 index 0000000..4203a62 --- /dev/null +++ b/app/views/olympiamanagements/olympia_managements_index.html.erb @@ -0,0 +1,7 @@ + + + +{{table}} + + + \ No newline at end of file diff --git a/app/views/olympiamanagements/olympia_managements_instructions_index.html.erb b/app/views/olympiamanagements/olympia_managements_instructions_index.html.erb new file mode 100644 index 0000000..4203a62 --- /dev/null +++ b/app/views/olympiamanagements/olympia_managements_instructions_index.html.erb @@ -0,0 +1,7 @@ + + + +{{table}} + + + \ No newline at end of file diff --git a/app/views/olympiamanagements/thumbs/thumb.png b/app/views/olympiamanagements/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/app/views/olympiamanagements/thumbs/thumb.png differ diff --git a/app/views/olympiamanagements/updata_school_data.html.erb b/app/views/olympiamanagements/updata_school_data.html.erb new file mode 100644 index 0000000..3635010 --- /dev/null +++ b/app/views/olympiamanagements/updata_school_data.html.erb @@ -0,0 +1 @@ +loading... \ No newline at end of file diff --git a/app/views/olympiamanagements/updata_student_data.html.erb b/app/views/olympiamanagements/updata_student_data.html.erb new file mode 100644 index 0000000..3635010 --- /dev/null +++ b/app/views/olympiamanagements/updata_student_data.html.erb @@ -0,0 +1 @@ +loading... \ No newline at end of file diff --git a/olympiamanagement/_olympia_managements_instructions_widget.html.erb b/olympiamanagement/_olympia_managements_instructions_widget.html.erb new file mode 100644 index 0000000..35f3164 --- /dev/null +++ b/olympiamanagement/_olympia_managements_instructions_widget.html.erb @@ -0,0 +1,5 @@ + +{{instructions}} + + + \ No newline at end of file diff --git a/olympiamanagement/_olympia_managements_widget.html.erb b/olympiamanagement/_olympia_managements_widget.html.erb new file mode 100644 index 0000000..4203a62 --- /dev/null +++ b/olympiamanagement/_olympia_managements_widget.html.erb @@ -0,0 +1,7 @@ + + + +{{table}} + + + \ No newline at end of file diff --git a/olympiamanagement/info.json b/olympiamanagement/info.json new file mode 100644 index 0000000..69131d2 --- /dev/null +++ b/olympiamanagement/info.json @@ -0,0 +1,38 @@ +{ + "frontend": [ + { + "filename" : "olympia_managements_index", + "name" : { + "zh_tw" : "1. 初選線上報名", + "en" : "1. Primary online registration" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "olympia_managements_instructions_index", + "name" : { + "zh_tw" : "2. 線上報名說明", + "en" : "2. Online registration instructions" + }, + "thumbnail" : "thumb.png" + } + ], + "widgets" : [ + { + "filename" : "olympia_managements_widget", + "name" : { + "zh_tw" : "1. 初選線上報名", + "en" : "1. Primary online registration" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "olympia_managements_instructions_widget", + "name" : { + "zh_tw" : "2. 線上報名說明", + "en" : "2. Online registration instructions" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/olympiamanagement/olympia_managements_index.html.erb b/olympiamanagement/olympia_managements_index.html.erb new file mode 100644 index 0000000..35f3164 --- /dev/null +++ b/olympiamanagement/olympia_managements_index.html.erb @@ -0,0 +1,5 @@ + +{{instructions}} + + + \ No newline at end of file diff --git a/olympiamanagement/olympia_managements_instructions_index.html.erb b/olympiamanagement/olympia_managements_instructions_index.html.erb new file mode 100644 index 0000000..35f3164 --- /dev/null +++ b/olympiamanagement/olympia_managements_instructions_index.html.erb @@ -0,0 +1,5 @@ + +{{instructions}} + + + \ No newline at end of file diff --git a/olympiamanagement/thumbs/thumb.png b/olympiamanagement/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/olympiamanagement/thumbs/thumb.png differ