captproton-restfulx 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +50 -0
- data/Rakefile +79 -0
- data/VERSION.yml +4 -0
- data/app_generators/rx_app/USAGE +22 -0
- data/app_generators/rx_app/rx_app_generator.rb +110 -0
- data/app_generators/rx_app/templates/actionscript.properties +16 -0
- data/app_generators/rx_app/templates/actionscriptair.properties +16 -0
- data/app_generators/rx_app/templates/app.yaml.erb +12 -0
- data/app_generators/rx_app/templates/default_tasks.rake +38 -0
- data/app_generators/rx_app/templates/empty.txt +0 -0
- data/app_generators/rx_app/templates/expressInstall.swf +0 -0
- data/app_generators/rx_app/templates/flex.properties +2 -0
- data/app_generators/rx_app/templates/generate.rb +17 -0
- data/app_generators/rx_app/templates/html-template/AC_OETags.js +276 -0
- data/app_generators/rx_app/templates/html-template/history/history.css +6 -0
- data/app_generators/rx_app/templates/html-template/history/history.js +645 -0
- data/app_generators/rx_app/templates/html-template/history/historyFrame.html +29 -0
- data/app_generators/rx_app/templates/html-template/index.template.html +121 -0
- data/app_generators/rx_app/templates/html-template/playerProductInstall.swf +0 -0
- data/app_generators/rx_app/templates/index.html.erb +18 -0
- data/app_generators/rx_app/templates/index.yaml +11 -0
- data/app_generators/rx_app/templates/mainair-app.xml +134 -0
- data/app_generators/rx_app/templates/mainapp-config.xml +22 -0
- data/app_generators/rx_app/templates/mainapp.mxml +152 -0
- data/app_generators/rx_app/templates/project-textmate.erb +72 -0
- data/app_generators/rx_app/templates/project.properties +18 -0
- data/app_generators/rx_app/templates/projectair.properties +24 -0
- data/app_generators/rx_app/templates/restfulx.yml +46 -0
- data/app_generators/rx_app/templates/swfobject.js +5 -0
- data/bin/rx-gen +31 -0
- data/lib/restfulx.rb +90 -0
- data/lib/restfulx/active_foo.rb +181 -0
- data/lib/restfulx/active_record_tasks.rb +90 -0
- data/lib/restfulx/active_record_uuid_helper.rb +17 -0
- data/lib/restfulx/configuration.rb +75 -0
- data/lib/restfulx/datamapper_foo.rb +81 -0
- data/lib/restfulx/rails/recipes.rb +60 -0
- data/lib/restfulx/rails/schema_to_yaml.rb +112 -0
- data/lib/restfulx/rails/schema_to_yaml/extensions/enumerable.rb +8 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/config.rb +17 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +73 -0
- data/lib/restfulx/rails/swf_helper.rb +59 -0
- data/lib/restfulx/tasks.rb +110 -0
- data/rails_generators/rx_config/USAGE +19 -0
- data/rails_generators/rx_config/rx_config_generator.rb +151 -0
- data/rails_generators/rx_config/templates/actionscript.properties +16 -0
- data/rails_generators/rx_config/templates/actionscriptair.properties +16 -0
- data/rails_generators/rx_config/templates/expressInstall.swf +0 -0
- data/rails_generators/rx_config/templates/flex.properties +2 -0
- data/rails_generators/rx_config/templates/flex_controller.erb +4 -0
- data/rails_generators/rx_config/templates/html-template/AC_OETags.js +276 -0
- data/rails_generators/rx_config/templates/html-template/history/history.css +6 -0
- data/rails_generators/rx_config/templates/html-template/history/history.js +645 -0
- data/rails_generators/rx_config/templates/html-template/history/historyFrame.html +29 -0
- data/rails_generators/rx_config/templates/html-template/index.template.html +121 -0
- data/rails_generators/rx_config/templates/html-template/playerProductInstall.swf +0 -0
- data/rails_generators/rx_config/templates/index.erb +16 -0
- data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
- data/rails_generators/rx_config/templates/mainapp-config.xml +22 -0
- data/rails_generators/rx_config/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_config/templates/project-textmate.erb +72 -0
- data/rails_generators/rx_config/templates/project.properties +18 -0
- data/rails_generators/rx_config/templates/projectair.properties +24 -0
- data/rails_generators/rx_config/templates/restfulx.erb +75 -0
- data/rails_generators/rx_config/templates/restfulx.yml +65 -0
- data/rails_generators/rx_config/templates/restfulx_tasks.rake +9 -0
- data/rails_generators/rx_config/templates/routes.erb +47 -0
- data/rails_generators/rx_config/templates/session_store_flash.erb +1 -0
- data/rails_generators/rx_config/templates/swfobject.js +5 -0
- data/rails_generators/rx_controller/USAGE +10 -0
- data/rails_generators/rx_controller/rx_controller_generator.rb +31 -0
- data/rails_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rails_generators/rx_main_app/USAGE +8 -0
- data/rails_generators/rx_main_app/rx_main_app_generator.rb +60 -0
- data/rails_generators/rx_main_app/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_scaffold/USAGE +35 -0
- data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +242 -0
- data/rails_generators/rx_scaffold/templates/controllers/default.rb.erb +125 -0
- data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
- data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +39 -0
- data/rails_generators/rx_scaffold/templates/functional_test.rb +45 -0
- data/rails_generators/rx_scaffold/templates/helper_test.rb +4 -0
- data/rails_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +46 -0
- data/rails_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rails_generators/rx_scaffold/templates/model.rb.erb +46 -0
- data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +68 -0
- data/rxgen_generators/rx_config/USAGE +5 -0
- data/rxgen_generators/rx_config/rx_config_generator.rb +21 -0
- data/rxgen_generators/rx_controller/USAGE +10 -0
- data/rxgen_generators/rx_controller/rx_controller_generator.rb +41 -0
- data/rxgen_generators/rx_controller/templates/assist.py +65 -0
- data/rxgen_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
- data/rxgen_generators/rx_controller/templates/restful.py +136 -0
- data/rxgen_generators/rx_main_app/USAGE +8 -0
- data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +65 -0
- data/rxgen_generators/rx_main_app/templates/main.py.erb +29 -0
- data/rxgen_generators/rx_main_app/templates/mainapp.mxml +152 -0
- data/rxgen_generators/rx_scaffold/USAGE +29 -0
- data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +194 -0
- data/rxgen_generators/rx_scaffold/templates/controller.py.erb +27 -0
- data/rxgen_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rxgen_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rxgen_generators/rx_scaffold/templates/model.py.erb +14 -0
- data/rxgen_generators/rx_yaml_scaffold/USAGE +45 -0
- data/rxgen_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
- data/spec/restfulx_spec.rb +4 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/restfulx.rake +2 -0
- data/test/rails/controllers/application_controller.rb +15 -0
- data/test/rails/controllers/locations_controller.rb +93 -0
- data/test/rails/controllers/notes_controller.rb +96 -0
- data/test/rails/controllers/projects_controller.rb +93 -0
- data/test/rails/controllers/tasks_controller.rb +93 -0
- data/test/rails/controllers/users_controller.rb +93 -0
- data/test/rails/database.yml +4 -0
- data/test/rails/fixtures/locations.yml +8 -0
- data/test/rails/fixtures/notes.yml +17 -0
- data/test/rails/fixtures/projects.yml +25 -0
- data/test/rails/fixtures/simple_properties.yml +19 -0
- data/test/rails/fixtures/tasks.yml +46 -0
- data/test/rails/fixtures/users.yml +13 -0
- data/test/rails/helpers/functional_test_helper.rb +21 -0
- data/test/rails/helpers/test_helper.rb +54 -0
- data/test/rails/helpers/unit_test_helper.rb +29 -0
- data/test/rails/model.yml +35 -0
- data/test/rails/models/location.rb +4 -0
- data/test/rails/models/note.rb +3 -0
- data/test/rails/models/project.rb +4 -0
- data/test/rails/models/simple_property.rb +2 -0
- data/test/rails/models/task.rb +18 -0
- data/test/rails/models/user.rb +20 -0
- data/test/rails/schema.rb +77 -0
- data/test/rails/test.swf +1 -0
- data/test/rails/test_active_foo.rb +36 -0
- data/test/rails/test_rails_integration_functional.rb +22 -0
- data/test/rails/test_to_fxml.rb +35 -0
- data/test/rails/test_to_json.rb +23 -0
- data/test/rails/views/notes/empty_params_action.html.erb +1 -0
- data/test/rails/views/notes/index.html.erb +1 -0
- metadata +234 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ResourceController::Base
|
2
|
+
|
3
|
+
before_filter :load_fxml_params
|
4
|
+
|
5
|
+
index.wants.fxml { render :fxml => @collection.to_fxml(@fxml_params) }
|
6
|
+
show.wants.fxml { render :fxml => @object.to_fxml(@fxml_params) }
|
7
|
+
create.wants.fxml { render :fxml => @object.to_fxml(@fxml_params) }
|
8
|
+
create.failure.wants.fxml { render :fxml => @object.errors }
|
9
|
+
update.wants.fxml { render :fxml => @object.to_fxml(@fxml_params) }
|
10
|
+
update.failure.wants.fxml { render :fxml => @object.errors }
|
11
|
+
destroy.wants.fxml { render :fxml => @object }
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def collection
|
16
|
+
@collection = end_of_association_chain.all
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_fxml_params
|
20
|
+
@fxml_params = { }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
|
3
|
+
<% unless attributes.empty? && belongs_tos.empty? -%>
|
4
|
+
<%= class_name.underscore -%>_one:
|
5
|
+
id: <%%= Fixtures.identify(:<%= class_name.underscore %>_one) %>
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<%= attribute.name %>: <%= attribute.default("#{class_name}1") %>
|
8
|
+
<% end -%>
|
9
|
+
<% for model in belongs_tos -%>
|
10
|
+
<%= model %>_id: <%%= Fixtures.identify(:<%= model %>_one) %>
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
<%= class_name.underscore -%>_two:
|
14
|
+
id: <%%= Fixtures.identify(:<%= class_name.underscore %>_two) %>
|
15
|
+
<% for attribute in attributes -%>
|
16
|
+
<%= attribute.name %>: <%= attribute.default("#{class_name}2") %>
|
17
|
+
<% end -%>
|
18
|
+
<% for model in belongs_tos -%>
|
19
|
+
<%= model %>_id: <%%= Fixtures.identify(:<%= model %>_two) %>
|
20
|
+
<% end -%>
|
21
|
+
|
22
|
+
<%= class_name.underscore -%>_three:
|
23
|
+
id: <%%= Fixtures.identify(:<%= class_name.underscore %>_three) %>
|
24
|
+
<% for attribute in attributes -%>
|
25
|
+
<%= attribute.name %>: <%= attribute.default("#{class_name}3") %>
|
26
|
+
<% end -%>
|
27
|
+
<% for model in belongs_tos -%>
|
28
|
+
<%= model %>_id: <%%= Fixtures.identify(:<%= model %>_three) %>
|
29
|
+
<% end -%>
|
30
|
+
|
31
|
+
<%= class_name.underscore -%>_four:
|
32
|
+
id: <%%= Fixtures.identify(:<%= class_name.underscore %>_four) %>
|
33
|
+
<% for attribute in attributes -%>
|
34
|
+
<%= attribute.name %>: <%= attribute.default("#{class_name}4") %>
|
35
|
+
<% end -%>
|
36
|
+
<% for model in belongs_tos -%>
|
37
|
+
<%= model %>_id: <%%= Fixtures.identify(:<%= model %>_four) %>
|
38
|
+
<% end -%>
|
39
|
+
<% end -%>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
4
|
+
test "should get index" do
|
5
|
+
get :index
|
6
|
+
assert_response :success
|
7
|
+
assert_not_nil assigns(:<%= table_name %>)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should get new" do
|
11
|
+
get :new
|
12
|
+
assert_response :success
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should create <%= file_name %>" do
|
16
|
+
assert_difference('<%= class_name %>.count') do
|
17
|
+
post :create, :<%= file_name %> => { }
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
21
|
+
end
|
22
|
+
|
23
|
+
test "should show <%= file_name %>" do
|
24
|
+
get :show, :id => <%= table_name %>(:one).id
|
25
|
+
assert_response :success
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should get edit" do
|
29
|
+
get :edit, :id => <%= table_name %>(:one).id
|
30
|
+
assert_response :success
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should update <%= file_name %>" do
|
34
|
+
put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { }
|
35
|
+
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
36
|
+
end
|
37
|
+
|
38
|
+
test "should destroy <%= file_name %>" do
|
39
|
+
assert_difference('<%= class_name %>.count', -1) do
|
40
|
+
delete :destroy, :id => <%= table_name %>(:one).id
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_redirected_to <%= table_name %>_path
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" label="<%= class_name %>"
|
3
|
+
xmlns:rx="org.restfulx.components.rx.*">
|
4
|
+
<mx:Script><![CDATA[
|
5
|
+
import org.restfulx.Rx;
|
6
|
+
import org.restfulx.utils.RxUtils;
|
7
|
+
import <%= base_package %>.models.<%= class_name %>;
|
8
|
+
<% for model in belongs_tos -%>
|
9
|
+
import <%= base_package %>.models.<%= model.camelcase %>;
|
10
|
+
<% end -%>
|
11
|
+
<% if attachment_field.size > 0 -%>
|
12
|
+
import flash.net.FileReference;
|
13
|
+
import org.restfulx.utils.RxFileReference;
|
14
|
+
<% end -%>
|
15
|
+
|
16
|
+
[Bindable]
|
17
|
+
private var <%= class_name.dcfirst %>:<%= class_name %> = new <%= class_name %>();
|
18
|
+
<% if attachment_field.size > 0 -%>
|
19
|
+
|
20
|
+
[Bindable]
|
21
|
+
private var fileName:String = "None selected";
|
22
|
+
|
23
|
+
private var file:RxFileReference;
|
24
|
+
<% end -%>
|
25
|
+
|
26
|
+
private function new<%= class_name %>():void {
|
27
|
+
<%= class_name.dcfirst %> = new <%= class_name %>();
|
28
|
+
<%= class_name.dcfirst.pluralize %>List.selectedIndex = -1;
|
29
|
+
}
|
30
|
+
|
31
|
+
private function save<%= class_name %>():void {
|
32
|
+
updateModelProperties();
|
33
|
+
if (<%= class_name.dcfirst %>.id) {
|
34
|
+
<%= class_name.dcfirst %>.update({onSuccess: on<%= class_name %>Update});
|
35
|
+
} else {
|
36
|
+
<%= class_name.dcfirst %>.create({onSuccess: on<%= class_name %>Create});
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
private function updateModelProperties():void {
|
41
|
+
<% for attribute in attributes -%>
|
42
|
+
<% if attribute.type == :boolean -%>
|
43
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
|
44
|
+
<% elsif attribute.type == :string -%>
|
45
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
|
46
|
+
<% elsif attribute.type == :text -%>
|
47
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
|
48
|
+
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
49
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
|
50
|
+
<% elsif attribute.type == :date -%>
|
51
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
|
52
|
+
<% else -%>
|
53
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_type %>(<%= attribute.flex_name %>TextInput.text);
|
54
|
+
<% end -%>
|
55
|
+
<% end -%>
|
56
|
+
<% for model in belongs_tos -%>
|
57
|
+
<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
|
58
|
+
<% end -%>
|
59
|
+
<% if attachment_field.size > 0 -%>
|
60
|
+
<%= class_name.dcfirst %>.attachment = file;
|
61
|
+
<% end -%>
|
62
|
+
}
|
63
|
+
|
64
|
+
private function destroy<%= class_name %>():void {
|
65
|
+
<%= class_name.dcfirst %>.destroy({onSuccess: on<%= class_name %>Destroy});
|
66
|
+
}
|
67
|
+
|
68
|
+
private function on<%= class_name %>Select():void {
|
69
|
+
<%= class_name.dcfirst %> = RxUtils.clone(<%= class_name.dcfirst.pluralize %>List.selectedItem) as <%= class_name %>;
|
70
|
+
}
|
71
|
+
|
72
|
+
private function on<%= class_name %>Create(result:<%= class_name %>):void {
|
73
|
+
<%= class_name.dcfirst %> = new <%= class_name %>;
|
74
|
+
}
|
75
|
+
|
76
|
+
private function on<%= class_name %>Update(result:<%= class_name %>):void {
|
77
|
+
<%= class_name.dcfirst.pluralize %>List.selectedItem = result;
|
78
|
+
on<%= class_name %>Select();
|
79
|
+
}
|
80
|
+
|
81
|
+
private function on<%= class_name %>Destroy(result:<%= class_name %>):void {
|
82
|
+
on<%= class_name %>Create(result);
|
83
|
+
}
|
84
|
+
<% if attachment_field.size > 0 -%>
|
85
|
+
|
86
|
+
private function chooseFile():void {
|
87
|
+
file = new RxFileReference("<%= attachment_field[0].camelcase(:lower) %>");
|
88
|
+
file.reference.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
|
89
|
+
file.reference.addEventListener(Event.SELECT, selectFile, false, 0, true);
|
90
|
+
file.reference.addEventListener(Event.CANCEL, cancelBrowse, false, 0, true);
|
91
|
+
file.reference.browse();
|
92
|
+
}
|
93
|
+
|
94
|
+
private function selectFile(event:Event):void {
|
95
|
+
fileSelected(event)
|
96
|
+
}
|
97
|
+
|
98
|
+
private function cancelBrowse(event:Event):void {
|
99
|
+
file = null;
|
100
|
+
}
|
101
|
+
|
102
|
+
private function fileSelected(event:Event):void {
|
103
|
+
fileName = FileReference(event.target).name;
|
104
|
+
}
|
105
|
+
|
106
|
+
private function ioErrorHandler(event:Event):void {
|
107
|
+
fileChooser.errorString = "Failed to selected a file. Please try again.";
|
108
|
+
}
|
109
|
+
<% end -%>
|
110
|
+
]]></mx:Script>
|
111
|
+
<mx:Panel id="<%= class_name.dcfirst.pluralize %>Panel"
|
112
|
+
title="<%= class_name.pluralize %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
|
113
|
+
borderThickness="1" backgroundColor="#EEEEEE" width="25%" height="100%">
|
114
|
+
<mx:List id="<%= class_name.dcfirst.pluralize %>List"
|
115
|
+
width="100%" height="100%"
|
116
|
+
dataProvider="{Rx.models.index(<%= class_name %>)}"
|
117
|
+
change="on<%= class_name %>Select()"/>
|
118
|
+
<mx:ControlBar width="100%">
|
119
|
+
<mx:Button label="New <%= class_name %>" width="100%" height="30"
|
120
|
+
click="new<%= class_name %>()"/>
|
121
|
+
</mx:ControlBar>
|
122
|
+
</mx:Panel>
|
123
|
+
<mx:Panel title="Edit <%= class_name %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
|
124
|
+
borderThickness="1" backgroundColor="#EEEEEE" width="75%" height="100%">
|
125
|
+
<mx:Form width="100%" height="100%">
|
126
|
+
<% for attribute in attributes -%>
|
127
|
+
<mx:FormItem label="<%= attribute.flex_name.ucfirst %>" width="100%">
|
128
|
+
<% if attribute.type == :boolean -%>
|
129
|
+
<mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
130
|
+
<% elsif attribute.type == :string -%>
|
131
|
+
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
132
|
+
<% elsif attribute.type == :text -%>
|
133
|
+
<mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
134
|
+
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
135
|
+
<rx:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
136
|
+
<% elsif attribute.type == :date -%>
|
137
|
+
<mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
138
|
+
<% else -%>
|
139
|
+
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
140
|
+
<% end -%>
|
141
|
+
</mx:FormItem>
|
142
|
+
<% end -%>
|
143
|
+
<% if attachment_field.size > 0 -%>
|
144
|
+
<mx:FormItem label="<%= attachment_field[0].camelcase %>:" width="100%" id="fileChooser">
|
145
|
+
<mx:Button label="Browse…" id="fileBrowseButton" click="chooseFile()"/>
|
146
|
+
<mx:Label text="{fileName}" maxWidth="190"/>
|
147
|
+
<mx:Image source="{<%= class_name.dcfirst %>.attachmentUrl}"/>
|
148
|
+
</mx:FormItem>
|
149
|
+
<% end -%>
|
150
|
+
<% for model in belongs_tos -%>
|
151
|
+
<mx:FormItem label="<%= model.camelcase %>" width="100%">
|
152
|
+
<mx:ComboBox id="<%= model.camelcase(:lower) %>ComboBox" width="200"
|
153
|
+
labelField="{<%= model.camelcase %>.LABEL}"
|
154
|
+
dataProvider="{Rx.models.index(<%= model.camelcase %>)}" prompt="<%= model.camelcase %> ..."
|
155
|
+
selectedItem="{<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %>}"/>
|
156
|
+
</mx:FormItem>
|
157
|
+
<% end -%>
|
158
|
+
</mx:Form>
|
159
|
+
<mx:ControlBar width="100%">
|
160
|
+
<mx:Button label="Save <%= class_name %>" width="50%" height="30"
|
161
|
+
click="save<%= class_name %>()"/>
|
162
|
+
<mx:Button label="Delete <%= class_name %>" width="50%" height="30"
|
163
|
+
enabled="{RxUtils.canDeleteModel(<%= class_name.dcfirst %>)}"
|
164
|
+
click="destroy<%= class_name %>()"/>
|
165
|
+
</mx:ControlBar>
|
166
|
+
</mx:Panel>
|
167
|
+
</mx:HBox>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
<% if distributed -%>
|
4
|
+
create_table :<%= table_name %>, :id => false do |t|
|
5
|
+
t.string :id
|
6
|
+
<% else -%>
|
7
|
+
create_table :<%= table_name %> do |t|
|
8
|
+
<% end -%>
|
9
|
+
<% for attribute in args_for_generation -%>
|
10
|
+
t.<%= attribute.split(':')[1] %> :<%= attribute.split(':')[0] %>
|
11
|
+
<% end -%>
|
12
|
+
<% for model in belongs_tos -%>
|
13
|
+
<% if distributed -%>
|
14
|
+
t.string :<%= model %>_id
|
15
|
+
<% else -%>
|
16
|
+
t.references :<%= model %>
|
17
|
+
<% end -%>
|
18
|
+
<% end -%>
|
19
|
+
<% if attachment_field.size > 0 -%>
|
20
|
+
<% if RxSettings.attachment_plugin == 'paperclip' -%>
|
21
|
+
# For paperclip
|
22
|
+
t.column :<%= attachment_field[0] %>_file_name, :string
|
23
|
+
t.column :<%= attachment_field[0] %>_content_type, :string
|
24
|
+
t.column :<%= attachment_field[0] %>_file_size, :integer
|
25
|
+
t.column :<%= attachment_field[0] %>_updated_at, :datetime
|
26
|
+
<% elsif RxSettings.attachment_plugin == 'attachment_fu' -%>
|
27
|
+
# For attachment_fu
|
28
|
+
t.column :parent_id, :integer
|
29
|
+
t.column :content_type, :string
|
30
|
+
t.column :filename, :string
|
31
|
+
t.column :thumbnail, :string
|
32
|
+
t.column :size, :integer
|
33
|
+
t.column :width, :integer
|
34
|
+
t.column :height, :integer
|
35
|
+
<% end -%>
|
36
|
+
<% end -%>
|
37
|
+
<% unless options[:skip_timestamps] %>
|
38
|
+
t.timestamps
|
39
|
+
<% end -%>
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.down
|
44
|
+
drop_table :<%= table_name %>
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
package <%= base_package %>.models {
|
2
|
+
<% if has_manies.length > 0 || has_many_through.length > 0 -%>
|
3
|
+
import org.restfulx.collections.ModelsCollection;
|
4
|
+
<% end -%>
|
5
|
+
<% if tree_model.size > 0 -%>
|
6
|
+
<% @tree_or_no_tree = 'RxTreeModel' %>
|
7
|
+
import org.restfulx.models.RxTreeModel
|
8
|
+
<% end -%>
|
9
|
+
<% unless tree_model.size > 0 -%>
|
10
|
+
<% @tree_or_no_tree = 'RxModel' %>
|
11
|
+
import org.restfulx.models.RxModel;
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
[Resource(name="<%= resource_controller_name %>")]
|
15
|
+
[Bindable]
|
16
|
+
public class <%= class_name %> extends <%= @tree_or_no_tree %> {
|
17
|
+
<% if attributes && !attributes.empty? && attributes[0].flex_type != "Boolean" -%>
|
18
|
+
public static const LABEL:String = "<%= attributes[0].flex_name %>";
|
19
|
+
<% else -%>
|
20
|
+
public static const LABEL:String = "id";
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
<% for attribute in attributes -%>
|
24
|
+
<% if attribute.type == :datetime || attribute.type == :time -%>
|
25
|
+
[DateTime]
|
26
|
+
<% end -%>
|
27
|
+
public var <%= attribute.flex_name %>:<%= attribute.flex_type %> = <%= attribute.flex_default %>;
|
28
|
+
|
29
|
+
<% end -%>
|
30
|
+
<% for model in belongs_tos -%>
|
31
|
+
[BelongsTo]
|
32
|
+
public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>;
|
33
|
+
|
34
|
+
<% end -%>
|
35
|
+
<% if tree_model.size > 0 -%>
|
36
|
+
[BelongsTo]
|
37
|
+
public var <%= tree_model[0].camelcase(:lower) %>:<%= class_name %>;
|
38
|
+
|
39
|
+
<% end -%>
|
40
|
+
<% for model in polymorphic -%>
|
41
|
+
[BelongsTo(polymorphic="true", dependsOn="Model1, Model2")]
|
42
|
+
public var <%= model.camelcase(:lower) %>:Object;
|
43
|
+
|
44
|
+
<% end -%>
|
45
|
+
<% if has_many_through.size > 0 -%>
|
46
|
+
<% has_many_through.each do |k,v| %>
|
47
|
+
[HasMany]
|
48
|
+
public var <%= k.camelcase(:lower) %>:ModelsCollection;
|
49
|
+
|
50
|
+
[HasMany(through="<%= k.camelcase %>")]
|
51
|
+
public var <%= v.camelcase(:lower) %>:ModelsCollection;
|
52
|
+
<% end -%>
|
53
|
+
<% end -%>
|
54
|
+
<% for model in has_ones -%>
|
55
|
+
[HasOne]
|
56
|
+
public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>;
|
57
|
+
|
58
|
+
<% end -%>
|
59
|
+
<% for model in has_manies -%>
|
60
|
+
[HasMany]
|
61
|
+
public var <%= model.camelcase(:lower) %>:ModelsCollection;
|
62
|
+
|
63
|
+
<% end -%>
|
64
|
+
<% if attachment_field.size > 0 -%>
|
65
|
+
[Ignored]
|
66
|
+
public var attachmentUrl:String;
|
67
|
+
|
68
|
+
<% end -%>
|
69
|
+
public function <%= class_name %>() {
|
70
|
+
super(LABEL);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Base
|
2
|
+
<% if distributed -%>
|
3
|
+
include RestfulX::UUIDHelper
|
4
|
+
<% end -%>
|
5
|
+
<% for model in belongs_tos -%>
|
6
|
+
belongs_to :<%= model %>
|
7
|
+
<% end -%>
|
8
|
+
<% for model in has_ones -%>
|
9
|
+
has_one :<%= model %>
|
10
|
+
<% end -%>
|
11
|
+
<% for model in has_manies -%>
|
12
|
+
has_many :<%= model %>, :dependent => :destroy
|
13
|
+
<% end -%>
|
14
|
+
<% for model in polymorphic -%>
|
15
|
+
belongs_to :<%= model %>, :polymorphic => true
|
16
|
+
<% end -%>
|
17
|
+
<% if has_many_through.size > 0 -%>
|
18
|
+
<% has_many_through.each do |k,v| %>
|
19
|
+
has_many :<%= k %>
|
20
|
+
has_many :<%= v %>, :through => :<%= k %>
|
21
|
+
<% end -%>
|
22
|
+
<% end -%>
|
23
|
+
<% if tree_model.size > 0 -%>
|
24
|
+
acts_as_category
|
25
|
+
<% end -%>
|
26
|
+
<% if attachment_field.size > 0 -%>
|
27
|
+
<% if RxSettings.attachment_plugin == 'paperclip' -%>
|
28
|
+
# paperclip examples:
|
29
|
+
# http://github.com/thoughtbot/paperclip/tree/master
|
30
|
+
has_attached_file :<%= attachment_field[0] %>,
|
31
|
+
:styles => { :medium => "600x480>", :thumb => "100x100#" }
|
32
|
+
|
33
|
+
def attachment_url
|
34
|
+
<%= attachment_field[0] %>.url(:original)
|
35
|
+
end
|
36
|
+
<% elsif RxSettings.attachment_plugin == 'attachment_fu' -%>
|
37
|
+
# attachment_fu examples:
|
38
|
+
# http://github.com/technoweenie/attachment_fu/blob/ab1e4f7b0b9de85e0c9decf061d2ef5c1dc0feaa/README#L56-69
|
39
|
+
has_attachment
|
40
|
+
|
41
|
+
def attachment_url
|
42
|
+
"" # FIX ME
|
43
|
+
end
|
44
|
+
<% end -%>
|
45
|
+
<% end -%>
|
46
|
+
end
|