-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(templates): modify
Field
class to support checkboxes
Signed-off-by: Elizabeth Danzberger <[email protected]>
- Loading branch information
Showing
4 changed files
with
113 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
apps/files/src/components/TemplateFiller/TemplateCheckboxField.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<div class="template-field__checkbox"> | ||
<label :for="fieldId"> | ||
{{ fieldLabel }} | ||
</label> | ||
|
||
<NcCheckboxRadioSwitch :id="fieldId" | ||
:checked.sync="value" | ||
type="switch" | ||
@update:checked="$emit('input', [field.index, 'checked', value])" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import { NcCheckboxRadioSwitch } from '@nextcloud/vue' | ||
export default defineComponent({ | ||
name: 'TemplateCheckboxField', | ||
components: { | ||
NcCheckboxRadioSwitch, | ||
}, | ||
props: { | ||
field: { | ||
type: Object, | ||
default: () => {}, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
value: this.field.checked ?? false, | ||
} | ||
}, | ||
computed: { | ||
fieldLabel() { | ||
const label = this.field.name ?? this.field.alias ?? 'Unknown field' | ||
return label.charAt(0).toUpperCase() + label.slice(1) | ||
}, | ||
fieldId() { | ||
return 'checkbox-field' + this.field.index | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.template-field__checkbox { | ||
margin: 20px 0; | ||
display: flex; | ||
align-items: center; | ||
label { | ||
font-weight: bold; | ||
flex-grow: 1; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters