Skip to content

Add multishop overwrite confirmation for category saves#64

Open
therampagerado wants to merge 1 commit intocategories-multistore-fields-overwrite-checkfrom
codex/add-warning-for-category-save-conflicts
Open

Add multishop overwrite confirmation for category saves#64
therampagerado wants to merge 1 commit intocategories-multistore-fields-overwrite-checkfrom
codex/add-warning-for-category-save-conflicts

Conversation

@therampagerado
Copy link
Copy Markdown
Owner

Motivation

  • Prevent accidental overwrites of per-shop category text fields when saving a category in the "All shops" multistore context by warning merchants and offering overwrite options.
  • Provide choices to Overwrite all shops, Fill empty values only (preserve existing per-shop non-empty values), or Cancel before committing changes across shops.

Description

  • Add constants MULTISHOP_OVERWRITE_ALL and MULTISHOP_OVERWRITE_EMPTY and multishop-aware save logic in AdminCategoriesController via an overridden processUpdate that blocks save when differences exist unless an overwrite mode is supplied.
  • Add an AJAX handler ajaxProcessCategoryShopDifferences and 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.
  • Expose template variables from renderForm and modify the category form template to add a hidden multishop_overwrite input, a confirmation modal, and client-side JS that requests diffs, shows the modal with affected shops/fields, and submits the chosen overwrite mode.
  • Minor SQL safety improvement using bqSQL when building the category_lang select list for text fields.

Testing

  • No automated tests were run for this change.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +61 to +65
renderDetails(response.shops);
$modal.modal('show');
} else {
$overwriteInput.val('all');
$form[0].submit();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant