Fix known bug.

This commit is contained in:
BoHung Chiu 2021-08-22 16:48:49 +08:00
parent f99f9a199e
commit 12b9e91751
5 changed files with 78 additions and 73 deletions

View File

@ -286,6 +286,9 @@ $(function() {
}; };
attributesHeaderLength = $('.attributes:not(:hidden)').length+1; attributesHeaderLength = $('.attributes:not(:hidden)').length+1;
attributesLength = $('#attributes-area .attributes').length; attributesLength = $('#attributes-area .attributes').length;
if(templateType == null){
templateType = "typeA";
}
$("#template-attributes").tmpl(setData(attributesLength, templateType, appendIndex)).appendTo( "#attributes-area" ); $("#template-attributes").tmpl(setData(attributesLength, templateType, appendIndex)).appendTo( "#attributes-area" );
$('.toggle-check').togglebox(); $('.toggle-check').togglebox();
}); });
@ -434,7 +437,6 @@ $(function() {
// appendIndex = appendIndex.split("]["); // appendIndex = appendIndex.split("][");
// appendIndex = parseInt(appendIndex[appendIndex.length-2])+1; // appendIndex = parseInt(appendIndex[appendIndex.length-2])+1;
appendIndex = parseInt(appendIndex.match(/[^[\D\]]+(?=])/g)[1])+1; appendIndex = parseInt(appendIndex.match(/[^[\D\]]+(?=])/g)[1])+1;
console.log(appendIndex)
attributeIndex = $(this).closest('.attributes').index(); attributeIndex = $(this).closest('.attributes').index();
templateType = $(this).closest('.attributes').find('.dataType').children("option:selected").attr('ref'); templateType = $(this).closest('.attributes').find('.dataType').children("option:selected").attr('ref');
$("#template-input-append").tmpl(setData(attributeIndex, templateType, appendIndex)).appendTo($(this).closest('.controls').find('.add-target')); $("#template-input-append").tmpl(setData(attributeIndex, templateType, appendIndex)).appendTo($(this).closest('.controls').find('.add-target'));

View File

@ -531,15 +531,17 @@ class Admin::SeminarsController < OrbitAdminController
end end
def update def update
@seminar_params = seminar_params rescue {}
params[:seminar_main][:registration_status] = (params[:seminar_main][:registration_status] ? params[:seminar_main][:registration_status] : []) if @seminar_params.count != 0
@seminar_params[:registration_status] = (@seminar_params[:registration_status] ? @seminar_params[:registration_status] : [])
uid = params[:id].split('-').last uid = params[:id].split('-').last
@seminar = SeminarMain.find_by(:uid=>uid) @seminar = SeminarMain.find_by(:uid=>uid)
seminar_params["reviewer_ids"] = [] if seminar_params["reviewer_ids"].nil? if @seminar_params.has_key?("title_translations")
seminar_params["organizer_id"] = nil if seminar_params["organizer_id"].nil? @seminar_params["reviewer_ids"] = [] if @seminar_params["reviewer_ids"].nil?
if params[:seminar_main][:seminar_signup_fields] @seminar_params["organizer_id"] = nil if @seminar_params["organizer_id"].nil?
seminar_params[:seminar_signup_fields].each do |a| end
if @seminar_params[:seminar_signup_fields]
@seminar_params[:seminar_signup_fields].each do |a|
@field_name = 'seminar_main' @field_name = 'seminar_main'
field_status = a.last[:id].present? field_status = a.last[:id].present?
@attribute_field = SeminarSignupField.add_seminar_signup_field(@seminar, a.last, a.last[:id], field_status) @attribute_field = SeminarSignupField.add_seminar_signup_field(@seminar, a.last, a.last[:id], field_status)
@ -548,8 +550,8 @@ class Admin::SeminarsController < OrbitAdminController
flash.now[:notice] = "Updated Fields" flash.now[:notice] = "Updated Fields"
@seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true} @seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true}
redirect_to admin_seminars_path redirect_to admin_seminars_path and return
elsif params[:seminar_main][:seminar_submission_fields] elsif @seminar_params[:seminar_submission_fields]
params[:seminar_main][:seminar_submission_fields].each do |a| params[:seminar_main][:seminar_submission_fields].each do |a|
@field_name = 'seminar_main' @field_name = 'seminar_main'
field_status = a.last[:id].present? field_status = a.last[:id].present?
@ -588,7 +590,7 @@ class Admin::SeminarsController < OrbitAdminController
@seminar.update(:assign_mode => 1) @seminar.update(:assign_mode => 1)
end end
end end
redirect_to admin_seminars_path redirect_to admin_seminars_path and return
else else
if !seminar_params['seminar_links_attributes'].nil? if !seminar_params['seminar_links_attributes'].nil?
@ -600,13 +602,14 @@ class Admin::SeminarsController < OrbitAdminController
@seminar.update_user_id = current_user.id @seminar.update_user_id = current_user.id
if @seminar.update_attributes(seminar_params) if @seminar.update_attributes(seminar_params)
@seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true} @seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true}
redirect_to params['referer_url'] redirect_to params['referer_url'] and return
else else
flash.now[:error] = t('update.error.category') flash.now[:error] = t('update.error.category')
render action: :edit render action: :edit and return
end end
end end
end
redirect_to admin_seminars_path
end end
def set_write_off def set_write_off

View File

@ -7,7 +7,7 @@
<% content_for :page_specific_javascript do -%> <% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %> <%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
<%= javascript_include_tag "field-forms.js" %> <%= javascript_include_tag "seminar-field-forms.js" %>
<% end -%> <% end -%>
<%= form_for @attribute,:url => admin_seminar_path(@attribute) , :html => { :class=> "form-horizontal main-forms" } do |f| %> <%= form_for @attribute,:url => admin_seminar_path(@attribute) , :html => { :class=> "form-horizontal main-forms" } do |f| %>

View File

@ -7,7 +7,7 @@
<% content_for :page_specific_javascript do -%> <% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %> <%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
<%= javascript_include_tag "field-forms-submission.js" %> <%= javascript_include_tag "seminar-field-forms-submission.js" %>
<% end -%> <% end -%>
<%= form_for @attribute,:url => admin_seminar_path(@attribute) , :html => { :class=> "form-horizontal main-forms" } do |f| %> <%= form_for @attribute,:url => admin_seminar_path(@attribute) , :html => { :class=> "form-horizontal main-forms" } do |f| %>
<% if flash.now[:notice].present? %> <% if flash.now[:notice].present? %>