contar los artículos seleccionados

This commit is contained in:
f 2020-11-19 17:53:11 -03:00
parent f9fdc5d400
commit fbfb6a7f51
2 changed files with 10 additions and 2 deletions

View file

@ -22,7 +22,7 @@ import { Controller } from 'stimulus'
* El objetivo es poder mover filas en tablas de miles de elementos.
*/
export default class extends Controller {
static targets = [ 'row', 'unselect', 'top', 'bottom', 'direction' ]
static targets = [ 'row', 'unselect', 'top', 'bottom', 'direction', 'counter' ]
connect () {
// Deseleccionar
@ -95,6 +95,8 @@ export default class extends Controller {
} else {
delete this.selected_rows[row.id]
}
this.counter()
})
})
@ -187,4 +189,8 @@ export default class extends Controller {
// Mantenemos el primero a la vista
rows[0].row.scrollIntoViewIfNeeded()
}
counter () {
this.counterTarget.innerText = Object.keys(this.selected_rows).length
}
}

View file

@ -52,7 +52,9 @@
%tr
%th.border-0.background-white.position-sticky{ style: 'top: 0', colspan: '4' }
= submit_tag t('posts.reorder.submit'), class: 'btn'
%button.btn{ data: { target: 'reorder.unselect' } }= t('posts.reorder.unselect')
%button.btn{ data: { target: 'reorder.unselect' } }
= t('posts.reorder.unselect')
%span.badge{ data: { target: 'reorder.counter' } } 0
%button.btn{ data: { target: 'reorder.direction', direction: 'up' } }= t('posts.reorder.up')
%button.btn{ data: { target: 'reorder.direction', direction: 'down' } }= t('posts.reorder.down')
%button.btn{ data: { target: 'reorder.top' } }= t('posts.reorder.top')