editing for the assets are done with replacable files and description
This commit is contained in:
parent
f920a4f6ba
commit
9e10a3c944
|
@ -32,12 +32,8 @@ class Admin::AssetsController < OrbitBackendController
|
|||
|
||||
def edit
|
||||
@asset = Asset.find(params[:id])
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = get_tags
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/edit'} }
|
||||
end
|
||||
render layout: false
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -74,10 +70,7 @@ class Admin::AssetsController < OrbitBackendController
|
|||
def update
|
||||
@asset = Asset.find(params[:id])
|
||||
if @asset.update_attributes(params[:asset])
|
||||
respond_to do |format|
|
||||
format.html { redirect_to admin_assets_url }
|
||||
format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} }
|
||||
end
|
||||
render layout: false
|
||||
else
|
||||
flash[:error] = t('update.fail')
|
||||
@asset_categories = AssetCategory.all
|
||||
|
|
|
@ -30,6 +30,6 @@
|
|||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="editform">Edit</a>
|
||||
<a href="<%= edit_admin_asset_path(asset) %>" class="editform">Edit</a>
|
||||
</td>
|
||||
</tr>
|
|
@ -1,18 +1,15 @@
|
|||
<div id='pop_up_content' class="main2">
|
||||
<h1><%= t('editing.asset') %></h1>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<%= form_for @asset, :url => admin_asset_path(@asset), :html => {:id => (is_html ? nil : 'ajaxForm'), :multipart => true } do |f| %>
|
||||
<%= flash_messages %>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3><%= t('editing.asset') %></h3>
|
||||
</div>
|
||||
<%= form_for @asset, :url => admin_asset_path(@asset), :remote => true do |f| %>
|
||||
<div class="modal-body" id="modal_body">
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<div class="button_bar">
|
||||
<% if is_html %>
|
||||
<%= link_back %>
|
||||
<%= f.submit t(:edit) %>
|
||||
<% else %>
|
||||
<a id='ajax_form_submit' class="btn btn-primary"><%= t(:update_) %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">Close</a>
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,38 +1,46 @@
|
|||
<div class="control-group">
|
||||
<label for="title" class="control-label"><%= t :title %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= content_tag :label do -%>
|
||||
<div>
|
||||
<%= I18nVariable.from_locale(locale) %>
|
||||
<%= f.text_field locale, :class => "input-large", :value => (@asset.title_translations[locale] rescue nil) %>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
<div class="control-group input-title">
|
||||
<%= f.label :title , t('asset.title'), :class=>"control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class=>'post-title', :value => (@asset.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group input-content">
|
||||
<%= f.label :description ,t('asset.description'), :class => "control-label muted" %>
|
||||
<%= f.fields_for :description_translations do |f| %>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= f.text_area locale, :style=>"width:100%;height:100px", :class => '', :value => (@asset.description_translations[locale] rescue nil) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= f.label :category, t(:category) %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :asset_category_id, @asset_categories.collect{|t| [ t.title, t.id ]}, {}, :class => "input-large" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t :tags %></label>
|
||||
<div class="controls">
|
||||
<label class="control-label muted">Tag</label>
|
||||
<div class="controls" data-toggle="buttons-checkbox">
|
||||
<% @tags.each do |tag| %>
|
||||
<%= content_tag :label, :class => "checkbox inline" do -%>
|
||||
<%= check_box_tag 'asset[tag_ids][]', tag.id, @asset.tag_ids.include?(tag.id) %>
|
||||
<label class="checkbox inline btn <%= 'active' if @asset.tag_ids.include?(tag.id) %>">
|
||||
<%= check_box_tag 'asset[tag_ids][]', tag.id, @asset.tag_ids.include?(tag.id)%>
|
||||
<%= tag.name %>
|
||||
<%= hidden_field_tag 'asset[tag_ids][]', '' %>
|
||||
<% end %>
|
||||
</label>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= f.label :data, t(:data) %></label>
|
||||
<label class="control-label muted"><%= f.label :data, t(:data) %></label>
|
||||
<div class="controls">
|
||||
<%= f.file_field :data, :class => 'upload' %>
|
||||
</div>
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<% if !request.xhr? %>
|
||||
<textarea>
|
||||
<% end %>
|
||||
var returnurl = "<%= @asset.data.url %>";
|
||||
var returntitle = "<%= show_all_fields(@asset, 'title') %>";
|
||||
var returndescription = "<%= show_all_fields(@asset, 'description') %>";
|
||||
var win = tinyMCEPopup.getWindowArg("window");
|
||||
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl;
|
||||
if(win.document.getElementById(tinyMCEPopup.getWindowArg("alt")))
|
||||
win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription;
|
||||
|
||||
win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle;
|
||||
if (typeof(win.ImageDialog) != "undefined") {
|
||||
// we are, so update image dimensions...
|
||||
if (win.ImageDialog.getImageData)
|
||||
win.ImageDialog.getImageData();
|
||||
|
||||
// ... and preview if necessary
|
||||
if (win.ImageDialog.showPreviewImage)
|
||||
win.ImageDialog.showPreviewImage(returnurl);
|
||||
}
|
||||
tinyMCEPopup.close();
|
||||
<% if !request.xhr? %>
|
||||
</textarea>
|
||||
<% end %>
|
|
@ -1,9 +1 @@
|
|||
<% content_for :secondary do %>
|
||||
<div class="assets_setup">
|
||||
<ul class="list">
|
||||
<li><%= link_to t('new.asset'), new_admin_asset_path, :remote => true, :class => 'button positive' %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<%= render :partial => 'edit', :locals => {:is_html => true} %>
|
|
@ -302,17 +302,9 @@
|
|||
</form>
|
||||
</div>
|
||||
<div id="editform" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Modal header</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>One fine body…</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">Close</a>
|
||||
<a href="#" class="btn btn-primary">Save changes</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
|
@ -402,8 +394,18 @@ $(document).ready(function(){
|
|||
deleteBtn.hide();
|
||||
})
|
||||
})
|
||||
var currentEdit = null;
|
||||
$(document).on("ajax:success","form[data-remote=true]",function(evt, data, xhr){
|
||||
currentEdit.replaceWith($(data));
|
||||
$("#editform").modal("hide");
|
||||
})
|
||||
|
||||
$("#asset_sort_list").on(clickEvent,".editform",function(){
|
||||
$("#editform").modal("show");
|
||||
currentEdit = $(this).parent().parent();
|
||||
$.get($(this).attr("href"),function(data){
|
||||
$("#editform").html(data).modal("show");
|
||||
})
|
||||
return false;
|
||||
})
|
||||
|
||||
function getUrlParam( paramName ) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<%= render :partial => 'asset', :object => @asset %>
|
Loading…
Reference in New Issue