mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 00:37:02 +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:
@@ -361,10 +361,11 @@ function InputfieldRepeater($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// determine which page IDs we don't accept for new items (because we already have them rendered)
|
// 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)');
|
// var $unpublishedItems = $inputfields.find('.InputfieldRepeaterUnpublished, .InputfieldRepeaterWasUnpublished'); // :not(.InputfieldRepeaterMinItem)');
|
||||||
if($unpublishedItems.length) {
|
var $existingItems = $inputfields.find('.InputfieldRepeaterItem:not(.InputfieldRepeaterNewItem)');
|
||||||
|
if($existingItems.length) {
|
||||||
ajaxURL += '&repeater_not=';
|
ajaxURL += '&repeater_not=';
|
||||||
$unpublishedItems.each(function() {
|
$existingItems.each(function() {
|
||||||
ajaxURL += $(this).attr('data-page') + ',';
|
ajaxURL += $(this).attr('data-page') + ',';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -209,6 +209,18 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
|
|||||||
return 1;
|
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
|
* Preload all assets used by Inputfields of this type
|
||||||
*
|
*
|
||||||
@@ -386,9 +398,13 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
|
|||||||
} else {
|
} else {
|
||||||
$wrap->label = "$label " . (++$cnt);
|
$wrap->label = "$label " . (++$cnt);
|
||||||
}
|
}
|
||||||
|
$itemType = $this->getRepeaterItemType($page);
|
||||||
|
$itemTypeName = $this->getRepeaterItemTypeName($itemType);
|
||||||
$wrap->name = "repeater_item_{$page->id}";
|
$wrap->name = "repeater_item_{$page->id}";
|
||||||
$wrap->wrapAttr('data-page', $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-editorPage', $this->page->id);
|
||||||
//$wrap->wrapAttr('data-parentPage', $page->parent->id);
|
//$wrap->wrapAttr('data-parentPage', $page->parent->id);
|
||||||
$wrap->wrapAttr('data-editUrl', $page->editUrl()); // if needed by any Inputfields within like InputfieldFile/InputfieldImage
|
$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'),
|
'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'),
|
'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'),
|
'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'),
|
'openAll' => $this->_x('Open all items?', 'repeater-item-action'),
|
||||||
'collapseAll' => $this->_x('Collapse 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.')
|
'disabledMinMax' => $this->_('This action is disabled per min and/or max item settings.')
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
* @property string $customOptions
|
* @property string $customOptions
|
||||||
* @property array $imageFields
|
* @property array $imageFields
|
||||||
* @property int $assetPageID
|
* @property int $assetPageID
|
||||||
|
* @property string $configName
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@@ -91,6 +91,14 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
*/
|
*/
|
||||||
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)
|
* Substituted master page (deprecated)
|
||||||
*
|
*
|
||||||
@@ -394,6 +402,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
if($this->page) {
|
if($this->page) {
|
||||||
$field = $this->input->get('field');
|
$field = $this->input->get('field');
|
||||||
$fields = $this->input->get('fields');
|
$fields = $this->input->get('fields');
|
||||||
|
if($this->input->get('fnsx') !== null) $this->fnsx = $this->input->get->fieldName('fnsx');
|
||||||
if($field && !$fields) $fields = $field;
|
if($field && !$fields) $fields = $field;
|
||||||
if($fields) {
|
if($fields) {
|
||||||
$fields = explode(',', $fields);
|
$fields = explode(',', $fields);
|
||||||
@@ -772,6 +781,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
'language' => $this->requestLanguage,
|
'language' => $this->requestLanguage,
|
||||||
'field' => '',
|
'field' => '',
|
||||||
'fields' => '',
|
'fields' => '',
|
||||||
|
'fnsx' => $this->fnsx,
|
||||||
'uploadOnlyMode' => '',
|
'uploadOnlyMode' => '',
|
||||||
);
|
);
|
||||||
if($this->field) {
|
if($this->field) {
|
||||||
@@ -785,12 +795,11 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
$uploadOnlyMode = (int) $this->input->get('uploadOnlyMode');
|
$uploadOnlyMode = (int) $this->input->get('uploadOnlyMode');
|
||||||
if($uploadOnlyMode && !$this->config->ajax) $defaults['uploadOnlyMode'] = $uploadOnlyMode;
|
if($uploadOnlyMode && !$this->config->ajax) $defaults['uploadOnlyMode'] = $uploadOnlyMode;
|
||||||
$options = array_merge($defaults, $options);
|
$options = array_merge($defaults, $options);
|
||||||
$url = './?';
|
$qs = array();
|
||||||
foreach($options as $name => $value) {
|
foreach($options as $name => $value) {
|
||||||
if(empty($value)) continue;
|
if(!empty($value)) $qs[] = "$name=$value";
|
||||||
$url .= "&$name=$value";
|
|
||||||
}
|
}
|
||||||
return $url;
|
return './?' . implode('&', $qs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -828,9 +837,16 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
|||||||
// focus in on a specific field or fields
|
// focus in on a specific field or fields
|
||||||
$form->addClass('ProcessPageEditSingleField');
|
$form->addClass('ProcessPageEditSingleField');
|
||||||
|
|
||||||
|
|
||||||
foreach($this->fields as $field) {
|
foreach($this->fields as $field) {
|
||||||
foreach($this->page->getInputfields($field->name) as $inputfield) {
|
$options = array(
|
||||||
if(!$this->page->editable($inputfield->name, false)) continue;
|
'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(
|
$skipCollapsed = array(
|
||||||
Inputfield::collapsedHidden,
|
Inputfield::collapsedHidden,
|
||||||
Inputfield::collapsedNoLocked,
|
Inputfield::collapsedNoLocked,
|
||||||
|
@@ -1459,18 +1459,21 @@ function InputfieldRequirements($target) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function InputfieldReloadEvent(event, extraData) {
|
function InputfieldReloadEvent(event, extraData) {
|
||||||
console.log('InputfieldReloadEvent ' + $(this).attr('id'));
|
|
||||||
var $t = $(this);
|
var $t = $(this);
|
||||||
var $form = $t.closest('form');
|
var $form = $t.closest('form');
|
||||||
var fieldName = $t.attr('id').replace('wrap_Inputfield_', '');
|
var fieldName = $t.attr('id').replace('wrap_Inputfield_', '');
|
||||||
|
var fnsx = ''; // field name suffix
|
||||||
var url = $form.attr('action');
|
var url = $form.attr('action');
|
||||||
if(fieldName.indexOf('_repeater') > 0) {
|
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);
|
url = url.replace(/\?id=\d+/, '?id=' + pageID);
|
||||||
|
fnsx = $repeaterItem.attr('data-fnsx');
|
||||||
fieldName = fieldName.replace(/_repeater\d+$/, '');
|
fieldName = fieldName.replace(/_repeater\d+$/, '');
|
||||||
}
|
}
|
||||||
url += url.indexOf('?') > -1 ? '&' : '?';
|
url += url.indexOf('?') > -1 ? '&' : '?';
|
||||||
url += 'field=' + fieldName + '&reloadInputfieldAjax=' + fieldName;
|
url += 'field=' + fieldName + '&reloadInputfieldAjax=' + fieldName;
|
||||||
|
if(fnsx.length) url += '&fnsx=' + fnsx;
|
||||||
if(typeof extraData != "undefined") {
|
if(typeof extraData != "undefined") {
|
||||||
if(typeof extraData['queryString'] != "undefined") {
|
if(typeof extraData['queryString'] != "undefined") {
|
||||||
url += '&' + extraData['queryString'];
|
url += '&' + extraData['queryString'];
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user