mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-16 10:06:57 +08:00
Add support row and columns unselection in storage locations [SCI-11701]
This commit is contained in:
parent
7ec561645c
commit
87e21c9fc6
2 changed files with 25 additions and 1 deletions
|
@ -8,6 +8,8 @@
|
|||
:selectedEmptyCells="selectedEmptyCells"
|
||||
@selectEmptyCell="selectEmptyCell"
|
||||
@select="selectRow"
|
||||
@unselectRow="unselectRow"
|
||||
@unselectColumn="unselectColumn"
|
||||
/>
|
||||
</div>
|
||||
<div class="h-full bg-white px-4">
|
||||
|
@ -136,6 +138,9 @@ export default {
|
|||
}
|
||||
return [];
|
||||
},
|
||||
rowsList() {
|
||||
return Array.from({ length: this.gridSize[0] }, (v, i) => String.fromCharCode(97 + i));
|
||||
},
|
||||
tableId() {
|
||||
return this.withGrid ? 'StorageLocationsContainerGrid' : 'StorageLocationsContainer';
|
||||
},
|
||||
|
@ -258,7 +263,16 @@ export default {
|
|||
this.assignToContainer = null;
|
||||
this.assignToPosition = null;
|
||||
this.cellIdToUnassign = data[0].id;
|
||||
|
||||
},
|
||||
unselectRow(row) {
|
||||
this.selectedEmptyCells = this.selectedEmptyCells.filter((cell) => cell.row !== this.rowsList.indexOf(row));
|
||||
this.$refs.table.selectedRows = this.$refs.table.selectedRows.filter((r) => r.position[0] !== this.rowsList.indexOf(row) + 1);
|
||||
this.$refs.table.restoreSelection();
|
||||
},
|
||||
unselectColumn(column) {
|
||||
this.selectedEmptyCells = this.selectedEmptyCells.filter((cell) => cell.column !== column - 1);
|
||||
this.$refs.table.selectedRows = this.$refs.table.selectedRows.filter((r) => r.position[1] !== column);
|
||||
this.$refs.table.restoreSelection();
|
||||
},
|
||||
async unassignRows(event, rows) {
|
||||
this.storageLocationUnassignDescription = this.i18n.t(
|
||||
|
|
|
@ -126,20 +126,30 @@ export default {
|
|||
this.$emit('selectEmptyCell', cell);
|
||||
},
|
||||
selectRow(row) {
|
||||
let selected = 0;
|
||||
this.columnsList.forEach((column) => {
|
||||
const cell = { row: this.rowsList.indexOf(row), column: column - 1 };
|
||||
if (!this.cellIsSelected(cell) && !this.cellIsOccupied(cell) && !this.cellIsHidden(cell)) {
|
||||
this.$emit('selectEmptyCell', cell);
|
||||
selected += 1;
|
||||
}
|
||||
});
|
||||
if (selected === 0) {
|
||||
this.$emit('unselectRow', row);
|
||||
}
|
||||
},
|
||||
selectColumn(column) {
|
||||
let selected = 0;
|
||||
this.rowsList.forEach((row) => {
|
||||
const cell = { row: this.rowsList.indexOf(row), column: column - 1 };
|
||||
if (!this.cellIsSelected(cell) && !this.cellIsOccupied(cell) && !this.cellIsHidden(cell)) {
|
||||
this.$emit('selectEmptyCell', cell);
|
||||
selected += 1;
|
||||
}
|
||||
});
|
||||
if (selected === 0) {
|
||||
this.$emit('unselectColumn', column);
|
||||
}
|
||||
},
|
||||
handleScroll() {
|
||||
this.$refs.columnsContainer.scrollLeft = this.$refs.cellsContainer.scrollLeft;
|
||||
|
|
Loading…
Add table
Reference in a new issue