Source
91
91
* @type {boolean}
92
92
*/
93
93
#is_selecting_typed_reference = false;
94
94
95
95
/**
96
96
* @type {boolean}
97
97
*/
98
98
#is_selected_typed_reference = false;
99
99
100
100
constructor({
101
+
multiselect_id,
101
102
field_name,
102
103
field_value,
103
104
in_type,
104
105
default_prevented = false,
105
106
widget_accepted = false,
106
107
dashboard_accepted = false,
107
108
object_labels,
108
109
params
109
110
}) {
110
111
this.#field_name = field_name;
113
114
this.#default_prevented = default_prevented;
114
115
this.#widget_accepted = widget_accepted;
115
116
this.#dashboard_accepted = dashboard_accepted;
116
117
this.#multiselect_params = params;
117
118
118
119
if ('selectedLimit' in params) {
119
120
this.#selected_limit = params.selectedLimit;
120
121
this.#is_multiple = this.#selected_limit != 1;
121
122
}
122
123
123
-
this.#initField();
124
+
this.#initField(multiselect_id);
124
125
125
126
if (CWidgetBase.FOREIGN_REFERENCE_KEY in field_value) {
126
127
this.#selectTypedReference(field_value[CWidgetBase.FOREIGN_REFERENCE_KEY]);
127
128
}
128
129
}
129
130
130
131
get disabled() {
131
132
return this.#is_disabled;
132
133
}
133
134
135
136
this.#is_disabled = is_disabled;
136
137
137
138
if (!this.#is_disabled) {
138
139
this.#multiselect.multiSelect('enable');
139
140
}
140
141
else {
141
142
this.#multiselect.multiSelect('disable');
142
143
}
143
144
}
144
145
145
-
#initField() {
146
+
#initField(multiselect_id) {
146
147
const has_optional_sources = this.#widget_accepted && (!this.#default_prevented || this.#dashboard_accepted);
147
148
148
-
const $multiselect = jQuery(`#${this.#field_name}${this.#is_multiple ? '_' : ''}`);
149
+
const $multiselect = jQuery(`#${multiselect_id}`);
149
150
150
151
$multiselect[0].dataset.params = JSON.stringify(this.#multiselect_params);
151
152
152
153
this.#multiselect = $multiselect.multiSelect();
153
154
154
155
if (has_optional_sources) {
155
156
this.#multiselect
156
157
.multiSelect('setSuggestListModifier', (entities) => this.#modifySuggestedList(entities));
157
158
158
159
this.#multiselect