Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirm dialog to group Remove button #1208

Merged
merged 10 commits into from
Dec 31, 2018

Conversation

slaFFik
Copy link
Member

@slaFFik slaFFik commented Dec 30, 2018

Fixes #529.

Changes proposed in this pull request

  • added new option remove_confirm to the custom options list for group field type; false by default - so all the current installations will not see any difference, should be enabled to be used

  • added group_remove_confirm - new translatable string to JS-based l10n list to display the test using JS

  • display a default browser confirm() modal window and a custom (filterable) text from above when a user tries to delete a group of fields. If the user agrees - process further with the old logic, if denied - nothing happens.

  • Documentation should be updated here.

@slaFFik slaFFik self-assigned this Dec 30, 2018
Copy link
Member

@jtsternberg jtsternberg left a comment

Choose a reason for hiding this comment

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

A few things I would like to see:

  • Use the remove_confirm field default as a string (just like the 'remove_button' above it, and then set that string in the data-confirm attribute, and use THAT for the confirmation dialog text. That allows users to define the confirmation text via field configuration instead of filtering the text via the cmb2_localized_data filter.
  • Use an empty string for the data-confirm attribute to indicate it should not be used. (instead of "no")
  • Follow the JS convention -- one var per line, per variable assignment.

js/cmb2.js Outdated Show resolved Hide resolved
1) make confirmation ON by default
2) confirmation text is now configurable when defining the group field
3) remove newly added string from l10n JS object (not used anymore)
4) support a case when group field renderer was redefined and doesn't have `data-confirm` attribute at all
5) fix tests
@slaFFik
Copy link
Member Author

slaFFik commented Dec 31, 2018

@jtsternberg Those changes were implemented.

I'm not sure what is a procedure in this project in this case (should I dismiss your initial review, or wait till you check your GH notifications for new commits etc) - so I'm just pinging you, just in case.

@jtsternberg jtsternberg merged commit 7c358b7 into develop Dec 31, 2018
jtsternberg added a commit that referenced this pull request Dec 31, 2018
@jtsternberg
Copy link
Member

I just updated the docs.

@jtsternberg jtsternberg deleted the feature/529-group-confirm-delete branch December 31, 2018 16:34
@jtsternberg jtsternberg self-requested a review December 31, 2018 16:34
lipemat added a commit to lipemat/CMB2 that referenced this pull request Jan 4, 2019
* upstream/develop:
  make use of phpunit 6.5 for PHP 5.6.
  fix failing test for group removal confirmation message.
  Add props for CMB2#1208
  Move the remove_confirm option to the example functions and leave default empty (to not break back-compat)
  Oops, fix typeof yoda check
  Fix removal confirmation in tests
  Simplify removal confirmation check
  Update typeof checks to use yoda
  make remove confirmation a bit more succinct
  Cannot use empty on an operation on older versions of php
  see CMB2#529 - improvements as per PR review:
  see CMB2#529 - fix tests with a default confirm value in DOM equal to no.
  fix CMB2#529 - Add confirm dialog to group Remove button.
  Add props for CMB2#1206
  Add php tests npm script
  Add grunt watch npm script
  Add props for CMB2#1204
  Ignore composer vendor dir
  fix CMB2#1205 - Package.json: fix the need of global (old) grunt.
  fix 1023 - Update PHPUnit version in composer.json.
  Add props for CMB2#1200
  Remove superfluous method definitions
  Add develop class suffix to init.php class
  Bump version for hotfix release
  Fix issue when wp.data does not have core/editor. Check it first. Fixes CMB2#1197
  Update version to 2.5.0
  Update changelog
  Make install-wp-tests.sh executable
  Update tests to pass
  Add cmb_init_pickers and cmb_init_code_editors events for allowing just-in-time configuration for pickers/editors
  Make CMB2.getFields/CMB2.getFields more robust, allowing a filter callback, and specifying by field id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants