diff --git a/wire/core/Page.php b/wire/core/Page.php index 9adf3b3d..06ea2af3 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -184,6 +184,13 @@ class Page extends WireData implements \Countable, WireMatchable { */ const statusOn = 1; + /** + * Reserved status + * #pw-internal + * + */ + const statusReserved = 2; + /** * Indicates page is locked for changes (name: "locked") * @@ -206,6 +213,7 @@ class Page extends WireData implements \Countable, WireMatchable { /** * Page has a globally unique name and no other pages may have the same name + * #pw-internal * */ const statusUnique = 32; @@ -224,8 +232,16 @@ class Page extends WireData implements \Countable, WireMatchable { */ const statusVersions = 128; + /** + * Page might have incomplete data because there were errors when last saved interactively or may be missing required fields + * #pw-internal + * + */ + const statusIncomplete = 256; + /** * Page is temporary. 1+ day old unpublished pages with this status may be automatically deleted (name: "temp"). + * Applies only if this status is combined with statusUnpublished. * #pw-internal * */ @@ -287,11 +303,14 @@ class Page extends WireData implements \Countable, WireMatchable { * */ static protected $statuses = array( + 'reserved' => self::statusReserved, 'locked' => self::statusLocked, 'systemID' => self::statusSystemID, 'system' => self::statusSystem, + 'unique' => self::statusUnique, 'draft' => self::statusDraft, 'versions' => self::statusVersions, + 'incomplete' => self::statusIncomplete, 'temp' => self::statusTemp, 'hidden' => self::statusHidden, 'unpublished' => self::statusUnpublished, @@ -3712,7 +3731,7 @@ class Page extends WireData implements \Countable, WireMatchable { * - `integer|string|array`: Status number(s) or status name(s) to set the current page status (same as $page->status = $value) * @param int|null $status If you specified `true` for first argument, optionally specify status value you want to use (if not the current). * @return int|array|Page If setting status, `$this` is returned. If getting status: current status or array of status names is returned. - * @see Page::addStauts(), Page::removeStatus(), Page::hasStatus() + * @see Page::addStatus(), Page::removeStatus(), Page::hasStatus() * */ public function status($value = false, $status = null) { diff --git a/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module b/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module index d5843faa..2fc1a48e 100644 --- a/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module +++ b/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module @@ -14,6 +14,7 @@ * @property string $noticeUnknown * @property string $noticeLocked * @property string $noticeNoAccess + * @property string $noticeIncomplete * @property string $viewAction One of 'panel', 'modal', 'new', 'this' (see getViewActions method) * @property bool $useBookmarks * @@ -349,6 +350,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod $this->set('noticeUnknown', $this->_("Unknown page")); // Init error: Unknown page $this->set('noticeLocked', $this->_("This page is locked for edits")); // Init error: Page is locked $this->set('noticeNoAccess', $this->_("You don't have access to edit")); // Init error: User doesn't have access + $this->set('noticeIncomplete', $this->_("This page might have one or more incomplete fields (attempt to save or publish for more info)")); // Init error: User doesn't have access $settings = $this->config->pageEdit; if(is_array($settings)) $this->configSettings = array_merge($this->configSettings, $settings); @@ -539,6 +541,8 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod } else { $this->error($this->noticeLocked); // Page locked error } + } else if(!$this->isPost && $this->page->status(Page::statusIncomplete) && !$this->input->get('s')) { + $this->warning($this->noticeIncomplete); } return $this->renderEdit(); @@ -582,7 +586,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod $config = $this->config; $file = $config->debug ? 'dropdown.js' : 'dropdown.min.js'; - $config->scripts->add($config->urls->InputfieldSubmit . $file); + $config->scripts->add($config->urls('InputfieldSubmit') . $file); $input = ""; $out = str_replace('', "$input", $out); @@ -915,7 +919,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod $submit2->attr('id', 'submit_save_unpublished'); $submit2->showInHeader(); $submit2->setSecondary(); - if($this->session->clientWidth > 900) { + if($this->session->get('clientWidth') > 900) { $submit2->attr('value', $this->_('Save + Keep Unpublished')); // Button: save unpublished } else { $submit2->attr('value', $saveLabel); // Button: save unpublished @@ -1908,6 +1912,17 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod foreach($this->notices as $notice) { if($notice instanceof NoticeError) $formErrors++; } + + // if any Inputfields threw errors during processing, give the page an 'incomplete' status + // so that it can later be identified the page may be missing something + if($formErrors && count($this->form->getErrors())) { + // add incomplete status when form had errors + $this->page->addStatus(Page::statusIncomplete); + } else if($this->page->hasStatus(Page::statusIncomplete)) { + // if no errors, remove incomplete status + $this->page->removeStatus(Page::statusIncomplete); + $this->message($this->_('Removed incomplete status because no errors reported during save')); + } $isUnpublished = $this->page->hasStatus(Page::statusUnpublished); diff --git a/wire/modules/Process/ProcessPageList/ProcessPageListActions.php b/wire/modules/Process/ProcessPageList/ProcessPageListActions.php index e0e20788..6105a848 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageListActions.php +++ b/wire/modules/Process/ProcessPageList/ProcessPageListActions.php @@ -125,12 +125,14 @@ class ProcessPageListActions extends Wire { if(!$locked && !$trash && !$noSettings && $statusEditable) { if($page->publishable()) { if($page->isUnpublished()) { - $extras['pub'] = array( - 'cn' => 'Publish', - 'name' => $this->actionLabels['pub'], - 'url' => "$adminUrl?action=pub&id=$page->id", - 'ajax' => true, - ); + if(!$page->hasStatus(Page::statusIncomplete)) { + $extras['pub'] = array( + 'cn' => 'Publish', + 'name' => $this->actionLabels['pub'], + 'url' => "$adminUrl?action=pub&id=$page->id", + 'ajax' => true, + ); + } } else if(!$page->template->noUnpublish) { $extras['unpub'] = array( 'cn' => 'Unpublish', @@ -282,7 +284,7 @@ class ProcessPageListActions extends Wire { } if($success) try { if($needSave) $success = $page->save(); - if(!$success) $message = sprintf($this->_('Error executing: %s', $message)); + if(!$success) $message = sprintf($this->_('Error executing: %s'), $message); } catch(\Exception $e) { $success = false; $message = $e->getMessage(); diff --git a/wire/modules/Process/ProcessPageList/ProcessPageListRenderJSON.php b/wire/modules/Process/ProcessPageList/ProcessPageListRenderJSON.php index c3d20e9a..e6de93b5 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageListRenderJSON.php +++ b/wire/modules/Process/ProcessPageList/ProcessPageListRenderJSON.php @@ -81,6 +81,7 @@ class ProcessPageListRenderJSON extends ProcessPageListRender { if($page->hasStatus(Page::statusTemp)) $icons[] = 'bolt'; if($page->hasStatus(Page::statusLocked)) $icons[] = 'lock'; if($page->hasStatus(Page::statusDraft)) $icons[] = 'paperclip'; + if($page->hasStatus(Page::statusIncomplete)) $icons[] = 'exclamation-triangle'; $numChildren = $this->numChildren($page, 1); $numTotal = strpos($this->qtyType, 'total') !== false ? $page->numDescendants : $numChildren; }