forked from saurabh/personal-patent
48 lines
2.1 KiB
Plaintext
48 lines
2.1 KiB
Plaintext
|
<% if !@page.nil? %>
|
||
|
<form id="form_for_plugin_fields" action="">
|
||
|
<div class="form-inline">
|
||
|
<ul class="current-fields">
|
||
|
<% if @page.custom_array_field.blank? %>
|
||
|
<% @default_fields_to_show.each do |fs| %>
|
||
|
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= fs == "authors" ? t("users.name") : t("personal_patent.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
|
||
|
<% end %>
|
||
|
<% else %>
|
||
|
<% @page.custom_array_field.each do |fs| %>
|
||
|
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= fs == "authors" ? t("users.name") : t("personal_patent.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</ul>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-horizontal controls-row">
|
||
|
|
||
|
<div class="attr-type-wrap control-group">
|
||
|
<label class="attr control-label">Fields: </label>
|
||
|
<div class="attr controls">
|
||
|
<%= select_tag "fields_to_show_for_pp", options_for_select(@fields_to_show), prompt: "---Select something---" %>
|
||
|
</div>
|
||
|
</div>
|
||
|
<a href="#" class="add-pp-field btn btn-info">Add Field</a>
|
||
|
<input type="hidden" name="plugin_key" value="<%= @page.module %>">
|
||
|
<input type="hidden" name="plugin_page_frontend_id" value="<%= @page.id.to_s %>">
|
||
|
</div>
|
||
|
</form>
|
||
|
<script type="text/javascript">
|
||
|
$(".current-fields").sortable();
|
||
|
var select = $("select#fields_to_show_for_pp");
|
||
|
$(".add-pp-field").on("click",function(){
|
||
|
var val = select.val(),
|
||
|
text = select.find("option:selected").text(),
|
||
|
li = null;
|
||
|
if(val != ""){
|
||
|
li = '<li class="clearfix" data-attrib-key="' + val + '"><span class="field-value">' + text + '</span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>';
|
||
|
}
|
||
|
$("#modify_plugin_fields ul.current-fields").append(li);
|
||
|
})
|
||
|
$(document).on("click",".remove-field",function(){
|
||
|
$(this).parent().remove();
|
||
|
})
|
||
|
</script>
|
||
|
<% else %>
|
||
|
<h3>Page not found.</h3>
|
||
|
<% end %>
|