1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" |
---|
3 | xmlns:local="clarin.cmdi.componentregistry.services.*" |
---|
4 | width="100%" |
---|
5 | height="100%" |
---|
6 | label="Import..."> |
---|
7 | |
---|
8 | <mx:Script> |
---|
9 | <![CDATA[ |
---|
10 | import clarin.cmdi.componentregistry.common.ItemDescription; |
---|
11 | |
---|
12 | private static const BTN_PROFILE_LABEL:String = "Select profile xml..."; |
---|
13 | private static const BTN_COMPONENT_LABEL:String = "Select component xml..."; |
---|
14 | |
---|
15 | [Bindable] |
---|
16 | private var isProfile:Boolean = true; |
---|
17 | [Bindable] |
---|
18 | private var btnLabel:String = BTN_PROFILE_LABEL; |
---|
19 | |
---|
20 | private function submit(event:Event):void { |
---|
21 | var item:ItemDescription = new ItemDescription(); |
---|
22 | item.description = description.text; |
---|
23 | item.name = nameInput.text; |
---|
24 | item.isProfile = isProfile; |
---|
25 | if (isProfile) { |
---|
26 | uploadSrv.submitProfile(item); |
---|
27 | } else { |
---|
28 | item.groupName = groupName.text; |
---|
29 | uploadSrv.submitComponent(item); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | private function setIsProfile(isProfileValue:Boolean):void { |
---|
34 | isProfile = isProfileValue; |
---|
35 | if (isProfile) { |
---|
36 | btnLabel = BTN_PROFILE_LABEL; |
---|
37 | } else { |
---|
38 | btnLabel = BTN_COMPONENT_LABEL; |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | private function registryChange(event:UploadCompleteEvent):void { |
---|
43 | parentApplication.viewStack.switchToBrowse(event.itemDescription); |
---|
44 | } |
---|
45 | ]]> |
---|
46 | </mx:Script> |
---|
47 | |
---|
48 | <local:UploadService id="uploadSrv" |
---|
49 | uploadComplete="registryChange(event)"/> |
---|
50 | <mx:VBox> |
---|
51 | <mx:Form> |
---|
52 | <mx:HBox> |
---|
53 | <mx:FormHeading label="Import"/> |
---|
54 | <mx:RadioButton groupName="importType" |
---|
55 | id="profileType" |
---|
56 | label="Profile" |
---|
57 | click="setIsProfile(true)" |
---|
58 | selected="true"/> |
---|
59 | <mx:RadioButton groupName="importType" |
---|
60 | id="componentType" |
---|
61 | label="Component" |
---|
62 | click="setIsProfile(false)"/> |
---|
63 | </mx:HBox> |
---|
64 | <mx:HBox> |
---|
65 | <mx:Button label="{btnLabel}" |
---|
66 | id="btnSelect" |
---|
67 | click="uploadSrv.selectXmlFile(event)"/> |
---|
68 | <mx:Text id="txtSelectedFile" |
---|
69 | text="{uploadSrv.selectedFile}"/> |
---|
70 | </mx:HBox> |
---|
71 | |
---|
72 | <mx:FormItem label="Name"> |
---|
73 | <mx:TextInput id="nameInput"/> |
---|
74 | </mx:FormItem> |
---|
75 | <mx:FormItem label="Description"> |
---|
76 | <mx:TextInput id="description"/> |
---|
77 | </mx:FormItem> |
---|
78 | <mx:FormItem label="Creator Name"> |
---|
79 | <mx:Text id="creatorName" text="loginName"/> |
---|
80 | </mx:FormItem> |
---|
81 | <mx:FormItem label="Group Name" |
---|
82 | visible="{!isProfile}" |
---|
83 | includeInLayout="{!isProfile}"> |
---|
84 | <mx:TextInput id="groupName"/> |
---|
85 | </mx:FormItem> |
---|
86 | <mx:Button label="Submit" |
---|
87 | click="submit(event)"/> |
---|
88 | <mx:ProgressBar id="uploadProgress" |
---|
89 | label="" |
---|
90 | mode="manual" |
---|
91 | creationComplete="uploadSrv.init(uploadProgress)" |
---|
92 | visible="false"/> |
---|
93 | </mx:Form> |
---|
94 | |
---|
95 | <mx:Text id="errorMessageField" |
---|
96 | text="{uploadSrv.message}"/> |
---|
97 | |
---|
98 | </mx:VBox> |
---|
99 | |
---|
100 | </mx:Canvas> |
---|
101 | |
---|