diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website_event_meet/static/src/js/customize_options.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_event_meet/static/src/js/customize_options.js')
| -rw-r--r-- | addons/website_event_meet/static/src/js/customize_options.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/addons/website_event_meet/static/src/js/customize_options.js b/addons/website_event_meet/static/src/js/customize_options.js new file mode 100644 index 00000000..4d8ccbd3 --- /dev/null +++ b/addons/website_event_meet/static/src/js/customize_options.js @@ -0,0 +1,69 @@ +odoo.define('website_event_meet.set_customize_options', function (require) { +"use strict"; + +let EventSpecificOptions = require('website_event.set_customize_options').EventSpecificOptions; + +EventSpecificOptions.include({ + xmlDependencies: (EventSpecificOptions.prototype.xmlDependencies || []) + .concat([ + '/website_event_meet/static/src/xml/customize_options.xml', + ]), + + events: _.extend({}, EventSpecificOptions.prototype.events, { + 'change #allow-room-creation': '_onAllowRoomCreationChange', + }), + + start: function () { + this.$allowRoomCreationInput = this.$('#allow-room-creation'); + this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + _onAllowRoomCreationChange: function () { + let checkboxValue = this.$allowRoomCreationInput.is(':checked'); + this._toggleAllowRoomCreation(checkboxValue); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + _getCheckboxFields: function () { + let fields = this._super(); + fields = _.union(fields, ['meeting_room_allow_creation']); + return fields; + }, + + _getCheckboxFieldMatch: function (checkboxField) { + if (checkboxField === 'meeting_room_allow_creation') { + return this.$allowRoomCreationInput; + } + return this._super(checkboxField); + }, + + _initCheckboxCallback: function (rpcData) { + this._super(rpcData); + if (rpcData[0]['meeting_room_allow_creation']) { + let submenuInput = this._getCheckboxFieldMatch('meeting_room_allow_creation'); + submenuInput.attr('checked', 'checked'); + } + }, + + _toggleAllowRoomCreation: async function (val) { + await this._rpc({ + model: this.modelName, + method: 'write', + args: [[this.eventId], { + meeting_room_allow_creation: val + }], + }); + + this._reloadEventPage(); + }, + +}); + +}); |
