1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00

Fix issue where using crop/resize tools on an image within a NESTED repeater item would not save the changes after clicking the Save button in the page editor.

This commit is contained in:
Ryan Cramer
2019-06-04 09:30:35 -04:00
parent ad2f60b544
commit a88c6a49c7
7 changed files with 54 additions and 17 deletions

View File

@@ -361,10 +361,11 @@ function InputfieldRepeater($) {
}
// determine which page IDs we don't accept for new items (because we already have them rendered)
var $unpublishedItems = $inputfields.find('.InputfieldRepeaterUnpublished, .InputfieldRepeaterWasUnpublished'); // :not(.InputfieldRepeaterMinItem)');
if($unpublishedItems.length) {
// var $unpublishedItems = $inputfields.find('.InputfieldRepeaterUnpublished, .InputfieldRepeaterWasUnpublished'); // :not(.InputfieldRepeaterMinItem)');
var $existingItems = $inputfields.find('.InputfieldRepeaterItem:not(.InputfieldRepeaterNewItem)');
if($existingItems.length) {
ajaxURL += '&repeater_not=';
$unpublishedItems.each(function() {
$existingItems.each(function() {
ajaxURL += $(this).attr('data-page') + ',';
});
}

File diff suppressed because one or more lines are too long

View File

@@ -208,6 +208,18 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
if($page) {}
return 1;
}
/**
* Get the name of the repeater item type (if used)
*
* @param Page|int $type
* @return string
*
*/
protected function getRepeaterItemTypeName($type) {
if($type) {} // ignore
return '';
}
/**
* Preload all assets used by Inputfields of this type
@@ -386,9 +398,13 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
} else {
$wrap->label = "$label " . (++$cnt);
}
$itemType = $this->getRepeaterItemType($page);
$itemTypeName = $this->getRepeaterItemTypeName($itemType);
$wrap->name = "repeater_item_{$page->id}";
$wrap->wrapAttr('data-page', $page->id);
$wrap->wrapAttr('data-type', $this->getRepeaterItemType($page));
$wrap->wrapAttr('data-type', $itemType);
$wrap->wrapAttr('data-typeName', $itemTypeName);
$wrap->wrapAttr('data-fnsx', "_repeater$page->id"); // fnsx=field name suffix
//$wrap->wrapAttr('data-editorPage', $this->page->id);
//$wrap->wrapAttr('data-parentPage', $page->parent->id);
$wrap->wrapAttr('data-editUrl', $page->editUrl()); // if needed by any Inputfields within like InputfieldFile/InputfieldImage
@@ -647,7 +663,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
'removeAll' => $this->_x('Delete all items?', 'repeater-item-action'),
'toggle' => $this->_x('Click to turn item on/off, or double-click to open/collapse all items', 'repeater-item-action'),
'clone' => $this->_x('Clone this item?', 'repeater-item-action'),
'settings' => $this->_('Show settings?', 'repeater-item-action'),
'settings' => $this->_x('Show settings?', 'repeater-item-action'),
'openAll' => $this->_x('Open all items?', 'repeater-item-action'),
'collapseAll' => $this->_x('Collapse all items?', 'repeater-item-action'),
'disabledMinMax' => $this->_('This action is disabled per min and/or max item settings.')

View File

@@ -24,6 +24,7 @@
* @property string $customOptions
* @property array $imageFields
* @property int $assetPageID
* @property string $configName
*
*
*/

View File

@@ -89,7 +89,15 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
* @var array|Field[]
*
*/
protected $fields = array();
protected $fields = array();
/**
* Field name suffix, applicable only when field or fields (above) is also set, in specific situations like repeaters
*
* @var string
*
*/
protected $fnsx = '';
/**
* Substituted master page (deprecated)
@@ -394,6 +402,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
if($this->page) {
$field = $this->input->get('field');
$fields = $this->input->get('fields');
if($this->input->get('fnsx') !== null) $this->fnsx = $this->input->get->fieldName('fnsx');
if($field && !$fields) $fields = $field;
if($fields) {
$fields = explode(',', $fields);
@@ -772,6 +781,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
'language' => $this->requestLanguage,
'field' => '',
'fields' => '',
'fnsx' => $this->fnsx,
'uploadOnlyMode' => '',
);
if($this->field) {
@@ -785,12 +795,11 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
$uploadOnlyMode = (int) $this->input->get('uploadOnlyMode');
if($uploadOnlyMode && !$this->config->ajax) $defaults['uploadOnlyMode'] = $uploadOnlyMode;
$options = array_merge($defaults, $options);
$url = './?';
$qs = array();
foreach($options as $name => $value) {
if(empty($value)) continue;
$url .= "&$name=$value";
if(!empty($value)) $qs[] = "$name=$value";
}
return $url;
return './?' . implode('&', $qs);
}
/**
@@ -826,11 +835,18 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
if($this->field) {
// focus in on a specific field or fields
$form->addClass('ProcessPageEditSingleField');
$form->addClass('ProcessPageEditSingleField');
foreach($this->fields as $field) {
foreach($this->page->getInputfields($field->name) as $inputfield) {
if(!$this->page->editable($inputfield->name, false)) continue;
$options = array(
'contextStr' => $this->fnsx,
'fieldName' => $field->name,
'namespace' => '',
'flat' => true,
);
foreach($this->page->getInputfields($options) as $inputfield) {
if(!$this->page->editable($field->name, false)) continue;
$skipCollapsed = array(
Inputfield::collapsedHidden,
Inputfield::collapsedNoLocked,

View File

@@ -1459,18 +1459,21 @@ function InputfieldRequirements($target) {
*
*/
function InputfieldReloadEvent(event, extraData) {
console.log('InputfieldReloadEvent ' + $(this).attr('id'));
var $t = $(this);
var $form = $t.closest('form');
var fieldName = $t.attr('id').replace('wrap_Inputfield_', '');
var fnsx = ''; // field name suffix
var url = $form.attr('action');
if(fieldName.indexOf('_repeater') > 0) {
var pageID = $t.closest('.InputfieldRepeaterItem').attr('data-page');
var $repeaterItem = $t.closest('.InputfieldRepeaterItem');
var pageID = $repeaterItem.attr('data-page');
url = url.replace(/\?id=\d+/, '?id=' + pageID);
fnsx = $repeaterItem.attr('data-fnsx');
fieldName = fieldName.replace(/_repeater\d+$/, '');
}
url += url.indexOf('?') > -1 ? '&' : '?';
url += 'field=' + fieldName + '&reloadInputfieldAjax=' + fieldName;
if(fnsx.length) url += '&fnsx=' + fnsx;
if(typeof extraData != "undefined") {
if(typeof extraData['queryString'] != "undefined") {
url += '&' + extraData['queryString'];

File diff suppressed because one or more lines are too long