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