~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/locking.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
function getPeriods()
 
3
{
 
4
        var periodTypeList = document.getElementById( "periodTypeId" );
 
5
        var periodTypeId = periodTypeList.options[ periodTypeList.selectedIndex ].value;
 
6
        
 
7
        if ( periodTypeId != null )
 
8
        {               
 
9
                var url = "../dhis-web-commons-ajax/getPeriods.action?name=" + periodTypeId;
 
10
                
 
11
                var request = new Request();
 
12
            request.setResponseTypeXML( 'period' );
 
13
            request.setCallbackSuccess( getPeriodsReceived );
 
14
            request.send( url );
 
15
        }
 
16
}
 
17
 
 
18
function getPeriodsReceived( xmlObject )
 
19
{       
 
20
        document.getElementById( "periodId" ).disabled = false;
 
21
        
 
22
        var periodList = document.getElementById( "periodId" );
 
23
        
 
24
        var periods = xmlObject.getElementsByTagName( "period" );
 
25
        
 
26
        periodList.options.length = 1;
 
27
        
 
28
        for ( var i = 0; i < periods.length; i++)
 
29
        {
 
30
                var id = periods[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
 
31
                var periodName = periods[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
 
32
                
 
33
                var option = document.createElement( "option" );
 
34
                option.value = id;
 
35
                option.text = periodName;
 
36
                
 
37
                periodList.add( option, null );
 
38
        }
 
39
}
 
40
 
 
41
function getDataSets()
 
42
{
 
43
        var periodList = document.getElementById( "periodId" );
 
44
        var periodId = periodList.options[ periodList.selectedIndex ].value;
 
45
        
 
46
        if ( periodId != null )
 
47
        {
 
48
                var url = "getDataSets.action?periodId=" + periodId;
 
49
                
 
50
                var request = new Request();
 
51
                request.setResponseTypeXML( 'dataSet' );
 
52
                request.setCallbackSuccess( getDataSetsReceived );
 
53
                request.send( url );
 
54
        }
 
55
}
 
56
 
 
57
function getDataSetsReceived( xmlObject )
 
58
{
 
59
        var unlockedDataSetList = document.getElementById( "unlockedDataSets" );
 
60
        var lockedDataSetList = document.getElementById( "lockedDataSets" );
 
61
        
 
62
        unlockedDataSetList.disabled = false;
 
63
        lockedDataSetList.disabled = false;
 
64
        
 
65
        clearList( unlockedDataSetList );
 
66
        clearList( lockedDataSetList );
 
67
        
 
68
        var dataSets = xmlObject.getElementsByTagName( "dataSet" );
 
69
        
 
70
        for ( var i = 0; i < dataSets.length; i++ )
 
71
        {
 
72
                var id = dataSets[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
 
73
                var dataSetName = dataSets[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
 
74
                var locked = dataSets[ i ].getElementsByTagName( "locked" )[0].firstChild.nodeValue;
 
75
                
 
76
                var option = document.createElement( "option" );
 
77
                option.value = id;
 
78
                option.text = dataSetName;
 
79
                
 
80
                if ( locked == "true" )
 
81
                {
 
82
                        lockedDataSetList.add( option, null );
 
83
                }
 
84
                else
 
85
                {
 
86
                        unlockedDataSetList.add( option, null );
 
87
                }
 
88
        }
 
89
}
 
90
 
 
91
function updateDataSets()
 
92
{
 
93
        selectAllById( "lockedDataSets" );
 
94
        selectAllById( "unlockedDataSets" );
 
95
        
 
96
        document.getElementById( "lockingForm" ).submit();
 
97
}