Subversion Repositories DevTools

Rev

Rev 5053 | Blame | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'   sdk_version_add.asp
'   This file is designed to be injected (loaded) into a 'div' on a window
'   It is a pop up dialog
'
'   Add a new version to the current sdk_id
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_general.asp"-->
<script>
$( "#fNewSdkVersion" ).dialog({
    autoOpen: true,
    width: 350,
    modal: true,
    draggable: true,
    resizable: true,
    dialogClass: "rounded_box",
        buttons: [
<%If canActionControlInProject("CreateSdk") Then %>
            {
            text  : 'Create',
            class : 'hideOnError',
            click : function(){
                        clearInfo();
                        $( "#fNewSdkVersion" ).submit();
                        },
            },
<%End If%>
            {
            text : 'Cancel',
            click : function(){ 
                        $( this ).dialog( "close" );
                        },
            },
        ],
    open: function( event, ui ) {
        },
    close : function(event, ui ){
        // Need to remove DOM elements on close so that
        // When it is opened again - the binds occur correctly
        $(this).dialog('destroy').remove();
        },
    });

function setInfo(txt) {
    $("#sdkv_info").text( txt).addClass("error");
}

function clearInfo(txt) {
    $("#sdkv_info").text(" ").removeClass("error");
}

$.validate({
    form: '#fNewSdkVersion',
    validateOnBlur : false,
    onSuccess : function(f) {
        processSdkForm(f);
    },

});

// Severe Error processing
//  Disable all the inputs on a form
//  Hide dialog buttons marked to be hidden
//  All the user can do is read the error message and close the form
function disableForm()
{   
    var form = $("#fNewSdkVersion");
    form.dialog( "widget" ).find(".hideOnError").hide();
    form.find(":input").prop("disabled",true);
}

//  Process the Form
//      Form has been validated and is ready to be saved
//      Once saved then
//          Close the dialog form
//          Trigger a custom event
//              Users can use this event to refresh any table being displayed
function processSdkForm(f)
{
    getAjaxData (
        "sdk_opr_json.asp",
        f.serializeArray(),
        function(data){
            f.dialog( "close" );
            $("#sdk_versions").trigger('sdkVersionAdded');
        });    
};

//  Attach a function to the submit event
//  Allows local processing
$( "#fNewSdkVersion" ).submit(function(e) {
        e.preventDefault(); //STOP default action
        return false;
        });

function populateProjects(){
    getAjaxData (
        "sdk_opr_json.asp",
        { action: "getProjectList" },
        function(data){
            // Populate selection
            var $options = $("#sel_project").empty();
            $options.append($("<option />").val(null).text('Select One'));
            $.each(data.aaData, function (index, value) {
                $options.append($("<option />").val(value.PROJ_ID).text(value.PROJ_NAME));
            });
            //$options[0].selectedIndex = 0
            //populateReleases( $options.val())

            populateReleases( null, null); 

        });    
};

function populateReleases(proj_id, rtag_id){
    getAjaxData (
        "sdk_opr_json.asp",
        { action: "getReleaseList", proj_id : proj_id, rtag_id : rtag_id, mode: $("#chk_release").is(':checked') },
        function(data){
            // Populate selection
            var $options = $("#sel_release").empty();
            $options.append($("<option />").val(null).text('Select One'));
            $.each(data.aaData, function (index, value) {
                $options.append($("<option />").val(value.RTAG_ID).text(value.RTAG_NAME));
            });
            if (rtag_id != null) 
                $options.val(rtag_id);
            $("#sel_project").val(data.proj_id);
        });    
};


//  getAjaxData - with error processing
//      url - url to fetch
//      data    - additional data to pass to ajax request
//      success - function to call on success
function getAjaxData( url, data, success )
{
    clearInfo();
    $("#sdkv_progressBar").css('visibility', 'visible');
    $.ajax(
    {
        url : url,
        type: "POST",
        data : data,
        dataType : "json",
        cache: false,
        success:function(data, textStatus, jqXHR)
        {
            //data: return data from server
            //console.log ("UpdateData", data);
            if (data.result != 0)
            {
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
                if (data.error >= 0) disableForm();
                return;
            }
            //  call user success function
            success(data);
        },
        error: function(jqXHR, textStatus, errorThrown)
        {
            setInfo("Error:" + errorThrown);
            disableForm();
            //if fails
        },
        complete : function()
        {
            $("#sdkv_progressBar").css('visibility', 'hidden');
        }
    });

}

//  Get getSdkDetails
//      When this is complete we will populate the remainder of the page.
getAjaxData (
    "sdk_opr_json.asp",
    { action: "getSdkDetails", sdk_id : <%=Request("sdk_id")%> },
    function(data){
        
        $("#sdkDetails").val( data.aaData.SDK_NAME);
        //  Populate the Projects Drop Down List
        populateProjects();
    });    


//  Wire up various controls to auto-populate others
$("#sel_project").change(function(){
    populateReleases( $(this).val(), null);
    });

$("#chk_release").change(function(){
    populateReleases( $("#sel_project").val(), $("#sel_release").val());
});

//# sourceURL=sdk_versions_add.asp
</script>
<form title="Create new SDK Version" id=fNewSdkVersion action="sdk_opr_json.asp" class=td>
    
        <div style='min-height:25px;position:relative;'>
        <img id='sdkv_progressBar' src='icons/i_processing.gif' width='79' height='14'style='visibility:hidden;position:absolute;'>
        <div id='sdkv_info' style='position:absolute;'></div>
    </div>

    <p>SDK:
    <br><input id=sdkDetails disabled>

    <fieldset>
    <legend>SDK Version</legend>
    <p>Name:
    <br><input id=sdk_name type="text" name="sdkName" maxlength=50 size=40 data-validation="length,alphanumeric" data-validation-length="min4" data-validation-allowing="_. -">

    <p>Description:
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
    </fieldset>

    <fieldset>
    <legend>Base Release</legend>
    <p>Project:<br>
        <select id=sel_project name=proj_id data-validation="required">
        <option value="">Select One</option>
        </select>

    <p>Release:<input id=chk_release type=checkbox>Show all versions
    <br>
        <select id=sel_release name=rtag_id data-validation="required">
        <option value="">Select One</option>
        </select>
    </fieldset>

    <input type="hidden" name="sdk_id" value="<%=Request("sdk_id")%>">
    <input type="hidden" name="action" value="addNewSdkVersion">
</form>