Subversion Repositories DevTools

Rev

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