Add multishop overwrite confirmation for category saves#64
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c9e9ef451
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| renderDetails(response.shops); | ||
| $modal.modal('show'); | ||
| } else { | ||
| $overwriteInput.val('all'); | ||
| $form[0].submit(); |
There was a problem hiding this comment.
Preserve clicked submit button before resubmitting
The submit handler prevents the native submit and later calls form.submit() after the AJAX check. A programmatic submit does not include the original submit button name/value, which AdminController relies on (e.g., submitAddcategoryAndStay vs submitAddcategoryAndBackToParent) to set the save action and redirect. In the “All shops” context this means Save/Save‑and‑Stay can be ignored or defaulted whenever multishop overwrite checking is enabled, because the resubmitted request lacks the submit button field. Capture the submitter (or inject a hidden input) before resubmitting so the controller can detect the intended action.
Useful? React with 👍 / 👎.
Motivation
Overwrite all shops,Fill empty values only(preserve existing per-shop non-empty values), orCancelbefore committing changes across shops.Description
MULTISHOP_OVERWRITE_ALLandMULTISHOP_OVERWRITE_EMPTYand multishop-aware save logic inAdminCategoriesControllervia an overriddenprocessUpdatethat blocks save when differences exist unless an overwrite mode is supplied.ajaxProcessCategoryShopDifferencesand helper methods (shouldCheckMultishopOverwrite,getMultishopTextFields,getMultishopTextFieldLabels,getSubmittedTextFieldValues,getCategoryLangValues,getTextFieldDifferences,restoreNonEmptyTextFields,isTextValueEmpty) to detect per-shop differences and to implement the "fill empty values only" behavior that restores non-empty per-shop values after a save.renderFormand modify the category form template to add a hiddenmultishop_overwriteinput, a confirmation modal, and client-side JS that requests diffs, shows the modal with affected shops/fields, and submits the chosen overwrite mode.bqSQLwhen building thecategory_langselect list for text fields.Testing
Codex Task