mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-18 22:31:04 +00:00
Converted search filters to not be vue based
This commit is contained in:
parent
76d02cd472
commit
715dee2d0e
15 changed files with 399 additions and 475 deletions
resources/js/components
31
resources/js/components/add-remove-rows.js
Normal file
31
resources/js/components/add-remove-rows.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import {onChildEvent} from "../services/dom";
|
||||
|
||||
/**
|
||||
* AddRemoveRows
|
||||
* Allows easy row add/remove controls onto a table.
|
||||
* Needs a model row to use when adding a new row.
|
||||
* @extends {Component}
|
||||
*/
|
||||
class AddRemoveRows {
|
||||
setup() {
|
||||
this.modelRow = this.$refs.model;
|
||||
this.addButton = this.$refs.add;
|
||||
this.removeSelector = this.$opts.removeSelector;
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
setupListeners() {
|
||||
this.addButton.addEventListener('click', e => {
|
||||
const clone = this.modelRow.cloneNode(true);
|
||||
clone.classList.remove('hidden');
|
||||
this.modelRow.parentNode.insertBefore(clone, this.modelRow);
|
||||
});
|
||||
|
||||
onChildEvent(this.$el, this.removeSelector, 'click', (e) => {
|
||||
const row = e.target.closest('tr');
|
||||
row.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default AddRemoveRows;
|
Loading…
Add table
Add a link
Reference in a new issue