Subversion Repositories DevTools

Rev

Rev 5357 | Rev 6579 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'|
'|  _iframe_pkgs_followed.asp
'|  This page is designed to be called from within an IFRAME
'|
'|  Follow specified package in one or more projects
'|
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0    ' always load the page, dont store
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/_form_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<%
'------------ Variable Definition -------------
Dim rsTemp
Dim parProjId
Dim parPkgId
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parProjId = Request("proj_id")
parPkgId = Request("pkg_id")
'----------------------------------------------

Function Get_My_Interest_Packages ( NNuser_id )
    Get_My_Interest_Packages = _
        "WITH Followed AS" &_
        "  (SELECT PRJ.proj_id," &_
        "    PRJ.proj_name," &_
        "    1 AS inUse" &_
        "  FROM PACKAGE_INTEREST PI," &_
        "    PROJECTS PRJ" &_
        "  WHERE PI.USER_ID = " & NNuser_id &_
        "  AND PI.PKG_ID    = " &  parPkgId &_
        "  AND PI.PROJ_ID   = PRJ.PROJ_ID" &_
        "  )" &_
        "SELECT prj.proj_id," &_
        "  prj.proj_name," &_
        "  NVL(Followed.inUse,0) as Followed" &_
        " FROM PROJECTS PRJ," &_
        "  Followed" &_
        " WHERE prj.proj_id = Followed.proj_id (+)" &_
        " ORDER BY upper(PRJ.PROJ_NAME)"
End Function
'--------------------------------------------------------------------------------------------------------------------------
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
<script language="JavaScript" src="images/common.js"></script>
<!--#include file="_jquery_includes.asp"-->
<script language="javascript">
$(document).ready(function () {
    //  Cancel button must close this iFrame using a function provided by the parent
    $('#btn_cancel').on('click', function (e) {parent.closeIFrame()});

    //  Restore the state of the checkboxes
    $('#btn_reset').on('click', function (e) {
        $('input.checkbox1[type="checkbox"]').prop("checked", false);
        $('input.checkbox0[type="checkbox"]').prop("checked", true);
        $('#btn_checkAll').prop("checked", false);
        $('#checktable').trigger('change');
    });

    //  Table all the tick boxes
    $('#btn_checkAll').on('change', function (e){
        var isChecked = $(this).prop("checked");
        $(".checkbox1").prop('checked', isChecked);
        $(".checkbox0").prop('checked', isChecked);
        $('#checktable').trigger('change');
    });

    //  Enable Update/Reset button when there is work to be done
    $('#checktable').on('change', function (e){
        var count = $('input.checkbox1[type="checkbox"]:checked').length;
        count += $('input.checkbox0[type="checkbox"]:not(:checked)').length; 
        $('#btn_update').prop('disabled', count <= 0);
        $('#btn_reset').prop('disabled', count <= 0);
    });

    //  Show Hide projects
    $('#btn_checkHide').on('change', function (e) {
        if($(this).prop("checked"))
        {
            $('input.checkbox1[type="checkbox"]').closest('tr').css('display', '');
            $('#eline1').text('Showing All projects');
        }
        else
        {
            $('input.checkbox1[type="checkbox"]').closest('tr').css('display', 'none');
            $('#eline1').text('Showing active projects');
        }
    });

    //  Update checked projects in the watchlist
    $('#btn_update').on('click', function(){
        vixConfirm("Update Notifications to the selected projects.", {ok : updateProjects});
    });

    //  Delete notifications for this package in selected projects
    function updateProjects()
    {
        console.log("updateProjects");
        var projectList = [];
        $('input.checkbox1[type="checkbox"]:checked').each(function(){
            projectList.push($(this).data('proj_id'));
            });

        var projectRmList = [];
        $('input.checkbox0[type="checkbox"]:not(:checked)').each(function(){
            projectRmList.push($(this).data('proj_id'));
            });

        console.log('ListAdd:',projectList.join());
        console.log('ListDel:',projectRmList.join());
        $('#eline1').empty();
        $('#eline2').empty();
        $.ajax({
            type : 'POST',
            url : '_json_Notifications.asp',
            data : {Opr : 'updateProjects', pkg_id : '<%=parPkgId%>', alist : projectList.join(), rlist : projectRmList.join()},
            dataType : 'json',
        }).fail(function( jqXHR, textStatus, errorThrown ){
            $('#eline1').text('Ajax Processing Error');
            $('#eline2').text(errorThrown);
        }).done(function( data, textStatus, jqXHR ){
            if (typeof data.result === undefined){
                vixAlert('Ajax Error. Unexpected result');
                $('#eline1').text('Ajax Error. Unexpected result');
            } else if (data.result != 0){
                $('#eline1').text('Processing Error:' + data.emsgSummary);
                $('#eline2').text(data.emsgDetails);
            } else {
            // Delete checked items
            $('input.checkbox1[type="checkbox"]:checked').removeClass("checkbox1").addClass("checkbox0");
            $('input.checkbox0[type="checkbox"]:not(:checked)').removeClass("checkbox0").addClass("checkbox1");
            $('#checktable').trigger('change');
            }
        });
    }
});
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
<!----------------------------------------------------->
<!-- BODY ---->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#FFFFFF" valign="top" class="form_item"> 
              <p>You are currently interested in this package in the selected projects.
              <p>NOTE: You will be notified when the package is officially released/autobuild.</p>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr class="form_field_hdr">
                <td nowrap><input type=checkbox id="btn_checkAll" title='Toggle all projects'></td>
                <td nowrap>Project&nbsp;</td>
                <td nowrap style='text-align:right' title='Show/Hide all projects'><input type=checkbox id="btn_checkHide" checked></td>
              </tr>
              </table>
              <div style="min-height:300px;max-height:500px;overflow:auto;">
              <table id=checktable width="100%" border="0" cellspacing="0" cellpadding="0">
              <%
              Set rsTemp = OraDatabase.DbCreateDynaset(Get_My_Interest_Packages( objAccessControl.UserId ), cint(0))
              While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
                %>
                    <tr class=form_item_grey>
                        <%If rsTemp("followed") <> 0 Then %>
                            <td nowrap><input type="checkbox" class="checkbox0" data-proj_id="<%=rsTemp("proj_id")%>" checked></td>
                        <%Else%>
                            <td nowrap><input type="checkbox" class="checkbox1" data-proj_id="<%=rsTemp("proj_id")%>"></td>
                        <%End If%>
                        <td nowrap><%=rsTemp("proj_name")%></td>
                    </tr>
                <%rsTemp.MoveNext
              WEnd%>
              </table>
              </div>
              <%If rsTemp.RecordCount = 0 Then%>
                <div class=form_item_grey>
                    You are interested in all current projects
                </div>
              <%End If%>
              <br>
              <%If rsTemp.RecordCount <> 0 Then%>
              <div>
                    <button id="btn_update" class="form_btn" disabled>Update</button>
                    <button id="btn_reset"  class="form_btn" disabled>Reset</button>
                    <button id="btn_cancel" class="form_btn">Cancel</button>
                </div>
              <%End If
              rsTemp.Close()
              set rsTemp = nothing
              %>
              <div id='eline1' class=err_alert>&nbsp;</div>
              <div id='eline2' class=err_alert>&nbsp;</div>
            </td>
        </tr>
    </td>
  </tr>
</table>
</body>
</html>
<%
Call Destroy_All_Objects
%>