{% extends "ndf/mis_base_create_edit.html" %} {% load i18n %} {% load ndf_tags %} {% load pagination_tags %} {% block body_content %}
{% endblock %} {% block script %} {{block.super}} // Default settings for date-widgets & tabs on page load --------------------------------------------------------- var currentYear = (new Date()).getFullYear() lowerYearLimit = currentYear - 80; upperYearLimit = currentYear; // Tabs navigation: Enable and Disable tabs in sequential manner using Next & Previous buttons ------------------- $(".content").on('click', '.tab_next' ,function(event){ event.preventDefault(); // Forcefully blur all input elements, so that mandatory fields become data-invalid if not fill $(this).parents(".tab-nav").parents(".content").find(':input[required]').blur(); // Then check no. of data-invalid fields // if count == 0, then only proceed to next tab if($(this).parents(".tab-nav").parents(".content").find(':input[data-invalid]').length == 0) { // Valid, move to next step $('.active').removeClass('active').next().addClass('active'); } }); $(".content").on('click', '.tab_prev' ,function(event){ event.preventDefault(); $('.active').removeClass('active').prev().addClass('active'); }); // Only keeping year's drop-down and hiding other datepicker's elements ------------------------------------------ $(document).on('focus click', '.date_year' ,function(){ $(".ui-datepicker-calendar").hide(); $(".ui-datepicker-month").hide(); $(".ui-datepicker-prev").hide(); $(".ui-datepicker-next").hide(); $("#ui-datepicker-div").position({ my: "center top", at: "center bottom", of: $(this) }); }); // State-wise District selection --------------------------------------------------------------------------------- $("select#organization_belongs_to_state").change(function() { // Get selected State's value (ObjectId) and selected-index selected_state_id = $(this).val() selected_state_index = this.selectedIndex if (selected_state_index != 0) { // Perform this only when a State is selected // Ajax call that fetches all Districts belonging to selected State $.ajax({ url:"{% url 'get_districts' groupid %}", data: { state_id: selected_state_id }, type: "GET", dataType: "json", complete: function () { // Enable District field $("select#organization_belongs_to_district").removeAttr('disabled') }, success: function (data) { if (data.hasOwnProperty("message")) { // Pops-up only when there is any error found during the ajax call alert(data["message"]) } else { // First empty all values of District field (dropdown/select) $("select#organization_belongs_to_district").empty(); // Make very first entry as given below $("select#organization_belongs_to_district").append( $("") .attr("value", "") .text("- - - Select district - - -") ); // Fill returned district values based on which state is selected $.each(data, function(i, value) { $("select#organization_belongs_to_district").append( $("") .attr("value", value[0]) .text(value[1]) ); }); // Set very first entry so that user doesn't forgets to select a value $("select#organization_belongs_to_district").prop("selectedIndex", 0); } } }); } else { // If state is not selected or changed back to very first element from State's dropdown // then set even District field's value to very first entry and disabled it until user again selects any state $("select#organization_belongs_to_district").prop("selectedIndex", 0); $("select#organization_belongs_to_district").attr('disabled', 'disabled') } }); // Tranferring values from multiple selection widget into outer dropdown ----------------------------------------- $(document).on('closed', '[data-reveal]', function () { /* * On closing of reveal-modal */ var widget_for = $(this).attr('id').replace('_modal', '') // First empty all values of given field (dropdown/select) $("select#" + widget_for).empty(); // Fetching class name of hidden input element(s) of drawer2 from corresponding drawer-widget class_value = ".node_id." + widget_for + "_values" right_drawer_len = $(class_value).size() if (right_drawer_len > 0) { $(class_value).each(function (){ // ObjectId & name of the resource inside drawer2 from corresponding drawer-widget resource_id = $(this).val() resource_name = $(this).attr('name') // Make very first entry as given below $("select#" + widget_for).append( $("") .attr("value", resource_id) .attr("selected", "selected") .text(resource_name) ); }); } else { // Make very first entry as given below $("select#" + widget_for).append( $("") .attr("value", "") .text("- - - Select - - -") ); } }); // On click of Register/Update ----------------------------------------------------------------------------------- $(document).on("click", "#save-node", function() { // Enable any disabled field as disabled values can't be fetched in views -------------------------------------- $(".content").find(":input[disabled]").each(function(){ $(this).removeAttr('disabled'); }); }); // totWhen ------------------------------------------------------------------------------------------------------- var totWhen = $("#tot_when") if(totWhen.length > 0) { totWhen.datetimepicker(); $(totWhen).after('