diff --git a/app/assets/javascripts/design_temp.js b/app/assets/javascripts/design_temp.js index 812c2a18..8cbc9470 100644 --- a/app/assets/javascripts/design_temp.js +++ b/app/assets/javascripts/design_temp.js @@ -17,7 +17,7 @@ $('input.multi_files').change(function(){ }); $('a.remove_mark').live("click",function(){ - $(this).prev("input").value("true"); + $(this).prev("input").val("true"); $(this).parent().css("text-decoration","line-through") $(this).remove(); return false; diff --git a/app/controllers/admin/.designs_controller.rb.swp b/app/controllers/admin/.designs_controller.rb.swp new file mode 100644 index 00000000..2336817e Binary files /dev/null and b/app/controllers/admin/.designs_controller.rb.swp differ diff --git a/app/models/design.rb b/app/models/design.rb index b9e664bd..bd391b15 100644 --- a/app/models/design.rb +++ b/app/models/design.rb @@ -17,6 +17,7 @@ class Design embeds_many :javascripts embeds_many :images + before_save :cleanup_empty_fields after_save :procs_embedded_objects def javascripts=(*attrs) @@ -40,10 +41,14 @@ class Design end protected - + def cleanup_empty_fields + end def procs_embedded_objects [self.stylesheets, self.javascripts, self.images].each do |objects| objects.each do |object| + if object.file.blank? + object.to_save = false + end if object.to_save object.to_save = false object.save diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index 610ba099..fb8a08ec 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -1,16 +1,24 @@ +<% item_destroy ||= false %> +<% item_snapshot ||= false %> +<% li_class = ''%> + <% fieldname_p = fieldname.pluralize %> <%= f.label "fieldname", t('admin.'+fieldname) %>
-<%= render :partial => 'design_file' ,:locals => { :fieldname=>"stylesheet",:object=>@design ,:f=>f,:rtype=>'stylesheets' } %> +<%= render :partial => 'design_file' ,:locals => { :fieldname=>"stylesheet",:object=>@design ,:f=>f,:rtype=>'stylesheets',:item_destroy=>true } %>
-<%= render :partial => 'design_file' ,:locals => { :fieldname=>"javascript",:object=>@design ,:f=>f,:rtype=>'javascripts' } %> +<%= render :partial => 'design_file' ,:locals => { :fieldname=>"javascript",:object=>@design ,:f=>f,:rtype=>'javascripts' ,:item_destroy=>true } %>
-<%= render :partial => 'design_file' ,:locals => { :fieldname=>"image",:object=>@design ,:f=>f,:rtype=>'' } %> +<%= render :partial => 'design_file' ,:locals => { :fieldname=>"image",:object=>@design ,:f=>f,:rtype=>'',:item_snapshot=>true ,:item_destroy=>true } %>