Skip to content

Commit

Permalink
add SettingsCheckbox components
Browse files Browse the repository at this point in the history
Signed-off-by: Greta Doci <gretadoci@gmail.com>
  • Loading branch information
GretaD committed Oct 14, 2019
1 parent e6a1668 commit 44f36c7
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
78 changes: 78 additions & 0 deletions src/components/SettingsCheckbox/SettingsCheckbox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--
- @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
-
- @author Julius Härtl <jus@bitgrid.net>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->

<template>
<p>
<input :id="id" type="checkbox" class="checkbox"
:checked="inputVal" :disabled="disabled" @change="$emit('input', $event.target.checked)">
<label :for="id">{{ label }}</label><br>
<em v-if="hint !== ''">{{ hint }}</em>
</p>
</template>

<script>
let uuid = 0
export default {
name: 'SettingsCheckbox',
props: {
label: {
type: String,
required: true
},
hint: {
type: String,
default: ''
},
value: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
inputVal: this.value
}
},
computed: {
id() {
return 'settings-checkbox-' + this.uuid
}
},
watch: {
value(newVal) {
this.inputVal = this.value
}
},
beforeCreate: function() {
this.uuid = uuid.toString()
uuid += 1
}
}
</script>

<style scoped>
</style>
25 changes: 25 additions & 0 deletions src/components/SettingsCheckbox/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @copyright Copyright (c) 2019 Greta Doci <gretadoci@gmail.com>
*
* @author Greta Doci <gretadoci@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import SettingsCheckbox from './SettingsCheckbox'

export default SettingsCheckbox
export { SettingsCheckbox }

0 comments on commit 44f36c7

Please sign in to comment.