Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #83 from a-barbieri/master
Browse files Browse the repository at this point in the history
0.0.8.pre.alpha.4
  • Loading branch information
a-barbieri authored Sep 12, 2017
2 parents db04e92 + 6b8d70a commit 3886352
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--color
--require spec_helper
--format documentation
104 changes: 50 additions & 54 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
binda (0.0.8.pre.alpha.3)
binda (0.0.8.pre.alpha.4)
aasm (>= 4.11, < 4.13)
ancestry (>= 2.1, < 3.1)
carrierwave (>= 0.10, < 1.12)
Expand All @@ -23,49 +23,48 @@ GEM
specs:
aasm (4.12.2)
concurrent-ruby (~> 1.0)
actioncable (5.1.3)
actionpack (= 5.1.3)
actioncable (5.1.4)
actionpack (= 5.1.4)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.3)
actionpack (= 5.1.3)
actionview (= 5.1.3)
activejob (= 5.1.3)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.3)
actionview (= 5.1.3)
activesupport (= 5.1.3)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (~> 0.6.3)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.3)
activesupport (= 5.1.3)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.3)
activesupport (= 5.1.3)
activejob (5.1.4)
activesupport (= 5.1.4)
globalid (>= 0.3.6)
activemodel (5.1.3)
activesupport (= 5.1.3)
activerecord (5.1.3)
activemodel (= 5.1.3)
activesupport (= 5.1.3)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
arel (~> 8.0)
activesupport (5.1.3)
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
addressable (2.4.0)
ancestry (3.0.1)
activerecord (>= 3.2.0)
arel (8.0.0)
autoprefixer-rails (7.1.2.4)
autoprefixer-rails (7.1.4)
execjs
backports (3.8.0)
bcrypt (3.1.11)
Expand All @@ -86,7 +85,7 @@ GEM
mime-types (>= 1.16)
childprocess (0.7.1)
ffi (~> 1.0, >= 1.0.11)
coderay (1.1.1)
coderay (1.1.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
Expand All @@ -95,7 +94,6 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
database_cleaner (1.6.1)
devise (4.3.0)
bcrypt (~> 3.0)
Expand All @@ -120,12 +118,12 @@ GEM
ffi (1.9.18)
friendly_id (5.2.1)
activerecord (>= 4.0.0)
gh (0.14.0)
addressable
gh (0.15.1)
addressable (~> 2.4.0)
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-persistent (~> 2.9)
net-http-pipeline
github-markup (1.6.1)
globalid (0.4.0)
Expand Down Expand Up @@ -166,61 +164,59 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.7.2)
mini_mime (0.1.3)
mini_mime (0.1.4)
mini_portile2 (2.2.0)
minitest (5.10.3)
minitest-rails (3.0.0)
minitest (~> 5.8)
railties (~> 5.0)
multi_json (1.12.1)
multi_json (1.12.2)
multipart-post (2.0.0)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
orm_adapter (0.5.0)
pg (0.21.0)
power_assert (0.2.6)
power_assert (1.1.0)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (2.0.5)
pusher-client (0.6.2)
json
websocket (~> 1.0)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.1.3)
actioncable (= 5.1.3)
actionmailer (= 5.1.3)
actionpack (= 5.1.3)
actionview (= 5.1.3)
activejob (= 5.1.3)
activemodel (= 5.1.3)
activerecord (= 5.1.3)
activesupport (= 5.1.3)
rack-test (0.7.0)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
bundler (>= 1.3.0)
railties (= 5.1.3)
railties (= 5.1.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-perftest (0.0.7)
railties (5.1.3)
actionpack (= 5.1.3)
activesupport (= 5.1.3)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (12.1.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand Down Expand Up @@ -259,7 +255,7 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.5.1)
selenium-webdriver (3.5.2)
childprocess (~> 0.5)
rubyzip (~> 1.0)
simple_form (3.5.0)
Expand All @@ -273,9 +269,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
test-unit (3.1.5)
test-unit (3.2.5)
power_assert
thor (0.19.4)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
tinymce-rails (4.6.6)
Expand Down
42 changes: 0 additions & 42 deletions app/controllers/concerns/binda/default_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,48 +151,6 @@ def get_board( slug, args = { fields: [] })
end
end

# This method retrieves a **repeater**.
# With this method you can optimize the query in order to avoid the infamous
# [N+1 issue](https://youtu.be/oJ4Ur5XPAF8) by specifing what field types
# you are going to request in the view. The list of field types available
# can be found in the [official documentation](https://github.com/lacolonia/binda/wiki/Fields).
# Field types must be listed as separated strings, lowercase and plural.
# See the following examples.
#
# @example Get a repeater with slug `slideshow`
# get_repeater('slideshow')
# # return the repeater
#
# get_repeater('slideshow', { fields: ['strings', 'assets'] })
# # return the repeater and optimize the query for any of the listed fields related to it
#
#
# @param slug [string] The slug of the repeater
# @param args [hash] A hash containing the options used to customize the query.
#
# The hash parameters are:
#
# - `fields` (array) - Include related field classes to the query. The list of field types available
# can be found in the [official documentation](https://github.com/lacolonia/binda/wiki/Fields).
# Field types must be listed as separated strings, lowercase and plural.
#
# @return [ActiveRecord Object]
def get_repeater( slug, args = { fields: [] })

validate_provided_arguments( args )

# Sets defaults
args[:fields] = [] if args[:fields].nil?

validate_provided_fields( args )

if args[:fields].any?
Repeater.where(slug: slug).first.inlcudes( args[:fields] )
else
Repeater.where(slug: slug).first
end
end

private

# Check if provided `fields` are ok, otherwise raise an error
Expand Down
16 changes: 8 additions & 8 deletions app/models/binda/field_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class FieldSetting < ApplicationRecord
has_many :dates, as: :fieldable
has_many :galleries, as: :fieldable
has_many :assets, as: :fieldable
has_many :repeater, as: :fieldable
has_many :radio, as: :fieldable
has_many :selection, as: :fieldable
has_many :checkbox, as: :fieldable
has_many :repeaters, as: :fieldable
has_many :radios, as: :fieldable
has_many :selections, as: :fieldable
has_many :checkboxes, as: :fieldable


# The following direct association is used to securely delete associated fields
Expand All @@ -28,10 +28,10 @@ class FieldSetting < ApplicationRecord
has_many :strings, dependent: :delete_all
has_many :dates, dependent: :delete_all
has_many :galleries, dependent: :delete_all
has_many :repeater, dependent: :delete_all
has_many :radio, dependent: :delete_all
has_many :selection, dependent: :delete_all
has_many :checkbox, dependent: :delete_all
has_many :repeaters, dependent: :delete_all
has_many :radios, dependent: :delete_all
has_many :selections, dependent: :delete_all
has_many :checkboxes, dependent: :delete_all

has_many :choices, dependent: :delete_all
has_one :default_choice, -> (field_setting) { where(id: field_setting.default_choice_id) }, class_name: 'Binda::Choice'
Expand Down
2 changes: 1 addition & 1 deletion app/views/binda/fieldable/_form_section_repeater.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<%# - - - - - - - - - - - - %>
<%# SELECTABLES %>
<%# - - - - - - - - - - - - %>
<% elsif ['radio', 'select', 'checkbox'].include? repeater_setting_child.field_type %>
<% elsif ['radio', 'selection', 'checkbox'].include? repeater_setting_child.field_type %>
<%# current = f.object.find_or_create_a_field_by( repeater_setting_child.id, 'radio' ) %>
<%= render 'binda/fieldable/form_item_selections', f: f, field_setting: repeater_setting_child %>
Expand Down
Binary file removed binda-0.0.8.pre.alpha.3.gem
Binary file not shown.
Binary file added binda-0.0.8.pre.alpha.4.gem
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/binda/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Binda
VERSION = '0.0.8-alpha.3'
VERSION = '0.0.8-alpha.4'
end
Loading

0 comments on commit 3886352

Please sign in to comment.