Fix design edit

This commit is contained in:
chris 2012-11-20 10:04:50 +08:00
parent 05081c1a5c
commit 6789d44431
4 changed files with 10 additions and 5 deletions

View File

@ -52,7 +52,7 @@ class Admin::DesignsController < OrbitBackendController
case params[:type] case params[:type]
when 'layout', 'css_default', 'css_reset' when 'layout', 'css_default', 'css_reset'
@object = @design.send(params[:type]) @object = @design.send(params[:type])
when 'image', 'javascript', 'theme' when 'javascripts', 'themes'#, 'images'
@object = @design.send(params[:type]).find(params[:object_id]) @object = @design.send(params[:type]).find(params[:object_id])
end end

View File

@ -11,7 +11,7 @@ class Design
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy has_one :css_reset, :autosave => true, :dependent => :destroy
has_many :images,as: :imgs, :autosave => true, :dependent => :destroy has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_many :pages has_many :pages
has_many :themes, as: :css, :autosave => true, :dependent => :destroy has_many :themes, as: :css, :autosave => true, :dependent => :destroy

View File

@ -7,7 +7,12 @@ class Stylesheet < DesignFile
# self.remove_file! # self.remove_file!
# self.remove_file_orig! # self.remove_file_orig!
names = {} names = {}
images = self.css.images case self._type
when 'Theme'
images = self.design.images
when 'CssDefault'
images = self.css.images
end
content.scan(/(?<=url)(.*?)(?=\))/){ content.scan(/(?<=url)(.*?)(?=\))/){
css_name = $1.gsub(' ','').gsub('(','') css_name = $1.gsub(' ','').gsub('(','')
unless names.has_key?(css_name) unless names.has_key?(css_name)

View File

@ -34,10 +34,10 @@
<div class="tab-pane" id="css_default"><%= render :partial => 'tab_form', :locals => {:type => :css_default, :object => @design.css_default} %></div> <div class="tab-pane" id="css_default"><%= render :partial => 'tab_form', :locals => {:type => :css_default, :object => @design.css_default} %></div>
<div class="tab-pane" id="css_reset"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => @design.css_reset} %></div> <div class="tab-pane" id="css_reset"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => @design.css_reset} %></div>
<% @design.themes.each do |theme| %> <% @design.themes.each do |theme| %>
<div class="tab-pane" id="<%= dom_id theme %>"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => theme} %></div> <div class="tab-pane" id="<%= dom_id theme %>"><%= render :partial => 'tab_form', :locals => {:type => :themes, :object => theme} %></div>
<% end %> <% end %>
<% @design.javascripts.each do |js| %> <% @design.javascripts.each do |js| %>
<div class="tab-pane" id="<%= dom_id js %>"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => js} %></div> <div class="tab-pane" id="<%= dom_id js %>"><%= render :partial => 'tab_form', :locals => {:type => :javascripts, :object => js} %></div>
<% end %> <% end %>
<div class="tab-pane" id="images"><%= render :partial => 'images' %></div> <div class="tab-pane" id="images"><%= render :partial => 'images' %></div>
</div> </div>