98 lines
3.4 KiB
Plaintext
98 lines
3.4 KiB
Plaintext
|
<% content_for :page_specific_css do %>
|
||
|
<%= stylesheet_link_tag "universal_table/universal-table" %>
|
||
|
<% end %>
|
||
|
|
||
|
<fieldset class="utable-heading-wrap">
|
||
|
<div class="utable-heading-header">
|
||
|
<h4>Table name</h4>
|
||
|
</div>
|
||
|
<div class="control-group">
|
||
|
<div class="controls">
|
||
|
<div class="input-append">
|
||
|
<div class="tab-content">
|
||
|
<% @site_in_use_locales.each do |locale| %>
|
||
|
<% active = (locale == @site_in_use_locales.first ? "active in" : "") %>
|
||
|
<div class="tab-pane fade <%= active %>" id="table_name_<%= locale.to_s %>">
|
||
|
<%= f.fields_for :title_translations do |f| %>
|
||
|
<%= f.text_field locale, :placeholder => "Title", :value => @table.title_translations[locale] %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
|
||
|
<div class="btn-group" data-toggle="buttons-radio">
|
||
|
<% @site_in_use_locales.each do |locale| %>
|
||
|
<% active = (locale == @site_in_use_locales.first ? "active" : "") %>
|
||
|
<%= link_to t(locale).to_s,"#table_name_#{locale.to_s}",:class=>"btn #{active}",:data=>{:toggle=>"tab"}%>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</fieldset>
|
||
|
|
||
|
<fieldset class="utable-content">
|
||
|
<div id="attributes-area" class="input-area">
|
||
|
<% @table.table_columns.asc(:order).each_with_index do |table_column, index| %>
|
||
|
<div class="attributes default ">
|
||
|
<%= f.fields_for :table_columns, table_column, :child_index => index.to_s do |f| %>
|
||
|
<%= render :partial => "column", :object => table_column, :locals => {:f => f, :i => index} %>
|
||
|
<%= f.hidden_field :id %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<div class="form-actions">
|
||
|
<button type="button" class="btn btn-success add-attributes">Add Column</button>
|
||
|
<input class="btn btn-primary" name="commit" type="submit" value="Save">
|
||
|
</div>
|
||
|
</fieldset>
|
||
|
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
var columnArea = $("#attributes-area"),
|
||
|
totalColumns = columnArea.find(".attributes.default").length,
|
||
|
columnCounter = totalColumns;
|
||
|
$("button.add-attributes").on("click",function(){
|
||
|
var html = "<%= escape_javascript(add_attribute 'column', f, :table_columns) %>",
|
||
|
replaceReg = new RegExp("new_table_columns","g"),
|
||
|
idNumber = new RegExp("XXX","g");
|
||
|
html = html.replace(replaceReg,columnCounter);
|
||
|
html = html.replace("ColumnXX", "Column " + (columnCounter + 1));
|
||
|
html = html.replace(idNumber,columnCounter);
|
||
|
columnArea.append(html);
|
||
|
columnCounter++;
|
||
|
})
|
||
|
|
||
|
$(document.body).on("click","a.delete",function(){
|
||
|
if($(this).parent().find(".attribute_field_to_delete").length == 0){
|
||
|
$(this).parent().parent().slideUp(function(){
|
||
|
$(this).remove();
|
||
|
});
|
||
|
}else{
|
||
|
if(confirm("Are you sure?")){
|
||
|
$(this).parent().parent().slideUp();
|
||
|
$(this).parent().find(".attribute_field_to_delete").val("true");
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
})
|
||
|
|
||
|
$(document.body).on("change","select.type-selector",function(){
|
||
|
var el = $(this),
|
||
|
label = el.parent().find("label");
|
||
|
if(el.val() == "text"){
|
||
|
label.removeClass("hide");
|
||
|
}else{
|
||
|
label.addClass("hide");
|
||
|
label.find("input[type=checkbox]").prop("checked",false);
|
||
|
}
|
||
|
})
|
||
|
|
||
|
</script>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|