Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5050 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'   sdk_version_add.asp
4
'   This file is designed to be injected (loaded) into a 'div' on a window
5
'   It is a pop up dialog
6
'
7
'   Add a new version to the current sdk_id
8
%>
9
<script>
5053 dpurdie 10
$( "#fNewSdkVersion" ).dialog({
5050 dpurdie 11
    autoOpen: true,
12
    width: 350,
13
    modal: true,
14
    draggable: true,
15
    resizable: true,
16
    dialogClass: "rounded_box",
17
        buttons: [
18
            {
19
            text  : 'Create',
20
            class : 'hideOnError',
21
            click : function(){
22
                        clearInfo();
5053 dpurdie 23
                        $( "#fNewSdkVersion" ).submit();
5050 dpurdie 24
                        },
25
            },
26
            {
27
            text : 'Cancel',
28
            click : function(){ 
29
                        $( this ).dialog( "close" );
30
                        },
31
            },
32
        ],
33
    open: function( event, ui ) {
34
        },
35
    close : function(event, ui ){
36
        // Need to remove DOM elements on close so that
37
        // When it is opened again - the binds occur correctly
38
        $(this).dialog('destroy').remove();
39
        },
40
    });
41
 
42
function setInfo(txt) {
43
    $("#sdkv_info").text( txt).addClass("error");
44
}
45
 
46
function clearInfo(txt) {
47
    $("#sdkv_info").text(" ").removeClass("error");
48
}
49
 
50
$.validate({
5053 dpurdie 51
    form: '#fNewSdkVersion',
5050 dpurdie 52
    validateOnBlur : false,
53
    onSuccess : function(f) {
54
        processSdkForm(f);
55
    },
56
 
57
});
58
 
59
// Severe Error processing
60
//  Disable all the inputs on a form
61
//  Hide dialog buttons marked to be hidden
62
//  All the user can do is read the error message and close the form
63
function disableForm()
64
{   
5053 dpurdie 65
    var form = $("#fNewSdkVersion");
5050 dpurdie 66
    form.dialog( "widget" ).find(".hideOnError").hide();
67
    form.find(":input").prop("disabled",true);
68
}
69
 
70
//  Process the Form
71
//      Form has been validated and is ready to be saved
72
//      Once saved then
73
//          Close the dialog form
74
//          Trigger a custom event
75
//              Users can use this event to refresh any table being displayed
76
function processSdkForm(f)
77
{
78
    getAjaxData (
79
        "sdk_opr_json.asp",
80
        f.serializeArray(),
81
        function(data){
82
            f.dialog( "close" );
5052 dpurdie 83
            $("#sdk_versions").trigger('sdkVersionAdded');
5050 dpurdie 84
        });    
85
};
86
 
87
//  Attach a function to the submit event
88
//  Allows local processing
5053 dpurdie 89
$( "#fNewSdkVersion" ).submit(function(e) {
5050 dpurdie 90
        e.preventDefault(); //STOP default action
91
        return false;
92
        });
93
 
94
function populateProjects(){
95
    getAjaxData (
96
        "sdk_opr_json.asp",
5053 dpurdie 97
        { action: "getProjectList" },
5050 dpurdie 98
        function(data){
99
            // Populate selection
100
            var $options = $("#sel_project").empty();
5053 dpurdie 101
            $options.append($("<option />").val(null).text('Select One'));
5050 dpurdie 102
            $.each(data.aaData, function (index, value) {
103
                $options.append($("<option />").val(value.PROJ_ID).text(value.PROJ_NAME));
104
            });
105
            //$options[0].selectedIndex = 0
106
            //populateReleases( $options.val())
107
 
5053 dpurdie 108
            populateReleases( null, null); 
5050 dpurdie 109
 
110
        });    
111
};
112
 
