payment_settup/app/views/admin/sites/_payment_detail.html.erb

55 lines
2.7 KiB
Plaintext

<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "payment/payment" %>
<% end %>
<style type="text/css">
.other_settings_<%= key_index %>{
border: 0.1em solid #10bf97;
margin-bottom: 1em;
padding-top: 1em;
}
#add_key_<%= key_index %>{
margin: 1em;
}
</style>
<div class="other_settings_<%= key_index %>">
<% helper1 = Admin::PaymentSetup.module_eval "#{select_option.split('_').map{|v| v.capitalize}.join('')}Helper" %>
<% helper1.get_setup_form(option_id).each do |child| %>
<label><%= t("#{select_option}.#{child[0]}") %>:</label>
<% if child[1]=='text' %>
<input class="payment_setup" type="text" name="data[<%= child[0] %>]" value="<%= child[2] %>">
<% elsif child[1]=='select' %>
<%= select_tag("data[#{child[0]}]",options_for_select(child[2],:selected => child[3]),{:class => 'payment_setup'}) %>
<% elsif child[1]=='number' %>
<br>
<% Array(child[2]).each_with_index do |number,index1| %>
<div class="all_key_div">
<span class="all_key"><span><%= index1+1 %></span>.</span><input class="payment_setup all_key_input" type="number" name="data[<%= child[0] %>][]" value='<%= number %>' min="3" step="3">
<%= "<button type='button' class='delete_key'>#{t('payment_settup.delete_key')}</button>".html_safe if index1!=0 %>
<br>
</div>
<% end %>
<button type="button" id="add_key_<%= key_index %>"><%= t('payment_settup.add_key') %></button>
<% end %>
<br>
<% end %>
<%= "<input type='hidden' name='payment_type' value='#{select_option}'>".html_safe %>
<%= "<input type='hidden' name='id' value='#{option_id}'>".html_safe if !option_id.nil? %>
</div>
<script type="text/javascript">
function delete_key_<%= key_index %>(){
$('.other_settings_<%= key_index %> .all_key_div').eq($(this).index('.delete_key')+1).remove()
$('.other_settings_<%= key_index %> .all_key').children('span').each(function(){
$(this).text($(this).parent().index('.all_key')+1)
})
}
$('.other_settings_<%= key_index %>').ready(
function(){
$('#add_key_<%= key_index %>').click(function(){
$('.other_settings_<%= key_index %> .all_key_div').eq(-1).after('<div class="all_key_div"><span class="all_key"><span>'+($('.other_settings_<%= key_index %> input.all_key_input').length+1)+'</span>.</span><input class="payment_setup all_key_input" type="number" name="'+$('input.all_key_input').attr('name')+'" min="3" step="3"> <button type="button" class="delete_key"><%= t('payment_settup.delete_key') %></button><br></div>')
$('.other_settings_<%= key_index %> .delete_key').off('click').on('click',delete_key_<%= key_index %>)
})
$('.other_settings_<%= key_index %> .delete_key').click(delete_key_<%= key_index %>)
}
)
</script>