diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/components/_buttons.sass | 41 | ||||
| -rw-r--r-- | app/decorators/line_decorator.rb | 18 | ||||
| -rw-r--r-- | app/helpers/table_builder_helper.rb | 13 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_page_header.html.slim | 10 | ||||
| -rw-r--r-- | app/views/lines/show.html.slim | 7 |
5 files changed, 53 insertions, 36 deletions
diff --git a/app/assets/stylesheets/components/_buttons.sass b/app/assets/stylesheets/components/_buttons.sass index a649a07ef..e70c89733 100644 --- a/app/assets/stylesheets/components/_buttons.sass +++ b/app/assets/stylesheets/components/_buttons.sass @@ -142,16 +142,25 @@ table, .table margin: 0 border-radius: 0 box-shadow: 0 0 3px rgba($darkgrey, 0.25) - - > li > a, > li > button - padding: 5px 15px - - > li.delete-action - > a, > button + > ul + padding: 0 + margin: 0 + > li > a, > li > button + padding: 5px 15px + white-space: nowrap + color: black + padding: 5px 15px + font-weight: normal + line-height: 1.42857 display: block + font-size: 14px + &:hover + text-decoration: none + color: #262626 + background-color: whitesmoke + &:not(:first-child) position: relative margin-top: 11px - &:before content: '' display: block @@ -162,14 +171,18 @@ table, .table height: 1px background-color: $grey - .fa:first-child - margin-right: 0.5em - - & + li.delete-action + > li.delete-action > a, > button - margin-top: 0 - &:before - display: none + display: block + position: relative + .fa:first-child + margin-right: 0.5em + + & + li.delete-action + > a, > button + margin-top: 0 + &:before + display: none &.table-2entries .t2e-item diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb index 6c6df1a95..9325c6a8b 100644 --- a/app/decorators/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -27,21 +27,21 @@ class LineDecorator < AF83::Decorator can_edit_line = ->(){ h.policy(Chouette::Line).create? && context[:line_referential].organisations.include?(context[:current_organisation]) } with_condition can_edit_line do - action_link on: :index do |l| - l.content { h.t('lines.actions.new') } - l.href { h.new_line_referential_line_path(context[:line_referential]) } - end - - action_link on: %i(index show), primary: :show do |l| + action_link on: %i(index show), primary: :show, secondary: :index do |l| l.content { h.t('lines.actions.edit') } l.href { h.edit_line_referential_line_path(context[:line_referential], object.id) } end + + action_link on: :index, secondary: :index do |l| + l.content { h.t('lines.actions.new') } + l.href { h.new_line_referential_line_path(context[:line_referential]) } + end end ### the option :policy will automatically check for the corresponding method ### on the object's policy - action_link policy: :deactivate, secondary: true do |l| + action_link policy: :deactivate, secondary: :show, footer: :index do |l| l.content { h.deactivate_link_content('lines.actions.deactivate') } l.href { h.deactivate_line_referential_line_path(context[:line_referential], object) } l.method :put @@ -49,7 +49,7 @@ class LineDecorator < AF83::Decorator l.extra_class "delete-action" end - action_link policy: :activate, secondary: true do |l| + action_link policy: :activate, secondary: :show, footer: :index do |l| l.content { h.activate_link_content('lines.actions.activate') } l.href { h.activate_line_referential_line_path(context[:line_referential], object) } l.method :put @@ -57,7 +57,7 @@ class LineDecorator < AF83::Decorator l.extra_class "delete-action" end - action_link policy: :destroy do |l| + action_link policy: :destroy, footer: true do |l| l.content { h.destroy_link_content('lines.actions.destroy') } l.href { h.line_referential_line_path(context[:line_referential], object) } l.method :delete diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index e66e9c942..bece3bb2a 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -306,12 +306,13 @@ module TableBuilderHelper content_tag :span, '', class: 'fa fa-cog' end - menu = content_tag :ul, class: 'dropdown-menu' do - ( - CustomLinks.new(item, pundit_user, links, referential).links + - item.action_links - ).map do |link| - gear_menu_link(link) + menu = content_tag :div, class: 'dropdown-menu' do + item.action_links(params[:action]).grouped_by(:primary, :secondary, :footer).map do |group, _links| + if _links.any? + content_tag :ul, class: group do + _links.map{|link| gear_menu_link(link)}.join.html_safe + end + end end.join.html_safe end diff --git a/app/views/layouts/navigation/_page_header.html.slim b/app/views/layouts/navigation/_page_header.html.slim index 90fd7d855..076c76de4 100644 --- a/app/views/layouts/navigation/_page_header.html.slim +++ b/app/views/layouts/navigation/_page_header.html.slim @@ -19,5 +19,15 @@ div.page_header - if content_for? :page_header_actions = yield :page_header_actions + - action_links = resource.action_links(params[:action]) rescue nil + - if action_links&.primary&.any? || action_links&.secondary&.any? + .row + .col-lg-12.text-right.mb-sm + - action_links.primary.each do |link| + = link.to_html do |l| + - l.class "btn btn-primary #{l.disabled ? "disabled" : ""} sticky-action" + - action_links.secondary.each do |link| + = link.to_html do |l| + - l.class "btn btn-primary #{l.disabled ? "disabled" : ""}" - if content_for? :page_header_content = yield :page_header_content diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index 1c0578b0b..34b907bdd 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -1,11 +1,4 @@ - breadcrumb :line, @line -- content_for :page_header_content do - .row - .col-lg-12.text-right.mb-sm - - @line.action_links(:show, :primary).each do |link| - = link.to_html do |l| - - l.class "btn btn-primary #{l.disabled ? "disabled" : ""}" - - page_header_content_for @line .page_content |
