diff options
| author | Teddy Wing | 2017-06-09 15:13:44 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-09 15:26:45 +0200 | 
| commit | 0fb0bd13e4e09c910bc4159985b714f43f6d0fe0 (patch) | |
| tree | 4abd806580de688ed7683ffe0d340b427118d650 | |
| parent | ca10698f263dad9298b001e9194c4e042c1a9cff (diff) | |
| download | chouette-core-0fb0bd13e4e09c910bc4159985b714f43f6d0fe0.tar.bz2 | |
TableBuilderHelper: Correct `selectable` behaviour
I had coded this the opposite of what it should have been. Instead, if
`selectable` is true, we should show the selection checkboxes.
Invert the conditions and add `selectable: true` to the
`table_builder_2` calls that expect a checkbox column.
Also remove the TODO because this argument is necessary.
Refs #3479
| -rw-r--r-- | app/helpers/table_builder_helper.rb | 6 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 1 | ||||
| -rw-r--r-- | spec/helpers/table_builder_helper_spec.rb | 1 | 
3 files changed, 5 insertions, 3 deletions
| diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index 01f356217..3e8602dac 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -5,7 +5,7 @@ module TableBuilderHelper      columns,      current_referential: nil,      sortable: true, -    selectable: false,  # TODO: is this necessary? +    selectable: false,      # selection_actions: [] ## this has been gotten rid of. The element based on this should be created elsewhere      links: [],  # links: or actions: ? I think 'links' is better since 'actions' evokes Rails controller actions and we want to put `link_to`s here      sort_by: {},  # { column: 'name', direction: 'desc' } @@ -31,7 +31,7 @@ module TableBuilderHelper          hcont = []          # Adds checkbox to table header -        if !selectable +        if selectable            cbx = content_tag :div, '', class: 'checkbox' do              check_box_tag('0', 'all').concat(content_tag(:label, '', for: '0'))            end @@ -64,7 +64,7 @@ module TableBuilderHelper            # Adds item checkboxes whose value = the row object's id            # Apparently the object id is also used in the HTML id attribute without any prefix -          if !selectable +          if selectable              # TODO: Extract method `build_checkbox(attribute)`              cbx = content_tag :div, '', class: 'checkbox' do                check_box_tag(item.try(:id), item.try(:id)).concat(content_tag(:label, '', for: item.try(:id))) diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 65fb4652b..61b9395fa 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -44,6 +44,7 @@                :created_at => Proc.new {|w| l(w.created_at, format: :short)},                :updated_at => Proc.new {|w| l(w.updated_at, format: :short)},                :published_at => ''}, +            selectable: true,              links: [:show, :edit, :archive, :unarchive, :delete],              cls: 'table has-filter has-search'            / [:delete], diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index 165e9c3f4..dd4db0840 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -110,6 +110,7 @@ describe TableBuilderHelper, type: :helper do            :created_at => Proc.new {|w| l(w.created_at, format: :short)},            :updated_at => Proc.new {|w| l(w.updated_at, format: :short)},            :published_at => ''}, +        selectable: true,          links: [:show, :edit, :archive, :unarchive, :delete],          cls: 'table has-filter has-search'        ) | 
