diff --git a/src/components/selectable_list/selectable_list.js b/src/components/selectable_list/selectable_list.js
index 93efa840..809133f5 100644
--- a/src/components/selectable_list/selectable_list.js
+++ b/src/components/selectable_list/selectable_list.js
@@ -6,14 +6,32 @@ const SelectableList = {
List,
Checkbox
},
- props: List.props,
+ props: {
+ items: {
+ type: Array,
+ default: () => []
+ },
+ getKey: {
+ type: Function,
+ default: item => item.id
+ }
+ },
data () {
return {
selected: []
}
},
+ computed: {
+ allSelected () {
+ return !this.items.find(item => !this.isSelected(item))
+ }
+ },
methods: {
- toggle (checked, key) {
+ isSelected (item) {
+ return this.selected.indexOf(this.getKey(item)) !== -1
+ },
+ toggle (checked, item) {
+ const key = this.getKey(item)
const oldChecked = this.isSelected(key)
if (checked !== oldChecked) {
if (checked) {
@@ -23,8 +41,12 @@ const SelectableList = {
}
}
},
- isSelected (key) {
- return this.selected.indexOf(key) !== -1
+ toggleAll (value) {
+ if (value) {
+ this.selected = this.items.map(this.getKey)
+ } else {
+ this.selected = []
+ }
}
}
}
diff --git a/src/components/selectable_list/selectable_list.vue b/src/components/selectable_list/selectable_list.vue
index d8938062..e8c5d09b 100644
--- a/src/components/selectable_list/selectable_list.vue
+++ b/src/components/selectable_list/selectable_list.vue
@@ -1,14 +1,21 @@
-
-
-
-
- toggle(checked, p.keyVal)" />
-
-
+
+
+
+
+
+
+ toggle(checked, p.item)" />
+
+
+
+
+
+
@@ -19,6 +26,7 @@
.selectable-list {
&-item-inner {
display: flex;
+ align-items: center;
}
&-item-selected-inner {
@@ -26,8 +34,14 @@
background-color: var(--lightBg, $fallback--lightBg);
}
+ &-header {
+ display: flex;
+ align-items: center;
+ padding: 0.6em 0;
+ }
+
&-checkbox-wrapper {
- padding: 10px;
+ padding: 0 10px;
flex: none;
}
}