editable_components 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 200fed582fb17cac432de9f0bf4f2b96b9d85942
4
- data.tar.gz: e580721dca4b54a3356eb7db8a5699c9b1d9668a
3
+ metadata.gz: 6b15a62ff9a33be2bad80e25169d394b663e7138
4
+ data.tar.gz: 2a77d6740bb6905de42be4f006ad1e8eeab059ee
5
5
  SHA512:
6
- metadata.gz: 230366bebdb5551b1fb1b6af0f43505b15c07b771b4bf8838689fea4f4efec5de16c906a200b5f52131322914df37e5a19dec8ece64a2e0f11d2494bad3c7465
7
- data.tar.gz: b1eeb2f5fa58c2b9c86b6e0c2a460fc642c31d7659600da38825f3d24f146d1763328044185a08e808781908d9c4156644f682f30c42b162f5a1d3d983ea23a5
6
+ metadata.gz: 65372a7bae39505a4461c5e556028f87bcee1b332605851829c06a8fcd580f62911b30cefaf12ba82f37243ce17b879ae5ea2fdb0e953b2c9b4a7d3e087280cd
7
+ data.tar.gz: 71891bd54edbcde732ee9b35587b7eb220f002c7e47c085b99677b0dff6aeb163bc926a19c60c983d87165ac21293b5c265148ad3abcb4de700e99b965e9b31d
data/README.md CHANGED
@@ -83,6 +83,10 @@ Create the new view blocks: `app/views/editable_components/_block_custom.html.er
83
83
 
84
84
  To add support for images add CarrierWave gem to your Gemfile and execute: `rails generate uploader File`
85
85
 
86
+ ##### Custom blocks
87
+
88
+ To create a "free form" block just use: `Page.first.create_block :intro, name: 'IntroBlock', schema: { intro: :item_string, subtitle: :item_string }`
89
+
86
90
  ### Notes
87
91
 
88
92
  - This is not a complete replacement for an admin interface but it could improve the usability of a CMS software or content editor
@@ -8,8 +8,8 @@ module EditableComponents
8
8
 
9
9
  # --- relations ---------------------------------------------------------- #
10
10
  belongs_to :parent, polymorphic: true
11
- has_many :ec_blocks, as: :parent, foreign_key: 'parent_id', class_name: 'Block'
12
- has_many :items
11
+ has_many :ec_blocks, as: :parent, dependent: :destroy, foreign_key: 'parent_id', class_name: 'Block'
12
+ has_many :items, dependent: :destroy
13
13
  accepts_nested_attributes_for :ec_blocks, allow_destroy: true
14
14
  accepts_nested_attributes_for :items
15
15
 
@@ -5,14 +5,16 @@ module EditableComponents
5
5
 
6
6
  included do
7
7
  # embeds_many :ec_blocks, as: :parent, cascade_callbacks: true, order: :position.desc, class_name: 'EditableComponents::Block'
8
- has_many :ec_blocks, as: :parent, foreign_key: 'parent_id', class_name: Block.to_s
8
+ has_many :ec_blocks, as: :parent, dependent: :destroy, foreign_key: 'parent_id', class_name: Block.to_s
9
9
  accepts_nested_attributes_for :ec_blocks, allow_destroy: true
10
10
 
11
11
  def create_block( type = :text, params = {} )
12
12
  block = Block.new( block_type: type )
13
+ block.name = params[:name] if params[:name]
13
14
  block.options = params[:options] if params[:options]
14
15
  block.validations = params[:validations] if params[:validations]
15
16
  ec_blocks << block
17
+ Block::init_items block, params[:schema] if params[:schema]
16
18
  block
17
19
  end
18
20
 
@@ -1,3 +1,3 @@
1
1
  module EditableComponents
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: editable_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails