1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +02:00

Fix issue processwire/processwire-issues#1010 add support for dependencies to InputfieldPageListSelectMultiple and InputfieldPageAutocomplete

This commit is contained in:
Ryan Cramer
2019-11-05 10:46:56 -05:00
parent ceca16506a
commit c9713f0bc4
4 changed files with 28 additions and 5 deletions

View File

@@ -331,9 +331,26 @@ var InputfieldPageAutocomplete = {
$ol.append($li); $ol.append($li);
InputfieldPageAutocomplete.rebuildInput($ol); InputfieldPageAutocomplete.rebuildInput($ol);
InputfieldPageAutocomplete.triggerChange($ol);
}, },
/**
* Trigger change event
*
* @param $item Any element within the autocomplete Inputfield
*
*/
triggerChange: function($item) {
var $input;
if($item.hasClass('InputfieldPageAutocompleteData')) {
$input = $item;
} else {
if(!$item.hasClass('Inputfield')) $item = $item.closest('.Inputfield');
$input = $item.find('.InputfieldPageAutocompleteData')
}
$input.trigger('change');
},
/** /**
* Rebuild the CSV values present in the hidden input[text] field * Rebuild the CSV values present in the hidden input[text] field
* *
@@ -398,7 +415,8 @@ $(document).ready(function() {
var $ol = $li.parent(); var $ol = $li.parent();
var id = $li.children(".itemValue").text(); var id = $li.children(".itemValue").text();
$li.remove(); $li.remove();
InputfieldPageAutocomplete.rebuildInput($ol); InputfieldPageAutocomplete.rebuildInput($ol);
InputfieldPageAutocomplete.triggerChange($ol);
return false; return false;
}); });

File diff suppressed because one or more lines are too long

View File

@@ -1098,6 +1098,8 @@ function InputfieldDependencies($target) {
consoleLog("Unable to locate field: " + conditionField); consoleLog("Unable to locate field: " + conditionField);
continue; continue;
} }
var $inputfield = $field.closest('.Inputfield');
// value of the dependency field we are checking (if not already populated above) // value of the dependency field we are checking (if not already populated above)
if (value === null) { if (value === null) {
@@ -1123,9 +1125,12 @@ function InputfieldDependencies($target) {
if (typeof value == 'object') { if (typeof value == 'object') {
// object, convert to array // object, convert to array
values = jQuery.makeArray(value); values = jQuery.makeArray(value);
} else if (typeof value == 'array') { } else if(typeof value == 'array') {
// array, already // array, already
values = value; values = value;
} else if(typeof value == "string" && $inputfield.hasClass('InputfieldPage') && value.indexOf(',') > -1 && value.match(/^[,0-9]+$/)) {
// CSV string of page IDs
values = value.split(',');
} else { } else {
// string: single value array // string: single value array
values[0] = value; values[0] = value;

File diff suppressed because one or more lines are too long