This commit is contained in:
did 2011-08-25 18:27:43 +02:00
parent c990a89e57
commit 71a592eec1
6 changed files with 19 additions and 16 deletions

View File

@ -1,5 +1,3 @@
require 'ruby-debug'
module Admin::ContentTypesHelper module Admin::ContentTypesHelper
MAX_DISPLAYED_CONTENTS = 4 MAX_DISPLAYED_CONTENTS = 4

View File

@ -8,8 +8,9 @@ class EditableElement
field :default_content field :default_content
field :default_attribute field :default_attribute
field :hint field :hint
field :disabled, :type => Boolean, :default => false field :priority, :type => Integer, :default => 0
field :assignable, :type => Boolean, :default => true field :disabled, :type => Boolean, :default => false
field :assignable, :type => Boolean, :default => true
field :from_parent, :type => Boolean, :default => false field :from_parent, :type => Boolean, :default => false
## associations ## ## associations ##
@ -18,6 +19,9 @@ class EditableElement
## validations ## ## validations ##
validates_presence_of :slug validates_presence_of :slug
## scopes ##
scope :by_priority, :order_by => [[:priority, :desc]]
## methods ## ## methods ##
end end

View File

@ -32,7 +32,7 @@ module Extensions
end end
def editable_elements_grouped_by_blocks def editable_elements_grouped_by_blocks
all_enabled = self.editable_elements.reject { |el| el.disabled? } all_enabled = self.editable_elements.by_priority.reject { |el| el.disabled? }
groups = all_enabled.group_by(&:block) groups = all_enabled.group_by(&:block)
groups.delete_if { |block, elements| elements.empty? } groups.delete_if { |block, elements| elements.empty? }
end end

View File

@ -15,7 +15,7 @@
%li{ :id => "block-#{index}", :class => 'block', :style => "display: #{index == 0 ? 'block' : 'none' }" } %li{ :id => "block-#{index}", :class => 'block', :style => "display: #{index == 0 ? 'block' : 'none' }" }
%fieldset.inputs %fieldset.inputs
%ol %ol
- elements.each_with_index do |el, index| - elements.each do |el|
= f.fields_for 'editable_elements', el, :child_index => el._index do |g| = f.fields_for 'editable_elements', el, :child_index => el._index do |g|
- case el - case el
- when EditableLongText - when EditableLongText

View File

@ -8,5 +8,4 @@
- fix carrierwave version to 0.5.6 (#163) - fix carrierwave version to 0.5.6 (#163)
- has_many target is not exported correctly (issue #165) + fix the import module as well - has_many target is not exported correctly (issue #165) + fix the import module as well
- XSS vulnerability when adding new content from the api_contents_controller (#170) - XSS vulnerability when adding new content from the api_contents_controller (#170)
- small bugs: #169 - small bugs: #169, #171, #179
-

View File

@ -23,14 +23,16 @@ module Locomotive
if @context[:page].present? if @context[:page].present?
@context[:page].add_or_update_editable_element({ @context[:page].add_or_update_editable_element({
:block => @context[:current_block].try(:name), :block => @context[:current_block].try(:name),
:slug => @slug, :slug => @slug,
:hint => @options[:hint], :hint => @options[:hint],
:default_attribute => @options[:default], :priority => @options[:priority] || 0,
:default_content => default_content_option, :default_attribute => @options[:default],
:assignable => @options[:assignable], :default_content => default_content_option,
:disabled => false, :assignable => @options[:assignable],
:from_parent => false :disabled => false,
:from_parent => false,
:_type => self.document_type.to_s
}, document_type) }, document_type)
end end
end end