View | Details | Raw Unified | Return to bug 10543
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js (+17 lines)
Lines 464-466 function CloneItemSubfield(original){ Link Here
464
    // insert this line on the page
464
    // insert this line on the page
465
    original.parentNode.insertBefore(clone,original.nextSibling);
465
    original.parentNode.insertBefore(clone,original.nextSibling);
466
}
466
}
467
468
/**
469
 * Check mandatory subfields of a cataloging form and adds <code>missing</code> class to those who are empty.<br>
470
 * @param p the parent object of subfields to check
471
 * @return the number of empty mandatory subfields
472
 */
473
function CheckMandatorySubfields(p){
474
    var total = 0;
475
    $(p).find(".subfield_line input[name='mandatory'][value='1']").each(function(i){
476
        var editor = $(this).siblings("[name='field_value']");
477
        if (!editor.val()) {
478
            editor.addClass("missing");
479
            total++;
480
        }
481
    });
482
    return total;
483
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-18 / +5 lines)
Lines 40-66 function active(numlayer) Link Here
40
    }
40
    }
41
}
41
}
42
function Check(f) {
42
function Check(f) {
43
    var total_errors=0;
43
    var total_errors = CheckMandatorySubfields(f);
44
    $("input[name='mandatory'],select[name='mandatory']").each(function(i){
44
    if (total_errors > 0) {
45
        if($(this).val() == 1){
45
        var alertString2 = _("Form not submitted because of the following problem(s)");
46
            var mandatory_field = $("input[name='field_value'],select[name='field_value']").eq(i);
47
            if(mandatory_field.val() == ''){
48
                mandatory_field.addClass("missing");
49
                total_errors++;
50
            }
51
        }
52
    });
53
54
    var alertString2;
55
    if (total_errors==0) {
56
        return true;
57
    } else {
58
        alertString2  = _("Form not submitted because of the following problem(s)");
59
        alertString2 += "\n------------------------------------------------------------------------------------\n";
46
        alertString2 += "\n------------------------------------------------------------------------------------\n";
60
        alertString2 += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)");
47
        alertString2 += "\n- "+ total_errors + _(" mandatory fields empty (highlighted)");
61
        alert(alertString2);
48
        alert(alertString2);
62
        return false;
49
        return false;
63
    }
50
    }
51
    return true;
64
}
52
}
65
function CheckMultipleAdd(f) {
53
function CheckMultipleAdd(f) {
66
54
67
- 

Return to bug 10543