Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update InputfieldRepeater so it knows to publish a field updated by a…

…jax (like a dragged-in image).
  • Loading branch information...
commit 88f809a137ba996ff128383719f624b8b0148008 1 parent 04a25a3
@ryancramerdesign authored
View
1  wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.js
@@ -76,6 +76,7 @@ $(document).ready(function() {
$readyItem.hide();
$readyItem.removeClass('InputfieldRepeaterReady');
$readyItem.find('input.InputfieldRepeaterDisabled').remove(); // allow it to be saved
+ $readyItem.find('input.InputfieldRepeaterPublish').attr('value', 1); // identify it as added
$readyItem.slideDown('fast');
$readyItem.children('.ui-widget-content').effect('highlight', {}, 1000);
return false;
View
14 wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module
@@ -150,6 +150,14 @@ class InputfieldRepeater extends Inputfield {
$wrap = wire('modules')->get('InputfieldFieldset');
$wrap->label = "$label #" . (++$cnt);
+ // add a hidden field that will be populated with a positive value for all visible repeater items
+ // this is so that processInput can see this item should be a published item
+ $f = wire('modules')->get('InputfieldHidden');
+ $f->attr('name', "publish_repeater{$page->id}");
+ $f->attr('class', 'InputfieldRepeaterPublish');
+ $f->attr('value', $page->is(Page::statusHidden) ? 0 : 1);
+ $wrap->add($f);
+
if($page->is(Page::statusHidden)) {
$wrap->class = 'InputfieldRepeaterReady';
$wrap->label .= ' - ' . $this->_('New');
@@ -162,6 +170,7 @@ class InputfieldRepeater extends Inputfield {
$f->attr('value', $page->id);
$wrap->add($f);
+
} else if($page->is(Page::statusUnpublished)) {
$wrap->label .= ' - ' . $this->_('Unpublished');
}
@@ -222,6 +231,7 @@ class InputfieldRepeater extends Inputfield {
$deleteName = "delete_repeater{$page->id}";
$sortName = "sort_repeater{$page->id}";
$disabledName = "_disable_repeater{$page->id}";
+ $publishName = "publish_repeater{$page->id}";
if($input->$deleteName == $page->id) {
$value->remove($page);
@@ -234,6 +244,10 @@ class InputfieldRepeater extends Inputfield {
continue;
}
+ if($input->$publishName > 0 && $page->is(Page::statusHidden)) {
+ $page->removeStatus(Page::statusHidden | Page::statusUnpublished);
+ }
+
$page->sort = (int) $input->$sortName;
if($page->isChanged('sort')) {
$this->message("Sort changed for field {$this->field} page {$page->id}", Notice::debug);
View
2  wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module
@@ -155,7 +155,7 @@ class ProcessPageEdit extends Process {
$this->processInput($this->form);
- foreach($this->page->getChanges() as $change) {
+ foreach(array_unique($this->page->getChanges()) as $change) {
$this->message(sprintf($this->_('Change: %s'), $change)); // Message shown for each changed field
}
Please sign in to comment.
Something went wrong with that request. Please try again.