[1227] | 1 | /* SwitchLogEntryCommand.as */
|
---|
| 2 |
|
---|
| 3 | package gov.va.med.edp.command
|
---|
| 4 | {
|
---|
| 5 | import com.adobe.cairngorm.commands.ICommand;
|
---|
| 6 | import com.adobe.cairngorm.control.CairngormEvent;
|
---|
| 7 |
|
---|
| 8 | import gov.va.med.edp.business.SwitchLogEntryDelegate;
|
---|
| 9 | import gov.va.med.edp.control.SwitchLogEntryEvent;
|
---|
| 10 | import gov.va.med.edp.factory.TrackingFactory;
|
---|
| 11 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
| 12 |
|
---|
| 13 | import mx.rpc.IResponder;
|
---|
| 14 | import mx.rpc.events.FaultEvent;
|
---|
| 15 | import mx.rpc.events.ResultEvent;
|
---|
| 16 | import gov.va.med.edp.vo.LogEntryVO;
|
---|
| 17 |
|
---|
| 18 | public class SwitchLogEntryCommand extends AbstractResponderCommand implements ICommand, IResponder
|
---|
| 19 | {
|
---|
| 20 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
| 21 |
|
---|
| 22 | public function execute(event:CairngormEvent): void
|
---|
| 23 | {
|
---|
| 24 | var delegate:SwitchLogEntryDelegate = new SwitchLogEntryDelegate(this);
|
---|
| 25 | var switchEvent:SwitchLogEntryEvent = SwitchLogEntryEvent(event);
|
---|
| 26 |
|
---|
| 27 | model.logEntryList.selectedIndex = switchEvent.selectedIndex;
|
---|
| 28 | model.logEntryList.selectedID = switchEvent.logID;
|
---|
| 29 |
|
---|
| 30 | delegate.switchLogEntry(switchEvent.logID, null, model.logEdit.choiceTS);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public override function result(data:Object): void
|
---|
| 34 | {
|
---|
| 35 | var xml:XML = ResultEvent(data).result as XML;
|
---|
| 36 |
|
---|
| 37 | // make sure the choices are set up before setting the logEntry
|
---|
| 38 | model.logEdit.setChoices(xml.choices[0]);
|
---|
| 39 |
|
---|
| 40 | // now that the choices are in place, we can set the log entry
|
---|
| 41 | model.logEdit.setEntry(TrackingFactory.buildLogEntryFromXML(xml.logEntry[0]));
|
---|
| 42 | model.logEdit.undo = new LogEntryVO; // used for resetting status right now
|
---|
| 43 | model.logEdit.entry.copyTo(model.logEdit.undo);
|
---|
| 44 | model.logEdit.dirty = false;
|
---|
| 45 | model.logEdit.patientSelected = false;
|
---|
| 46 | model.entryRemoveReady();
|
---|
| 47 | model.setEditState();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | protected override function getFaultMessage(faultEvent:FaultEvent):String {
|
---|
| 51 | return "Loading log entry failed: " + super.getFaultMessage(faultEvent);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | public override function fault(info:Object): void
|
---|
| 55 | {
|
---|
| 56 | model.synchToLastEntry();
|
---|
| 57 | super.fault(info);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | } // class
|
---|
| 61 | } // package
|
---|