updates for universal table
This commit is contained in:
parent
8fbdcd65ac
commit
a10d4e81ac
|
@ -2,6 +2,10 @@
|
|||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "select2-v4/select2.min" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "select2-v4/select2.min" %>
|
||||
<% end %>
|
||||
<style type="text/css">
|
||||
.icons-list-2 {
|
||||
|
@ -747,14 +751,57 @@
|
|||
}
|
||||
})
|
||||
<% if defined? UniversalTable %>
|
||||
var selectedUTable = null;
|
||||
var select2Options = {
|
||||
maximumSelectionSize: 10,
|
||||
minimumResultsForSearch: Infinity,
|
||||
multiple: true,
|
||||
minimumInputLength: 2,
|
||||
placeholder: "<%= t("curation.search_entries") %>",
|
||||
ajax: {
|
||||
type: 'get',
|
||||
url: "/admin/universal_tables/get_entries",
|
||||
allowClear: true,
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
var query = {
|
||||
q: params.term
|
||||
}
|
||||
return query;
|
||||
},
|
||||
processResults: function(data, page) {
|
||||
return {
|
||||
results: data
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
templateResult: function(i) {
|
||||
return '<div>' + i.text + '</div>';
|
||||
}, // Formats results in drop down
|
||||
templateSelection: function(i) {
|
||||
console.log(i);
|
||||
return '<div>' + i.text + '</div>';
|
||||
}, //Formats result that is selected
|
||||
// dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
|
||||
escapeMarkup: function(m) {
|
||||
return m;
|
||||
} // we do not want to escape markup since we are displaying html in results
|
||||
}
|
||||
$(document).on('change', '.section_type_ut select', function(){
|
||||
var parent = $(this).parents(".curation_section");
|
||||
if($(this).val()){
|
||||
selectedUTable = $(this).val();
|
||||
parent.find(".section_type_ut_entries").show();
|
||||
select2Options.ajax.url = select2Options.ajax.url + "?uid=" + selectedUTable;
|
||||
parent.find('.section_type_ut_entries input.select2').select2(select2Options);
|
||||
}else{
|
||||
parent.find(".section_type_ut_entries").hide();
|
||||
parent.find('.section_type_ut_entries input.select2').select2('destroy');
|
||||
}
|
||||
})
|
||||
|
||||
<% end %>
|
||||
|
||||
$("#enable_sub_annc").click(function(){
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
<% if defined? UniversalTable %>
|
||||
<span class="tab-content section_type_ut" style="display:none">
|
||||
<span class="add-on"><%= t("curation.tables") %></span>
|
||||
<%= f.select :section_type, UTable.all.map { |table| [table.title, table.id.to_s] },
|
||||
<%= f.select :section_type, UTable.all.map { |table| [table.title, table.uid] },
|
||||
{ include_blank: t("curation.please_select") },
|
||||
class: 'form-control' %>
|
||||
</span>
|
||||
<span class="tab-content section_type_ut_entries" style="display:none">
|
||||
<span class="add-on"><%= t("curation.table_entries") %></span>
|
||||
<%= f.select :table_entries, [], :class => "" %>
|
||||
<%= f.text_field :table_entries, :class => "select2" %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -212,4 +212,6 @@ en:
|
|||
universal_table: Universal Table
|
||||
section_type: Section Type
|
||||
tables: Tables
|
||||
search_entries: Search Entries
|
||||
title: Title
|
||||
|
|
@ -201,4 +201,6 @@ zh_tw:
|
|||
text: Text
|
||||
universal_table: Universal Table
|
||||
section_type: Section Type
|
||||
tables: Tables
|
||||
tables: Tables
|
||||
search_entries: Search Entries
|
||||
title: Title
|
Loading…
Reference in New Issue