Skip to content

Commit

Permalink
Restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Aug 10, 2023
1 parent 4ee74d9 commit 25f9d01
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions web/js/edit_entry.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@


<?php
// Function to (1) add a 'required' attribute to the rep_interval field if it's a repeating booking
// and (2) to display the secondary repeat type fieldset appropriate to the selected repeat type.
// Function to (1) add a 'required' attribute to the rep_interval field if it's a repeating booking,
// (2) show/hide the repeat end date and skip fields and (3) display the secondary repeat type fieldset
// appropriate to the selected repeat type.
?>
var changeRepTypeDetails = function changeRepTypeDetails() {
var repType = parseInt($('input[name="rep_type"]:checked').val(), 10);
var isRepeat = (repType !== <?php echo RepeatRule::NONE ?>);
<?php
// Add a 'required' attribute to the rep_interval input to prevent users entering an
// empty string. But remove it if it's not a repeating entry, because if they happen
// to have an empty string they won't see the validation message because the input
// will be hidden.
// to have an empty string they won't see the validation message since the input will
// be hidden.
?>
$('#rep_interval').prop('required', (repType !== <?php echo RepeatRule::NONE ?>));
$('#rep_interval').prop('required', isRepeat);
<?php // Show/hide the repeat end date and skip fields ?>
$('#rep_end_date').parent().toggle(isRepeat);
$('#skip').parent().toggle(isRepeat);
<?php // Show the appropriate details ?>
$('.rep_type_details').hide();
switch (repType)
Expand All @@ -81,7 +86,6 @@

<?php
// Function to change the units for the repeat interval to match the repeat type.
// Additionally, the lines for repetition and skipping are shown/hidden.
?>
var changeRepIntervalUnits = function changeRepIntervalUnits() {
var repType = parseInt($('input[name="rep_type"]:checked').val(), 10);
Expand Down Expand Up @@ -109,9 +113,6 @@
units.text(text);

units.parent().toggle(repType !== <?php echo RepeatRule::NONE ?>);

$('#rep_end_date').parent().toggle(repType !== <?php echo RepeatRule::NONE ?>);
$('#skip').parent().toggle(repType !== <?php echo RepeatRule::NONE ?>);
};


Expand Down

0 comments on commit 25f9d01

Please sign in to comment.