ScanItem collapsable

This commit is contained in:
Tim Wundenberg
2021-07-29 20:26:25 +02:00
parent 5f735dc525
commit f27628c57d
2 changed files with 56 additions and 17 deletions

View File

@@ -2,36 +2,52 @@
<div> <div>
<font-awesome-icon class="icon" :icon="iconName" @click="onClickVisible" /> <font-awesome-icon class="icon" :icon="iconName" @click="onClickVisible" />
<font-awesome-icon class="icon" icon="edit" @click="onClickEdit" /> <font-awesome-icon class="icon" icon="edit" @click="onClickEdit" />
<p>Scan Name</p> <p @click="onClickEdit()">Scan Name</p>
<!-- <div id="settings" class="collapsed">
button(id="Visible" + scan.id, onclick="buttonVisibleClicked("+scan.id+")"type="button", class="fa fa-eye") <div id="settings-container">
button(id="Edit" + scan.id, type="button",class="fa fa-edit") <div>
p(id="Label" + scan.id)= scan.name --> <input type="text" value="Scan Name" />
</div>
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
// import MenuIcon from "vue-material-design-icons/Menu.vue";
export default { export default {
name: "ScanItem", name: "ScanItem",
data: function () { data() {
return { return {
visible: true, isVisible: true,
isCollapsed: true,
}; };
}, },
methods: { methods: {
onClickVisible: function () { onClickVisible() {
this.visible = !this.visible; this.isVisible = !this.isVisible;
}, },
onClickEdit: function () { onClickEdit() {
alert("Edit!"); this.isCollapsed = !this.isCollapsed;
const settings = document.getElementById("settings");
if (this.isCollapsed) {
settings.style.height = 0;
} else {
const container = document.getElementById("settings-container");
settings.style.height = this.outerHeight(container) + "px";
}
},
outerHeight(el) {
var width = el.offsetHeight;
const style = getComputedStyle(el);
width += parseInt(style.marginTop) + parseInt(style.marginTop);
return width;
}, },
}, },
computed: { computed: {
iconName: function () { iconName() {
if (this.visible) return "eye"; return this.isVisible ? "eye" : "eye-slash";
else return "eye-slash";
}, },
}, },
}; };
@@ -49,5 +65,28 @@ p {
margin: 0px; margin: 0px;
margin-left: 5px; margin-left: 5px;
font-size: 0.8em; font-size: 0.8em;
cursor: pointer;
user-select: none;
}
#settings {
-moz-transition: height 0.3s;
-ms-transition: height 0.3s;
-o-transition: height 0.3s;
-webkit-transition: height 0.3s;
transition: height 0.3s;
height: 0;
overflow: hidden;
}
#settings-container {
padding: 10px;
margin-left: 25px;
margin-top: 10px;
margin-bottom: 30px;
border-style: solid;
border-width: 1px;
border-color: grey;
} }
</style>e </style>e

View File

@@ -25,7 +25,7 @@
import ScanItem from "@/components/ScanItem"; import ScanItem from "@/components/ScanItem";
export default { export default {
data: function () { data() {
return { return {
items: [ items: [
1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6,