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
%>
5089 dpurdie 9
<%
10
Option explicit
11
' Good idea to set when using redirect
12
Response.Expires = 0   ' always load the page, dont store
5103 dpurdie 13
' Determine mode of operation
14
' inReleaseMode: true:  Have rtag_id and proj_id, so we need to determine the sdk  
15
'                false: Have sdk_id so we need to determine the release
16
Dim inReleaseMode : inReleaseMode = Request("proj_id") <> "" AND  Request("rtag_id") <> "" 
5089 dpurdie 17
%>
18
<!--#include file="common/conf.asp"-->
19
<!--#include file="common/globals.asp"-->
20
<!--#include file="common/formating.asp"-->
21
<!--#include file="common/qstr.asp"-->
22
<!--#include file="common/common_subs.asp"-->
23
<%
24
'------------ ACCESS CONTROL ------------------
25
%>
26
<!--#include file="_access_control_general.asp"-->
5050 dpurdie 27
<script>
5053 dpurdie 28
$( "#fNewSdkVersion" ).dialog({
5050 dpurdie 29
    autoOpen: true,
30
    width: 350,
5102 dpurdie 31
    position: { my: "top", at: "top+100", of: window },
5050 dpurdie 32
    modal: true,
33
    draggable: true,
34
    resizable: true,
35
    dialogClass: "rounded_box",
36
        buttons: [
5089 dpurdie 37
<%If canActionControlInProject("CreateSdk") Then %>
5050 dpurdie 38
            {
39
            text  : 'Create',
40
            class : 'hideOnError',
41
            click : function(){
42
                        clearInfo();
5053 dpurdie 43
                        $( "#fNewSdkVersion" ).submit();
5050 dpurdie 44
                        },
45
            },
5089 dpurdie 46
<%End If%>
5050 dpurdie 47
            {
48
            text : 'Cancel',
49
            click : function(){ 
50
                        $( this ).dialog( "close" );
51
                        },
52
            },
53
        ],
54
    open: function( event, ui ) {
55
        },
56
    close : function(event, ui ){
57
        // Need to remove DOM elements on close so that
58
        // When it is opened again - the binds occur correctly
59
        $(this).dialog('destroy').remove();
60
        },
61
    });
62
 
63
function setInfo(txt) {
64
    $("#sdkv_info").text( txt).addClass("error");
65
}
66
 
67
function clearInfo(txt) {
68
    $("#sdkv_info").text(" ").removeClass("error");
69
}
70
 
5103 dpurdie 71
// Form Validation processing
72
//      Load in the required JavaScript support
73
$.getScript("jquery/form-validator/jquery.form-validator.min.js", registerValidation);
5050 dpurdie 74
 
5103 dpurdie 75
function registerValidation()
76
{
77
    $.validate({
78
        form: '#fNewSdkVersion',
79
        validateOnBlur : false,
80
        onSuccess : function(f) {
81
            processSdkForm(f);
82
        },
5050 dpurdie 83
 
5103 dpurdie 84
    });
85
}
5050 dpurdie 86
// Severe Error processing
87
//  Disable all the inputs on a form
88
//  Hide dialog buttons marked to be hidden
89
//  All the user can do is read the error message and close the form
90
function disableForm()
91
{   
5053 dpurdie 92
    var form = $("#fNewSdkVersion");
5050 dpurdie 93
    form.dialog( "widget" ).find(".hideOnError").hide();
94
    form.find(":input").prop("disabled",true);
95
}
96
 
97
//  Process the Form
98
//      Form has been validated and is ready to be saved
99
//      Once saved then
100
//          Close the dialog form
101
//          Trigger a custom event
102
//              Users can use this event to refresh any table being displayed
103
function processSdkForm(f)
104
{
5103 dpurdie 105
<%If inReleaseMode Then%>
106
    //  Enable the disabled fieldset so that the values within are sent as a part of the form
107
    $("#sel_base_release").prop("disabled", false);
108
<%End If%>
109
 
5050 dpurdie 110
    getAjaxData (
111
        "sdk_opr_json.asp",
112
        f.serializeArray(),
113
        function(data){
114
            f.dialog( "close" );
5103 dpurdie 115
<%If inReleaseMode Then%>
116
            window.location.href = "sdk_main_page.asp#url=sdk_details.asp&sdktag_id=" + data.SDKTAG_ID;
117
<%Else%>
5052 dpurdie 118
            $("#sdk_versions").trigger('sdkVersionAdded');
5103 dpurdie 119
<%End If%>
120
 
5050 dpurdie 121
        });    
122
};
123
 
