From fe2ac973d825b3488646d4f481636afa240af617 Mon Sep 17 00:00:00 2001 From: brunonzanini <98592514+brunonzanini@users.noreply.github.com> Date: Thu, 17 Feb 2022 09:40:32 -0300 Subject: [PATCH 1/5] Add Ids to forms to be used in main.js Added Ids to form manual and form settings; Added Ids to Mailrelay auto sync and for the Mailrelay Groups to be able to hide the groups if the auto-sync is disabled. --- src/inc/class-mailrelaypages.php | 39 +++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/inc/class-mailrelaypages.php b/src/inc/class-mailrelaypages.php index 43fb4b7..120267a 100644 --- a/src/inc/class-mailrelaypages.php +++ b/src/inc/class-mailrelaypages.php @@ -106,7 +106,7 @@ public function render_admin_page() { settings_errors(); ?> -
+ 'return check_form();' ); @@ -156,9 +156,14 @@ public function render_admin_page() { settings_errors(); ?> - + +
+ +
+
+ +
'return check_form();' ); $submit_text = __( 'Save', 'mailrelay' ); submit_button( $submit_text, 'primary', 'submit-settings', true, $attributes ); @@ -228,16 +233,6 @@ public function setup_settings_page_fields() { 'settings_page_setting_section'// section ); - $link = 'javascript:window.location.href=window.location.href'; - add_settings_field( - 'groups', // id - /* translators: %s link */ - sprintf( __( 'Groups that you want to automatically syncronize
(refresh groups)', 'mailrelay' ), $link ), // title - array( $this, 'groups_callback' ), // callback - 'mailrelay-settings-page', // page - 'settings_page_setting_section' // section - ); - add_settings_field( 'action', // id null, // title @@ -248,6 +243,24 @@ public function setup_settings_page_fields() { 'class' => 'hidden', ) ); + + add_settings_section( + 'settings_page_setting_section2', // id + '', // title + array( $this, 'settings_page_section_info' ), // callback + 'mailrelay-settings-page2' // page + ); + + $link = 'javascript:window.location.href=window.location.href'; + add_settings_field( + 'groups', // id + /* translators: %s link */ + sprintf( __( 'Groups that you want to automatically syncronize
(refresh groups)', 'mailrelay' ), $link ), // title + array( $this, 'groups_callback' ), // callback + 'mailrelay-settings-page2', // page + 'settings_page_setting_section2' // section + ); + } public function settings_page_section_info() { } From 1dab0d5d6c912682c7c176b8df787e0d76605467 Mon Sep 17 00:00:00 2001 From: brunonzanini <98592514+brunonzanini@users.noreply.github.com> Date: Thu, 17 Feb 2022 09:55:30 -0300 Subject: [PATCH 2/5] Add to test if Groups are empty before form submit Show or hide Groups if Auto-Sync is enabled or disabled in Settings Tab; Alert the user if he tries to submit a form without selecting a group in Settings Tab and in Manual Tab; --- src/js/main.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/js/main.js diff --git a/src/js/main.js b/src/js/main.js new file mode 100644 index 0000000..a9bcf0d --- /dev/null +++ b/src/js/main.js @@ -0,0 +1,35 @@ +jQuery( document ).ready(function() { + if ( false == jQuery( '#mailrelay_auto_sync' ).is( ':checked' ) ) { + jQuery( '#mailrelay_groups' ).hide() + } + + jQuery( '#mailrelay_auto_sync' ).on('change', function() { + jQuery( '#mailrelay_groups' ).toggle(); + }); + + jQuery( "#manual-form" ).submit(function() { + if (jQuery( '#mailrelay_auto_sync' ).is( ':checked' )) { + + if ( 0 == jQuery.trim( jQuery( '#mailrelay_auto_sync_groups' ).val()).length ) { + alert( 'Please select at least on group' ); + return false; + } + } + else { + return true; + } + }); + + jQuery( "#manual-sync" ).submit(function() { + + if ( 0 == jQuery.trim( jQuery( '#mailrelay_group' ).val()).length ) { + alert( 'Please select at least on group' ); + return false; + } + + else { + return true; + } + }); + +}); From f7f392ea6e29edc4f5dbc1bf606db4fda4a6b26f Mon Sep 17 00:00:00 2001 From: brunonzanini <98592514+brunonzanini@users.noreply.github.com> Date: Thu, 17 Feb 2022 10:05:29 -0300 Subject: [PATCH 3/5] Unreleased for version 2.0.3 --- src/readme.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/readme.txt b/src/readme.txt index 028cd0c..7a28c01 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -38,6 +38,11 @@ Once this data is successfully saved you can run the user sync. == Changelog == += UNREALESED = + +- Add main.js file +- Add checks to alert the user if he tries to submit without selection a Group + = 2.0.2 = *Release Date - 08 Feb 2022* From 202701c0f5ec0e23dda399cdbd06ae16031c5265 Mon Sep 17 00:00:00 2001 From: brunonzanini <98592514+brunonzanini@users.noreply.github.com> Date: Thu, 17 Feb 2022 10:08:47 -0300 Subject: [PATCH 4/5] Unreleased version 2.0.3 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc4f45f..78d93b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## UNRELEASED - 2022-02-17 + +### Added +- /js/main.js file +- Alert the user if he tries to submit Manual Sync or Settings Form without selection a Group + ## [2.0.2] - 2022-02-08 ### Fixed @@ -40,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add German translation +[unrealeased]: https://github.com/mailrelay/wordpress/compare/v2.0.1...unreleased [2.0.2]: https://github.com/mailrelay/wordpress/compare/v2.0.1...v2.0.2 [2.0.1]: https://github.com/mailrelay/wordpress/compare/v2.0...v2.0.1 [2.0]: https://github.com/mailrelay/wordpress/compare/v1.8.1...v2.0 From f6dc4d07ea34d6ff4eaded452617b9390cc94c77 Mon Sep 17 00:00:00 2001 From: brunonzanini <98592514+brunonzanini@users.noreply.github.com> Date: Thu, 17 Feb 2022 10:10:18 -0300 Subject: [PATCH 5/5] Unrelesead version 2.0.3 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78d93b0..b417135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add German translation -[unrealeased]: https://github.com/mailrelay/wordpress/compare/v2.0.1...unreleased +[unrealeased]: https://github.com/mailrelay/wordpress/compare/v2.0.1...head [2.0.2]: https://github.com/mailrelay/wordpress/compare/v2.0.1...v2.0.2 [2.0.1]: https://github.com/mailrelay/wordpress/compare/v2.0...v2.0.1 [2.0]: https://github.com/mailrelay/wordpress/compare/v1.8.1...v2.0