mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
add ReadOnlyField to display config readonly values
This commit is contained in:
parent
97bd1564c4
commit
9d02438348
2 changed files with 68 additions and 1 deletions
65
app/src/components/globals/ReadOnlyField.vue
Normal file
65
app/src/components/globals/ReadOnlyField.vue
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<template>
|
||||||
|
<b-row no-gutters class="description-row">
|
||||||
|
<b-col v-bind="cols_" class="font-weight-bold">
|
||||||
|
{{ label }}
|
||||||
|
</b-col>
|
||||||
|
|
||||||
|
<!-- FIXME not sure about rendering html -->
|
||||||
|
<b-col v-html="text" />
|
||||||
|
</b-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ReadOnlyField',
|
||||||
|
|
||||||
|
inheritAttrs: false,
|
||||||
|
|
||||||
|
props: {
|
||||||
|
label: { type: String, required: true },
|
||||||
|
component: { type: String, default: 'InputItem' },
|
||||||
|
value: { type: null, default: null },
|
||||||
|
cols: { type: Object, default: () => ({ md: 4, lg: 3 }) }
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
cols_ () {
|
||||||
|
return Object.assign({ md: 4, lg: 3 }, this.cols)
|
||||||
|
},
|
||||||
|
|
||||||
|
text () {
|
||||||
|
return this.parseValue(this.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
parseValue (value) {
|
||||||
|
const item = this.component
|
||||||
|
if (item === 'FileItem') value = value.file ? value.file.name : null
|
||||||
|
if (item === 'CheckboxItem') value = this.$i18n.t(value ? 'yes' : 'no')
|
||||||
|
if (item === 'TextAreaItem') value = value.replaceAll('\n', '<br>')
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value = value.length ? value.join(this.$i18n.t('words.separator')) : null
|
||||||
|
}
|
||||||
|
if ([null, undefined, ''].includes(this.value)) value = this.$i18n.t('words.none')
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.description-row {
|
||||||
|
@include media-breakpoint-up(md) {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
@include media-breakpoint-down(sm) {
|
||||||
|
flex-direction: column;
|
||||||
|
&:not(:last-of-type) {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
border-bottom: $border-width solid $card-border-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -544,7 +544,9 @@
|
||||||
"words": {
|
"words": {
|
||||||
"browse": "Browse",
|
"browse": "Browse",
|
||||||
"collapse": "Collapse",
|
"collapse": "Collapse",
|
||||||
"default": "Default"
|
"default": "Default",
|
||||||
|
"none": "None",
|
||||||
|
"separator": ", "
|
||||||
},
|
},
|
||||||
"wrong_password": "Wrong password",
|
"wrong_password": "Wrong password",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
|
|
Loading…
Add table
Reference in a new issue