124
//  Attach a function to the submit event
125
//  Allows local processing
5053 dpurdie 126
$( "#fNewSdkVersion" ).submit(function(e) {
5050 dpurdie 127
        e.preventDefault(); //STOP default action
128
        return false;
129
        });
130
 
5103 dpurdie 131
function populateProjects(proj_id, rtag_id){
5050 dpurdie 132
    getAjaxData (
133
        "sdk_opr_json.asp",
5053 dpurdie 134
        { action: "getProjectList" },
5050 dpurdie 135
        function(data){
136
            // Populate selection
137
            var $options = $("#sel_project").empty();
5103 dpurdie 138
            $options.append($("<option selected disabled/>").val(null).text('Select One'));
5050 dpurdie 139
            $.each(data.aaData, function (index, value) {
140
                $options.append($("<option />").val(value.PROJ_ID).text(value.PROJ_NAME));
141
            });
142
 
5103 dpurdie 143
            populateReleases( proj_id, rtag_id); 
5050 dpurdie 144
        });    
145
};
146
 
147
function populateReleases(proj_id, rtag_id){
148
    getAjaxData (
149
        "sdk_opr_json.asp",
150
        { action: "getReleaseList", proj_id : proj_id, rtag_id : rtag_id, mode: $("#chk_release").is(':checked') },
151
        function(data){
152
            // Populate selection
153
            var $options = $("#sel_release").empty();
5103 dpurdie 154
            $options.append($("<option selected disabled/>").val(null).text('Select One'));
5050 dpurdie 155
            $.each(data.aaData, function (index, value) {
156
                $options.append($("<option />").val(value.RTAG_ID).text(value.RTAG_NAME));
157
            });
158
            if (rtag_id != null) 
159
                $options.val(rtag_id);
160
            $("#sel_project").val(data.proj_id);
161
        });    
162
};
163
 
164
 
165
//  getAjaxData - with error processing
166
//      url - url to fetch
167
//      data    - additional data to pass to ajax request
168
//      success - function to call on success
169
function getAjaxData( url, data, success )
170
{
171
    clearInfo();
172
    $("#sdkv_progressBar").css('visibility', 'visible');
173
    $.ajax(
174
    {
175
        url : url,
176
        type: "POST",
177
        data : data,
178
        dataType : "json",
179
        cache: false,
180
        success:function(data, textStatus, jqXHR)
181
        {
182
            //data: return data from server
183
            //console.log ("UpdateData", data);
184
            if (data.result != 0)
185
            {
186
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
187
                if (data.error >= 0) disableForm();
188
                return;
189
            }
190
            //  call user success function
191
            success(data);
192
        },
193
        error: function(jqXHR, textStatus, errorThrown)
194
        {
195
            setInfo("Error:" + errorThrown);
196
            disableForm();
197
            //if fails
198
        },
199
        complete : function()
200
        {
201
            $("#sdkv_progressBar").css('visibility', 'hidden');
202
        }
203
    });
204
 
205
}
206
 
5103 dpurdie 207
//  If we have a proj_id and rtag_id, then we need to populate the SDK selector
208
//  When this is complete we will polulate the rest of the page
209
//
210
<%If inReleaseMode Then%>
211
    getAjaxData (
212
        "sdk_opr_json.asp",
213
        { action: "getSdkNames" , proj_id : <%=Request("proj_id")%>},
214
        function(data){
215
            // Populate selection
216
            var $options = $("#sel_sdkname").empty();
217
            var len = data.aaData.length;
218
 
219
            if ( len == 0 ) {
220
                $options.append($("<option selected disabled/>").val(null).text('None Available'));
221
                disableForm();
222
                setInfo("Project not configured for SDKs");
223
                return;
224
 
225
            } else if ( len > 1 ) {
226
                $options.append($("<option selected disabled/>").val(null).text('Select One'));
227
            }
228
            $.each(data.aaData, function (index, value) {
229
                $options.append($("<option />").val(value.SDK_ID).text(value.SDK_NAME));
230
            });
231
 
232
            //  Display the controlling Project and Release
233
            populateProjects(<%=Request("proj_id")%>, <%=Request("rtag_id")%>);
234
 
235
            if( $options.val() > 0 ) {
236
                populateSdkVersions( $options.val());
237
            }
238
        });
