Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 26 additions & 13 deletions src/inc/class-mailrelaypages.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function render_admin_page() {
settings_errors();
?>

<form method="post">
<form method="post" id="manual-sync">
<?php
do_settings_sections( 'manual-page-admin' );
$attributes = array( 'onclick' => 'return check_form();' );
Expand Down Expand Up @@ -156,9 +156,14 @@ public function render_admin_page() {
settings_errors();
?>

<form method="post">
<form method="post" id="manual-form">
<div id="mailrelay_autosync">
<?php do_settings_sections( 'mailrelay-settings-page' ); ?>
</div>
<div id="mailrelay_groups">
<?php do_settings_sections( 'mailrelay-settings-page2' ); ?>
</div>
<?php
do_settings_sections( 'mailrelay-settings-page' );
$attributes = array( 'onclick' => 'return check_form();' );
$submit_text = __( 'Save', 'mailrelay' );
submit_button( $submit_text, 'primary', 'submit-settings', true, $attributes );
Expand Down Expand Up @@ -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 <br /><a href="%s">(refresh groups)</a>', 'mailrelay' ), $link ), // title
array( $this, 'groups_callback' ), // callback
'mailrelay-settings-page', // page
'settings_page_setting_section' // section
);

add_settings_field(
'action', // id
null, // title
Expand All @@ -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 <br /><a href="%s">(refresh groups)</a>', 'mailrelay' ), $link ), // title
array( $this, 'groups_callback' ), // callback
'mailrelay-settings-page2', // page
'settings_page_setting_section2' // section
);

}

public function settings_page_section_info() { }
Expand Down
35 changes: 35 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
@@ -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;
}
});

});
5 changes: 5 additions & 0 deletions src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down