1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 16:54:44 +02:00

Some minor repeater adjustments to support derived fieldtype in progress

This commit is contained in:
Ryan Cramer
2017-08-25 10:15:10 -04:00
parent c9fca29283
commit fc2b7944a2
4 changed files with 48 additions and 9 deletions

View File

@@ -355,13 +355,19 @@ class FieldtypeRepeater extends Fieldtype implements ConfigurableModule {
// check for nested repeater
foreach($repeaters as $name) {
$repeaterItems = $ownerPage->get($name);
if(!$repeaterItems || !$repeaterItems instanceof PageArray) continue;
foreach($repeaterItems as $nestedOwnerPage) {
// perform recursive check
$hasField = $this->isRepeaterItemValidOnPage($repeaterItem, $nestedOwnerPage);
if($hasField) break;
if(!$repeaterItems) continue;
if($repeaterItems instanceof PageArray) {
foreach($repeaterItems as $nestedOwnerPage) {
// perform recursive check
$hasField = $this->isRepeaterItemValidOnPage($repeaterItem, $nestedOwnerPage);
if($hasField) break;
}
} else if($repeaterItems instanceof RepeaterPage) {
// for single item value (i.e. FieldtypeFieldsetPage)
$hasField = $this->isRepeaterItemValidOnPage($repeaterItem, $repeaterItems);
} else {
continue;
}
if($hasField) break;
}
return $hasField;
@@ -1321,6 +1327,14 @@ class FieldtypeRepeater extends Fieldtype implements ConfigurableModule {
if(!$page->id || !$field->id) return false;
$value = $page->get($field->name);
if($value instanceof RepeaterPage) {
// for FieldsetPage compatibility
$pageArray = $this->getBlankValue($page, $field);
$pageArray->add($value);
$pageArray->resetTrackChanges();
$value = $pageArray;
}
// pages that will be saved
$savePages = array();

View File

@@ -61,6 +61,12 @@
display: none; }
.Inputfields .InputfieldRepeater .InputfieldRepeaterDelete {
display: none; }
.Inputfields .InputfieldRepeater.InputfieldRepeaterSingle > .InputfieldContent > .Inputfields {
margin-bottom: 0; }
.Inputfields .InputfieldRepeater.InputfieldRepeaterSingle > .InputfieldContent > .Inputfields > .InputfieldRepeaterItem {
margin-bottom: 0; }
.Inputfields .InputfieldRepeater.InputfieldRepeaterSingle > .InputfieldContent > .Inputfields > .InputfieldRepeaterItem > .InputfieldHeader {
display: none; }
.InputfieldRepeater .InputfieldWrapper,
.InputfieldRepeater .InputfieldWrapper > .Inputfields {

View File

@@ -579,16 +579,22 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
$this->wire('modules')->get('JqueryUI')->use('vex');
$this->preloadInputfieldAssets();
$min = (int) $this->repeaterMinItems;
$max = (int) $this->repeaterMaxItems;
if($this->field->get('repeaterLoading') == FieldtypeRepeater::loadingOff) {
$this->addClass('InputfieldRepeaterNoAjaxAdd', 'wrapClass');
}
if($this->repeaterMaxItems > 0) {
if($max > 0) {
$this->addClass('InputfieldRepeaterMax', 'wrapClass');
}
if($this->repeaterMinItems > 0) {
if($min > 0) {
$this->addClass('InputfieldRepeaterMin', 'wrapClass');
}
if($this->repeaterDepth > 0) {
if($min === 1 && $max === 1) {
$this->addClass('InputfieldRepeaterSingle', 'wrapClass');
} else if($this->repeaterDepth > 0) {
$this->addClass('InputfieldRepeaterDepth', 'wrapClass');
}
if($this->accordionMode) {

View File

@@ -110,6 +110,19 @@
// delete checkbox
display: none;
}
&.InputfieldRepeaterSingle {
// repeater in single-item mode
> .InputfieldContent > .Inputfields {
margin-bottom: 0;
> .InputfieldRepeaterItem {
margin-bottom: 0;
> .InputfieldHeader {
display: none;
}
}
}
}
}