- 1 :
import { EMPTY_STRING } from '../../../../mel_metapage/js/lib/constants/constants.js';
- 2 :
import {
- 3 :
SELECTOR_CHECKBOX_CHANNEL,
- 4 :
SELECTOR_DIV_CHANNEL,
- 5 :
SELECTOR_DIV_WSP,
- 6 :
} from '../consts.js';
- 7 :
import { ACheckBox } from './abstract/ACheckBox.js';
- 8 :
export { ChannelPart };
- 9 :
- 10 :
/**
- 11 :
* Classes lié au choix des canaux lié à la visio si un plugin compatible existe
- 12 :
* @module Visio/Parts/Channel
- 13 :
* @local ChannelPart
- 14 :
*/
- 15 :
- 16 :
/**
- 17 :
* @class
- 18 :
* @classdesc Récupère le champs qui correspond à l'état de la checkbox
- 19 :
* @extends ACheckBox
- 20 :
* @frommodule Visio/Abstract/Checkbox
- 21 :
*/
- 22 :
class ChannelPart extends ACheckBox {
- 23 :
constructor() {
- 24 :
super(SELECTOR_CHECKBOX_CHANNEL);
- 25 :
this._init()._setup()._main();
- 26 :
}
- 27 :
- 28 :
/**
- 29 :
* @private
- 30 :
* @returns
- 31 :
*/
- 32 :
_init() {
- 33 :
/**
- 34 :
* Champ qui correspond à l'état de la checkbox
- 35 :
* @type {external:jQuery}
- 36 :
* @readonly
- 37 :
* @member
- 38 :
*/
- 39 :
this.$field = null;
- 40 :
- 41 :
return this;
- 42 :
}
- 43 :
- 44 :
/**
- 45 :
* @private
- 46 :
* @returns
- 47 :
*/
- 48 :
_setup() {
- 49 :
Object.defineProperty(this, '$field', {
- 50 :
get: () =>
- 51 :
this.is_checked()
- 52 :
? $(`${SELECTOR_DIV_WSP} select`)
- 53 :
: $(`${SELECTOR_DIV_CHANNEL} select`),
- 54 :
});
- 55 :
- 56 :
return this;
- 57 :
}
- 58 :
- 59 :
/**
- 60 :
* @private
- 61 :
*/
- 62 :
_main() {
- 63 :
this._p_on_change.push(this._on_checkbox_change.bind(this));
- 64 :
this._p_on_change.call(this.is_checked());
- 65 :
- 66 :
//Gestion des champs si les plugins n'éxistent pas
- 67 :
if (
- 68 :
rcmail.env['visio.has_channel'] !== true ||
- 69 :
rcmail.env['visio.has_wsp'] !== true
- 70 :
) {
- 71 :
this._p_$checkbox.parent().hide();
- 72 :
- 73 :
if (rcmail.env['visio.has_channel'] !== true) {
- 74 :
$(SELECTOR_DIV_CHANNEL).remove();
- 75 :
this._p_$checkbox.prop('checked', true);
- 76 :
$(SELECTOR_DIV_WSP)
- 77 :
.css('display', EMPTY_STRING)
- 78 :
.find('.title-conf-item')
- 79 :
.text('Attacher à un espace de travail ?')
- 80 :
.parent()
- 81 :
.find('select')
- 82 :
.prepend('<option value="" selected>Ne pas attacher</option>');
- 83 :
}
- 84 :
- 85 :
if (rcmail.env['visio.has_wsp'] !== true) {
- 86 :
this._p_$checkbox.prop('checked', false);
- 87 :
$(SELECTOR_DIV_WSP).remove();
- 88 :
}
- 89 :
- 90 :
try {
- 91 :
this.value();
- 92 :
} catch (error) {
- 93 :
this.value = () => EMPTY_STRING;
- 94 :
}
- 95 :
}
- 96 :
}
- 97 :
- 98 :
/**
- 99 :
* Action à faire lorsque la checkbox change d'état
- 100 :
* @param {!boolean} state
- 101 :
* @package
- 102 :
*/
- 103 :
_on_checkbox_change(state) {
- 104 :
if (state) {
- 105 :
$(SELECTOR_DIV_WSP).show();
- 106 :
$(SELECTOR_DIV_CHANNEL).hide();
- 107 :
} else {
- 108 :
$(SELECTOR_DIV_WSP).hide();
- 109 :
$(SELECTOR_DIV_CHANNEL).show();
- 110 :
}
- 111 :
}
- 112 :
- 113 :
/**
- 114 :
* Désactive les champs
- 115 :
* @override
- 116 :
*/
- 117 :
disable() {
- 118 :
super.disable();
- 119 :
this._p_disable(this.$field);
- 120 :
}
- 121 :
- 122 :
/**
- 123 :
* Active les champs
- 124 :
* @override
- 125 :
*/
- 126 :
enable() {
- 127 :
super.enable();
- 128 :
this._p_enable(this.$field);
- 129 :
}
- 130 :
- 131 :
/**
- 132 :
* Récupère la valeur du champ
- 133 :
* @override
- 134 :
* @returns {string}
- 135 :
*/
- 136 :
value() {
- 137 :
return this.$field?.val?.() || EMPTY_STRING;
- 138 :
}
- 139 :
}