1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
2 | <mx:HBox
|
---|
3 | xmlns:mx="http://www.adobe.com/2006/mxml"
|
---|
4 | xmlns:acc="flash.accessibility.*"
|
---|
5 | xmlns:config-model="gov.va.med.edp.vo.*"
|
---|
6 | xmlns:widget="gov.va.med.edp.widget.*"
|
---|
7 | creationComplete="init()"
|
---|
8 | horizontalGap="0"
|
---|
9 | width="100%" height="100%"
|
---|
10 | currentState="{selectedBed != null ? 'editing' : ''}" xmlns:config="gov.va.med.edp.view.config.*">
|
---|
11 |
|
---|
12 | <mx:Script>
|
---|
13 | <![CDATA[
|
---|
14 | import mx.events.DragEvent;
|
---|
15 | import mx.validators.Validator;
|
---|
16 | import mx.controls.Image;
|
---|
17 | import mx.binding.utils.BindingUtils;
|
---|
18 | import mx.events.ListEvent;
|
---|
19 | import gov.va.med.edp.util.Vista;
|
---|
20 | import gov.va.med.edp.widget.InfoDialog;
|
---|
21 | import gov.va.med.edp.widget.CenteredCheckBox;
|
---|
22 | import mx.collections.ArrayCollection;
|
---|
23 | import gov.va.med.edp.control.config.ConfigurationEvent;
|
---|
24 | import mx.core.UIComponent;
|
---|
25 | import mx.controls.CheckBox;
|
---|
26 | import mx.controls.ComboBox;
|
---|
27 | import mx.controls.TextInput;
|
---|
28 | import mx.events.CollectionEvent;
|
---|
29 | import mx.events.CollectionEventKind;
|
---|
30 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
31 | import gov.va.med.edp.control.config.ChangeBedSequenceEvent;
|
---|
32 | import gov.va.med.edp.control.config.SaveBedConfigEvent;
|
---|
33 | import gov.va.med.edp.control.config.AddBedEvent;
|
---|
34 | import gov.va.med.edp.vo.RoomBedVO;
|
---|
35 | import gov.va.med.edp.widget.ColorSelector;
|
---|
36 | import gov.va.med.edp.vo.ColorSelectionVO;
|
---|
37 | import gov.va.med.edp.util.AccessibilityTools;
|
---|
38 |
|
---|
39 | [Embed(source="icon_close16.png")]
|
---|
40 | public var inactiveImg:Class;
|
---|
41 |
|
---|
42 | public var activeImg:Class = Bitmap;
|
---|
43 |
|
---|
44 | [Bindable]
|
---|
45 | private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
46 |
|
---|
47 | private var reordering:Boolean = false;
|
---|
48 |
|
---|
49 | private var _selectedBed:RoomBedVO;
|
---|
50 |
|
---|
51 | private var newCount: int = 0;
|
---|
52 |
|
---|
53 | private var validators:Array;
|
---|
54 |
|
---|
55 | [Bindable(event="selectedBedChange")]
|
---|
56 | private function get selectedBed():RoomBedVO {
|
---|
57 | return _selectedBed;
|
---|
58 | }
|
---|
59 |
|
---|
60 | private function set selectedBed(bed:RoomBedVO):void {
|
---|
61 | if (bed == null) {
|
---|
62 | if (reordering) {
|
---|
63 | callLater(reselect);
|
---|
64 | return;
|
---|
65 | }
|
---|
66 | } else if (bed === _selectedBed) {
|
---|
67 | if (reordering) reordering = false;
|
---|
68 | }
|
---|
69 | _selectedBed = bed;
|
---|
70 | dispatchEvent(new Event("selectedBedChange"));
|
---|
71 | }
|
---|
72 |
|
---|
73 | private function reselect():void {
|
---|
74 | var index:int = grdBeds.dataProvider.getItemIndex(_selectedBed);
|
---|
75 | grdBeds.scrollToIndex(index);
|
---|
76 | grdBeds.selectedIndex = index;
|
---|
77 | model.config.bedMods = true;
|
---|
78 | }
|
---|
79 |
|
---|
80 | private function init():void {
|
---|
81 | validators = [roomBedNameValidator, roomBedDisplayNameValidator];
|
---|
82 | }
|
---|
83 |
|
---|
84 | private function selectedItemChanged(): void {
|
---|
85 | Validator.validateAll(validators);
|
---|
86 | }
|
---|
87 |
|
---|
88 | private function inactiveImgFunction(o:Object, c:DataGridColumn):String {
|
---|
89 | var bed:RoomBedVO = o as RoomBedVO;
|
---|
90 | if (bed.inactive)
|
---|
91 | return "inactiveImg";
|
---|
92 | else
|
---|
93 | return "activeImg";
|
---|
94 | }
|
---|
95 |
|
---|
96 | private function saveBeds(): void
|
---|
97 | {
|
---|
98 | // loop thru all beds checking for duplicates
|
---|
99 | var i: int;
|
---|
100 | var bed: RoomBedVO;
|
---|
101 | var empties: Boolean = false;
|
---|
102 | var dups: String = "";
|
---|
103 | var dflts: String = "";
|
---|
104 | for (i = 0; i < model.config.beds.source.length; i++) {
|
---|
105 | bed = model.config.beds.source[i] as RoomBedVO;
|
---|
106 | if (bed.name == null || bed.name.length == 0 || bed.displayName == null || bed.displayName.length == 0) {
|
---|
107 | empties = true;
|
---|
108 | break;
|
---|
109 | }
|
---|
110 | if (isDuplicate("name", bed.name, i) || isDuplicate("displayName", bed.displayName, i)) {
|
---|
111 | dups = dups + bed.name + ": " + bed.displayName + "\n";
|
---|
112 | }
|
---|
113 | if (bed.inactive && (bed.id == model.config.params.ambulanceArea)) {
|
---|
114 | dflts = dflts + bed.name + ": " + bed.displayName + "\n";
|
---|
115 | }
|
---|
116 | if (bed.inactive && (bed.id == model.config.params.defaultRoom)) {
|
---|
117 | dflts = dflts + bed.name + ": " + bed.displayName + "\n";
|
---|
118 | }
|
---|
119 | }
|
---|
120 | if (empties) {
|
---|
121 | InfoDialog.show("There are Room/Areas with blank names which must be corrected before saving.\n"
|
---|
122 | , "Required Names", false, btnSave);
|
---|
123 | return;
|
---|
124 | }
|
---|
125 | if (dups.length > 0) {
|
---|
126 | InfoDialog.show("The following duplicate names must be corrected before saving:\n"
|
---|
127 | + dups, "Duplicate Names", false, btnSave);
|
---|
128 | return;
|
---|
129 | }
|
---|
130 |
|
---|
131 | if (dflts.length > 0) {
|
---|
132 | InfoDialog.show("The following are default rooms/areas and may not be inactivated:\n"
|
---|
133 | + dflts, "Default Rooms/Areas", false, btnSave);
|
---|
134 | return;
|
---|
135 | }
|
---|
136 |
|
---|
137 | var saveEvent: SaveBedConfigEvent =
|
---|
138 | new SaveBedConfigEvent(SaveBedConfigEvent.EVENT_SAVE_CONFIG_BEDS);
|
---|
139 | saveEvent.dispatch();
|
---|
140 | }
|
---|
141 |
|
---|
142 | private function addBed(): void
|
---|
143 | {
|
---|
144 | newCount++;
|
---|
145 | var addEvent: AddBedEvent = new AddBedEvent(AddBedEvent.EVENT_ADD_BED);
|
---|
146 | addEvent.newIndex = newCount;
|
---|
147 | addEvent.dispatch();
|
---|
148 | this.callLater(selectNewIndex, [model.config.beds.length]);
|
---|
149 | }
|
---|
150 |
|
---|
151 | private function isDuplicate(field: String, value: String, index: int): Boolean
|
---|
152 | {
|
---|
153 | if (!((field == "name") || (field == "displayName"))) return false;
|
---|
154 |
|
---|
155 | var bed: RoomBedVO;
|
---|
156 | for (var i: int = 0; i < model.config.beds.length; i++) {
|
---|
157 | if (i == index) continue;
|
---|
158 | bed = model.config.beds[i] as RoomBedVO;
|
---|
159 | if (bed[field].toLowerCase() == value.toLowerCase()) return true;
|
---|
160 | }
|
---|
161 | return false;
|
---|
162 | }
|
---|
163 |
|
---|
164 | private function markChanged(event: Event): void
|
---|
165 | {
|
---|
166 | var bed: RoomBedVO = selectedBed;
|
---|
167 |
|
---|
168 | if (event.currentTarget === nameInput) {
|
---|
169 | if (bed.name != nameInput.text) {
|
---|
170 | bed.name = nameInput.text;
|
---|
171 | bed.changed = true;
|
---|
172 | }
|
---|
173 | } else if (event.currentTarget === displayNameInput) {
|
---|
174 | if (bed.displayName != displayNameInput.text) {
|
---|
175 | bed.displayName = displayNameInput.text;
|
---|
176 | bed.changed = true;
|
---|
177 | }
|
---|
178 | } else if (event.currentTarget === whenChooser) {
|
---|
179 | if (bed.displayWhen != whenChooser.selectedItem.data) {
|
---|
180 | bed.displayWhen = int(whenChooser.selectedItem.data);
|
---|
181 | bed.changed = true;
|
---|
182 | }
|
---|
183 | } else if (event.currentTarget === statusChooser) {
|
---|
184 | if (bed.defaultStatus != statusChooser.selectedItem.data) {
|
---|
185 | bed.defaultStatus = statusChooser.selectedItem.data;
|
---|
186 | bed.changed = true;
|
---|
187 | }
|
---|
188 | } else if (event.currentTarget === inactiveCheckBox) {
|
---|
189 | if (bed.inactive != inactiveCheckBox.selected) {
|
---|
190 | bed.inactive = inactiveCheckBox.selected;
|
---|
191 | bed.changed = true;
|
---|
192 | }
|
---|
193 | } else if (event.currentTarget === roomCategoryChooser) {
|
---|
194 | if (bed.category != roomCategoryChooser.selectedItem.data) {
|
---|
195 | bed.category = int(roomCategoryChooser.selectedItem.data);
|
---|
196 | bed.changed = true;
|
---|
197 | }
|
---|
198 | } else if (event.currentTarget === sharedInput) {
|
---|
199 | if (bed.sharedName != sharedInput.text) {
|
---|
200 | bed.sharedName = sharedInput.text;
|
---|
201 | bed.changed = true;
|
---|
202 | }
|
---|
203 | } else if (event.currentTarget === boardInput) {
|
---|
204 | if (bed.boardName != boardInput.text) {
|
---|
205 | bed.boardName = boardInput.text;
|
---|
206 | bed.changed = true;
|
---|
207 | }
|
---|
208 | } else if (event.currentTarget === colorSelector) {
|
---|
209 | if (bed.color != colorSelector.color) {
|
---|
210 | bed.color.ignore = colorSelector.color.ignore;
|
---|
211 | bed.color.text = colorSelector.color.text;
|
---|
212 | bed.color.back = colorSelector.color.back;
|
---|
213 | bed.changed = true;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | if (bed.changed) {
|
---|
217 | new ConfigurationEvent(ConfigurationEvent.EVENT_BED_MODIFIED).dispatch();
|
---|
218 | }
|
---|
219 | model.config.beds.refresh();
|
---|
220 | }
|
---|
221 |
|
---|
222 | private function listOrderTextChanged(event:Event):void {
|
---|
223 | if (listOrderInput.text.length == 0) return;
|
---|
224 | var newIndex:int = int(listOrderInput.text) - 1;
|
---|
225 | if (newIndex < 0 || newIndex >= grdBeds.dataProvider.length) return;
|
---|
226 | if (newIndex != grdBeds.selectedIndex) {
|
---|
227 | reordering = true;
|
---|
228 | var changeEvent: ChangeBedSequenceEvent = new ChangeBedSequenceEvent(ChangeBedSequenceEvent.EVENT_CHANGE_BED_SEQUENCE);
|
---|
229 | changeEvent.newIndex = newIndex;
|
---|
230 | changeEvent.oldIndex = grdBeds.selectedIndex;
|
---|
231 | changeEvent.dispatch();
|
---|
232 | grdBeds.selectedIndex = -1;
|
---|
233 | }
|
---|
234 | }
|
---|
235 |
|
---|
236 | private function selectNewIndex(newIndex: int): void
|
---|
237 | {
|
---|
238 | grdBeds.scrollToIndex(newIndex);
|
---|
239 | grdBeds.selectedIndex = newIndex;
|
---|
240 | }
|
---|
241 |
|
---|
242 | private function refreshBedFilter(): void {
|
---|
243 | if (hideInactiveCheckBox.selected) {
|
---|
244 | model.config.beds.filterFunction = activeBedFilter;
|
---|
245 | } else {
|
---|
246 | model.config.beds.filterFunction = null;
|
---|
247 | }
|
---|
248 | model.config.beds.refresh();
|
---|
249 | }
|
---|
250 |
|
---|
251 | private function activeBedFilter(item:Object): Boolean {
|
---|
252 | var roomBed : RoomBedVO = item as RoomBedVO;
|
---|
253 | return !roomBed.inactive;
|
---|
254 | }
|
---|
255 |
|
---|
256 | private function keyDownHadler(event:KeyboardEvent): void {
|
---|
257 | if (event.keyCode == Keyboard.ESCAPE) {
|
---|
258 | update();
|
---|
259 | }
|
---|
260 | }
|
---|
261 |
|
---|
262 | private function update():void {
|
---|
263 | if (btnSave.enabled)
|
---|
264 | btnSave.setFocus();
|
---|
265 | else
|
---|
266 | grdBeds.setFocus();
|
---|
267 | grdBeds.selectedIndex = -1;
|
---|
268 | }
|
---|
269 |
|
---|
270 | private function doDragDrop(event:DragEvent):void {
|
---|
271 | reordering = true;
|
---|
272 | }
|
---|
273 |
|
---|
274 | ]]>
|
---|
275 | </mx:Script>
|
---|
276 |
|
---|
277 | <mx:VBox height="100%" width="100%">
|
---|
278 | <mx:HBox width="100%" verticalAlign="middle">
|
---|
279 | <mx:Button
|
---|
280 | label="Add Room/Area"
|
---|
281 | id="addRoomBtn"
|
---|
282 | click="addBed()"
|
---|
283 | tabIndex="1100"/>
|
---|
284 | <mx:Spacer width="100%"/>
|
---|
285 | <mx:Label
|
---|
286 | text="Rooms / Areas"
|
---|
287 | styleName="controlLabel"/>
|
---|
288 | <mx:Spacer width="100%"/>
|
---|
289 | <mx:CheckBox
|
---|
290 | id="hideInactiveCheckBox"
|
---|
291 | label="Hide Inactive"
|
---|
292 | click="refreshBedFilter()" visible="false"
|
---|
293 | tabIndex="1101"/>
|
---|
294 | </mx:HBox>
|
---|
295 |
|
---|
296 | <mx:HBox width="100%" height="100%">
|
---|
297 | <mx:DataGrid
|
---|
298 | id="grdBeds"
|
---|
299 | accessibilityProperties="{bedGridAcc}"
|
---|
300 | width="100%" height="100%"
|
---|
301 | keyDown="keyDownHadler(event)"
|
---|
302 | change="selectedItemChanged()"
|
---|
303 | resizeEffect="{resizeEffect}"
|
---|
304 | editable="false"
|
---|
305 | sortableColumns="false"
|
---|
306 | dragEnabled="true"
|
---|
307 | dragMoveEnabled="true"
|
---|
308 | dropEnabled="true"
|
---|
309 | dragDrop="doDragDrop(event)"
|
---|
310 | dataProvider="{model.config.beds}"
|
---|
311 | tabIndex="1102">
|
---|
312 | <mx:columns>
|
---|
313 | <mx:DataGridColumn
|
---|
314 | width="100"
|
---|
315 | headerText="Name"
|
---|
316 | dataField="name"/>
|
---|
317 | <mx:DataGridColumn
|
---|
318 | width="72"
|
---|
319 | headerText="Display Name"
|
---|
320 | dataField="displayName"/>
|
---|
321 | <mx:DataGridColumn
|
---|
322 | width="72"
|
---|
323 | headerText="Display When"
|
---|
324 | dataField="displayWhen"
|
---|
325 | itemRenderer="gov.va.med.edp.widget.WhenRenderer"
|
---|
326 | visible="{currentState != 'editing'}"/>
|
---|
327 | <mx:DataGridColumn
|
---|
328 | width="90"
|
---|
329 | headerText="Default Status"
|
---|
330 | dataField="defaultStatus"
|
---|
331 | itemRenderer="gov.va.med.edp.widget.StatusRenderer"
|
---|
332 | visible="{currentState != 'editing'}"/>
|
---|
333 | <mx:DataGridColumn
|
---|
334 | width="40"
|
---|
335 | headerText="Inactive?"
|
---|
336 | dataField="inactive"
|
---|
337 | itemRenderer="gov.va.med.edp.widget.CenteredEmbedImage"
|
---|
338 | labelFunction="inactiveImgFunction"/>
|
---|
339 | <mx:DataGridColumn
|
---|
340 | width="80"
|
---|
341 | headerText="Category"
|
---|
342 | dataField="category"
|
---|
343 | itemRenderer="gov.va.med.edp.widget.RoomCategoryRenderer"
|
---|
344 | visible="{currentState != 'editing'}"/>
|
---|
345 | <mx:DataGridColumn
|
---|
346 | width="50"
|
---|
347 | headerText="Shared"
|
---|
348 | dataField="sharedName"
|
---|
349 | visible="{currentState != 'editing'}"/>
|
---|
350 | <mx:DataGridColumn
|
---|
351 | width="50"
|
---|
352 | headerText="Board"
|
---|
353 | dataField="boardName"
|
---|
354 | visible="{currentState != 'editing'}"/>
|
---|
355 | <mx:DataGridColumn
|
---|
356 | width="60"
|
---|
357 | headerText="Color"
|
---|
358 | dataField="color"
|
---|
359 | itemRenderer="gov.va.med.edp.widget.ColorSampleRenderer"/>
|
---|
360 | </mx:columns>
|
---|
361 | </mx:DataGrid>
|
---|
362 | </mx:HBox>
|
---|
363 |
|
---|
364 | <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
|
---|
365 | <mx:Button
|
---|
366 | id="btnSave"
|
---|
367 | label="Save Room / Area Changes"
|
---|
368 | enabled="{(model.config.bedMods && model.config.bedLoaded)}"
|
---|
369 | click="saveBeds()" tabIndex="1900"/>
|
---|
370 | </mx:HBox>
|
---|
371 | </mx:VBox>
|
---|
372 | <mx:states>
|
---|
373 | <mx:State name="editing">
|
---|
374 | <mx:AddChild relativeTo="{grdBeds}" position="after">
|
---|
375 | <mx:VBox id="roomBedForm">
|
---|
376 | <mx:Form>
|
---|
377 | <mx:FormHeading label="Room / Area Details"/>
|
---|
378 | <mx:FormItem label="Name">
|
---|
379 | <mx:TextInput id="nameInput" text="{selectedBed.name}" styleName="formField"
|
---|
380 | change="markChanged(event)" tabIndex="1200"/>
|
---|
381 | </mx:FormItem>
|
---|
382 | <mx:FormItem label="Display Name">
|
---|
383 | <mx:TextInput id="displayNameInput" text="{selectedBed.displayName}" styleName="formField"
|
---|
384 | change="markChanged(event)" tabIndex="1201"/>
|
---|
385 | </mx:FormItem>
|
---|
386 | <mx:FormItem label="Display When">
|
---|
387 | <mx:ComboBox id="whenChooser" dataProvider="{model.config.whenList}"
|
---|
388 | selectedIndex="{Vista.locateIndex(model.config.whenList, selectedBed.displayWhen)}"
|
---|
389 | styleName="formField" change="markChanged(event)" tabIndex="1202"/>
|
---|
390 | </mx:FormItem>
|
---|
391 | <mx:FormItem label="Default Status">
|
---|
392 | <mx:ComboBox id="statusChooser" dataProvider="{model.config.statusList}"
|
---|
393 | selectedIndex="{Vista.locateIndex(model.config.statusList, selectedBed.defaultStatus)}"
|
---|
394 | styleName="formField" change="markChanged(event)" tabIndex="1203"/>
|
---|
395 | </mx:FormItem>
|
---|
396 | <mx:FormItem label="Inactive?">
|
---|
397 | <mx:CheckBox id="inactiveCheckBox" selected="{selectedBed.inactive}" styleName="formField"
|
---|
398 | change="markChanged(event)" tabIndex="1204"/>
|
---|
399 | </mx:FormItem>
|
---|
400 | <mx:FormItem label="Category">
|
---|
401 | <mx:ComboBox id="roomCategoryChooser" dataProvider="{model.config.roomCategoryList}"
|
---|
402 | selectedIndex="{Vista.locateIndex(model.config.roomCategoryList, selectedBed.category)}"
|
---|
403 | styleName="formField" change="markChanged(event)" tabIndex="1205"/>
|
---|
404 | </mx:FormItem>
|
---|
405 | <mx:FormItem label="Shared Name">
|
---|
406 | <mx:TextInput id="sharedInput" text="{selectedBed.sharedName}" styleName="formField"
|
---|
407 | change="markChanged(event)" tabIndex="1206"/>
|
---|
408 | </mx:FormItem>
|
---|
409 | <mx:FormItem label="Use Board">
|
---|
410 | <mx:TextInput id="boardInput" text="{selectedBed.boardName}" styleName="formField"
|
---|
411 | change="markChanged(event)" tabIndex="1207"/>
|
---|
412 | </mx:FormItem>
|
---|
413 | <mx:FormItem label="Color">
|
---|
414 | <widget:ColorSelector id="colorSelector" styleName="formField" tabIndex="1208"
|
---|
415 | color="{selectedBed.color}" colorChange="markChanged(event)"/>
|
---|
416 | </mx:FormItem>
|
---|
417 | <mx:FormItem label="List Order" visible="{AccessibilityTools.isAccessibilityActive()}">
|
---|
418 | <mx:TextInput id="listOrderInput" styleName="formField" tabIndex="1220"
|
---|
419 | text="{model.config.beds.getItemIndex(selectedBed) + 1}"
|
---|
420 | change="listOrderTextChanged(event)"/>
|
---|
421 | </mx:FormItem>
|
---|
422 | </mx:Form>
|
---|
423 | <mx:Button id="updateBedButton" label="All Columns >>" click="update()"
|
---|
424 | tabIndex="1300"/>
|
---|
425 | </mx:VBox>
|
---|
426 | </mx:AddChild>
|
---|
427 | </mx:State>
|
---|
428 | </mx:states>
|
---|
429 |
|
---|
430 | <mx:Resize id="resizeEffect" duration="200"/>
|
---|
431 |
|
---|
432 | <config:DuplicateNameValidator id="roomBedNameValidator"
|
---|
433 | field="name"
|
---|
434 | beds="{model.config.beds}"
|
---|
435 | selectedBed="{selectedBed}"
|
---|
436 | source="{nameInput}"
|
---|
437 | property="text"/>
|
---|
438 | <config:DuplicateNameValidator id="roomBedDisplayNameValidator"
|
---|
439 | field="displayName"
|
---|
440 | beds="{model.config.beds}"
|
---|
441 | selectedBed="{selectedBed}"
|
---|
442 | source="{displayNameInput}"
|
---|
443 | property="text"/>
|
---|
444 | <mx:NumberValidator id="listOrderValidator" minValue="1" maxValue="{model.config.beds.length}"
|
---|
445 | source="{listOrderInput}" property="text"/>
|
---|
446 |
|
---|
447 | <acc:AccessibilityProperties name="Up" id="upButtonAcc"/>
|
---|
448 | <acc:AccessibilityProperties name="Down" id="downButtonAcc"/>
|
---|
449 | <acc:AccessibilityProperties id="bedGridAcc" name="Rooms / Areas"/>
|
---|
450 |
|
---|
451 | <mx:Binding source="RoomBedVO(grdBeds.selectedItem)" destination="selectedBed"/>
|
---|
452 | </mx:HBox>
|
---|