diff --git a/CHANGELOG.md b/CHANGELOG.md index bc4f45f..b417135 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...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 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() { } 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; + } + }); + +}); 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*