2022-05-01 15:34:15 +02:00
|
|
|
<template>
|
2022-05-30 09:18:19 +02:00
|
|
|
<div class="entity-icon-container"
|
|
|
|
:class="{'with-color-fill': !!colorFill}"
|
|
|
|
:style="colorFillStyle">
|
2022-05-01 15:34:15 +02:00
|
|
|
<img src="@/assets/img/spinner.gif" class="loading" v-if="loading">
|
|
|
|
<i class="fas fa-circle-exclamation error" v-else-if="error" />
|
2022-05-30 09:18:19 +02:00
|
|
|
<Icon v-bind="computedIcon" v-else />
|
2022-05-01 15:34:15 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Icon from "@/components/elements/Icon";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "EntityIcon",
|
|
|
|
components: {Icon},
|
|
|
|
props: {
|
|
|
|
loading: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
error: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
icon: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-05-30 09:18:19 +02:00
|
|
|
|
|
|
|
hasColorFill: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-05-01 15:34:15 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
component: null,
|
|
|
|
modalVisible: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-05-30 09:18:19 +02:00
|
|
|
colorFill() {
|
|
|
|
return (this.hasColorFill && this.icon.color) ? this.icon.color : null
|
|
|
|
},
|
|
|
|
|
|
|
|
colorFillStyle() {
|
2022-10-14 23:37:36 +02:00
|
|
|
return this.colorFill && !this.error ? {'background': this.colorFill} : {}
|
2022-05-30 09:18:19 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
computedIcon() {
|
|
|
|
const icon = {...this.icon}
|
|
|
|
if (this.colorFill)
|
|
|
|
delete icon.color
|
|
|
|
return icon
|
|
|
|
},
|
|
|
|
|
2022-05-01 15:34:15 +02:00
|
|
|
type() {
|
|
|
|
let entityType = (this.entity.type || '')
|
|
|
|
return entityType.charAt(0).toUpperCase() + entityType.slice(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "vars";
|
|
|
|
|
|
|
|
.entity-icon-container {
|
2022-05-30 09:18:19 +02:00
|
|
|
width: 1.625em;
|
2022-05-01 15:34:15 +02:00
|
|
|
height: 1.5em;
|
2022-05-30 09:18:19 +02:00
|
|
|
display: inline-flex;
|
2022-05-01 15:34:15 +02:00
|
|
|
margin-top: 0.25em;
|
2022-05-30 09:18:19 +02:00
|
|
|
margin-left: 0.25em;
|
2022-05-01 15:34:15 +02:00
|
|
|
position: relative;
|
|
|
|
text-align: center;
|
2022-05-30 09:18:19 +02:00
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
&.with-color-fill {
|
|
|
|
border-radius: 1em;
|
|
|
|
}
|
2022-05-01 15:34:15 +02:00
|
|
|
|
|
|
|
.loading {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
2022-05-01 15:44:57 +02:00
|
|
|
transform: translate(0%, -50%);
|
2022-05-01 15:34:15 +02:00
|
|
|
width: 1em;
|
|
|
|
height: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.error {
|
|
|
|
color: $error-fg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|