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