2021-02-27 04:19:24 +00:00
|
|
|
<% # encoding: utf-8 %>
|
|
|
|
<% content_for :page_specific_css do %>
|
|
|
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
|
|
|
<%= stylesheet_link_tag "lib/fileupload" %>
|
|
|
|
<%= stylesheet_link_tag "lib/main-list" %>
|
|
|
|
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
|
|
|
<style type="text/css">
|
|
|
|
.ui-helper-hidden-accessible{
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<% end %>
|
|
|
|
<% content_for :page_specific_javascript do %>
|
|
|
|
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
|
|
|
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
|
|
|
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
|
|
|
<%= javascript_include_tag "lib/file-type" %>
|
|
|
|
<%= javascript_include_tag "lib/module-area" %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<!-- Input Area -->
|
|
|
|
<div class="input-area">
|
|
|
|
|
|
|
|
<!-- Language Tabs -->
|
|
|
|
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
|
|
|
<ul class="nav nav-pills language-nav">
|
|
|
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
|
|
|
<li class="<%= 'active' if i == 0 %>">
|
|
|
|
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
|
|
|
</li>
|
|
|
|
<% end %>
|
|
|
|
<li class="pull-right">
|
|
|
|
<%= copy_to_all_language_button(".language-nav", ".language-area") %>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- Language -->
|
|
|
|
<div class="tab-content language-area">
|
|
|
|
|
|
|
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
|
|
|
|
|
|
|
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
|
|
|
|
|
|
|
<!-- personal_plugin_field title-->
|
|
|
|
<div class="control-group input-title">
|
|
|
|
<label class="control-label muted"><%= t("personal_plugin_generator.personal_plugin_name") %></label>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.fields_for :title_translations do |f| %>
|
|
|
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_plugin_generator.personal_plugin_name"), value: (@personal_plugin_field.title_translations[locale] rescue nil) %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-01 15:44:52 +00:00
|
|
|
<!-- author_translation_name -->
|
|
|
|
<div class="control-group input-title">
|
|
|
|
<label class="control-label muted"><%= t("personal_plugin_generator.author_translation_name") %></label>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.fields_for :author_name_translations do |f| %>
|
|
|
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_plugin_generator.author_translation_name"), value: (@personal_plugin_field.author_name_translations[locale] rescue nil) %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-27 04:19:24 +00:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
|
|
|
<ul class="nav nav-pills module-nav">
|
|
|
|
<li></li>
|
|
|
|
<li class="active">
|
|
|
|
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- Module -->
|
|
|
|
<div class="tab-content module-area">
|
|
|
|
|
|
|
|
<!-- Basic Module -->
|
|
|
|
<div class="tab-pane fade in active" id="basic">
|
|
|
|
<div class="control-group">
|
|
|
|
<label class="control-label muted"><%=thead_field("module_name")%></label>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.text_field :module_name, placeholder: thead_field("module_name") %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
|
|
<label class="control-label muted"><%=thead_field("primary_modal_name")%></label>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.text_field :primary_modal_name, placeholder: thead_field("primary_modal_name"), class: "primary_modal_name" %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
|
|
<label class="control-label muted"><%=thead_field("related_modal_name")%></label>
|
|
|
|
<div class="controls">
|
|
|
|
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
|
|
|
<div>
|
2022-07-27 05:52:42 +00:00
|
|
|
<%= text_field_tag "#{f.object_name}[related_modal_name][]", related_modal_name,placeholder: thead_field("related_modal_name"), class: "related_modal_name", title: thead_field("related_modal_name") %>
|
2021-02-27 04:19:24 +00:00
|
|
|
<button type="button" class="remove_related_modal" index="<%=i%>"><%=t(:remove)%></button>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<button type="button" class="btn btn-primary" id="add_related_modal"><%= t(:add) %></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Status Module -->
|
|
|
|
<div class="tab-pane fade" id="status">
|
|
|
|
<div class="control-group">
|
|
|
|
<label class="control-label muted"><%= t(:status) %></label>
|
|
|
|
<div class="controls" data-toggle="buttons-checkbox">
|
|
|
|
<label class="checkbox inline btn <%= 'active' if @personal_plugin_field.is_hidden? %>">
|
|
|
|
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-03 07:44:42 +00:00
|
|
|
<% field_types = ["text_field","text_editor","file","link","year","year_month","date","time","date_time","member"].map{|field| [thead_field(field),field]}
|
2021-03-01 15:44:52 +00:00
|
|
|
field_types1 = field_types.select{|a| a[1] != "file" && a[1] != "member"}
|
2021-02-27 04:19:24 +00:00
|
|
|
%>
|
|
|
|
<div class="tab-content language-area">
|
|
|
|
<div id="primary_modal_plane">
|
|
|
|
<h4><%=thead_field("primary_modal_name")%> : <span class="primary_modal_name"><%= f.object.primary_modal_name%></span></h4>
|
|
|
|
<% if f.object.primary_modal_fields.present? %>
|
|
|
|
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => f.object.primary_modal_fields,:field_types => field_types } %>
|
|
|
|
<% else %>
|
|
|
|
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil,nil],:field_types => field_types,:@include_blank => true} %>
|
|
|
|
<% end %>
|
|
|
|
<button type="button" onclick="add_primary_modal_field()" class="btn btn-primary"><%= thead_field('add_field') %></button>
|
|
|
|
</div>
|
|
|
|
<div id="related_modal_plane">
|
|
|
|
<% if f.object.related_modal_name.present? %>
|
|
|
|
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
|
|
|
<% field_values = f.object.related_modal_fields[i].to_a %>
|
|
|
|
<div index="<%= i %>">
|
|
|
|
<h4><%=thead_field("related_modal_name")%> : <span class="related_modal_name"><%= related_modal_name %></span></h4>
|
|
|
|
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "related_modal_fields][#{i}",:field_values => field_values,:field_types => field_types1 } %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Form Actions -->
|
|
|
|
<div class="form-actions">
|
|
|
|
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
|
|
|
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
|
|
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
|
|
|
<%= link_to t('cancel'), request.referer, :class=>"btn" %>
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
$(document).on('click', '.delete_file', function(){
|
|
|
|
$(this).parents('.input-prepend').remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click', '.remove_existing_record', function(){
|
|
|
|
if(window.confirm("<%= I18n.t(:sure?)%>")){
|
|
|
|
$(this).children('.should_destroy').attr('value', 1);
|
|
|
|
$(this).parents('.start-line').hide();
|
|
|
|
}
|
|
|
|
});
|
2022-07-27 05:52:42 +00:00
|
|
|
var related_modal_name_html = '<%= text_field_tag "#{f.object_name}[related_modal_name][]", '',placeholder: thead_field("related_modal_name"), class: "related_modal_name", title: thead_field("related_modal_name") %>';
|
2021-02-27 04:19:24 +00:00
|
|
|
related_modal_name_html = $("<div></div>").append(related_modal_name_html);
|
|
|
|
related_modal_name_html.append("<button type=\"button\" class=\"remove_related_modal\"><%=t(:remove) %></button>")
|
|
|
|
$(".remove_btn").off("click").on("click",function(){
|
|
|
|
if(window.confirm("<%=thead_field('remove_text')%>")){
|
|
|
|
$(this).parent().parent().remove();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
<%
|
|
|
|
related_modal_fields_html = "<div index=\"new_index\"><h4>#{thead_field("related_modal_name")} : <span class=\"related_modal_name\"></span></h4>"
|
2021-03-08 11:19:10 +00:00
|
|
|
related_modal_fields_html += render(:partial => 'render_table',locals: {:f => f,:root_name => "related_modal_fields][new_index",:field_values => [nil],:field_types => field_types1,:@include_blank=>false})
|
2021-02-27 04:19:24 +00:00
|
|
|
related_modal_fields_html += "</div>"
|
2021-03-08 11:19:10 +00:00
|
|
|
primary_modal_field_html = render(:partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil],:field_types => field_types,:@include_blank=>false})
|
2021-02-27 04:19:24 +00:00
|
|
|
%>
|
|
|
|
var related_modal_fields_html = "<%= escape_javascript(related_modal_fields_html.html_safe) %>";
|
|
|
|
var primary_modal_field_html = $("<%= escape_javascript(primary_modal_field_html.html_safe) %>").find("tbody tr")[0].outerHTML;
|
|
|
|
var add_related_modal_field_btn = '<button type="button" onclick="add_related_modal_field(this)" class="btn btn-primary"><%=thead_field('add_field')%></button>';
|
|
|
|
$("#add_related_modal").click(function(){
|
|
|
|
var clone_modal = related_modal_name_html.clone();
|
|
|
|
var new_index = $("#related_modal_plane > div").length;
|
|
|
|
clone_modal.find(".remove_related_modal").attr("index",new_index);
|
|
|
|
$(this).before(clone_modal);
|
|
|
|
$("#related_modal_plane").append(related_modal_fields_html.replaceAll("new_index",new_index).replaceAll("new_field_index",0));
|
|
|
|
$("#related_modal_plane >").eq(-1).append(add_related_modal_field_btn);
|
|
|
|
clone_modal.find(".remove_related_modal").click(function(){
|
|
|
|
remove_related_modal_func(this);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
$("#related_modal_plane >").append(add_related_modal_field_btn);
|
|
|
|
$(".remove_related_modal").click(function(){
|
|
|
|
remove_related_modal_func(this);
|
|
|
|
});
|
|
|
|
function remove_related_modal_func(item){
|
|
|
|
if(window.confirm("<%=thead_field('remove_text')%>")){
|
|
|
|
var index = $(item).attr("index");
|
|
|
|
$(item).parent().remove();
|
|
|
|
console.log(index);
|
|
|
|
$("#related_modal_plane > div[index=\""+index+"\"]").remove();
|
|
|
|
$("#related_modal_plane > div").each(function(i,v){
|
|
|
|
$(v).attr("index",i);
|
|
|
|
})
|
|
|
|
$(".remove_related_modal").each(function(i,v){
|
|
|
|
$(v).attr("index",i);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function add_related_modal_field(item){
|
|
|
|
var current_index = $(item).parent().attr("index");
|
|
|
|
var related_modal = $(related_modal_fields_html.replaceAll("new_field_index",$(item).parent().find("tbody tr").length));
|
|
|
|
$(item).parent().find("tbody").append(related_modal.find("tbody tr")[0].outerHTML.replaceAll("new_index",current_index));
|
|
|
|
$(".remove_btn").off("click").on("click",function(){
|
|
|
|
if(window.confirm("<%=thead_field('remove_text')%>")){
|
|
|
|
$(this).parent().parent().remove();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_primary_modal_field(){
|
|
|
|
var primary_modal = $(primary_modal_field_html.replaceAll("new_field_index",$("#primary_modal_plane tbody tr").length));
|
|
|
|
$("#primary_modal_plane tbody").append(primary_modal);
|
|
|
|
$(".remove_btn").off("click").on("click",function(){
|
|
|
|
if(window.confirm("<%=thead_field('remove_text')%>")){
|
|
|
|
$(this).parent().parent().remove();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2021-03-03 12:24:10 +00:00
|
|
|
$.ajaxSetup({async: false});
|
2021-03-03 07:44:42 +00:00
|
|
|
$(".main-forms").submit(function(){
|
2021-02-27 04:19:24 +00:00
|
|
|
if($("#primary_modal_plane .slug_title:checked").length == 0){
|
|
|
|
alert("<%=thead_field('please_choose_one_slug_title')%>");
|
|
|
|
}else if($("#primary_modal_plane .slug_title:checked").length > 1){
|
|
|
|
alert("<%=thead_field('slug_title_can_only_choose_one')%>");
|
|
|
|
}else{
|
2021-03-03 12:24:10 +00:00
|
|
|
var can_install;
|
|
|
|
$.post("<%=check_plugin_exist_admin_personal_plugin_field_path%>",{plugin_name: $("#personal_plugin_field_module_name").val(), id: "<%=f.object.id %>"}).done(function(data){
|
|
|
|
console.log(data);
|
|
|
|
if(data["can_install"]){
|
2021-03-04 06:33:01 +00:00
|
|
|
$("#personal_plugin_field_module_name").css('border', '');
|
2021-03-03 12:24:10 +00:00
|
|
|
can_install = true;
|
2021-03-04 06:33:01 +00:00
|
|
|
var modal_names = $("[name*=modal_name]").map(function(i,v){return v.value})
|
|
|
|
modal_names = Array.from(modal_names);
|
|
|
|
$.post("<%=check_modal_name_admin_personal_plugin_field_path%>",{modal_names: modal_names, id: "<%=f.object.id %>"}).done(function(data){
|
|
|
|
if(!data["success"]){
|
|
|
|
var invalid_modal_names = data["invalid_modal_names"];
|
|
|
|
console.log(invalid_modal_names)
|
|
|
|
$("[name*=modal_name]").each(function(i,v){
|
|
|
|
if(invalid_modal_names.indexOf($(v).val()) != -1){
|
|
|
|
$(v).css("border", '2px solid red');
|
|
|
|
window.location.href = "#" + $(".main-forms")[0].id;
|
|
|
|
}else{
|
|
|
|
$(v).css("border", '');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
can_install = false;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-03-03 12:24:10 +00:00
|
|
|
}else{
|
|
|
|
$("#personal_plugin_field_module_name").css('border', '2px solid red');
|
|
|
|
alert("<%=thead_field("please_change_module_name")%>");
|
|
|
|
window.location.href = "#" + $(".main-forms")[0].id;
|
|
|
|
can_install = false;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return can_install;
|
2021-02-27 04:19:24 +00:00
|
|
|
}
|
|
|
|
$('tr >:last-child').css( 'border', '2px solid red');
|
|
|
|
return false;
|
|
|
|
})
|
|
|
|
$('.slug_title').click(function(){
|
|
|
|
if($('.slug_title:checked').length == 1){
|
|
|
|
$('tr >:last-child').css( 'border','');
|
|
|
|
}
|
|
|
|
})
|
2022-07-27 05:52:42 +00:00
|
|
|
$(document).on('blur', 'input.related_modal_name', function(){
|
|
|
|
var _this = $(this);
|
|
|
|
var idx = _this.index('input.related_modal_name');
|
|
|
|
$('span.related_modal_name').eq(idx).text(_this.val());
|
|
|
|
})
|
2021-02-27 04:19:24 +00:00
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
|
|
.module-area .control-group {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
span.fade{
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
span.fade.in{
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
.remove_btn{
|
|
|
|
cursor: pointer;
|
|
|
|
color: red;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
</style>
|