source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/view/config/ConfigStaff.mxml@ 1227

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

initial load of EDIS 1.0

File size: 16.9 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<mx:VBox
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:widget="gov.va.med.edp.widget.*"
5 xmlns:accessibility="flash.accessibility.*"
6 width="100%" height="100%"
7 show="providerSrc.setFocus();"
8 paddingTop="6" paddingBottom="6" paddingLeft="12" paddingRight="12"
9 currentState="{getState(model.appViewState)}"
10 styleName="contentArea" >
11
12 <mx:Script>
13 <![CDATA[
14 import gov.va.med.edp.control.config.ColorChangedEvent;
15 import gov.va.med.edp.widget.InfoDialog;
16 import mx.collections.ICollectionView;
17 import gov.va.med.edp.control.config.MatchPersonEvent;
18 import mx.events.DataGridEvent;
19 import gov.va.med.edp.widget.AutoComplete;
20 import gov.va.med.edp.widget.ColorSelector;
21 import mx.controls.DataGrid;
22 import gov.va.med.edp.vo.StaffMemberVO;
23 import gov.va.med.edp.control.config.UpdateStaffEvent;
24 import gov.va.med.edp.control.config.ConfigurationEvent;
25 import gov.va.med.edp.model.TrackingModelLocator;
26 import gov.va.med.edp.util.AccessibilityTools;
27 import gov.va.med.edp.util.KeyUtils;
28 import mx.core.UIComponent;
29
30 [Bindable]
31 private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
32
33 [Bindable]
34 private var selectedProvider:StaffMemberVO;
35 [Bindable]
36 private var selectedResident:StaffMemberVO;
37 [Bindable]
38 private var selectedNurse:StaffMemberVO;
39
40 private static const WIDTH:int = 320;
41
42 private var curStaffSrc: AutoComplete;
43 private var keyTimer: Timer;
44 private var lastRoot: String = "";
45
46 private function getState(state: int): String
47 // monitor state instead of using show event, since show not called on initial view
48 {
49 if (model.appViewState == TrackingModelLocator.VIEW_APP_ASSIGN_STAFF) {
50 loadStaffLists();
51 }
52 return "";
53 }
54
55 private function setStaffSrc(src: AutoComplete): void
56 {
57 // clear the control we are leaving
58 if (curStaffSrc != null) {
59 curStaffSrc.typedText = "";
60 }
61 if (src == null) {
62 var e:MatchPersonEvent = new MatchPersonEvent(MatchPersonEvent.EVENT_MATCH_PERSON);
63 e.partial = "";
64 e.personType = "";
65 }
66
67 // set to the new control or null
68 curStaffSrc = src;
69 lastRoot = "";
70 if ((keyTimer != null) && keyTimer.running) {
71 keyTimer.stop();
72 }
73 }
74
75 private function setTimer(event: Event): void
76 {
77 // stop the running timer, if we come back here too soon
78 if ((keyTimer != null) && keyTimer.running) {
79 keyTimer.stop();
80 }
81 // don't start the timer if we already have the subset of choices
82 if ((lastRoot.length > 0) && (curStaffSrc.typedText.substr(0, lastRoot.length) == lastRoot)) {
83 return;
84 }
85 // only search for inputs of length 3 or more
86 if (curStaffSrc != null && curStaffSrc.typedText.length > 2) {
87 keyTimer = new Timer(500,1);
88 keyTimer.addEventListener("timer", refreshStaffSrc);
89 keyTimer.start();
90 }
91 }
92
93 private function refreshStaffSrc(event: TimerEvent): void
94 {
95 lastRoot = curStaffSrc.typedText.toUpperCase();
96 var e: MatchPersonEvent = new MatchPersonEvent(MatchPersonEvent.EVENT_MATCH_PERSON);
97 e.partial = lastRoot;
98 if (curStaffSrc == providerSrc) {e.personType = "P"}
99 if (curStaffSrc == residentSrc) {e.personType = "R"}
100 if (curStaffSrc == nurseSrc) {e.personType = "N"}
101 e.dispatch();
102 }
103
104 private function set staffSrcReady(isReady: Boolean): void
105 {
106 if (isReady == false) return;
107 curStaffSrc.dataProvider = model.config.srcStaff;
108 curStaffSrc.open();
109 if (model.config.srcStaff.length > 0) curStaffSrc.selectedIndex = 0;
110 }
111
112 private function loadStaffLists(): void
113 {
114 if (model.config.staffConfigLoaded) return;
115 var loadEvent: ConfigurationEvent =
116 new ConfigurationEvent(ConfigurationEvent.EVENT_LOAD_STAFF_CONFIG);
117 loadEvent.dispatch();
118 }
119
120 private function addStaff(list: AutoComplete, role: String, grid: DataGrid): void
121 {
122 var staff:StaffMemberVO = null;
123 if (list!= null && list.selectedItem != null) {
124 staff = list.selectedItem as StaffMemberVO;
125 UpdateStaffEvent.dispatchAdd(staff, role);
126 grid.setFocus();
127 } else {
128 var selectedStaffMemberName:String = list.typedText;
129 if (selectedStaffMemberName != null && selectedStaffMemberName != ""){
130 var ac:ICollectionView = list.dataProvider as ICollectionView;
131 for each (var item:StaffMemberVO in ac){
132 if (selectedStaffMemberName == item.displayName){
133 staff = item;
134 UpdateStaffEvent.dispatchAdd(staff, role);
135 grid.setFocus();
136 break;
137 }
138 }
139 }
140 }
141 resetAutoComplete(list);
142
143 }
144
145
146 private function resetAutoComplete(list:AutoComplete):void{
147 list.selectedIndex = -1;
148 list.typedText = "";
149 }
150
151 private function handleRemoveAndEscKeys(event:KeyboardEvent, grid: DataGrid):void{
152 if (KeyUtils.isRemoveKey(event)){
153 removeStaff(grid);
154 } else if (event.keyCode == Keyboard.ESCAPE){
155 grid.selectedIndex = -1;
156 btnSaveStaff.setFocus();
157 }
158 }
159
160
161 private function removeStaff(grid: DataGrid): void
162 {
163 if (grid.selectedIndex < 0 || grid.selectedItem == null) return;
164 var selectedIndx:int = grid.selectedIndex;
165 var staff:StaffMemberVO = grid.selectedItem as StaffMemberVO;
166 UpdateStaffEvent.dispatchRemove(staff);
167 if (AccessibilityTools.isAccessibilityActive())InfoDialog.show("removed successfully", "Message", true, grid);
168 grid.setFocus();
169 if (grid.dataProvider.length > 0){
170 grid.selectedIndex = selectedIndx - 1;
171 }
172 }
173
174 private function saveStaff(): void
175 {
176 var saveEvent: ConfigurationEvent =
177 new ConfigurationEvent(ConfigurationEvent.EVENT_SAVE_STAFF_CONFIG);
178 saveEvent.dispatch();
179
180 providerDest.selectedIndex = -1;
181 residentDest.selectedIndex = -1;
182 nurseDest.selectedIndex = -1;
183 }
184
185
186 private function enableButton(list: AutoComplete,component:UIComponent):void
187 {
188 var enableFlag:Boolean = false;
189
190 if (list.typedText == "")
191 {
192 enableFlag = false;
193 }
194 else
195 {
196 if ((list.selectedIndex > -1) || ((list.text.length > 0) && (list.text != null)))
197 {
198 enableFlag = true;
199 }
200 }
201
202 component.enabled = enableFlag;
203 }
204
205 private function fireColorChange(event:ColorChangedEvent):void {
206 var staffMember:StaffMemberVO = null;
207 if (event.currentTarget === providerColorSelector) {
208 staffMember = selectedProvider;
209 if (staffMember.color != providerColorSelector.color) {
210 staffMember.color.ignore = providerColorSelector.color.ignore;
211 staffMember.color.text = providerColorSelector.color.text;
212 staffMember.color.back = providerColorSelector.color.back;
213 staffMember.colorChanged = true;
214 new ConfigurationEvent(ConfigurationEvent.EVENT_STAFF_MODIFIED).dispatch();
215 model.config.providers.refresh();
216 }
217 } else if (event.currentTarget === residentColorSelector) {
218 staffMember = selectedResident;
219 if (staffMember.color != residentColorSelector.color) {
220 staffMember.color.ignore = residentColorSelector.color.ignore;
221 staffMember.color.text = residentColorSelector.color.text;
222 staffMember.color.back = residentColorSelector.color.back;
223 staffMember.colorChanged = true;
224 new ConfigurationEvent(ConfigurationEvent.EVENT_STAFF_MODIFIED).dispatch();
225 model.config.residents.refresh();
226 }
227 } else if (event.currentTarget === nurseColorSelector) {
228 staffMember = selectedNurse;
229 if (staffMember.color != nurseColorSelector.color) {
230 staffMember.color.ignore = nurseColorSelector.color.ignore;
231 staffMember.color.text = nurseColorSelector.color.text;
232 staffMember.color.back = nurseColorSelector.color.back;
233 staffMember.colorChanged = true;
234 new ConfigurationEvent(ConfigurationEvent.EVENT_STAFF_MODIFIED).dispatch();
235 model.config.nurses.refresh();
236 }
237 }
238 }
239 ]]>
240 </mx:Script>
241
242 <mx:HBox width="100%" height="100%">
243 <mx:VBox verticalGap="0">
244 <mx:Label id="mdLabel" text="Providers" styleName="controlLabel" />
245 <widget:AutoComplete
246 id="providerSrc"
247 name="Autocomplete Provider Name"
248 focusIn="{setStaffSrc(providerSrc); enableButton(providerSrc,addProvider)}"
249 focusOut="{setStaffSrc(null); enableButton(providerSrc,addProvider)}"
250 keyUp="enableButton(providerSrc,addProvider)"
251 typedTextChange="setTimer(event)"
252 selectedIndex="-1"
253 prompt="(type provider name)"
254 labelField="displayName"
255 width="190"
256 enter="{addStaff(providerSrc, 'P', providerDest)}"
257 tabIndex="1001"/>
258 </mx:VBox>
259 <mx:Canvas height="100%">
260 <mx:Button
261 label="Add &gt;&gt;"
262 id="addProvider"
263 initialize="{AccessibilityTools.accessComponentDescription(addProvider,'Press button to add provider to the list.')}"
264 top="{mdLabel.height}" horizontalCenter="0"
265 click="addStaff(providerSrc, 'P', providerDest); enableButton(providerSrc,addProvider)"
266 enabled="{false}"
267 tabIndex="1002"
268 focusEnabled="false"/>
269 <mx:Button
270 label="Remove"
271 id="removeProvider"
272 initialize="{AccessibilityTools.accessComponentDescription(removeProvider,'Press button to remove provider from the list.')}"
273 verticalCenter="0" horizontalCenter="0"
274 click="removeStaff(providerDest)"
275 enabled="{providerDest.selectedItem != null}"
276 tabIndex="1004"
277 focusEnabled="false"/>
278 </mx:Canvas>
279 <mx:DataGrid
280 id="providerDest"
281 accessibilityProperties="{providerAccProps}"
282 height="100%"
283 editable="false"
284 keyDown="handleRemoveAndEscKeys(event,providerDest)"
285 dataProvider="{model.config.providers}"
286 headerStyleName="controlLabel"
287 tabIndex="1003">
288 <mx:columns>
289 <mx:DataGridColumn
290 headerText="Provider"
291 dataField="name"
292 width="190"/>
293 <mx:DataGridColumn
294 headerText="Initials"
295 dataField="initials"
296 width="60"/>
297 <mx:DataGridColumn
298 editable="true"
299 headerText="Color"
300 width="90"
301 dataField="color"
302 itemRenderer="gov.va.med.edp.widget.ColorSampleRenderer" />
303 </mx:columns>
304 </mx:DataGrid>
305 <mx:VBox
306 verticalGap="2"
307 height="100%"
308 id="providerColorSelectorFrm"
309 visible="{providerDest.selectedItem != null}">
310 <mx:Label text="Change Color"/>
311 <widget:ColorSelector id="providerColorSelector" tabIndex="1004" color="{selectedProvider.color}" colorChange="fireColorChange(event)"/>
312 </mx:VBox>
313 </mx:HBox>
314
315 <mx:HBox width="100%" height="100%" paddingTop="18">
316 <mx:VBox verticalGap="0">
317 <mx:Label text="Residents" styleName="controlLabel" />
318 <widget:AutoComplete
319 id="residentSrc"
320 name="Autocomplete resident name"
321 focusIn="setStaffSrc(residentSrc); enableButton(residentSrc,addResident)"
322 focusOut="setStaffSrc(null); enableButton(residentSrc,addResident)"
323 keyUp="enableButton(residentSrc,addResident)"
324 typedTextChange="setTimer(event)"
325 selectedIndex="-1"
326 prompt="(type resident name)"
327 labelField="displayName"
328 width="190"
329 enter="addStaff(residentSrc, 'R', residentDest)"
330 tabIndex="1010"/>
331 </mx:VBox>
332 <mx:Canvas height="100%">
333 <mx:Button
334 label="Add &gt;&gt;"
335 id="addResident"
336 initialize="{AccessibilityTools.accessComponentDescription(addResident,'Press button to add resident to the list.')}"
337 top="{mdLabel.height}" horizontalCenter="0"
338 click="addStaff(residentSrc, 'R', residentDest); enableButton(residentSrc,addResident)"
339 tabIndex="1011"
340 enabled="{false}"
341 focusEnabled="false"/>
342 <mx:Button
343 label="Remove"
344 id="remResident"
345 initialize="{AccessibilityTools.accessComponentDescription(remResident,'Press button to remove resident from the list.')}"
346 verticalCenter="0" horizontalCenter="0"
347 click="removeStaff(residentDest)"
348 tabIndex="1013"
349 enabled="{residentDest.selectedItem != null}"
350 focusEnabled="false"/>
351 </mx:Canvas>
352
353 <mx:DataGrid
354 id="residentDest"
355 accessibilityProperties="{residentAccProps}"
356 height="100%"
357 editable="false"
358 keyDown="handleRemoveAndEscKeys(event,residentDest)"
359 dataProvider="{model.config.residents}"
360 headerStyleName="controlLabel"
361 tabIndex="1012">
362 <mx:columns>
363 <mx:DataGridColumn
364 headerText="Resident"
365 dataField="name"
366 width="190"/>
367 <mx:DataGridColumn
368 headerText="Initials"
369 dataField="initials"
370 width="60"/>
371 <mx:DataGridColumn
372 editable="true"
373 headerText="Color"
374 width="90"
375 dataField="color"
376 itemRenderer="gov.va.med.edp.widget.ColorSampleRenderer" />
377 </mx:columns>
378 </mx:DataGrid>
379 <mx:VBox
380 verticalGap="2"
381 height="100%"
382 id="residentColorSelectorFrm"
383 visible="{residentDest.selectedItem != null}">
384 <mx:Label text="Change Color"/>
385 <widget:ColorSelector id="residentColorSelector" tabIndex="1013" color="{selectedResident.color}" colorChange="fireColorChange(event)"/>
386 </mx:VBox>
387 </mx:HBox>
388
389 <mx:HBox width="100%" height="100%" paddingTop="18">
390 <mx:VBox verticalGap="0">
391 <mx:Label text="Nurses" styleName="controlLabel" />
392 <widget:AutoComplete
393 id="nurseSrc"
394 name="Autocomplete nurse name"
395 focusIn="setStaffSrc(nurseSrc); enableButton(nurseSrc,addNurse)"
396 focusOut="setStaffSrc(null); enableButton(nurseSrc,addNurse)"
397 keyUp="enableButton(nurseSrc,addNurse)"
398 typedTextChange="setTimer(event)"
399 selectedIndex="-1"
400 prompt="(type nurse name)"
401 labelField="displayName"
402 width="190"
403 enter="addStaff(nurseSrc, 'N', nurseDest)"
404 tabIndex="1020"/>
405 </mx:VBox>
406 <mx:Canvas height="100%">
407 <mx:Button
408 label="Add &gt;&gt;"
409 id="addNurse"
410 initialize="{AccessibilityTools.accessComponentDescription(addNurse,'Press button to add nurse to the list.')}"
411 top="{mdLabel.height}" horizontalCenter="0"
412 click="addStaff(nurseSrc, 'N', nurseDest); enableButton(nurseSrc,addNurse)"
413 enabled="{false}"
414 tabIndex="1021"
415 focusEnabled="false"/>
416 <mx:Button
417 label="Remove"
418 id="remNurse"
419 initialize="{AccessibilityTools.accessComponentDescription(remNurse,'Press button to remove nurse from the list.')}"
420 verticalCenter="0" horizontalCenter="0"
421 click="removeStaff(nurseDest)"
422 enabled="{nurseDest.selectedItem != null}"
423 tabIndex="1023"
424 focusEnabled="false"/>
425 </mx:Canvas>
426 <mx:DataGrid
427 id="nurseDest"
428 accessibilityProperties="{nurseAccProps}"
429 height="100%"
430 editable="false"
431 keyDown="handleRemoveAndEscKeys(event,nurseDest)"
432 dataProvider="{model.config.nurses}"
433 headerStyleName="controlLabel"
434 tabIndex="1022">
435 <mx:columns>
436 <mx:DataGridColumn
437 headerText="Nurse"
438 dataField="name"
439 width="190"/>
440 <mx:DataGridColumn
441 headerText="Initials"
442 dataField="initials"
443 width="60"/>
444 <mx:DataGridColumn
445 editable="true"
446 headerText="Color"
447 width="90"
448 dataField="color"
449 itemRenderer="gov.va.med.edp.widget.ColorSampleRenderer" />
450 </mx:columns>
451 </mx:DataGrid>
452 <mx:VBox
453 verticalGap="2"
454 height="100%"
455 id="nurseColorSelectorFrm"
456 visible="{nurseDest.selectedItem != null}">
457 <mx:Label text="Change Color"/>
458 <widget:ColorSelector id="nurseColorSelector" tabIndex="1023" color="{selectedNurse.color}" colorChange="fireColorChange(event)"/>
459 </mx:VBox>
460 </mx:HBox>
461
462 <mx:Canvas width="100%" >
463 <mx:Button
464 id = "btnSaveStaff"
465 label="Save Staff Changes"
466 enabled="{(model.config.staffMods &amp;&amp; model.config.staffConfigLoaded)}"
467 horizontalCenter="0" top="6" bottom="6"
468 click="saveStaff()"
469 tabIndex="1100"/>
470 </mx:Canvas>
471 <accessibility:AccessibilityProperties id="residentAccProps" name="active residents list"/>
472 <accessibility:AccessibilityProperties id="providerAccProps" name="active providers list"/>
473 <accessibility:AccessibilityProperties id="nurseAccProps" name="active nurses list"/>
474 <mx:Binding source="model.config.srcStaffReady" destination="staffSrcReady" />
475 <mx:Binding source="StaffMemberVO(providerDest.selectedItem)" destination="selectedProvider"/>
476 <mx:Binding source="StaffMemberVO(residentDest.selectedItem)" destination="selectedResident"/>
477 <mx:Binding source="StaffMemberVO(nurseDest.selectedItem)" destination="selectedNurse"/>
478</mx:VBox>
Note: See TracBrowser for help on using the repository browser.