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