Subversion Repositories DevTools

Rev

Rev 5814 | Rev 6048 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'   sdk_version_edit.asp
'   This file is designed to be injected (loaded) into a 'div' on a window
'   It is a pop up dialog
'
'   Edit the Version Metadata for  sdktag_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>
//# sourceURL=sdk_version_edit.asp
$( "#fEditSdkVersion" ).dialog({
    autoOpen: true,
    width: 350,
    position: { my: "top", at: "top+100", of: window },
    modal: true,
    draggable: true,
    resizable: true,
    dialogClass: "rounded_box",
        buttons: [
<%If canActionControl("AdminSdk") Then %>
            {
            text  : 'Update',
            class : 'hideOnError',
            click : function(){
                        clearInfo();
                        $( "#fEditSdkVersion" ).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: '#fEditSdkVersion',
    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 = $("#fEditSdkVersion");
    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
$( "#fEditSdkVersion" ).submit(function(e) {
        e.preventDefault(); //STOP default action
        return false;
        });


//  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: "getSdkVersionDetails", sdktag_id : <%=Request("sdktag_id")%> },
    function(data){
        
        $("#sdkDetails").val( data.aaData.SDK_NAME);
        $("#sdk_name").val( data.aaData.SDKTAG_NAME);
        $("#sdk_comment").val( data.aaData.DESCRIPTION);
    });    

</script>
<%If canActionControl("AdminSdk") Then %>
<form title="Edit SDK Version Details" id=fEditSdkVersion action="sdk_opr_json.asp" class=td>
<%Else%>
<form title="View SDK Version Details" id=fEditSdkVersion action="sdk_opr_json.asp" class=td>
<%End If%>
        <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="sdkTagName" maxlength=50 size=40 data-validation="length,alphanumeric" data-validation-length="min4" data-validation-allowing="_. -">

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

    <input type="hidden" name="sdktag_id" value="<%=Request("sdktag_id")%>">
    <input type="hidden" name="action" value="updateSdkVersionDetails">
</form>
<%Call Destroy_All_Objects%>