Creates prop for setting the collapse state of panels

This commit is contained in:
Alicia Sykes 2019-09-01 17:31:00 +01:00
parent 335c8eec53
commit 45edb85b36
5 changed files with 41 additions and 5 deletions

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="collapsable"> <div class="collapsable">
<input :id="`collapsible-${uniqueKey}`" class="toggle" type="checkbox" checked> <input
:id="`collapsible-${uniqueKey}`"
class="toggle"
type="checkbox"
:checked="!collapsed">
<label :for="`collapsible-${uniqueKey}`" class="lbl-toggle" tabindex="0"> <label :for="`collapsible-${uniqueKey}`" class="lbl-toggle" tabindex="0">
<h2>{{ title }}</h2> <h2>{{ title }}</h2>
</label> </label>
@ -18,6 +22,7 @@ export default {
props: { props: {
uniqueKey: String, uniqueKey: String,
title: String, title: String,
collapsed: Boolean,
}, },
}; };
</script> </script>

View File

@ -41,9 +41,13 @@ export default {
window.addEventListener('keyup', (event) => { window.addEventListener('keyup', (event) => {
const { key } = event; const { key } = event;
if (/^[a-zA-Z]$/.test(key) && !document.activeElement.id) { if (/^[a-zA-Z]$/.test(key) && !document.activeElement.id) {
this.input += key; try {
this.$refs.filter.focus(); this.input += key;
this.userIsTypingSomething(); this.$refs.filter.focus();
this.userIsTypingSomething();
} catch (e) {
// Do nothing
}
} }
}); });
}, },

View File

@ -1,5 +1,5 @@
<template> <template>
<Collapsable :title="title" :uniqueKey="groupId"> <Collapsable :title="title" :uniqueKey="groupId" :collapsed="collapsed">
<div v-if="!items || items.length < 1" class="no-items"> <div v-if="!items || items.length < 1" class="no-items">
No Items to Show Yet No Items to Show Yet
</div> </div>
@ -25,6 +25,7 @@ export default {
props: { props: {
groupId: String, groupId: String,
title: String, title: String,
collapsed: Boolean,
items: Array, items: Array,
}, },
components: { components: {

View File

@ -2,6 +2,7 @@
{ {
"id": "0", "id": "0",
"name": "Server Management | External", "name": "Server Management | External",
"collapsed": false,
"items": [ "items": [
{ {
"id":"001", "id":"001",
@ -32,6 +33,7 @@
{ {
"id": "1", "id": "1",
"name": "Server Management | Hosted", "name": "Server Management | Hosted",
"collapsed": false,
"items": [ "items": [
{ {
"id":"001", "id":"001",
@ -98,5 +100,28 @@
"url": "" "url": ""
} }
] ]
},
{
"id": "2",
"name": "Dev Tools",
"collapsed": true,
"items": [
{
"id":"001",
"title": "DNS Management",
"description": "Configure Server Gateways",
"provider": "CloudFlare",
"icon": "009-cloud",
"url": "https://dash.cloudflare.com"
},
{
"id":"002",
"title": "Servers",
"description": "Manage scaling, power and credentials",
"provider": "Digital Ocean",
"icon": "021-folder",
"url": "https://cloud.digitalocean.com"
}
]
} }
] ]

View File

@ -9,6 +9,7 @@
:key="item.id" :key="item.id"
:groupId="item.id" :groupId="item.id"
:title="item.name" :title="item.name"
:collapsed="item.collapsed"
:items="filterTiles(item.items)" :items="filterTiles(item.items)"
/> />
</div> </div>