Skip to content

Commit 55f7b0d

Browse files
committed
prevent selected items manipulation if row/checkb selectable is disabled
1 parent 904dc92 commit 55f7b0d

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/components/Row.vue

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
this.$refs.vbt_row.addEventListener('mouseover', () => {this.rowHiglighted = true;});
7979
this.$refs.vbt_row.addEventListener('mouseleave', () => {this.rowHiglighted = false;});
8080
}
81-
this.checkInSelecteditems();
81+
this.checkInSelecteditems(this.selectedItems,this.row);
8282
},
8383
methods: {
8484
@@ -97,10 +97,14 @@
9797
this.rowSelected = !this.rowSelected;
9898
},
9999
// compare the selected items list with curretn row item and update checkbox accordingly
100-
checkInSelecteditems() {
100+
checkInSelecteditems(selectedItems,row) {
101+
if (!this.checkboxRows && !this.rowsSelectable) {
102+
return;
103+
}
104+
101105
// TODO replace with find index
102-
let difference = differenceWith(this.selectedItems, [this.row], isEqual);
103-
if (difference.length != this.selectedItems.length) {
106+
let difference = differenceWith(selectedItems, [row], isEqual);
107+
if (difference.length != selectedItems.length) {
104108
this.rowSelected = true;
105109
} else {
106110
this.rowSelected = false;
@@ -141,25 +145,13 @@
141145
watch: {
142146
row: {
143147
handler: function(newVal, oldVal) {
144-
// TODO replace with find index
145-
let difference = differenceWith(this.selectedItems, [newVal], isEqual);
146-
if (difference.length != this.selectedItems.length) {
147-
this.rowSelected = true;
148-
} else {
149-
this.rowSelected = false;
150-
}
148+
this.checkInSelecteditems(this.selectedItems,newVal);
151149
},
152150
deep: true
153151
},
154152
selectedItems: {
155153
handler: function(newVal, oldVal) {
156-
// TODO replace with find index
157-
let difference = differenceWith(newVal, [this.row], isEqual);
158-
if (difference.length != this.selectedItems.length) {
159-
this.rowSelected = true;
160-
} else {
161-
this.rowSelected = false;
162-
}
154+
this.checkInSelecteditems(newVal,this.row);
163155
},
164156
deep: true
165157
}

0 commit comments

Comments
 (0)