source: EDIS/tags/ed/tracking-ui-core/src/main/flex/gov/va/med/edp/view/board/DisplayBoard.mxml@ 1240

Last change on this file since 1240 was 1240, checked in by George Lilly, 13 years ago

new version from the VA

File size: 5.7 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!-- DisplayBoard.mxml -->
3
4<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
5 width="100%" height="100%"
6 paddingBottom="0" paddingRight="0" paddingLeft="0" paddingTop="0"
7 creationComplete="initDisplayBoard()"
8 show="startBoardTimer(false)"
9 hide="stopBoardTimer()"
10 styleName="contentArea" xmlns:accessibility="flash.accessibility.*">
11
12 <mx:Script>
13 <![CDATA[
14 import gov.va.med.edp.util.AccessibilityTools;
15 import mx.controls.Alert;
16 import mx.utils.ObjectUtil;
17 import gov.va.med.edp.util.BoardTools;
18 import gov.va.med.edp.view.LoadingDialog;
19 import gov.va.med.edp.widget.VisitRenderer;
20 import gov.va.med.edp.control.SortHeaderEvent;
21 import mx.controls.dataGridClasses.DataGridColumn;
22 import mx.events.DataGridEvent;
23 import gov.va.med.edp.vo.ColumnSpecVO;
24 import gov.va.med.edp.control.DisplayBoardEvent;
25 import gov.va.med.edp.model.TrackingModelLocator;
26 import gov.va.med.edp.widget.ColorCellRenderer;
27
28 [Bindable]
29 private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
30 private var sortColumn:DataGridColumn;
31
32 private var refreshTimer: Timer = new Timer(30000);
33 private var visibleBoardTimer: Timer = new Timer(1000, 1);
34
35 private function initDisplayBoard(): void
36 {
37 if (model.session.area < 1) return;
38
39 var resetEvent: DisplayBoardEvent =
40 new DisplayBoardEvent(DisplayBoardEvent.EVENT_INIT_DISPLAY_BOARD);
41 resetEvent.dispatch();
42
43 refreshTimer.addEventListener(TimerEvent.TIMER, refreshDisplayBoard);
44 visibleBoardTimer.addEventListener(TimerEvent.TIMER_COMPLETE, removeLoadingDialog);
45
46 LoadingDialog.show();
47 visibleBoardTimer.start();
48
49 startBoardTimer(true);
50 }
51
52 private function startBoardTimer(firstTime:Boolean): void
53 {
54 //Dispatch a refresh event so that ppl are able to see their
55 //changes right away rather than sitting around waiting..
56 if (!firstTime)refreshDisplayBoard(new TimerEvent(TimerEvent.TIMER));
57 //do not refresh the display doard when the JAWS reader is active
58 //only fire refresh on demand by pressing F7 key...
59 if (!AccessibilityTools.isAccessibilityActive())refreshTimer.start();
60 callLater(board.setFocus);
61 }
62
63 private function stopBoardTimer(): void
64 {
65 refreshTimer.stop();
66 }
67
68 private function refreshDisplayBoard(event: TimerEvent): void
69 {
70 if (model.session.area < 1) return;
71
72 var refreshEvent: DisplayBoardEvent =
73 new DisplayBoardEvent(DisplayBoardEvent.EVENT_REFRESH_DISPLAY_BOARD);
74 refreshEvent.dispatch();
75 }
76
77 private function set readyToBuild(value: Boolean): void
78 {
79 if (value == true) {
80 callLater(buildColumns);
81 }
82 }
83
84 private function buildColumns(): void
85 {
86 var newCols:Array = new Array();
87 var newCol: DataGridColumn;
88 for each (var colInfo: ColumnSpecVO in model.boardSpec.columns) {
89 newCol = new DataGridColumn(colInfo.attribute);
90 newCol.headerText = colInfo.header;
91 newCol.dataField = colInfo.attribute;
92 newCol.width = colInfo.width;
93
94 //set the label and sort function for any minute based columns
95 if (colInfo.attribute.indexOf("min") != -1 ) {
96 newCol.sortCompareFunction = sortMinutes;
97 newCol.labelFunction = BoardTools.displayTimeAsHrsAndMins;
98 }
99
100 if ((colInfo.attribute == "@last4") || (colInfo.attribute == "@ptNm")) {
101 newCol.itemRenderer = new ClassFactory(gov.va.med.edp.widget.PatientCellRenderer);
102 //newCol.labelFunction = renderPatientName;
103 } else if (colInfo.attribute == "@visit") {
104 newCol.itemRenderer = new ClassFactory(gov.va.med.edp.widget.VisitRenderer);
105 } else {
106 newCol.itemRenderer = new ClassFactory(gov.va.med.edp.widget.ColorCellRenderer);
107 }
108 newCols.push(newCol);
109 }
110 board.columns = newCols;
111 callLater(board.setFocus);
112 }
113
114 private function sortMinutes(obj1:Object, obj2:Object):int
115 {
116 if (sortColumn == null) return 0;
117
118 var num1:Number = parseInt(obj1[sortColumn.dataField]);
119 var num2:Number = parseInt(obj2[sortColumn.dataField]);
120 return ObjectUtil.numericCompare(num1, num2);
121 }
122
123 private function removeLoadingDialog(event: TimerEvent): void
124 {
125 LoadingDialog.hide();
126 board.setFocus();
127 }
128
129 // this must be called later by handleHeader for the sortField to be accurate
130 private function saveSortInfo(col:DataGridColumn): void
131 {
132 var sortEvent:SortHeaderEvent =
133 new SortHeaderEvent(SortHeaderEvent.EVENT_SORT_DISPLAY_BOARD);
134 sortEvent.sortDescending = col.sortDescending;
135 sortEvent.sortField = col.dataField;
136 sortEvent.dispatch();
137 }
138
139 private function handleHeader(event:DataGridEvent): void
140 {
141 sortColumn = DataGridColumn(event.currentTarget.columns[event.columnIndex]);
142 callLater(saveSortInfo, [sortColumn]);
143 }
144
145 private function refreshBoardOnDemand(event:KeyboardEvent): void
146 {
147 if (event.keyCode == Keyboard.F7){
148 refreshDisplayBoard(new TimerEvent(TimerEvent.TIMER));
149 }
150 }
151
152 ]]>
153 </mx:Script>
154 <accessibility:AccessibilityProperties id="accssibleProps" name="EDIS Tracker Display Board. Press F7 to refresh data in Display Board"/>
155 <mx:DataGrid
156 id="board"
157 accessibilityProperties="{accssibleProps}"
158 dataProvider="{model.boardData}"
159 headerRelease="handleHeader(event)"
160 keyDown="refreshBoardOnDemand(event)"
161 width="100%" height="100%"
162 useRollOver="false" tabIndex="1000"/>
163
164 <mx:Binding source="model.boardSpec.specReady" destination="readyToBuild" />
165
166</mx:HBox>
Note: See TracBrowser for help on using the repository browser.