113
function populateReleases(proj_id, rtag_id){
114
    getAjaxData (
115
        "sdk_opr_json.asp",
116
        { action: "getReleaseList", proj_id : proj_id, rtag_id : rtag_id, mode: $("#chk_release").is(':checked') },
117
        function(data){
118
            // Populate selection
119
            var $options = $("#sel_release").empty();
120
            $options.append($("<option />").val(null).text('Select One'));
121
            $.each(data.aaData, function (index, value) {
122
                $options.append($("<option />").val(value.RTAG_ID).text(value.RTAG_NAME));
123
            });
124
            if (rtag_id != null) 
125
                $options.val(rtag_id);
126
            $("#sel_project").val(data.proj_id);
127
        });    
128
};
129
 
130
 
131
//  getAjaxData - with error processing
132
//      url - url to fetch
133
//      data    - additional data to pass to ajax request
134
//      success - function to call on success
135
function getAjaxData( url, data, success )
136
{
137
    clearInfo();
138
    $("#sdkv_progressBar").css('visibility', 'visible');
139
    $.ajax(
140
    {
141
        url : url,
142
        type: "POST",
143
        data : data,
144
        dataType : "json",
145
        cache: false,
146
        success:function(data, textStatus, jqXHR)
147
        {
148
            //data: return data from server
149
            //console.log ("UpdateData", data);
150
            if (data.result != 0)
151
            {
152
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
153
                if (data.error >= 0) disableForm();
154
                return;
155
            }
156
            //  call user success function
157
            success(data);
158
        },
159
        error: function(jqXHR, textStatus, errorThrown)
160
        {
161
            setInfo("Error:" + errorThrown);
162
            disableForm();
163
            //if fails
164
        },
165
        complete : function()
166
        {
167
            $("#sdkv_progressBar").css('visibility', 'hidden');
168
        }
169
    });
170
 
171
}
172
 
5053 dpurdie 173
//  Get getSdkDetails
174
//      When this is complete we will populate the remainder of the page.
175
getAjaxData (
176
    "sdk_opr_json.asp",
177
    { action: "getSdkDetails", sdk_id : <%=Request("sdk_id")%> },
178
    function(data){
179
 
180
        $("#sdkDetails").val( data.aaData.SDK_NAME);
181
        //  Populate the Projects Drop Down List
182
        populateProjects();
183
    });    
5050 dpurdie 184
 
5053 dpurdie 185
 
5050 dpurdie 186
//  Wire up various controls to auto-populate others
187
$("#sel_project").change(function(){
188
    populateReleases( $(this).val(), null);
189
    });
190
 
191
$("#chk_release").change(function(){
192
    populateReleases( $("#sel_project").val(), $("#sel_release").val());
193
});
194
 
195
//# sourceURL=sdk_versions_add.asp
196
</script>
5053 dpurdie 197
<form title="Create new SDK Version" id=fNewSdkVersion action="sdk_opr_json.asp" class=td>
5050 dpurdie 198
 
199
	<div style='min-height:25px;position:relative;'>
200
        <img id='sdkv_progressBar' src='icons/i_processing.gif' width='79' height='14'style='visibility:hidden;position:absolute;'>
201
        <div id='sdkv_info' style='position:absolute;'></div>
202
    </div>
203
 
5053 dpurdie 204
    <p>SDK:
205
    <br><input id=sdkDetails disabled>
5050 dpurdie 206
 
207
    <fieldset>
208
    <legend>SDK Version</legend>
209
    <p>Name:
5053 dpurdie 210
    <br><input id=sdk_name type="text" name="sdkName" maxlength=50 size=40 data-validation="length,alphanumeric" data-validation-length="min4" data-validation-allowing="_. -">
5050 dpurdie 211
 
212
    <p>Description:
213
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
214
    </fieldset>
215
 
216
    <fieldset>
217
    <legend>Base Release</legend>
218
    <p>Project:<br>
219
        <select id=sel_project name=proj_id data-validation="required">
220
        <option value="">Select One</option>
221
        </select>
222
 
223
    <p>Release:<input id=chk_release type=checkbox>Show all versions
224
    <br>
225
        <select id=sel_release name=rtag_id data-validation="required">
226
        <option value="">Select One</option>
227
        </select>
228
    </fieldset>
229
 
5053 dpurdie 230
    <input type="hidden" name="sdk_id" value="<%=Request("sdk_id")%>">
5050 dpurdie 231
    <input type="hidden" name="action" value="addNewSdkVersion">
232
</form>
233