diff --git a/modules/stic_Custom_View_Conditions/stic_Custom_View_Conditions.php b/modules/stic_Custom_View_Conditions/stic_Custom_View_Conditions.php index 316d61e7aa1..70ce6b5fcb2 100644 --- a/modules/stic_Custom_View_Conditions/stic_Custom_View_Conditions.php +++ b/modules/stic_Custom_View_Conditions/stic_Custom_View_Conditions.php @@ -108,6 +108,11 @@ public function save_lines($post_data, $view_module, $parent, $key = '') $condition->condition_order = ++$j; $condition->name = $parent->name . '-' . $condition->condition_order; $condition->stic_custo233dzations_ida = $parent->id; + if ($condition->value===true) { + $condition->value = 1; + } else if ($condition->value===false) { + $condition->value = 0; + } $condition->save(); } } diff --git a/modules/stic_Custom_Views/processor/js/sticCVUtils.js b/modules/stic_Custom_Views/processor/js/sticCVUtils.js index f41d549b2d8..f2c63e2d247 100644 --- a/modules/stic_Custom_Views/processor/js/sticCVUtils.js +++ b/modules/stic_Custom_Views/processor/js/sticCVUtils.js @@ -268,7 +268,7 @@ var sticCVUtils = class sticCVUtils { static getValue(fieldContent, value_list) { var $elem = fieldContent.$editor; - if (fieldContent.customView.view == "detailview") { + if (fieldContent.customView.view == "detailview" && fieldContent.type != "bool") { $elem = fieldContent.$fieldText; } if ($elem.length == 0 || $elem.get(0).parentNode === null) { @@ -279,6 +279,9 @@ var sticCVUtils = class sticCVUtils { if (fieldContent.type == "relate") { return $elem.attr("data-id-value") + "|" + $elem.text().trim(); } + if (fieldContent.type == "bool") { + return $elem.prop("checked"); + } var text = fieldContent.text(); if ( value_list != undefined && @@ -499,11 +502,11 @@ var sticCVUtils = class sticCVUtils { return false; } - static onChange($elem, callback, alsoInline = false) { + static onChange($elem, callback) { $elem.each(function() { $(this).on("change paste keyup", callback); YAHOO.util.Event.on($(this)[0], "change", callback); - if (!$(this).is(":input") || alsoInline) { + if (!$(this).is(":input")) { var observer = new MutationObserver(callback); observer.observe($(this)[0], { attributes: true, childList: true, subtree: true, characterData: true }); } diff --git a/modules/stic_Custom_Views/processor/js/sticCV_Element_Div.js b/modules/stic_Custom_Views/processor/js/sticCV_Element_Div.js index 722ac9e6eaa..90a405d69ba 100644 --- a/modules/stic_Custom_Views/processor/js/sticCV_Element_Div.js +++ b/modules/stic_Custom_Views/processor/js/sticCV_Element_Div.js @@ -93,4 +93,11 @@ var sticCV_Element_Div = class sticCV_Element_Div { } return false; } + + onChange(callback) { + return sticCVUtils.onChange(this.$element, callback); + } + change() { + return sticCVUtils.change(this.$element, callback); + } }; diff --git a/modules/stic_Custom_Views/processor/js/sticCV_Element_Label.js b/modules/stic_Custom_Views/processor/js/sticCV_Element_Label.js index db78a3cc052..aa09928bf0e 100644 --- a/modules/stic_Custom_Views/processor/js/sticCV_Element_Label.js +++ b/modules/stic_Custom_Views/processor/js/sticCV_Element_Label.js @@ -39,11 +39,4 @@ var sticCV_Element_Label = class sticCV_Element_Label extends sticCV_Element_Div } return super.applyAction(action); } - - onChange(callback, alsoInline = false) { - return sticCVUtils.onChange(this.$element, callback, alsoInline); - } - change() { - return sticCVUtils.change(this.$element, callback); - } }; diff --git a/modules/stic_Custom_Views/processor/js/sticCV_Record_Field_Content.js b/modules/stic_Custom_Views/processor/js/sticCV_Record_Field_Content.js index 01905e8a475..440783b4d39 100644 --- a/modules/stic_Custom_Views/processor/js/sticCV_Record_Field_Content.js +++ b/modules/stic_Custom_Views/processor/js/sticCV_Record_Field_Content.js @@ -217,8 +217,11 @@ var sticCV_Record_Field_Content = class sticCV_Record_Field_Content extends stic } onChange(callback) { - var alsoInline = this.customView.view == "detailview"; - return sticCVUtils.onChange(this.$editor, callback, alsoInline) || super.onChange(callback, alsoInline); + if (this.customView.view == "detailview") { + return this.field.container.onChange(callback); + } else { + return sticCVUtils.onChange(this.$editor, callback) || super.onChange(callback); + } } change() { return sticCVUtils.change(this.$editor) || super.change(); diff --git a/modules/stic_Custom_Views/processor/js/sticCV_View_Record_Base.js b/modules/stic_Custom_Views/processor/js/sticCV_View_Record_Base.js index 83f18ff3513..38c7334a2ea 100644 --- a/modules/stic_Custom_Views/processor/js/sticCV_View_Record_Base.js +++ b/modules/stic_Custom_Views/processor/js/sticCV_View_Record_Base.js @@ -39,8 +39,8 @@ var sticCV_View_Record_Base = class sticCV_View_Record_Base { this._tabs = []; } - field(fieldName) { - if (fieldName in this._fields === false) { + field(fieldName, forceReloadField = false) { + if (forceReloadField || fieldName in this._fields === false) { this._fields[fieldName] = new sticCV_Record_Field(this, fieldName); } return this._fields[fieldName]; @@ -100,7 +100,7 @@ var sticCV_View_Record_Base = class sticCV_View_Record_Base { var self = this; conditions.forEach(condition => { self.field(condition.field).onChange(function() { - self.processCustomization(index); + self.processCustomization(index, false, true); }); }); } @@ -170,8 +170,8 @@ var sticCV_View_Record_Base = class sticCV_View_Record_Base { * value: social_services * } */ - checkCondition(condition) { - return this.field(condition.field).checkCondition(condition); + checkCondition(condition, forceReloadField = false) { + return this.field(condition.field, forceReloadField).checkCondition(condition); } /** @@ -187,12 +187,14 @@ var sticCV_View_Record_Base = class sticCV_View_Record_Base { /** * Process a Customization: Checks all conditions in order to apply all actions */ - processCustomization(index, resetLastResult = false) { + processCustomization(index, resetLastResult = false, forceReloadField = false) { var customization = this.customizations[index]; var value = true; if (Array.isArray(customization.conditions) && customization.conditions.length) { var self = this; - customization.conditions.forEach(condition => (value = value ? self.checkCondition(condition) : value)); + customization.conditions.forEach( + condition => (value = value ? self.checkCondition(condition, forceReloadField) : value) + ); } if (resetLastResult) { customization.lastResult = false;