source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/view/config/ConfigSelections.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: 15.3 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<mx:VBox
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:acc="flash.accessibility.*"
5 width="100%" height="100%"
6 horizontalAlign="center"
7 creationComplete="init()"
8 show="loadSelectionLists()"
9 horizontalScrollPolicy="off"
10 verticalScrollPolicy="off"
11 currentState="{selectedListItem != null ? 'editing' : ''}">
12
13 <mx:Script>
14 <![CDATA[
15 import gov.va.med.edp.util.AccessibilityTools;
16 import mx.events.ListEvent;
17 import mx.managers.DragManager;
18 import mx.events.DragEvent;
19 import mx.binding.utils.BindingUtils;
20 import mx.collections.ArrayCollection;
21 import gov.va.med.edp.widget.InfoDialog;
22 import flash.events.Event;
23 import mx.events.DataGridEvent;
24 import gov.va.med.edp.vo.CodeSelectionVO;
25 import gov.va.med.edp.control.config.ConfigurationEvent;
26 import gov.va.med.edp.model.TrackingModelLocator;
27
28 [Embed(source="icon_close16.png")]
29 public var inactiveImg:Class;
30 public var activeImg:Class = Bitmap;
31
32 [Bindable]
33 private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
34
35 private var _selectedListItem:CodeSelectionVO;
36 private var reordering:Boolean = false;
37
38 [Bindable(event="selectedListItemChange")]
39 private function get selectedListItem():CodeSelectionVO {
40 return _selectedListItem;
41 }
42
43 private function set selectedListItem(item:CodeSelectionVO):void {
44 if (item == null) {
45 if (reordering) {
46 callLater(reselect);
47 return;
48 }
49 } else if (item === _selectedListItem) {
50 if (reordering) reordering = false;
51 }
52 _selectedListItem = item;
53 dispatchEvent(new Event("selectedListItemChange"));
54 }
55
56 private function reselect():void {
57 var index:int = selections.dataProvider.getItemIndex(_selectedListItem);
58 selections.scrollToIndex(index);
59 selections.selectedIndex = index;
60 setModifiedFlags();
61 }
62
63 private var newCount: int = 0;
64
65 [Bindable]
66 private var selectionLists:ArrayCollection = new ArrayCollection();
67
68 private function inactiveImgFunction(o:Object, c:DataGridColumn):String {
69 var code:CodeSelectionVO = o as CodeSelectionVO;
70 if (code.inactive)
71 return "inactiveImg";
72 else
73 return "activeImg";
74 }
75
76 private function loadSelectionLists(): void
77 {
78 if (model.config.selectionConfigLoaded) return;
79 var loadEvent: ConfigurationEvent =
80 new ConfigurationEvent(ConfigurationEvent.EVENT_LOAD_SELECTION_CONFIG);
81 loadEvent.dispatch();
82 }
83
84 private function init():void
85 {
86 var statuses:SelectionListDescriptor = new SelectionListDescriptor();
87 statuses.shortName = "Status";
88 statuses.longName = "Selections for Status";
89 statuses.flagsVisible = true;
90 BindingUtils.bindProperty(statuses, "list", model.config, "statuses");
91
92 var dispositions:SelectionListDescriptor = new SelectionListDescriptor();
93 dispositions.shortName = "Disposition";
94 dispositions.longName = "Selections for Disposition";
95 dispositions.flagsVisible = true;
96 BindingUtils.bindProperty(dispositions, "list", model.config, "dispositions");
97
98 var delays:SelectionListDescriptor = new SelectionListDescriptor();
99 delays.shortName = "Delay Reason";
100 delays.longName = "Selections for Delay Reason";
101 delays.flagsVisible = false;
102 BindingUtils.bindProperty(delays, "list", model.config, "delays");
103
104 var arrivals:SelectionListDescriptor = new SelectionListDescriptor();
105 arrivals.shortName = "Source";
106 arrivals.longName = "Selections for Mode of Arrival";
107 arrivals.flagsVisible = false;
108 BindingUtils.bindProperty(arrivals, "list", model.config, "arrivals");
109
110 selectionLists.addItem(statuses);
111 selectionLists.addItem(dispositions);
112 selectionLists.addItem(delays);
113 selectionLists.addItem(arrivals);
114 }
115
116 private function showFlagTip(item: Object): String
117 {
118 if (availLists.selectedIndex < 0) return "";
119
120 switch (availLists.selectedIndex) {
121 case 0:
122 return "A = Admission\nO = Observation";
123 case 1:
124 return "VA = VA Admission\n A = Admission\n M = Missed Opportunity";
125 }
126 return ""
127 }
128
129 private function markChanged(event:Event): void
130 {
131 //TODO: prevent default if exported selection?
132 if (availLists.selectedIndex < 0) return;
133
134 if (event.currentTarget === nameInput) {
135 selectedListItem.displayName = nameInput.text;
136 } else if (event.currentTarget === abbreviationInput) {
137 selectedListItem.abbreviation = abbreviationInput.text;
138 } else if (event.currentTarget === flagInput) {
139 selectedListItem.flag = flagInput.text;
140 } else if (event.currentTarget === inactiveCheckBox) {
141 selectedListItem.inactive = inactiveCheckBox.selected;
142 }
143
144 setModifiedFlags();
145 }
146
147 private function setModifiedFlags(): void
148 {
149 new ConfigurationEvent(ConfigurationEvent.EVENT_SELECTION_MODIFIED).dispatch();
150 //TODO: post event to model instead of modifying directly
151 switch (availLists.selectedIndex) {
152 case 0:
153 model.config.statusesChanged = true;
154 break;
155 case 1:
156 model.config.dispositionsChanged = true;
157 break;
158 case 2:
159 model.config.delaysChanged = true;
160 break;
161 case 3:
162 model.config.arrivalsChanged = true;
163 break;
164 }
165 }
166
167 private function listOrderTextChanged(event:Event):void {
168 if (listOrderInput.text.length == 0) return;
169 var newIndex:int = int(listOrderInput.text) - 1;
170 if (newIndex < 0 || newIndex >= selections.dataProvider.length) return;
171 if (newIndex != selections.selectedIndex) {
172 reordering = true;
173 var list: ArrayCollection = selections.dataProvider as ArrayCollection;
174 var sel: Object = list.removeItemAt(selections.selectedIndex);
175 list.addItemAt(sel, newIndex);
176 selections.selectedIndex = -1;
177 }
178 }
179
180 private function addEntry(): void
181 {
182 if (availLists.selectedIndex < 0) return;
183
184 //TODO: post event to model instead of just updating dataprovider
185 newCount++;
186 var list: ArrayCollection = selections.dataProvider as ArrayCollection;
187 var newEntry: CodeSelectionVO = new CodeSelectionVO();
188 newEntry.displayName = "new" + newCount;
189 newEntry.id = 0;
190 list.addItem(newEntry);
191 setModifiedFlags();
192 if (AccessibilityTools.isAccessibilityActive()) InfoDialog.show("New Item Added", "Message", true);
193
194 var newIndex: int = list.length - 1;
195 selections.scrollToIndex(newIndex);
196 selections.selectedIndex = newIndex;
197
198 }
199
200 private function saveChanges(): void
201 {
202 for each (var selectionList:SelectionListDescriptor in selectionLists) {
203 for each (var code:CodeSelectionVO in selectionList.list) {
204 if (code.displayName == null || code.displayName.length == 0) {
205 InfoDialog.show("There are selection list items with blank names which must be corrected before saving.\n"
206 , "Required Names", false, btnSaveSelectionChanges);
207 return;
208 }
209 }
210 }
211
212 var e:ConfigurationEvent =
213 new ConfigurationEvent(ConfigurationEvent.EVENT_SAVE_SELECTION_CONFIG);
214 e.dispatch();
215 }
216
217
218 private function handleEscKey(event:KeyboardEvent): void {
219 if (event.keyCode == Keyboard.ESCAPE) {
220 selections.selectedIndex = -1;
221 availLists.selectedIndex = -1;
222 if (btnSaveSelectionChanges.enabled)
223 btnSaveSelectionChanges.setFocus();
224 else
225 availLists.setFocus();
226 }
227 }
228
229 private function done():void {
230 selections.selectedIndex = -1;
231 if (btnSaveSelectionChanges.enabled)
232 btnSaveSelectionChanges.setFocus();
233 else
234 selections.setFocus();
235 }
236
237 private function doDragDrop(event:DragEvent):void {
238 reordering = true;
239 }
240
241 ]]>
242 </mx:Script>
243
244 <mx:HBox height="100%" width="100%" keyDown="handleEscKey(event)" horizontalScrollPolicy="off">
245 <mx:VBox>
246 <mx:Label
247 text="Selection List"
248 minHeight="{listControlBox.height}"
249 styleName="controlLabel" />
250 <mx:List
251 id="availLists"
252 accessibilityProperties="{availListsAcc}"
253 dataProvider="{selectionLists}"
254 labelField="shortName"
255 rowCount="{selectionLists.length}"
256 width="84"
257 backgroundColor="0xe7e7e7" cornerRadius="4"
258 tabIndex="1100"/>
259 </mx:VBox>
260 <mx:VBox
261 id="listArea"
262 height="100%"
263 visible="{availLists.selectedIndex > -1}">
264 <mx:HBox id="listControlBox" width="100%" verticalAlign="middle">
265 <mx:Button label="Add" click="addEntry()" tabIndex="1101"/>
266 <mx:Spacer width="2" />
267 <mx:Label id="viewTitle" styleName="controlLabel"
268 text="{availLists.selectedItem.longName}"/>
269 </mx:HBox>
270 <mx:DataGrid
271 id="selections"
272 accessibilityProperties="{selectionsAcc}"
273 width="100%" height="100%"
274 dataProvider="{availLists.selectedItem.list}"
275 editable="false"
276 dragEnabled="true"
277 dropEnabled="true"
278 dragMoveEnabled="true"
279 dragDrop="doDragDrop(event)"
280 tabIndex="1102">
281 <mx:columns>
282 <mx:DataGridColumn
283 headerText="Name"
284 dataField="displayName"
285 width="184" />
286 <mx:DataGridColumn
287 headerText="Abbr"
288 dataField="abbreviation"
289 width="42" />
290 <mx:DataGridColumn
291 headerText="Flags"
292 dataField="flag"
293 visible="{availLists.selectedItem.flagsVisible}"
294 dataTipFunction="showFlagTip"
295 showDataTips="true"
296 width="42" />
297 <mx:DataGridColumn
298 headerText="Inactive" textAlign="center"
299 labelFunction="inactiveImgFunction"
300 itemRenderer="gov.va.med.edp.widget.CenteredEmbedImage"
301 width="60" />
302 <mx:DataGridColumn
303 headerText="National Name"
304 dataField="national"
305 width="184" />
306 </mx:columns>
307 </mx:DataGrid>
308 </mx:VBox>
309 </mx:HBox>
310
311 <mx:HBox width="100%" horizontalAlign="center">
312 <mx:Button
313 id="btnSaveSelectionChanges"
314 label="Save Selection List Changes"
315 enabled="{(model.config.selectionMods &amp;&amp; model.config.selectionConfigLoaded)}"
316 click="saveChanges()" tabIndex="1900"/>
317 </mx:HBox>
318
319 <acc:AccessibilityProperties id="availListsAcc" name="Selection List"/>
320 <acc:AccessibilityProperties id="upButtonAcc" name="Up"/>
321 <acc:AccessibilityProperties id="downButtonAcc" name="Down"/>
322 <acc:AccessibilityProperties id="selectionsAcc" name="{viewTitle.text}"/>
323
324 <mx:states>
325 <mx:State name="editing">
326 <mx:AddChild position="after" relativeTo="{listArea}">
327 <mx:Form paddingLeft="0">
328 <mx:FormHeading label="Edit Selection Item"/>
329 <mx:FormItem label="Name">
330 <mx:TextInput id="nameInput" minWidth="184" text="{selectedListItem.displayName}"
331 styleName="formField"
332 change="markChanged(event)" tabIndex="1200"/>
333 </mx:FormItem>
334 <mx:FormItem label="Abbreviation">
335 <mx:TextInput id="abbreviationInput" minWidth="{nameInput.minWidth}" text="{selectedListItem.abbreviation}"
336 styleName="formField" change="markChanged(event)" tabIndex="1201"/>
337 </mx:FormItem>
338 <mx:FormItem label="Flags" visible="{availLists.selectedItem.flagsVisible}"
339 toolTip="{showFlagTip(null)}">
340 <mx:TextInput id="flagInput" minWidth="{nameInput.minWidth}" text="{selectedListItem.flag}" styleName="formField"
341 change="markChanged(event)" tabIndex="1202"/>
342 </mx:FormItem>
343 <mx:FormItem label="Inactive">
344 <mx:CheckBox id="inactiveCheckBox" selected="{selectedListItem.inactive}"
345 styleName="formField" change="markChanged(event)" tabIndex="1203"/>
346 </mx:FormItem>
347 <mx:FormItem label="List Order" visible="{AccessibilityTools.isAccessibilityActive()}">
348 <mx:TextInput
349 id="listOrderInput"
350 minWidth="{nameInput.minWidth}"
351 text="{availLists.selectedItem.list.getItemIndex(selectedListItem) + 1}"
352 styleName="formField"
353 tabIndex="1205"
354 change="listOrderTextChanged(event)"/>
355 </mx:FormItem>
356 </mx:Form>
357 </mx:AddChild>
358 </mx:State>
359 </mx:states>
360
361 <mx:NumberValidator id="listOrderValidator" minValue="1" maxValue="{availLists.selectedItem.list.length}"
362 source="{listOrderInput}" property="text"/>
363 <mx:StringValidator id="nameValidator" required="true" source="{nameInput}" property="text"/>
364
365 <mx:Binding source="selections.selectedItem as CodeSelectionVO" destination="selectedListItem"/>
366</mx:VBox>
Note: See TracBrowser for help on using the repository browser.