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
MAX_DISPLAYED_CONTENTS = 4

View File

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

View File

@ -32,7 +32,7 @@ module Extensions
end
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.delete_if { |block, elements| elements.empty? }
end

View File

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

View File

@ -8,5 +8,4 @@
- fix carrierwave version to 0.5.6 (#163)
- 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)
- small bugs: #169
-
- small bugs: #169, #171, #179

View File

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