source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/command/config/SaveConfigStaffCommand.as

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

initial load of EDIS 1.0

File size: 2.3 KB
Line 
1/* SaveConfigStaffCommand.as */
2
3package gov.va.med.edp.command.config
4{
5 import com.adobe.cairngorm.commands.ICommand;
6 import com.adobe.cairngorm.control.CairngormEvent;
7
8 import gov.va.med.edp.business.config.SaveConfigStaffDelegate;
9 import gov.va.med.edp.command.AbstractResponderCommand;
10 import gov.va.med.edp.model.TrackingModelLocator;
11 import gov.va.med.edp.util.BoardTools;
12 import gov.va.med.edp.vo.StaffMemberVO;
13 import gov.va.med.edp.widget.InfoDialog;
14
15 import mx.collections.ArrayCollection;
16 import mx.rpc.IResponder;
17 import mx.rpc.events.FaultEvent;
18 import mx.rpc.events.ResultEvent;
19
20 public class SaveConfigStaffCommand extends AbstractResponderCommand implements ICommand, IResponder
21 {
22 private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
23
24 public function execute(event:CairngormEvent):void
25 {
26 var updatedStaff: ArrayCollection = new ArrayCollection();
27 var staff: StaffMemberVO;
28
29 for each (staff in model.config.providers.source) {
30 if (staff.changed || staff.colorChanged) { updatedStaff.addItem(staff); }
31 }
32 for each (staff in model.config.residents.source) {
33 if (staff.changed || staff.colorChanged) { updatedStaff.addItem(staff); }
34 }
35 for each (staff in model.config.nurses.source) {
36 if (staff.changed || staff.colorChanged) { updatedStaff.addItem(staff); }
37 }
38
39 model.config.staffConfigLoaded = false;
40 var delegate: SaveConfigStaffDelegate = new SaveConfigStaffDelegate(this);
41 delegate.saveConfigStaff(model.logArea, model.config.staffToken, updatedStaff);
42 }
43
44 public override function result(data:Object):void
45 {
46 var xml:XML = ResultEvent(data).result as XML;
47 if ((xml.save.@status == "ok") || (xml.save.@status == "collide")) {
48 BoardTools.applyStaffLists(model.config, xml);
49 model.config.staffConfigLoaded = true;
50
51 if (xml.save.@status == "ok") {
52 InfoDialog.show("New staff configuration saved.");
53 } else {
54 InfoDialog.show("Save failed: " + xml.save);
55 }
56 }
57
58 if (xml.save.@status == "fail") {
59 InfoDialog.show("Save failed: " + xml.save);
60 }
61 }
62
63 protected override function getFaultMessage(faultEvent:FaultEvent):String {
64 return "Error saving configuration for staff: " + super.getFaultMessage(faultEvent);
65 }
66 }
67}
Note: See TracBrowser for help on using the repository browser.