123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <!--
- Copyright 2019 Hackware SpA <human@hackware.cl>
- This file is part of "Hackware Userland" and licensed under the terms
- of the GNU Affero General Public License version 3, or (at your option)
- a later version. You should have received a copy of this license along
- with the software. If not, see <https://www.gnu.org/licenses/>.
- -->
- <template>
- <component
- :is="widget"
- :name="name"
- :property="property"
- :readonly="isReadOnly"
- />
- </template>
- <script>
- import SchemaFormInputWidget from './SchemaFormInputWidget.vue';
- import SchemaFormSelectWidget from './SchemaFormSelectWidget.vue';
- export default {
- name: 'SchemaFormWidget',
- components: {
- SchemaFormInputWidget,
- SchemaFormSelectWidget,
- },
- props: {
- name: {
- type: String,
- required: true,
- },
- property: {
- type: Object,
- required: true,
- },
- },
- computed: {
- widget() {
- if (this.isSelect) {
- return 'SchemaFormSelectWidget';
- }
- return 'SchemaFormInputWidget';
- },
- isSelect() {
- if ('enum' in this.property || 'oneOf' in this.property) {
- return true;
- }
- return false;
- },
- isReadOnly() {
- return ('readOnly' in this.property) && this.property.readOnly === true;
- },
- },
- };
- </script>
|