dima-restfulx 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +65 -30
- data/VERSION.yml +4 -0
- data/app_generators/rx_app/rx_app_generator.rb +25 -9
- data/app_generators/rx_app/templates/actionscript.properties +3 -3
- data/app_generators/rx_app/templates/actionscriptair.properties +3 -3
- data/app_generators/rx_app/templates/app.yaml.erb +1 -1
- data/app_generators/rx_app/templates/default_tasks.rake +5 -18
- data/app_generators/rx_app/templates/generate.rb +1 -1
- data/app_generators/rx_app/templates/index.html.erb +1 -1
- data/app_generators/rx_app/templates/mainair-app.xml +3 -3
- data/app_generators/rx_app/templates/mainapp.mxml +107 -2
- data/app_generators/rx_app/templates/project-textmate.erb +4 -4
- data/app_generators/rx_app/templates/project.properties +1 -1
- data/app_generators/rx_app/templates/projectair.properties +1 -1
- data/app_generators/rx_app/templates/restfulx.yml +61 -0
- data/lib/restfulx/active_foo.rb +0 -7
- data/lib/restfulx/active_record_tasks.rb +10 -0
- data/lib/restfulx/configuration.rb +15 -10
- data/lib/restfulx/rails/swf_helper.rb +1 -1
- data/lib/restfulx/schema_to_yaml/extensions/enumerable.rb +7 -0
- data/lib/restfulx/schema_to_yaml/settings/config.rb +16 -0
- data/lib/restfulx/schema_to_yaml/settings/core.rb +70 -0
- data/lib/restfulx/schema_to_yaml.rb +120 -0
- data/lib/restfulx/tasks.rb +68 -42
- data/lib/restfulx/uuid_helper.rb +15 -0
- data/lib/restfulx.rb +5 -28
- data/rails_generators/rx_config/USAGE +2 -1
- data/rails_generators/rx_config/rx_config_generator.rb +78 -53
- data/rails_generators/rx_config/templates/actionscript.properties +3 -3
- data/rails_generators/rx_config/templates/actionscriptair.properties +3 -3
- data/rails_generators/rx_config/templates/flex_controller.erb +4 -0
- data/rails_generators/rx_config/templates/{index.html.erb → index.erb} +2 -4
- data/rails_generators/rx_config/templates/mainair-app.xml +3 -3
- data/rails_generators/rx_config/templates/mainapp.mxml +100 -2
- data/rails_generators/rx_config/templates/project-textmate.erb +4 -4
- data/rails_generators/rx_config/templates/project.properties +1 -1
- data/rails_generators/rx_config/templates/projectair.properties +1 -1
- data/rails_generators/rx_config/templates/restfulx.erb +39 -0
- data/rails_generators/rx_config/templates/restfulx.yml +51 -4
- data/rails_generators/rx_config/templates/restfulx_tasks.rake +3 -0
- data/rails_generators/rx_config/templates/routes.erb +47 -0
- data/rails_generators/rx_controller/rx_controller_generator.rb +9 -6
- data/rails_generators/rx_controller/templates/controller.as.erb +7 -9
- data/{generators → rails_generators}/rx_main_app/USAGE +0 -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/rx_scaffold_generator.rb +89 -35
- data/rails_generators/rx_scaffold/templates/{controller.rb.erb → controllers/default.rb.erb} +29 -1
- data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
- data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +9 -5
- data/{generators/rx_scaffold/templates/component.mxml.erb → rails_generators/rx_scaffold/templates/layouts/default.erb} +75 -59
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +29 -2
- data/rails_generators/rx_scaffold/templates/model.as.erb +33 -2
- data/rails_generators/rx_scaffold/templates/model.rb.erb +36 -1
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +29 -10
- data/{generators → rxgen_generators}/rx_config/USAGE +0 -0
- data/{generators → rxgen_generators}/rx_config/rx_config_generator.rb +0 -0
- data/{generators → rxgen_generators}/rx_controller/USAGE +0 -0
- data/{generators → rxgen_generators}/rx_controller/rx_controller_generator.rb +6 -5
- data/{generators → rxgen_generators}/rx_controller/templates/assist.py +2 -2
- data/{generators → rxgen_generators}/rx_controller/templates/controller.as.erb +8 -6
- data/{generators → rxgen_generators}/rx_controller/templates/restful.py +0 -0
- data/rxgen_generators/rx_main_app/USAGE +8 -0
- data/{generators → rxgen_generators}/rx_main_app/rx_main_app_generator.rb +10 -5
- data/{generators → rxgen_generators}/rx_main_app/templates/main.py.erb +0 -0
- data/rxgen_generators/rx_main_app/templates/mainapp.mxml +136 -0
- data/{generators → rxgen_generators}/rx_scaffold/USAGE +0 -0
- data/{generators → rxgen_generators}/rx_scaffold/rx_scaffold_generator.rb +5 -4
- data/{rails_generators → rxgen_generators}/rx_scaffold/templates/component.mxml.erb +24 -52
- data/{generators → rxgen_generators}/rx_scaffold/templates/controller.py.erb +1 -1
- data/{generators → rxgen_generators}/rx_scaffold/templates/model.as.erb +0 -0
- data/{generators → rxgen_generators}/rx_scaffold/templates/model.py.erb +0 -0
- data/{generators → rxgen_generators}/rx_yaml_scaffold/USAGE +0 -0
- data/{generators → rxgen_generators}/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +0 -0
- metadata +104 -66
- data/History.txt +0 -7
- data/Manifest.txt +0 -127
- data/generators/rx_main_app/templates/mainapp.mxml +0 -35
- data/rdoc/generators/template/html/jamis.rb +0 -588
- data/test/rails/playing_around_in_a_console.txt +0 -71
@@ -1,4 +1,7 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Base
|
2
|
+
<% if distributed -%>
|
3
|
+
include RestfulX::UUIDHelper
|
4
|
+
<% end -%>
|
2
5
|
<% for model in belongs_tos -%>
|
3
6
|
belongs_to :<%= model %>
|
4
7
|
<% end -%>
|
@@ -6,6 +9,38 @@ class <%= class_name %> < ActiveRecord::Base
|
|
6
9
|
has_one :<%= model %>
|
7
10
|
<% end -%>
|
8
11
|
<% for model in has_manies -%>
|
9
|
-
has_many :<%= model
|
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 -%>
|
10
45
|
<% end -%>
|
11
46
|
end
|
@@ -26,14 +26,31 @@ class RxYamlScaffoldGenerator < Rails::Generator::Base
|
|
26
26
|
line = extract_attrs(line, attrs)
|
27
27
|
end
|
28
28
|
line = model[0].camelcase + " " + line
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
|
30
|
+
if ARGV.size > 0
|
31
|
+
ARGV.each do |arg|
|
32
|
+
if model[0].camelcase == arg
|
33
|
+
puts 'running: rx_scaffold ' + line
|
34
|
+
Rails::Generator::Scripts::Generate.new.run(["rx_scaffold"] + line.split,
|
35
|
+
:flex_only => options[:flex_only],
|
36
|
+
:flex_view_only => options[:flex_view_only],
|
37
|
+
:rails_only => options[:rails_only])
|
38
|
+
puts 'done ...'
|
39
|
+
sleep 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
puts 'running: rx_scaffold ' + line
|
44
|
+
Rails::Generator::Scripts::Generate.new.run(["rx_scaffold"] + line.split,
|
45
|
+
:flex_only => options[:flex_only],
|
46
|
+
:flex_view_only => options[:flex_view_only],
|
47
|
+
:rails_only => options[:rails_only])
|
48
|
+
puts 'done ...'
|
49
|
+
sleep 1
|
50
|
+
end
|
34
51
|
end
|
35
|
-
|
36
|
-
|
52
|
+
|
53
|
+
Rails::Generator::Scripts::Generate.new.run(["rx_main_app"])
|
37
54
|
end
|
38
55
|
end
|
39
56
|
|
@@ -41,9 +58,11 @@ class RxYamlScaffoldGenerator < Rails::Generator::Base
|
|
41
58
|
def add_options!(opt)
|
42
59
|
opt.separator ''
|
43
60
|
opt.separator 'Options:'
|
44
|
-
opt.on("--flex-only", "Only generate the Flex/AIR files
|
61
|
+
opt.on("-f", "--flex-only", "Only generate the Flex/AIR files",
|
45
62
|
"Default: false") { |v| options[:flex_only] = v }
|
46
|
-
opt.on("--
|
47
|
-
"Default: false") { |v| options[:
|
63
|
+
opt.on("-r", "--rails-only", "Only generate the Rails files",
|
64
|
+
"Default: false") { |v| options[:rails_only] = v }
|
65
|
+
opt.on("-fv", "--flex-view-only", "Only generate the Flex component files",
|
66
|
+
"Default: false") { |v| options[:flex_view_only] = v }
|
48
67
|
end
|
49
68
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -7,20 +7,21 @@ class RxControllerGenerator < RubiGen::Base
|
|
7
7
|
:base_folder,
|
8
8
|
:command_controller_name,
|
9
9
|
:model_names,
|
10
|
-
:command_names
|
10
|
+
:command_names,
|
11
|
+
:flex_root
|
11
12
|
|
12
13
|
def initialize(runtime_args, runtime_options = {})
|
13
14
|
super
|
14
15
|
@project_name, @flex_project_name, @command_controller_name,
|
15
|
-
@base_package, @base_folder = extract_names
|
16
|
+
@base_package, @base_folder, @flex_root = extract_names
|
16
17
|
|
17
|
-
@model_names = list_as_files("
|
18
|
-
@command_names = list_as_files("
|
18
|
+
@model_names = list_as_files("#{flex_root}/#{base_folder}/models")
|
19
|
+
@command_names = list_as_files("#{flex_root}/#{base_folder}/commands")
|
19
20
|
end
|
20
21
|
|
21
22
|
def manifest
|
22
23
|
record do |m|
|
23
|
-
m.template 'controller.as.erb', File.join("
|
24
|
+
m.template 'controller.as.erb', File.join("#{flex_root}/#{base_folder}/controllers",
|
24
25
|
"#{command_controller_name}.as")
|
25
26
|
if options[:gae]
|
26
27
|
m.file 'restful.py', 'app/controllers/restful.py' if !File.exist?('app/controllers/restful.py')
|
@@ -51,13 +51,13 @@ def update_model_from_params(model, params):
|
|
51
51
|
elif isinstance(getattr(model, k), int) and v != "":
|
52
52
|
setattr(model, k, int(v))
|
53
53
|
elif isinstance(getattr(model, k), datetime.datetime) and v != "":
|
54
|
-
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S")
|
54
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S%Z")
|
55
55
|
setattr(model, k, value)
|
56
56
|
elif isinstance(getattr(model, k), datetime.date) and v != "":
|
57
57
|
value = datetime.datetime.strptime(v, "%Y-%m-%d")
|
58
58
|
setattr(model, k, datetime.date(value.year, value.month, value.day))
|
59
59
|
elif isinstance(getattr(model, k), datetime.time) and v != "":
|
60
|
-
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S")
|
60
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S%Z")
|
61
61
|
setattr(model, k, datetime.time(value.hour, value.minute, value.second))
|
62
62
|
else:
|
63
63
|
setattr(model, k, v)
|
@@ -14,8 +14,8 @@ package <%= base_package %>.controllers {
|
|
14
14
|
|
15
15
|
public static var commands:Array = [<%= command_names %>]; /* Commands */
|
16
16
|
|
17
|
-
public function <%= command_controller_name %>(enforcer:SingletonEnforcer,
|
18
|
-
defaultServiceId:int = -1) {
|
17
|
+
public function <%= command_controller_name %>(enforcer:SingletonEnforcer,
|
18
|
+
extraServices:Array, defaultServiceId:int = -1) {
|
19
19
|
super(commands, models, extraServices, defaultServiceId);
|
20
20
|
}
|
21
21
|
|
@@ -24,11 +24,13 @@ package <%= base_package %>.controllers {
|
|
24
24
|
return controller;
|
25
25
|
}
|
26
26
|
|
27
|
-
public static function initialize(extraServices:Array = null,
|
28
|
-
airDatabaseName:String = null):void {
|
27
|
+
public static function initialize(extraServices:Array = null,
|
28
|
+
defaultServiceId:int = -1, airDatabaseName:String = null):void {
|
29
29
|
if (!RxUtils.isEmpty(airDatabaseName)) Rx.airDatabaseName = airDatabaseName;
|
30
|
-
controller = new <%= command_controller_name %>(new SingletonEnforcer,
|
31
|
-
defaultServiceId);
|
30
|
+
controller = new <%= command_controller_name %>(new SingletonEnforcer,
|
31
|
+
extraServices, defaultServiceId);
|
32
|
+
Rx.sessionToken = Application.application.parameters.session_token;
|
33
|
+
Rx.authenticityToken = Application.application.parameters.authenticity_token;
|
32
34
|
}
|
33
35
|
}
|
34
36
|
}
|
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Description:
|
2
|
+
Refreshes main Flex/AIR application file to make sure that
|
3
|
+
any of the generated components are included. Warning,
|
4
|
+
this will wipe your main application file. Used mostly
|
5
|
+
during code generation phase.
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
`./script/generate rx_main_app`
|
@@ -11,11 +11,14 @@ class RxMainAppGenerator < RubiGen::Base
|
|
11
11
|
:controller_names,
|
12
12
|
:use_air,
|
13
13
|
:use_gae,
|
14
|
-
:application_tag
|
14
|
+
:application_tag,
|
15
|
+
:flex_root,
|
16
|
+
:distributed
|
15
17
|
|
16
18
|
def initialize(runtime_args, runtime_options = {})
|
17
19
|
super
|
18
|
-
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder
|
20
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder,
|
21
|
+
@flex_root, @distributed = extract_names
|
19
22
|
|
20
23
|
project_file_name = APP_ROOT + '/.project'
|
21
24
|
if File.exist?(project_file_name)
|
@@ -29,8 +32,8 @@ class RxMainAppGenerator < RubiGen::Base
|
|
29
32
|
end
|
30
33
|
|
31
34
|
@component_names = []
|
32
|
-
if File.exists?("
|
33
|
-
@component_names = list_mxml_files("
|
35
|
+
if File.exists?("#{flex_root}/#{base_folder}/components/generated")
|
36
|
+
@component_names = list_mxml_files("#{flex_root}/#{base_folder}/components/generated")
|
34
37
|
end
|
35
38
|
|
36
39
|
@controller_names = []
|
@@ -43,7 +46,7 @@ class RxMainAppGenerator < RubiGen::Base
|
|
43
46
|
|
44
47
|
def manifest
|
45
48
|
record do |m|
|
46
|
-
m.template 'mainapp.mxml', File.join(
|
49
|
+
m.template 'mainapp.mxml', File.join("#{flex_root}", "#{flex_project_name}.mxml")
|
47
50
|
if options[:gae]
|
48
51
|
m.template 'main.py.erb', 'main.py'
|
49
52
|
end
|
@@ -56,5 +59,7 @@ class RxMainAppGenerator < RubiGen::Base
|
|
56
59
|
opt.separator 'Options:'
|
57
60
|
opt.on("--gae", "Generate Google App Engine Python classes in addition to RestfulX Flex resources.",
|
58
61
|
"Default: false") { |v| options[:gae] = v }
|
62
|
+
opt.on("--distributed", "Creates migrations, controllers and models that use UUIDs and are distribution ready",
|
63
|
+
"Default: false") { |v| options[:distributed] = v }
|
59
64
|
end
|
60
65
|
end
|
File without changes
|
@@ -0,0 +1,136 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<mx:<%= application_tag %> xmlns:mx="http://www.adobe.com/2006/mxml"
|
3
|
+
xmlns:generated="<%= base_package %>.components.generated.*"
|
4
|
+
paddingBottom="8" paddingLeft="8" paddingRight="8" paddingTop="8"
|
5
|
+
layout="horizontal" styleName="plain" initialize="init()">
|
6
|
+
<mx:Script>
|
7
|
+
<![CDATA[
|
8
|
+
<% if use_air -%>
|
9
|
+
<% if distributed -%>
|
10
|
+
import air.net.SocketMonitor;
|
11
|
+
import org.restfulx.events.PullEndEvent;
|
12
|
+
import org.restfulx.events.PullStartEvent;
|
13
|
+
import org.restfulx.events.PushEndEvent;
|
14
|
+
import org.restfulx.events.PushStartEvent;
|
15
|
+
import org.restfulx.controllers.ChangeController;
|
16
|
+
import org.restfulx.services.ISyncingServiceProvider;
|
17
|
+
import org.restfulx.services.http.XMLHTTPServiceProvider;
|
18
|
+
<% end -%>
|
19
|
+
import org.restfulx.services.air.AIRServiceProvider;
|
20
|
+
<% end -%>
|
21
|
+
<% if use_gae -%>
|
22
|
+
import org.restfulx.services.http.GAEHTTPServiceProvider;
|
23
|
+
<% end -%>
|
24
|
+
import org.restfulx.Rx;
|
25
|
+
import <%= base_package %>.controllers.<%= command_controller_name %>;
|
26
|
+
<% if use_air -%>
|
27
|
+
<% if distributed -%>
|
28
|
+
|
29
|
+
[Bindable]
|
30
|
+
private var socketMonitor:SocketMonitor;
|
31
|
+
|
32
|
+
[Bindable]
|
33
|
+
private var online:Boolean;
|
34
|
+
|
35
|
+
[Bindable]
|
36
|
+
private var syncStatus:String;
|
37
|
+
<% end -%>
|
38
|
+
<% end -%>
|
39
|
+
|
40
|
+
private function init():void {
|
41
|
+
<% if use_air -%>
|
42
|
+
<% if distributed -%>
|
43
|
+
Rx.httpRootUrl = "http://localhost:3000/";
|
44
|
+
Rx.enableSync = true;
|
45
|
+
|
46
|
+
socketMonitor = new SocketMonitor("localhost", 3000);
|
47
|
+
socketMonitor.pollInterval = 2000; /* miliseconds */
|
48
|
+
socketMonitor.addEventListener(StatusEvent.STATUS, onNetworkStatusChange);
|
49
|
+
socketMonitor.start();
|
50
|
+
|
51
|
+
<% end -%>
|
52
|
+
<%= command_controller_name %>.initialize([AIRServiceProvider],
|
53
|
+
AIRServiceProvider.ID, "<%= base_package %>");
|
54
|
+
<% if distributed -%>
|
55
|
+
|
56
|
+
Rx.changes.setSyncProviders(
|
57
|
+
ISyncingServiceProvider(Rx.services.getServiceProvider(AIRServiceProvider.ID)),
|
58
|
+
Rx.services.getServiceProvider(XMLHTTPServiceProvider.ID));
|
59
|
+
|
60
|
+
Rx.changes.addEventListener(PushStartEvent.ID, onPushStart);
|
61
|
+
Rx.changes.addEventListener(PushEndEvent.ID, onPushEnd);
|
62
|
+
Rx.changes.addEventListener(PullStartEvent.ID, onPullStart);
|
63
|
+
Rx.changes.addEventListener(PullEndEvent.ID, onPullEnd);
|
64
|
+
<% end -%>
|
65
|
+
<% else -%>
|
66
|
+
<% if use_gae -%>
|
67
|
+
<%= command_controller_name %>.initialize([GAEHTTPServiceProvider], GAEHTTPServiceProvider.ID);
|
68
|
+
<% else -%>
|
69
|
+
<%= command_controller_name %>.initialize();
|
70
|
+
<% end -%>
|
71
|
+
<% end -%>
|
72
|
+
}
|
73
|
+
<% if use_air -%>
|
74
|
+
<% if distributed -%>
|
75
|
+
|
76
|
+
private function onPushStart(event:Event):void {
|
77
|
+
syncStatus = "Pushing changes ...";
|
78
|
+
}
|
79
|
+
|
80
|
+
private function onPushEnd(event:Event):void {
|
81
|
+
syncStatus = "Push complete.";
|
82
|
+
}
|
83
|
+
|
84
|
+
private function onPullStart(event:Event):void {
|
85
|
+
syncStatus = "Pulling data...";
|
86
|
+
}
|
87
|
+
|
88
|
+
private function onPullEnd(event:Event):void {
|
89
|
+
syncStatus = "Pull complete.";
|
90
|
+
}
|
91
|
+
|
92
|
+
private function onNetworkStatusChange(event:StatusEvent):void {
|
93
|
+
online = (socketMonitor.available) ? true : false;
|
94
|
+
|
95
|
+
if (online) {
|
96
|
+
Rx.defaultServiceId = XMLHTTPServiceProvider.ID;
|
97
|
+
} else {
|
98
|
+
Rx.defaultServiceId = AIRServiceProvider.ID;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
private function getCurrentProviderName(id:int):String {
|
103
|
+
switch (id) {
|
104
|
+
case XMLHTTPServiceProvider.ID:
|
105
|
+
return "Rails";
|
106
|
+
case AIRServiceProvider.ID:
|
107
|
+
return "AIR (SQLite)";
|
108
|
+
default :
|
109
|
+
return "No idea";
|
110
|
+
}
|
111
|
+
}
|
112
|
+
<% end -%>
|
113
|
+
<% end -%>
|
114
|
+
]]>
|
115
|
+
</mx:Script>
|
116
|
+
<% if use_air -%>
|
117
|
+
<% if distributed -%>
|
118
|
+
<mx:VBox height="100%">
|
119
|
+
<mx:Label text="Current Provider: {getCurrentProviderName(Rx.defaultServiceId)}"/>
|
120
|
+
<mx:Label text="Status: {online ? 'Online' : 'Offline' }"/>
|
121
|
+
<mx:HBox>
|
122
|
+
<mx:Button label="Push" click="{Rx.changes.push()}" enabled="{online}"/>
|
123
|
+
<mx:Button label="Pull" click="{Rx.changes.pull()}" enabled="{online}"/>
|
124
|
+
</mx:HBox>
|
125
|
+
<mx:Label text="{syncStatus}"/>
|
126
|
+
</mx:VBox>
|
127
|
+
<% end -%>
|
128
|
+
<% end -%>
|
129
|
+
<mx:LinkBar dataProvider="{mainViewStack}" direction="vertical" borderStyle="solid" backgroundColor="#EEEEEE"/>
|
130
|
+
<mx:ViewStack id="mainViewStack" width="100%" height="100%">
|
131
|
+
<!-- For a simple demo, put all the components here. -->
|
132
|
+
<% for component in component_names -%>
|
133
|
+
<generated:<%= component %>/>
|
134
|
+
<% end -%>
|
135
|
+
</mx:ViewStack>
|
136
|
+
</mx:<%= application_tag %>>
|
File without changes
|
@@ -65,7 +65,8 @@ class RxScaffoldGenerator < RubiGen::Base
|
|
65
65
|
:flex_project_name,
|
66
66
|
:base_package,
|
67
67
|
:base_folder,
|
68
|
-
:command_controller_name
|
68
|
+
:command_controller_name,
|
69
|
+
:flex_root
|
69
70
|
|
70
71
|
attr_reader :belongs_tos,
|
71
72
|
:has_manies,
|
@@ -87,18 +88,18 @@ class RxScaffoldGenerator < RubiGen::Base
|
|
87
88
|
@class_name = @name.camelize
|
88
89
|
|
89
90
|
@project_name, @flex_project_name, @command_controller_name,
|
90
|
-
@base_package, @base_folder = extract_names
|
91
|
+
@base_package, @base_folder, @flex_root = extract_names
|
91
92
|
extract_relationships
|
92
93
|
end
|
93
94
|
|
94
95
|
def manifest
|
95
96
|
record do |m|
|
96
97
|
m.template 'model.as.erb',
|
97
|
-
File.join("
|
98
|
+
File.join("#{flex_root}", base_folder, "models", "#{@class_name}.as"),
|
98
99
|
:assigns => { :resource_controller_name => "#{file_name.pluralize}" }
|
99
100
|
|
100
101
|
m.template 'component.mxml.erb',
|
101
|
-
File.join("
|
102
|
+
File.join("#{flex_root}", base_folder, "components", "generated", "#{@class_name}Box.mxml"),
|
102
103
|
:assigns => { :resource_controller_name => "#{file_name.pluralize}" }
|
103
104
|
|
104
105
|
if options[:gae]
|
@@ -10,23 +10,23 @@
|
|
10
10
|
<% end -%>
|
11
11
|
|
12
12
|
[Bindable]
|
13
|
-
private var
|
13
|
+
private var <%= class_name.dcfirst %>:<%= class_name %> = new <%= class_name %>();
|
14
14
|
|
15
15
|
private function new<%= class_name %>():void {
|
16
|
-
|
16
|
+
<%= class_name.dcfirst %> = new <%= class_name %>();
|
17
17
|
<%= class_name.dcfirst.pluralize %>List.selectedIndex = -1;
|
18
18
|
}
|
19
19
|
|
20
20
|
private function save<%= class_name %>():void {
|
21
|
-
|
22
|
-
|
21
|
+
updateModelProperties();
|
22
|
+
if (<%= class_name.dcfirst %>.id) {
|
23
|
+
<%= class_name.dcfirst %>.update({onSuccess: on<%= class_name %>Update});
|
23
24
|
} else {
|
24
|
-
create<%= class_name %>
|
25
|
+
<%= class_name.dcfirst %>.create({onSuccess: on<%= class_name %>Create});
|
25
26
|
}
|
26
27
|
}
|
27
28
|
|
28
|
-
private function
|
29
|
-
var <%= class_name.dcfirst %>:<%= class_name %> = new <%= class_name %>();
|
29
|
+
private function updateModelProperties():void {
|
30
30
|
<% for attribute in attributes -%>
|
31
31
|
<% if attribute.type == :boolean -%>
|
32
32
|
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
|
@@ -46,55 +46,27 @@
|
|
46
46
|
<% for model in belongs_tos -%>
|
47
47
|
<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
|
48
48
|
<% end -%>
|
49
|
-
<%= class_name.dcfirst %>.create({onSuccess: on<%= class_name %>Create});
|
50
|
-
}
|
51
|
-
|
52
|
-
private function update<%= class_name %>():void {
|
53
|
-
<% for attribute in attributes -%>
|
54
|
-
<% if attribute.type == :boolean -%>
|
55
|
-
_<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
|
56
|
-
<% elsif attribute.type == :string -%>
|
57
|
-
_<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
|
58
|
-
<% elsif attribute.type == :text -%>
|
59
|
-
_<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
|
60
|
-
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
61
|
-
_<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
|
62
|
-
<% elsif attribute.type == :date -%>
|
63
|
-
_<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
|
64
|
-
<% else -%>
|
65
|
-
_<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_type %>(<%= attribute.flex_name %>TextInput.text);
|
66
|
-
<% end -%>
|
67
|
-
<% end -%>
|
68
|
-
|
69
|
-
<% for model in belongs_tos -%>
|
70
|
-
_<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
|
71
|
-
<% end -%>
|
72
|
-
_<%= class_name.dcfirst %>.update({onSuccess: on<%= class_name %>Update});
|
73
49
|
}
|
74
50
|
|
75
51
|
private function destroy<%= class_name %>():void {
|
76
|
-
|
52
|
+
<%= class_name.dcfirst %>.destroy({onSuccess: on<%= class_name %>Destroy});
|
77
53
|
}
|
78
54
|
|
79
55
|
private function on<%= class_name %>Select():void {
|
80
|
-
|
56
|
+
<%= class_name.dcfirst %> = RxUtils.clone(<%= class_name.dcfirst.pluralize %>List.selectedItem) as <%= class_name %>;
|
81
57
|
}
|
82
58
|
|
83
|
-
private function on<%= class_name %>Create(
|
84
|
-
|
59
|
+
private function on<%= class_name %>Create(result:<%= class_name %>):void {
|
60
|
+
<%= class_name.dcfirst %> = new <%= class_name %>;
|
85
61
|
}
|
86
62
|
|
87
|
-
private function on<%= class_name %>Update(
|
88
|
-
<%= class_name.dcfirst.pluralize %>List.selectedItem =
|
89
|
-
|
63
|
+
private function on<%= class_name %>Update(result:<%= class_name %>):void {
|
64
|
+
<%= class_name.dcfirst.pluralize %>List.selectedItem = result;
|
65
|
+
on<%= class_name %>Select();
|
90
66
|
}
|
91
67
|
|
92
|
-
private function on<%= class_name %>Destroy(
|
93
|
-
on<%= class_name %>Create(
|
94
|
-
}
|
95
|
-
|
96
|
-
private function canDelete<%= class_name %>(<%= class_name.dcfirst %>:<%= class_name %>):Boolean {
|
97
|
-
return <%= class_name.dcfirst %> != null && !RxUtils.isEmpty(<%= class_name.dcfirst %>.id);
|
68
|
+
private function on<%= class_name %>Destroy(result:<%= class_name %>):void {
|
69
|
+
on<%= class_name %>Create(result);
|
98
70
|
}
|
99
71
|
]]></mx:Script>
|
100
72
|
<mx:Panel id="<%= class_name.dcfirst.pluralize %>Panel"
|
@@ -115,17 +87,17 @@
|
|
115
87
|
<% for attribute in attributes -%>
|
116
88
|
<mx:FormItem label="<%= attribute.flex_name.ucfirst %>" width="100%">
|
117
89
|
<% if attribute.type == :boolean -%>
|
118
|
-
<mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{
|
90
|
+
<mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
119
91
|
<% elsif attribute.type == :string -%>
|
120
|
-
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{
|
92
|
+
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
121
93
|
<% elsif attribute.type == :text -%>
|
122
|
-
<mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{
|
94
|
+
<mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
123
95
|
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
124
|
-
<rx:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{
|
96
|
+
<rx:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
125
97
|
<% elsif attribute.type == :date -%>
|
126
|
-
<mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{
|
98
|
+
<mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
127
99
|
<% else -%>
|
128
|
-
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{
|
100
|
+
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
129
101
|
<% end -%>
|
130
102
|
</mx:FormItem>
|
131
103
|
<% end -%>
|
@@ -134,7 +106,7 @@
|
|
134
106
|
<mx:ComboBox id="<%= model.camelcase(:lower) %>ComboBox" width="200"
|
135
107
|
labelField="{<%= model.camelcase %>.LABEL}"
|
136
108
|
dataProvider="{Rx.models.index(<%= model.camelcase %>)}" prompt="<%= model.camelcase %> ..."
|
137
|
-
selectedItem="{
|
109
|
+
selectedItem="{<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %>}" />
|
138
110
|
</mx:FormItem>
|
139
111
|
<% end -%>
|
140
112
|
</mx:Form>
|
@@ -142,7 +114,7 @@
|
|
142
114
|
<mx:Button label="Save <%= class_name %>" width="50%" height="30"
|
143
115
|
click="save<%= class_name %>()"/>
|
144
116
|
<mx:Button label="Delete <%= class_name %>" width="50%" height="30"
|
145
|
-
enabled="{
|
117
|
+
enabled="{RxUtils.canDeleteModel(<%= class_name.dcfirst %>)}"
|
146
118
|
click="destroy<%= class_name %>()"/>
|
147
119
|
</mx:ControlBar>
|
148
120
|
</mx:Panel>
|
@@ -17,7 +17,7 @@ class Controller(restful.Controller):
|
|
17
17
|
restful.send_successful_response(self, model.to_xml())
|
18
18
|
|
19
19
|
def put(self):
|
20
|
-
model = <%= file_name %>.<%= class_name %>.
|
20
|
+
model = <%= file_name %>.<%= class_name %>.get(db.Key(restful.get_model_key(self)))
|
21
21
|
assist.update_model_from_params(model, self.request.params)
|
22
22
|
restful.send_successful_response(self, model.to_xml())
|
23
23
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|