contar los artículos seleccionados
This commit is contained in:
parent
f9fdc5d400
commit
fbfb6a7f51
2 changed files with 10 additions and 2 deletions
|
@ -22,7 +22,7 @@ import { Controller } from 'stimulus'
|
||||||
* El objetivo es poder mover filas en tablas de miles de elementos.
|
* El objetivo es poder mover filas en tablas de miles de elementos.
|
||||||
*/
|
*/
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = [ 'row', 'unselect', 'top', 'bottom', 'direction' ]
|
static targets = [ 'row', 'unselect', 'top', 'bottom', 'direction', 'counter' ]
|
||||||
|
|
||||||
connect () {
|
connect () {
|
||||||
// Deseleccionar
|
// Deseleccionar
|
||||||
|
@ -95,6 +95,8 @@ export default class extends Controller {
|
||||||
} else {
|
} else {
|
||||||
delete this.selected_rows[row.id]
|
delete this.selected_rows[row.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.counter()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -187,4 +189,8 @@ export default class extends Controller {
|
||||||
// Mantenemos el primero a la vista
|
// Mantenemos el primero a la vista
|
||||||
rows[0].row.scrollIntoViewIfNeeded()
|
rows[0].row.scrollIntoViewIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
counter () {
|
||||||
|
this.counterTarget.innerText = Object.keys(this.selected_rows).length
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,9 @@
|
||||||
%tr
|
%tr
|
||||||
%th.border-0.background-white.position-sticky{ style: 'top: 0', colspan: '4' }
|
%th.border-0.background-white.position-sticky{ style: 'top: 0', colspan: '4' }
|
||||||
= submit_tag t('posts.reorder.submit'), class: 'btn'
|
= 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: 'up' } }= t('posts.reorder.up')
|
||||||
%button.btn{ data: { target: 'reorder.direction', direction: 'down' } }= t('posts.reorder.down')
|
%button.btn{ data: { target: 'reorder.direction', direction: 'down' } }= t('posts.reorder.down')
|
||||||
%button.btn{ data: { target: 'reorder.top' } }= t('posts.reorder.top')
|
%button.btn{ data: { target: 'reorder.top' } }= t('posts.reorder.top')
|
||||||
|
|
Loading…
Reference in a new issue