Skip to content

Commit

Permalink
Don't do anything special for unpublished drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 11, 2024
1 parent 40c495e commit 4fb9681
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1347,11 +1347,13 @@ public function actionSaveNestedElementForDerivative(): ?Response
// Get the new owner and make sure it's a derivative element,
// and that its canonical element is the nested element's primary owner
$owner = $elementsService->getElementById($this->_newOwnerId, siteId: $element->siteId);
if (
$owner->getIsCanonical() ||
$owner->getCanonicalId() !== $element->getPrimaryOwnerId() ||
!$elementsService->canSave($owner, $user)
) {
if ($owner->getIsCanonical()) {
throw new BadRequestHttpException('The owner element must be a derivative.');
}
if ($owner->getCanonicalId() !== $element->getPrimaryOwnerId()) {
throw new BadRequestHttpException('The canonical owner element must be the primary owner of the nested element.');
}
if (!$elementsService->canSave($owner, $user)) {
throw new ForbiddenHttpException('User not authorized to save the owner element.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/web/assets/cp/src/js/NestedElementManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ Craft.NestedElementManager = Garnish.Base.extend(
// then ensure we're working with a draft and save the nested entry changes to the draft
if (
$element.data('primary-owner-id') ===
$element.data('owner-id')
$element.data('owner-id') &&
!this.elementEditor.settings.isUnpublishedDraft
) {
await slideout.elementEditor.checkForm(true, true);
await this.markAsDirty();
Expand Down

0 comments on commit 4fb9681

Please sign in to comment.