Commit 55c50c1c authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1756764: Alert user if shared with rules 2nd option empty



This is for the 'Search for...' Friends / Groups / Users

Currently we don't allow the submission / cancel of the form if any of
these 3 options are selected but the second select2 box is empty

But we also don't tell the user why.

I've added an alert to mention why the form will not submit / cancel

behatnotneeded

Change-Id: I71827647fd7a2f8177c336bdb91f6ce8b9b23df8
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 3927b696
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1458,10 +1458,12 @@ function jsstrings() {
                'toggletoolbarsoff',
                'imagexofy',
                'remove',
                'errorprocessingform',
            ),
            'pieforms' => array(
                'element.calendar.opendatepicker',
                'rule.maxlength.maxlength'
                'rule.maxlength.maxlength',
                'rule.required.required',
            )
        ),
        'tablerenderer' => array(
+5 −0
Original line number Diff line number Diff line
@@ -108,6 +108,11 @@
            line-height: $input-height-base / 2;
        }
    }
    .input-short-error {
        max-width: 205px;
        display: inline-block;
        width: 230px;
    }
}


+12 −0
Original line number Diff line number Diff line
@@ -125,13 +125,25 @@ jQuery(function($) {
            $j('#{{$formname}} select:required').each(function() {
                if ($j(this).val()) {
                    $j(this).prop("required", false);
                    $j(this).parent().parent().find('div.errmsg').remove();
                }
                else {
                    var b = $j(this).attr("data-type");
                    $j('#messages').html('<div class="alert alert-danger"><div>' + get_string('errorprocessingform', 'mahara') + '</div></div>');
                    if ($j(this).parent().parent().find('div.errmsg').length === 0) {
                        $j(this).parent().parent().append('<div class="errmsg"><span class="input-short-error"></span><span id="' + $j(this).prop('id') + '_error">' + get_string('rule.required.required', 'pieforms') + '</span></div>');
                    }
                    e.preventDefault();
                    e.stopPropagation();
                }
            });
        });
        // Remove 'required' on cancel
        $j('#cancel_{{$formname}}_submit').click(function(e) {
            $j('#{{$formname}} select:required').each(function() {
                $j(this).prop("required", false);
            });
        });

        function setDatePicker(target) {
            var loc = '{{strstr(current_language(), '.', true)}}'; // Get current langauge to use for locale