source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/command/config/UpdateStaffCommand.as@ 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: 2.3 KB
Line 
1/* UpdateStaffCommand.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.control.config.UpdateStaffEvent;
9 import gov.va.med.edp.model.TrackingModelLocator;
10 import gov.va.med.edp.util.AccessibilityTools;
11 import gov.va.med.edp.vo.StaffMemberVO;
12 import gov.va.med.edp.widget.InfoDialog;
13
14 import mx.collections.ArrayCollection;
15
16 public class UpdateStaffCommand implements ICommand
17 {
18 private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
19
20 public function execute(event:CairngormEvent):void
21 {
22 var update: UpdateStaffEvent = UpdateStaffEvent(event);
23
24 if (update.type == UpdateStaffEvent.EVENT_ADD_STAFF) {
25 switch (update.staff.role) {
26 case "P":
27 addStaff(model.config.providers, update.staff);
28 break;
29 case "R":
30 addStaff(model.config.residents, update.staff);
31 break;
32 case "N":
33 addStaff(model.config.nurses, update.staff);
34 break;
35 }
36 } else if (update.type == UpdateStaffEvent.EVENT_REMOVE_STAFF) {
37 removeStaff(update.staff);
38 }
39 }
40
41 private function addStaff(list : ArrayCollection, staff : StaffMemberVO) : void {
42 if (contains(list, staff)) {
43 InfoDialog.show("Staff member " + staff.name + " has already been added and cannot be added again.");
44 return;
45 }
46 staff.changed = true;
47 list.addItem(staff);
48 model.config.staffMods = true;
49
50 if (AccessibilityTools.isAccessibilityActive())InfoDialog.show("added successfully", "Message", true);
51
52 }
53
54 private function removeStaff(staff : StaffMemberVO) : void {
55 staff.inactive = true;
56 staff.changed = true;
57 model.config.staffMods = true;
58 }
59
60 private function contains(list : ArrayCollection, staff : StaffMemberVO) : Boolean {
61 for (var i:int = 0; i < list.length; i++) {
62 var s : StaffMemberVO = list.getItemAt(i) as StaffMemberVO;
63 if (s.duz == staff.duz) return true;
64 }
65 return false;
66 }
67 }
68}
Note: See TracBrowser for help on using the repository browser.