Created
December 6, 2017 18:55
-
-
Save javier-delgado/f04912313f93cfa82f173c75f364496e to your computer and use it in GitHub Desktop.
Table actions for rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .row-actions.dont-propagate.btn-toolbar.pull-right | |
| - except = Array(except) | |
| - resources = [:panel].concat(Array(resource)).flatten | |
| - resource = resources.last | |
| - paths = paths || {} | |
| = yield | |
| - unless except.include? :show | |
| = link_to (paths[:show] || polymorphic_path(resources)), rel: "tooltip", title: "Ver detalles", class: 'btn btn-sm btn-info' do | |
| i.fa.fa-info-circle.fa-lg | |
| - unless except.include? :edit | |
| = link_to (paths[:edit] || polymorphic_path(resources, action: :edit)), rel: "tooltip", title: "Editar", class: 'btn btn-sm btn-primary' do | |
| i.fa.fa-pencil.fa-lg | |
| - if resource.has_attribute?(:habilitado) && !except.include?(:habilitar) && resource.habilitado | |
| = link_to (paths[:habilitar] || polymorphic_path(resources, action: :switch_habilitado)), class: 'btn btn-sm btn-default tooltiped', title: "Deshabilitar", method: :post, data: { confirm: '¿Estás seguro que quieres deshabilitar el registro?'} do | |
| i.fa.fa-ban.fa-lg | |
| - if resource.has_attribute?(:habilitado) && !except.include?(:habilitar) && !resource.habilitado | |
| = link_to (paths[:habilitar] || polymorphic_path(resources, action: :switch_habilitado)), class: 'btn btn-sm btn-success tooltiped', title: "Habilitar", method: :post, data: { confirm: '¿Estás seguro que quieres habilitar el registro?'} do | |
| i.fa.fa-check.fa-lg | |
| - unless except.include? :destroy | |
| = link_to (paths[:destroy] || polymorphic_path(resources)), class: 'btn btn-sm btn-danger tooltiped', title: "Eliminar", method: :delete, data: { confirm: '¿Estás seguro que quieres eliminar este elemento? No podrás deshacer esta acción.'} do | |
| i.fa.fa-trash.fa-lg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment