summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/components/custom_checkbox.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/components/custom_checkbox.js')
-rw-r--r--addons/web/static/src/js/components/custom_checkbox.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/addons/web/static/src/js/components/custom_checkbox.js b/addons/web/static/src/js/components/custom_checkbox.js
new file mode 100644
index 00000000..bc98dd7b
--- /dev/null
+++ b/addons/web/static/src/js/components/custom_checkbox.js
@@ -0,0 +1,58 @@
+odoo.define('web.CustomCheckbox', function (require) {
+ "use strict";
+
+ const utils = require('web.utils');
+
+ const { Component } = owl;
+
+ /**
+ * Custom checkbox
+ *
+ * Component that can be used in templates to render the custom checkbox of Odoo.
+ *
+ * <CustomCheckbox
+ * value="boolean"
+ * disabled="boolean"
+ * text="'Change the label text'"
+ * t-on-change="_onValueChange"
+ * />
+ *
+ * @extends Component
+ */
+ class CustomCheckbox extends Component {
+ /**
+ * @param {Object} [props]
+ * @param {string | number | null} [props.id]
+ * @param {boolean} [props.value=false]
+ * @param {boolean} [props.disabled=false]
+ * @param {string} [props.text]
+ */
+ constructor() {
+ super(...arguments);
+ this._id = `checkbox-comp-${utils.generateID()}`;
+ }
+ }
+
+ CustomCheckbox.props = {
+ id: {
+ type: [String, Number],
+ optional: 1,
+ },
+ disabled: {
+ type: Boolean,
+ optional: 1,
+ },
+ value: {
+ type: Boolean,
+ optional: 1,
+ },
+ text: {
+ type: String,
+ optional: 1,
+ },
+ };
+
+ CustomCheckbox.template = 'web.CustomCheckbox';
+
+ return CustomCheckbox;
+});