Merge branch 'design_team' into ldap
This commit is contained in:
commit
79f484300e
|
@ -30,7 +30,7 @@ class Admin::AssetsController < OrbitBackendController
|
|||
|
||||
def create
|
||||
@asset = Asset.new(params[:asset])
|
||||
@asset.filename = @asset.i18n_variable[I18n.locale] rescue nil
|
||||
@asset.filename = @asset.title[I18n.locale] rescue nil
|
||||
if @asset.filename && @asset.save
|
||||
respond_to do |format|
|
||||
format.js {
|
||||
|
|
|
@ -8,16 +8,38 @@ class Asset
|
|||
field :filename
|
||||
field :description
|
||||
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
has_one :description, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
|
||||
validates_presence_of :filename, :data, :asset_category_id
|
||||
validates_presence_of :title, :data, :description
|
||||
|
||||
belongs_to :asset_category
|
||||
belongs_to :assetable, polymorphic: true
|
||||
has_and_belongs_to_many :tags, :class_name => "AssetTag"
|
||||
|
||||
before_save :set_key
|
||||
|
||||
def title
|
||||
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
||||
def description
|
||||
@description ||= I18nVariable.first(:conditions => {:key => 'description', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
||||
def sorted_tags
|
||||
tags.order_by(I18n.locale, :asc)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_key
|
||||
if title.new_record?
|
||||
title.key = 'title'
|
||||
end
|
||||
if description.new_record?
|
||||
description.key = 'description'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div class="control-group">
|
||||
<label for="title" class="control-label error"><%= t 'admin.title' %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :i18n_variable, (@asset.new_record? ? @asset.build_i18n_variable : @asset.i18n_variable) do |f| %>
|
||||
<%= f.fields_for :title, (@asset.new_record? ? @asset.build_title : @asset.title) do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= content_tag :label do -%>
|
||||
<div>
|
||||
|
@ -23,20 +23,18 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group error">
|
||||
<%= f.label :category, t('admin.category'), :class => "control-label" %>
|
||||
<div class="controls">
|
||||
<%= f.select :asset_category_id, @asset_categories.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-large" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t 'admin.tags' %></label>
|
||||
<label for="description" class="control-label error"><%= t 'admin.description' %></label>
|
||||
<div class="controls">
|
||||
<% @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) %>
|
||||
<%= tag[I18n.locale] %>
|
||||
<%= f.fields_for :description, (@asset.new_record? ? @asset.build_description : @asset.description) do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= content_tag :label do -%>
|
||||
<div>
|
||||
<%= I18nVariable.from_locale(locale) %>
|
||||
<%= f.text_field locale, :class => "input-large" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue