diff --git a/src/controllers/BulkEditController.php b/src/controllers/BulkEditController.php index 872f994..3e1550d 100644 --- a/src/controllers/BulkEditController.php +++ b/src/controllers/BulkEditController.php @@ -42,14 +42,6 @@ */ class BulkEditController extends Controller { - - // Protected Properties - // ========================================================================= - - - // Public Methods - // ========================================================================= - /** * Return the file preview for an Asset. * @@ -135,6 +127,8 @@ public function actionGetEditScreen(): Response { $baseEntry = null; $view = \Craft::$app->getView(); +// $baseElements = BulkEdit::$plugin->bulkEdit->getBaseElementForFieldIds($fieldIds); + $modalHtml = $view->renderTemplate('bulkedit/elementactions/BulkEdit/_edit', [ 'fields' => $fieldModels, 'elementIds' => $elementIds, @@ -175,7 +169,7 @@ public function actionSaveContext(): Response $fieldId = $field->id; } } - if (!$fieldId) { + if ($fieldId === null) { throw new \Exception('Failed to locate field'); } $keyedFieldValues[$fieldId] = $value; diff --git a/src/services/BulkEdit.php b/src/services/BulkEdit.php index fd641e1..2befaef 100644 --- a/src/services/BulkEdit.php +++ b/src/services/BulkEdit.php @@ -11,7 +11,11 @@ namespace venveo\bulkedit\services; use Craft; +use craft\base\Field; use craft\elements\actions\Edit; +use craft\elements\Category; +use craft\elements\Entry; +use craft\models\FieldGroup; use craft\records\Element; use craft\records\FieldLayout; use venveo\bulkedit\BulkEdit as Plugin; @@ -59,6 +63,15 @@ public function getFieldLayoutsForElementIds($elementIds) return $layouts; } + public function getBaseElementForFieldIds($fieldIds) { + $elements = []; +// +// foreach($fieldIds as $fieldId) { +// +//// \Craft::$app->elements->getPlaceholderElement() +// } + } + public function getBulkEditContextFromId($id) { return EditContext::findOne($id); } @@ -116,6 +129,15 @@ public function processHistoryItemsForElement($historyItems, \craft\base\Element Craft::info('Saved history item', __METHOD__); } \Craft::$app->elements->saveElement($element, false); + + switch (get_class($element)) { + case Entry::class: + \Craft::$app->entryRevisions->saveVersion($element); + break; + default: + break; + } + Craft::info('Saved element', __METHOD__); $transaction->commit(); return $element;