[IMP] survey_event_registration_generation: manage multiple training products fields in survey
This commit is contained in:
@@ -30,22 +30,41 @@ SurveyFormWidget.include({
|
||||
return result;
|
||||
},
|
||||
|
||||
_onChangeChoiceItem: function (event) {
|
||||
var event_select = $('select[data-question-type="event"]:visible')
|
||||
|
||||
_onChangeChoiceItem: function (event) {
|
||||
|
||||
//Check if event product selection change
|
||||
if ($(event.currentTarget).data('questionType') == 'event_product') {
|
||||
//Check if event selection visible
|
||||
if (event_select) {
|
||||
var question_type = $(event.currentTarget).data('questionType');
|
||||
if (question_type == 'event_product' || question_type == 'multiple_event_products') {
|
||||
|
||||
//Current question (for event products) id
|
||||
var event_product_question_id = event.currentTarget.name;
|
||||
|
||||
//find event selector concerned by this event product question
|
||||
var event_selects = $('select[data-question-type="event"][data-event-product-question-id="'+event_product_question_id+'"]:visible');
|
||||
|
||||
//find all event products selected in this question
|
||||
var event_product_ids = [];
|
||||
if (question_type == 'multiple_event_products') {
|
||||
// find event products selected in case of multiple event products question
|
||||
event_product_ids = $('input[name="'+event_product_question_id+'"]:checked').map(function() {
|
||||
return parseInt($(this).attr("value"));
|
||||
}).get();
|
||||
} else {
|
||||
// find event products selected in case of simple event product question
|
||||
event_product_ids = [parseInt($(event.currentTarget).find(":selected").val())];
|
||||
}
|
||||
|
||||
// populate concerned events selectors
|
||||
event_selects.each(function( index ) {
|
||||
var event_select = $(this);
|
||||
|
||||
//Disable event selection
|
||||
event_select.prop('disabled', 'disabled');
|
||||
|
||||
//Get event product id
|
||||
var eventProductId = parseInt($(event.currentTarget).find(":selected").val())
|
||||
|
||||
//Ajax : get new events
|
||||
ajax.jsonRpc('/survey_event/get_events_from_product', 'call', {
|
||||
'product_id': eventProductId,
|
||||
'product_ids': event_product_ids,
|
||||
'only_visible_in_survey': event_select.data('only-visible-in-survey') === "True"
|
||||
}).then((new_events) => {
|
||||
// Delete old events
|
||||
$(event_select).find('option').remove()
|
||||
@@ -60,8 +79,9 @@ SurveyFormWidget.include({
|
||||
//Enable event selection
|
||||
event_select.prop('disabled', false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user