diff options
| author | jpl | 2017-02-08 10:27:01 +0100 | 
|---|---|---|
| committer | jpl | 2017-02-08 10:27:01 +0100 | 
| commit | 0c87977f1fba112bdd1082de8be6fde778fb53bd (patch) | |
| tree | 01bbe326934cf3b77b6336646d4f4ac55cdbf983 | |
| parent | de3e71567767e5fcb1de55ef852ea19454d230f7 (diff) | |
| download | chouette-core-0c87977f1fba112bdd1082de8be6fde778fb53bd.tar.bz2 | |
Refs #2535: adding selection behav. for table toolbox
| -rw-r--r-- | app/assets/javascripts/selectable_table.coffee | 15 | ||||
| -rw-r--r-- | app/assets/stylesheets/components/_forms.sass | 10 | ||||
| -rw-r--r-- | app/assets/stylesheets/components/_tables.sass | 6 | ||||
| -rw-r--r-- | app/helpers/newapplication_helper.rb | 24 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 4 | ||||
| -rw-r--r-- | config/locales/actions.fr.yml | 4 | 
6 files changed, 47 insertions, 16 deletions
| diff --git a/app/assets/javascripts/selectable_table.coffee b/app/assets/javascripts/selectable_table.coffee index 84a026d8a..1b4b95c0b 100644 --- a/app/assets/javascripts/selectable_table.coffee +++ b/app/assets/javascripts/selectable_table.coffee @@ -1,6 +1,8 @@  @selectTable = -> -  $('.table').each -> +  $('.select_table').each ->      selection = [] +    toolbox = $(this).children('.select_toolbox') +      $(this).on 'click', "[type='checkbox']", (e)->        if e.currentTarget.id == '0'          selection = [] @@ -26,7 +28,14 @@            elm = selection.indexOf(e.currentTarget.id)            selection.splice(elm, 1) -      # We log the selection (for now) -      console.log selection +      # Updating toolbox, according to selection +      if selection.length > 0 +        toolbox +          .removeClass 'noselect' +          .children('.info-msg').children('span').text(selection.length) +      else +        toolbox +          .addClass 'noselect' +          .children('.info-msg').children('span').text(selection.length)  $(document).on 'ready page:load', selectTable diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass index 228a5dc1a..3425bc9cc 100644 --- a/app/assets/stylesheets/components/_forms.sass +++ b/app/assets/stylesheets/components/_forms.sass @@ -168,12 +168,22 @@ $cbx-size: 20px        font-weight: 700        background-color: transparent        padding: 2px 20px +      transition: 0.2s        &.btn-link          padding: 2px 10px + +        &:hover, &:focus +          text-decoration: none +        &.btn-default          border: 1px solid #fff +        &:hover, &:focus, &.focus, &.active +          background-color: #fff +          color: $blue +          transition: 0.2s +    > .form-group      position: relative diff --git a/app/assets/stylesheets/components/_tables.sass b/app/assets/stylesheets/components/_tables.sass index caebc22e0..80e695a6f 100644 --- a/app/assets/stylesheets/components/_tables.sass +++ b/app/assets/stylesheets/components/_tables.sass @@ -87,6 +87,12 @@          &:hover            background-color: rgba($blue, 0.5) +  &.noselect +    .st_action > a +      &, &:hover, &:focus +        background-color: rgba($grey, 0.65) +        cursor: not-allowed +    > .info-msg      font-style: italic      font-size: 0.85em diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index 88aae9432..9b743b929 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -1,14 +1,14 @@  module NewapplicationHelper    # Table Builder -  def table_builder collection, columns, actions, selectable, cls = nil +  def table_builder collection, columns, actions, selectable = [], cls = nil      return unless collection.present?      head = content_tag :thead do        content_tag :tr do          hcont = [] -        if selectable.to_s == 'selectable' +        unless selectable.empty?            cbx = content_tag :div, '', class: 'checkbox' do              check_box_tag('0', 'all').concat(content_tag(:label, '', for: '0'))            end @@ -29,7 +29,7 @@ module NewapplicationHelper          content_tag :tr do            bcont = [] -          if selectable.to_s == 'selectable' +          unless selectable.empty?              cbx = content_tag :div, '', class: 'checkbox' do                check_box_tag(item.try(:id), item.try(:id)).concat(content_tag(:label, '', for: item.try(:id)))              end @@ -70,7 +70,15 @@ module NewapplicationHelper        end.join.html_safe      end -    content_tag :table, head + body, class: cls +    if selectable.empty? +      content_tag :table, head + body, class: cls +    else +      content_tag :div, '', class: 'select_table' do +        table = content_tag :table, head + body, class: cls +        toolbox = select_toolbox(selectable) +        table + toolbox +      end +    end    end    def links_builder(item, actions) @@ -150,8 +158,8 @@ module NewapplicationHelper      end    end -  # Actions on select toolbox -  def select_toolbox actions +  # Actions on select toolbox (for selectables tables) +  def select_toolbox(actions)      tools = content_tag :ul do        actions.collect do |action| @@ -167,8 +175,8 @@ module NewapplicationHelper        end.join.html_safe      end -    content_tag :div, '', class: 'select_toolbox' do -      tools.concat(content_tag(:span, "n élément(s) sélectionné(s)", class: 'info-msg')) +    content_tag :div, '', class: 'select_toolbox noselect' do +      tools.concat(content_tag(:span, ("<span>0</span> élément(s) sélectionné(s)").html_safe, class: 'info-msg'))      end    end diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 3066d1228..4c9fe3e2e 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -48,11 +48,9 @@                @wbench_refs.human_attribute_name(:updated_at) => Proc.new {|w| l(w.updated_at, format: :short)},                @wbench_refs.human_attribute_name(:published_at) => ''},              [:show, :edit, :archive, :unarchive, :delete], -            :selectable, +            [:delete],              'table' -          = select_toolbox [:delete] -            = new_pagination @wbench_refs, 'pull-right'          - else diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml index 758c0ab3e..d49c4ef20 100644 --- a/config/locales/actions.fr.yml +++ b/config/locales/actions.fr.yml @@ -6,8 +6,8 @@ fr:      search: "Chercher"      add: 'Ajouter'      show: 'Consulter' -    archive: 'Archiver' -    unarchive: 'Désarchiver' +    archive: 'Conserver' +    unarchive: 'Déconserver'    or: "ou"    cancel: "Annuler"    search_hint: "Entrez un texte à rechercher" | 
