binda 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ed52b6a7c00c6370108c689ba3396a79f5e85b8
4
- data.tar.gz: 72aaf34b07c36b78c832fe061c4beb35be278a9b
3
+ metadata.gz: 0a0ed652cd145d7bd16c1e6488c5fdd9a3177018
4
+ data.tar.gz: ae29ad9b71bd43ba1a40eeb67b69ab9c919fe847
5
5
  SHA512:
6
- metadata.gz: c2649f0eeeaa9265c349a303e981d44f459dad81d871cb730a8a5094224ab8212425659f31f80d56212d471cba466657d89fd361a6c793b30d44bc49f7a90e1e
7
- data.tar.gz: 63e9fd484c883eac80fd00d3c8b5bff90222418df2290d55bc6bccec1a564371307441ae06827183b327a0f1eb85973a9e3132a62996f93f921afdf7233c8ab0
6
+ metadata.gz: 00f4c1845cfeb066332494f6213d92abccdc41f5d6f8be0a7d2901b9b06f7d47a3a61a1ef324a08665db8d0f998f71bca1868a149ed3e33bbca002e72bb2285f
7
+ data.tar.gz: 738f6490b90e4efd030938c372f70ba1fb8e65150571e02204a11e3221a1b051c07ad18785cd80bedbc72074953221461a7f081a716f2c2eb2d1aa2b690a5975
data/README.md CHANGED
@@ -10,7 +10,7 @@ A modular CMS for Ruby on Rails 5.
10
10
  Add this line to your application's Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'binda', '~> 0.0.5'
13
+ gem 'binda', '~> 0.0.6'
14
14
  ```
15
15
 
16
16
  Then execute:
@@ -82,16 +82,58 @@ module Binda
82
82
  # Only allow a trusted parameter "white list" through.
83
83
  def field_group_params
84
84
  params.require(:field_group).permit(
85
- :name, :slug, :description, :position, :layout, :structure_id,
86
- field_settings_attributes: [ :id, :field_group_id, :field_setting_id, :name, :slug, :description, :field_type, :position, :required, :default_text, :ancestry, choices: [], :default_choice_id_id, :allow_null,
87
- choices_attributes: [ :field_setting_id, :label, :value ]
88
- ])
85
+ :name,
86
+ :slug,
87
+ :description,
88
+ :position,
89
+ :layout,
90
+ :structure_id,
91
+ field_settings_attributes:
92
+ [ :id,
93
+ :field_group_id,
94
+ :field_setting_id,
95
+ :name,
96
+ :slug,
97
+ :description,
98
+ :field_type,
99
+ :position,
100
+ :required,
101
+ :default_text,
102
+ :ancestry,
103
+ :default_choice_id_id,
104
+ :allow_null,
105
+ choices: [],
106
+ choices_attributes:
107
+ [ :field_setting_id,
108
+ :label,
109
+ :value
110
+ ]
111
+ ]
112
+ )
89
113
  end
90
114
 
91
115
  def new_params
92
116
  params.require(:field_group).permit(
93
- new_field_settings:[ :field_group_id, :field_setting_id, :name, :slug, :description, :field_type, :position, :required, :ancestry, choices: [], :default_choice_id, :allow_null ],
94
- new_choices: [ :field_setting_id, :label, :value ])
117
+ new_field_settings:
118
+ [ :field_group_id,
119
+ :field_setting_id,
120
+ :name,
121
+ :slug,
122
+ :description,
123
+ :field_type,
124
+ :position,
125
+ :required,
126
+ :ancestry,
127
+ :default_choice_id,
128
+ :allow_null,
129
+ choices: []
130
+ ],
131
+ new_choices:
132
+ [ :field_setting_id,
133
+ :label,
134
+ :value
135
+ ]
136
+ )
95
137
  end
96
138
 
97
139
  def reset_field_settings_cache
@@ -24,9 +24,9 @@ module Binda
24
24
 
25
25
  if @structure.save
26
26
  # Creates a default empty field group
27
- @fiedl_group = @structure.field_groups.build( name: 'General Details' )
27
+ @field_group = @structure.field_groups.build( name: 'General Details', position: 1 )
28
28
  # Unless there is a problem...
29
- unless @fiedl_group.save
29
+ unless @field_group.save
30
30
  return redirect_to structure_path( @structure.slug ), flash: { error: 'General Details group hasn\'t been created' }
31
31
  end
32
32
  # ... redirect to the new structure path
@@ -17,6 +17,7 @@ module Binda
17
17
  extend FriendlyId
18
18
  friendly_id :default_slug, use: [:slugged, :finders]
19
19
 
20
+ after_create :update_position
20
21
 
21
22
  # CUSTOM METHODS
22
23
  # --------------
@@ -36,5 +37,13 @@ module Binda
36
37
  attributes['name'].blank? && attributes['field_type'].blank?
37
38
  end
38
39
 
40
+ private
41
+
42
+ def update_position
43
+ if self.position.nil?
44
+ self.update_attribute( 'position', self.structure.field_groups.length )
45
+ end
46
+ end
47
+
39
48
  end
40
49
  end
@@ -17,11 +17,11 @@
17
17
  </tr>
18
18
  </thead>
19
19
 
20
- <tbody class="sortable" data-update-url="<%= structure_field_groups_sort_path() %>">
20
+ <tbody class="sortable" data-update-url="<%= structure_field_groups_sort_path %>">
21
21
  <% @field_groups.order( :position, :name ).each do |field_group| %>
22
22
  <tr id="field_group_<%= field_group.id %>">
23
23
  <td colspan="3"><%= field_group.name %></td>
24
- <td><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> <%= link_to 'Edit', edit_structure_field_group_path( @structure.slug, field_group ) %> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <%= link_to 'Destroy', structure_field_group, method: :delete, data: { confirm: 'This operation will delete this group and all related field settings and component content. Are you ok with that?' }, class: 'text-danger' %></td>
24
+ <td><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> <%= link_to 'Edit', edit_structure_field_group_path( structure_id: @structure.slug, field_group.slug ) %> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <%= link_to 'Destroy', structure_field_group_path, method: :delete, data: { confirm: 'This operation will delete this group and all related field settings and component content. Are you ok with that?' }, class: 'text-danger' %></td>
25
25
  </tr>
26
26
  <% end %>
27
27
  <tbody>
@@ -4,7 +4,7 @@
4
4
  <%# - - - - - - - - - - - - %>
5
5
  <%# FORM ITEM %>
6
6
  <%# - - - - - - - - - - - - %>
7
- <%= f.simple_fields_for :field_groups do |ff| %>
7
+ <%= f.simple_fields_for :field_groups, f.object.field_groups.order( :position ) do |ff| %>
8
8
 
9
9
  <div class="form-item">
10
10
 
data/lib/binda/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Binda
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Barbieri
@@ -432,10 +432,10 @@ dependencies:
432
432
  - - "~>"
433
433
  - !ruby/object:Gem::Version
434
434
  version: '0.9'
435
- description: "A modular CMS for Ruby on Rails 5 with an intuitive out-of-the-box interface
436
- to manage and customize components. \n Use Binda if you want to speed up your setup
437
- process and concentrate directly on what your application is about. \n Please read
438
- the documentation for more information and a quick"
435
+ description: A modular CMS for Ruby on Rails 5 with an intuitive out-of-the-box interface
436
+ to manage and customize components. Use Binda if you want to speed up your setup
437
+ process and concentrate directly on what your application is about. Please read
438
+ the documentation for more information and a quick start guide.
439
439
  email:
440
440
  - alessandro@lacolonia.studio
441
441
  executables: []