239
 
240
$("#sel_sdkname").change(function(){
241
    populateSdkVersions( $("#sel_sdkname").val());
242
});
243
 
244
function populateSdkVersions(sdk_id){
245
    getAjaxData (
246
        "sdk_opr_json.asp",
247
        { action: "getSdkVersions", sdk_id : sdk_id, active: false, mode : true },
248
        function(data){
249
            // Populate selection
250
            var $options = $("#sel_sdkversion").empty();
251
            $options.append($("<option selected disabled />").val(null).text('Current Versions'));
252
            $.each(data.aaData, function (index, value) {
253
                $options.append($("<option />").val(value.SDKTAG_ID).text(value.SDKTAG_NAME));
254
            });
255
        });    
256
}
257
 
258
<%End If%>
259
 
260
 
261
<%If NOT inReleaseMode Then%>
5053 dpurdie 262
//  Get getSdkDetails
263
//      When this is complete we will populate the remainder of the page.
264
getAjaxData (
265
    "sdk_opr_json.asp",
266
    { action: "getSdkDetails", sdk_id : <%=Request("sdk_id")%> },
267
    function(data){
268
 
269
        $("#sdkDetails").val( data.aaData.SDK_NAME);
270
        //  Populate the Projects Drop Down List
271
        populateProjects();
272
    });    
5050 dpurdie 273
 
274
//  Wire up various controls to auto-populate others
275
$("#sel_project").change(function(){
276
    populateReleases( $(this).val(), null);
277
    });
278
 
279
$("#chk_release").change(function(){
280
    populateReleases( $("#sel_project").val(), $("#sel_release").val());
281
});
5103 dpurdie 282
<%End If%>
5050 dpurdie 283
 
284
//# sourceURL=sdk_versions_add.asp
285
</script>
5103 dpurdie 286
<link rel="stylesheet" href="jquery/form-validator.css" type="text/css">
5053 dpurdie 287
<form title="Create new SDK Version" id=fNewSdkVersion action="sdk_opr_json.asp" class=td>
5050 dpurdie 288
 
289
	<div style='min-height:25px;position:relative;'>
290
        <img id='sdkv_progressBar' src='icons/i_processing.gif' width='79' height='14'style='visibility:hidden;position:absolute;'>
291
        <div id='sdkv_info' style='position:absolute;'></div>
292
    </div>
293
 
5103 dpurdie 294
<%If inReleaseMode Then%>
295
    <fieldset>
296
    <legend>SDK</legend>
297
    <p>SDK Family:
298
    <br><select id=sel_sdkname name=sdk_id data-validation="required"></select>
299
    <p>Current Versions: (for reference only)
300
    <br><select id=sel_sdkversion></select>
301
    </fieldset>
302
<%Else%>
5053 dpurdie 303
    <p>SDK:
304
    <br><input id=sdkDetails disabled>
5103 dpurdie 305
    <input type="hidden" name="sdk_id" value="<%=Request("sdk_id")%>">
306
<%End If%>
5050 dpurdie 307
 
308
    <fieldset>
309
    <legend>SDK Version</legend>
310
    <p>Name:
5053 dpurdie 311
    <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 312
 
313
    <p>Description:
314
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
315
    </fieldset>
316
 
5103 dpurdie 317
    <fieldset id="sel_base_release" <%If inReleaseMode Then Response.Write(" disabled")%>>
5050 dpurdie 318
    <legend>Base Release</legend>
5103 dpurdie 319
    <br>Project:<br>
5050 dpurdie 320
        <select id=sel_project name=proj_id data-validation="required">
321
        <option value="">Select One</option>
322
        </select>
323
 
324
    <p>Release:<input id=chk_release type=checkbox>Show all versions
325
    <br>
326
        <select id=sel_release name=rtag_id data-validation="required">
327
        <option value="">Select One</option>
328
        </select>
329
    </fieldset>
330
 
331
    <input type="hidden" name="action" value="addNewSdkVersion">
332
</form>
333