ruboss4ruby 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. data/Generators +5 -0
  2. data/Manifest.txt +39 -41
  3. data/Rakefile +2 -1
  4. data/lib/ruboss4ruby.rb +16 -12
  5. data/lib/ruboss4ruby/active_foo.rb +39 -3
  6. data/lib/ruboss4ruby/recipes.rb +62 -0
  7. data/lib/ruboss4ruby/ruboss_helper.rb +54 -0
  8. data/lib/ruboss4ruby/ruboss_test_helpers.rb +31 -0
  9. data/lib/ruboss4ruby/tasks.rb +0 -2
  10. data/lib/ruboss4ruby/version.rb +2 -2
  11. data/merb_generators/ruboss_config.rb +19 -19
  12. data/merb_generators/ruboss_controller.rb +3 -3
  13. data/merb_generators/ruboss_flex_app.rb +3 -3
  14. data/merb_generators/ruboss_resource_controller.rb +3 -3
  15. data/merb_generators/ruboss_scaffold.rb +47 -47
  16. data/rails_generators/ruboss_config/ruboss_config_generator.rb +2 -2
  17. data/rails_generators/ruboss_config/templates/index.html.erb +2 -2
  18. data/rails_generators/ruboss_config/templates/mainapp-config.xml +21 -0
  19. data/rails_generators/ruboss_config/templates/mainapp.mxml +4 -7
  20. data/rails_generators/ruboss_config/templates/project-textmate.erb +52 -0
  21. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +0 -2
  22. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +0 -2
  23. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +4 -3
  24. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -1
  25. data/test/controllers/application.rb +15 -0
  26. data/test/controllers/locations_controller.rb +93 -0
  27. data/test/controllers/notes_controller.rb +96 -0
  28. data/test/controllers/projects_controller.rb +93 -0
  29. data/test/controllers/tasks_controller.rb +93 -0
  30. data/test/controllers/users_controller.rb +93 -0
  31. data/test/database.yml +4 -0
  32. data/test/fixtures/locations.yml +8 -0
  33. data/test/fixtures/notes.yml +17 -0
  34. data/test/fixtures/projects.yml +25 -0
  35. data/test/fixtures/tasks.yml +46 -0
  36. data/test/fixtures/users.yml +13 -0
  37. data/test/helpers/controllers.log +8 -0
  38. data/test/helpers/functional_test_helper.rb +32 -0
  39. data/test/helpers/models.log +170 -0
  40. data/test/helpers/test_helper.rb +25 -0
  41. data/test/helpers/unit_test_helper.rb +23 -0
  42. data/test/model.yml +35 -0
  43. data/test/models/location.rb +4 -0
  44. data/test/models/note.rb +3 -0
  45. data/test/models/project.rb +6 -0
  46. data/test/models/task.rb +20 -0
  47. data/test/models/user.rb +23 -0
  48. data/test/playing_around_in_a_console.txt +71 -0
  49. data/test/schema.rb +63 -0
  50. data/test/test.sqlite3 +0 -0
  51. data/test/test.swf +1 -0
  52. data/test/test_active_foo.rb +79 -0
  53. data/test/test_ruboss_rails_integration_functional.rb +27 -0
  54. data/test/test_swfobject_helper.rb +63 -0
  55. data/test/to_fxml_test.rb +79 -0
  56. data/test/views/notes/empty_params_action.html.erb +1 -0
  57. data/test/views/notes/index.html.erb +1 -0
  58. metadata +57 -52
  59. data/merb_generators/ruboss_config/USAGE +0 -18
  60. data/merb_generators/ruboss_config/ruboss_config_generator.rb +0 -135
  61. data/merb_generators/ruboss_config/templates/actionscript.properties +0 -16
  62. data/merb_generators/ruboss_config/templates/actionscriptair.properties +0 -16
  63. data/merb_generators/ruboss_config/templates/expressInstall.swf +0 -0
  64. data/merb_generators/ruboss_config/templates/flex.properties +0 -2
  65. data/merb_generators/ruboss_config/templates/html-template/AC_OETags.js +0 -276
  66. data/merb_generators/ruboss_config/templates/html-template/history/history.css +0 -6
  67. data/merb_generators/ruboss_config/templates/html-template/history/history.js +0 -645
  68. data/merb_generators/ruboss_config/templates/html-template/history/historyFrame.html +0 -29
  69. data/merb_generators/ruboss_config/templates/html-template/index.template.html +0 -121
  70. data/merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  71. data/merb_generators/ruboss_config/templates/index.html.erb +0 -18
  72. data/merb_generators/ruboss_config/templates/mainair-app.xml +0 -134
  73. data/merb_generators/ruboss_config/templates/mainapp.mxml +0 -34
  74. data/merb_generators/ruboss_config/templates/project.properties +0 -18
  75. data/merb_generators/ruboss_config/templates/projectair.properties +0 -24
  76. data/merb_generators/ruboss_config/templates/swfobject.js +0 -5
  77. data/merb_generators/ruboss_controller/USAGE +0 -11
  78. data/merb_generators/ruboss_controller/ruboss_controller_generator.rb +0 -32
  79. data/merb_generators/ruboss_resource_controller/USAGE +0 -5
  80. data/merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb +0 -70
  81. data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb +0 -55
  82. data/merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
  83. data/merb_generators/ruboss_scaffold/USAGE +0 -5
  84. data/merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +0 -127
  85. data/merb_generators/ruboss_yaml_scaffold/USAGE +0 -5
  86. data/merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -53
  87. data/merb_generators/templates/ruboss_scaffold/component.mxml.erb +0 -148
  88. data/merb_generators/templates/ruboss_scaffold/fixtures.yml.erb +0 -35
  89. data/merb_generators/templates/ruboss_scaffold/migration.rb.erb +0 -19
  90. data/merb_generators/templates/ruboss_scaffold/model.as.erb +0 -42
  91. data/merb_generators/templates/ruboss_scaffold/model.rb.erb +0 -11
  92. data/test/active_foo_test.rb +0 -16
  93. data/test/test_generator_helper.rb +0 -29
  94. data/test/test_helper.rb +0 -2
  95. data/test/test_ruboss_config_generator.rb +0 -45
  96. data/test/test_ruboss_controller_generator.rb +0 -45
  97. data/test/test_ruboss_on_ruby.rb +0 -11
  98. data/test/test_ruboss_scaffold_generator.rb +0 -45
  99. data/test/test_ruboss_yaml_scaffold_generator.rb +0 -46
@@ -1,70 +0,0 @@
1
- class RubossResourceControllerGenerator < Merb::GeneratorBase
2
-
3
- attr_reader :controller_class_name,
4
- :controller_file_name,
5
- :controller_base_path,
6
- :controller_modules,
7
- :model_class_name,
8
- :full_controller_const,
9
- :singular_model,
10
- :plural_model
11
-
12
- def initialize(args, runtime_args = {})
13
- @base = File.dirname(__FILE__)
14
-
15
- super
16
- name = args.shift
17
- nfp = name.snake_case.gsub("::", "/")
18
- nfp = nfp.split("/")
19
- @model_class_name = nfp.pop.singularize.to_const_string
20
- @model_class_name = runtime_args[:model_class_name] if runtime_args[:model_class_name]
21
- @singular_model = @model_class_name.snake_case
22
- @plural_model = @singular_model.pluralize
23
-
24
- nfp << @plural_model
25
-
26
- @controller_file_name = nfp.join("/")
27
-
28
- # Need to setup the directories
29
- unless @controller_file_name == File.basename(@controller_file_name)
30
- @controller_base_path = controller_file_name.split("/")[0..-2].join("/")
31
- end
32
-
33
- @controller_modules = @controller_file_name.to_const_string.split("::")[0..-2]
34
- @controller_class_name = @controller_file_name.to_const_string.split("::").last
35
-
36
- @full_controller_const = ((@controller_modules.dup || []) << @controller_class_name).join("::")
37
- end
38
-
39
- def manifest
40
- record do |m|
41
- @m = m
42
-
43
- # Create the controller directory
44
- m.directory File.join("app/controllers", controller_base_path) if controller_base_path
45
-
46
- # Create the helpers directory
47
- m.directory File.join("app/helpers", controller_base_path) if controller_base_path
48
-
49
- @assigns = {
50
- :controller_modules => controller_modules,
51
- :controller_class_name => controller_class_name,
52
- :controller_file_name => controller_file_name,
53
- :controller_base_path => controller_base_path,
54
- :full_controller_const => full_controller_const,
55
- :model_class_name => model_class_name,
56
- :singular_model => singular_model,
57
- :plural_model => plural_model
58
- }
59
- copy_dirs
60
- copy_files
61
-
62
- m.dependency "merb_resource_controller_test", [@controller_class_name], @assigns
63
- end
64
- end
65
-
66
- protected
67
- def banner
68
- "Usage: #{$0} #{spec.name}"
69
- end
70
- end
@@ -1,55 +0,0 @@
1
- <% counter = 0 -%>
2
- <% controller_modules.each_with_index do |mod, i| -%>
3
- <%= " " * i %>module <%= mod %>
4
- <% counter = i -%>
5
- <% end -%>
6
- <% counter = counter == 0 ? 0 : (counter + 1) -%>
7
- <%= " " * counter %>class <%= controller_class_name %> < Application
8
- <%= " " * counter %> provides :xml, :fxml
9
-
10
- <%= " " * counter %> def index
11
- <%= " " * counter %> @<%= plural_model %> = <%= model_class_name %>.find(:all)
12
- <%= " " * counter %> display @<%= plural_model %>
13
- <%= " " * counter %> end
14
-
15
- <%= " " * counter %> def show
16
- <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
17
- <%= " " * counter %> raise NotFound unless @<%= singular_model %>
18
- <%= " " * counter %> display @<%= singular_model %>
19
- <%= " " * counter %> end
20
-
21
- <%= " " * counter %> def create
22
- <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
23
- <%= " " * counter %> if @<%= singular_model %>.save
24
- <%= " " * counter %> display @<%= singular_model %>
25
- <%= " " * counter %> else
26
- <%= " " * counter %> display @<%= singular_model %>.errors
27
- <%= " " * counter %> end
28
- <%= " " * counter %> end
29
-
30
- <%= " " * counter %> def update
31
- <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
32
- <%= " " * counter %> raise NotFound unless @<%= singular_model %>
33
- <%= " " * counter %> if @<%= singular_model %>.update_attributes(params[:<%= singular_model %>])
34
- <%= " " * counter %> display @<%= singular_model %>
35
- <%= " " * counter %> else
36
- <%= " " * counter %> display @<%= singular_model %>.errors
37
- <%= " " * counter %> end
38
- <%= " " * counter %> end
39
-
40
- <%= " " * counter %> def destroy
41
- <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
42
- <%= " " * counter %> raise NotFound unless @<%= singular_model %>
43
- <%= " " * counter %> if @<%= singular_model %>.destroy
44
- <%= " " * counter %> display @<%= singular_model %>
45
- <%= " " * counter %> else
46
- <%= " " * counter %> display @<%= singular_model %>.errors
47
- <%= " " * counter %> end
48
- <%= " " * counter %> end
49
-
50
- <%= " " * counter %>end
51
- <% counter = counter == 0 ? 0 : (counter - 1) -%>
52
- <% controller_modules.reverse.each_with_index do |mod, i| -%>
53
- <%= " " * counter %>end # <%= mod %>
54
- <% counter = counter - 1 -%>
55
- <% end -%>
@@ -1,16 +0,0 @@
1
- <% counter = 1 -%>
2
- module Merb
3
- <% controller_modules.each_with_index do |mod, i| -%>
4
- <%= " " * i %>module <%= mod %>
5
- <% counter = i -%>
6
- <% end -%>
7
- <% counter = counter == 0 ? 0 : (counter + 1) -%>
8
- <%= " " * counter %>module <%= controller_class_name %>Helper
9
-
10
- <%= " " * counter %>end
11
- <% counter = counter == 0 ? 0 : (counter - 1) -%>
12
- <% controller_modules.reverse.each_with_index do |mod, i| -%>
13
- <%= " " * counter %>end # <%= mod %>
14
- <% counter = counter - 1 -%>
15
- <% end -%>
16
- end
@@ -1,5 +0,0 @@
1
- Description:
2
-
3
-
4
- Usage:
5
-
@@ -1,127 +0,0 @@
1
- require 'ruboss4ruby/configuration'
2
-
3
- class RubossScaffoldGenerator < Merb::GeneratorBase
4
- include Ruboss::Configuration
5
-
6
- attr_reader :class_name,
7
- :file_name,
8
- :table_name,
9
- :provided_args,
10
- :actual_args
11
-
12
- attr_reader :project_name,
13
- :flex_project_name,
14
- :base_package,
15
- :base_folder,
16
- :command_controller_name
17
-
18
- attr_reader :belongs_tos,
19
- :has_manies,
20
- :has_ones
21
-
22
- def initialize(runtime_args, runtime_options = {})
23
- @base = File.dirname(__FILE__)
24
- super
25
- @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
26
-
27
- @actual_args = runtime_args
28
- @provided_args = runtime_args.dup
29
- @file_name = actual_args.shift.snake_case
30
- @table_name = @file_name.pluralize
31
- @class_name = @file_name.to_const_string
32
-
33
- @belongs_tos = []
34
- @has_ones = []
35
- @has_manies = []
36
- # Figure out has_one, has_many and belongs_to based on args
37
- @args.each do |arg|
38
- if arg =~ /^has_one:/
39
- # arg = "has_one:arg1,arg2", so all the has_one are together
40
- @has_ones = arg.split(':')[1].split(',')
41
- elsif arg =~ /^has_many:/
42
- # arg = "has_many:arg1,arg2", so all the has_many are together
43
- @has_manies = arg.split(":")[1].split(",")
44
- elsif arg =~ /^belongs_to:/ # belongs_to:arg1,arg2
45
- @belongs_tos = arg.split(":")[1].split(',')
46
- end
47
- end
48
-
49
- # Remove the has_one and has_many arguments since they are
50
- # not for consumption by the scaffold generator, and since
51
- # we have already used them to set the @belongs_tos, @has_ones and
52
- # @has_manies.
53
- @actual_args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
54
- @provided_args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
55
- end
56
-
57
- def manifest
58
- record do |m|
59
- @m = m
60
-
61
- #singularize the model & pluralize the name of the controller
62
- model_args = provided_args.dup
63
- controller_args = provided_args.dup
64
-
65
- # normalize the model_args
66
- model_args[0] = model_args.first.snake_case.gsub("::", "/").split("/").last.singularize
67
-
68
- controller_args[0] = controller_args.first.pluralize
69
-
70
- m.dependency "ruboss_resource_controller", controller_args, options.dup
71
-
72
- # # Create a new generated ActiveRecord model based on the Ruboss templates.
73
- m.directory 'app/models'
74
- m.template 'model.rb.erb', File.join("app", "models", "#{@file_name}.rb"),
75
- :collision => :force unless options[:flex_only]
76
-
77
- unless options[:skip_fixture]
78
- m.directory 'spec/fixtures'
79
- m.template 'fixtures.yml.erb', File.join("spec", "fixtures", "#{@table_name}.yml"),
80
- :collision => :force unless options[:flex_only]
81
- end
82
-
83
- unless options[:skip_migration]
84
- m.directory 'schema/migrations'
85
- current_migration_number = Dir[Dir.pwd+'/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
86
- migration_file_name = format("%03d_%s", (current_migration_number.to_i+1), file_name) + "_migration"
87
- m.template 'migration.rb.erb', "schema/migrations/#{migration_file_name}.rb", :assigns => {
88
- :migration_name => "#{@class_name}Migration"
89
- } unless options[:flex_only]
90
- end
91
-
92
- m.dependency "merb_model_test", [@file_name], { :model_file_name => @file_name, :model_class_name => @class_name }
93
-
94
- # Generate Flex AS model and MXML component based on the
95
- # Ruboss templates.
96
- m.template 'model.as.erb',
97
- File.join("app", "flex", base_folder, "models", "#{@class_name}.as"),
98
- :assigns => { :resource_controller_name => "#{@table_name}" }
99
-
100
- m.template 'component.mxml.erb',
101
- File.join("app", "flex", base_folder, "components", "generated", "#{@class_name}Box.mxml"),
102
- :assigns => { :resource_controller_name => "#{@table_name}" }
103
-
104
- # Run the rcontroller generator to clobber the
105
- # RubossCommandController subclass to include the new models.
106
- m.dependency 'ruboss_controller', [], :collision => :force
107
- end
108
- end
109
-
110
- protected
111
- def attributes
112
- @attributes ||= @args.collect do |attribute|
113
- Ruboss::Generator::GeneratedAttribute.new(*attribute.split(":"))
114
- end
115
- end
116
-
117
- def add_options!(opt)
118
- opt.separator ''
119
- opt.separator 'Options:'
120
- opt.on("-f", "--flex-only", "Scaffold Flex code only",
121
- "Default: false") { |v| options[:flex_only] = v}
122
- end
123
-
124
- def banner
125
- "Usage: #{$0} #{spec.name}"
126
- end
127
- end
@@ -1,5 +0,0 @@
1
- Description:
2
-
3
-
4
- Usage:
5
-
@@ -1,53 +0,0 @@
1
- require 'yaml'
2
- require 'ruboss4ruby/configuration'
3
-
4
- class RubossYamlScaffoldGenerator < Merb::GeneratorBase
5
- include Ruboss::Configuration
6
-
7
- def initialize(runtime_args, runtime_options = {})
8
- runtime_args.push ""
9
- super
10
- end
11
-
12
- def extract_attrs(line, attrs)
13
- attrs.each do |key,value|
14
- if value.class == Array
15
- line << " #{key}:#{value.join(',')}"
16
- else
17
- line << " #{key}:#{value}"
18
- end
19
- end
20
- line
21
- end
22
-
23
- def manifest
24
- record do |m|
25
- models = YAML.load(File.open(File.join(APP_ROOT, 'schema/model.yml'), 'r'))
26
- models.each do |model|
27
- line = ""
28
- attrs = model[1]
29
- if attrs.class == Array
30
- attrs.each do |elm|
31
- line = extract_attrs(line, elm)
32
- end
33
- else
34
- line = extract_attrs(line, attrs)
35
- end
36
- line = model[0].camelcase + " " + line
37
- line = '--flex-only ' + line if ARGV.include?('flexonly')
38
- puts 'running: ruboss_scaffold ' + line
39
- Merb::ComponentGenerator.run "ruboss_scaffold", line.split(" "), "ruboss_scaffold", "generate"
40
- puts 'done ...'
41
- sleep 1
42
- end
43
- config_args = ['--main-only']
44
- config_args << '--skip-framework' if ARGV.include?('skipframework')
45
- Merb::ComponentGenerator.run "ruboss_config", config_args, "ruboss_config", "generate"
46
- end
47
- end
48
-
49
- protected
50
- def banner
51
- "Usage: #{$0} #{spec.name}"
52
- end
53
- end
@@ -1,148 +0,0 @@
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:rcomponents="org.ruboss.components.*">
4
- <mx:Script><![CDATA[
5
- import org.ruboss.Ruboss;
6
- import org.ruboss.utils.RubossUtils;
7
- import <%= base_package %>.models.<%= class_name %>;
8
- <% for model in belongs_tos -%>
9
- import <%= base_package %>.models.<%= model.camelcase %>;
10
- <% end -%>
11
-
12
- [Bindable]
13
- private var _<%= class_name.downcase_first_letter %>:<%= class_name %> = new <%= class_name %>();
14
-
15
- private function new<%= class_name %>():void {
16
- _<%= class_name.downcase_first_letter %> = new <%= class_name %>();
17
- <%= class_name.downcase_first_letter.pluralize %>List.selectedIndex = -1;
18
- }
19
-
20
- private function save<%= class_name %>():void {
21
- if (_<%= class_name.downcase_first_letter %>.id) {
22
- update<%= class_name %>();
23
- } else {
24
- create<%= class_name %>();
25
- }
26
- }
27
-
28
- private function create<%= class_name %>():void {
29
- var <%= class_name.downcase_first_letter %>:<%= class_name %> = new <%= class_name %>();
30
- <% for attribute in attributes -%>
31
- <% if attribute.type == :boolean -%>
32
- <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
33
- <% elsif attribute.type == :string -%>
34
- <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
35
- <% elsif attribute.type == :text -%>
36
- <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
37
- <% elsif attribute.type == :datetime || attribute.type == :time -%>
38
- <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
39
- <% elsif attribute.type == :date -%>
40
- <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
41
- <% else -%>
42
- <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_type %>(<%= attribute.flex_name %>TextInput.text);
43
- <% end -%>
44
- <% end -%>
45
-
46
- <% for model in belongs_tos -%>
47
- <%= class_name.downcase_first_letter %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
48
- <% end -%>
49
- <%= class_name.downcase_first_letter %>.create({afterCallback: 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.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
56
- <% elsif attribute.type == :string -%>
57
- _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
58
- <% elsif attribute.type == :text -%>
59
- _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
60
- <% elsif attribute.type == :datetime || attribute.type == :time -%>
61
- _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
62
- <% elsif attribute.type == :date -%>
63
- _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
64
- <% else -%>
65
- _<%= class_name.downcase_first_letter %>.<%= 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.downcase_first_letter %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
71
- <% end -%>
72
- _<%= class_name.downcase_first_letter %>.update({afterCallback: on<%= class_name %>Update});
73
- }
74
-
75
- private function destroy<%= class_name %>():void {
76
- _<%= class_name.downcase_first_letter %>.destroy({afterCallback: on<%= class_name %>Destroy});
77
- }
78
-
79
- private function on<%= class_name %>Select():void {
80
- _<%= class_name.downcase_first_letter %> = RubossUtils.clone(<%= class_name.downcase_first_letter.pluralize %>List.selectedItem) as <%= class_name %>;
81
- }
82
-
83
- private function on<%= class_name %>Create(<%= class_name.downcase_first_letter %>:<%= class_name %>):void {
84
- _<%= class_name.downcase_first_letter %> = new <%= class_name %>;
85
- }
86
-
87
- private function on<%= class_name %>Update(<%= class_name.downcase_first_letter %>:<%= class_name %>):void {
88
- <%= class_name.downcase_first_letter.pluralize %>List.selectedItem = <%= class_name.downcase_first_letter %>;
89
- _<%= class_name.downcase_first_letter %> = RubossUtils.clone(<%= class_name.downcase_first_letter %>) as <%= class_name %>;
90
- }
91
-
92
- private function on<%= class_name %>Destroy(<%= class_name.downcase_first_letter %>:<%= class_name %>):void {
93
- on<%= class_name %>Create(<%= class_name.downcase_first_letter %>);
94
- }
95
-
96
- private function canDelete<%= class_name %>(<%= class_name.downcase_first_letter %>:<%= class_name %>):Boolean {
97
- return <%= class_name.downcase_first_letter %> != null && <%= class_name.downcase_first_letter %>.id != 0;
98
- }
99
- ]]></mx:Script>
100
- <mx:Panel id="<%= class_name.downcase_first_letter.pluralize %>Panel"
101
- title="<%= class_name.pluralize %>"
102
- width="25%" height="100%">
103
- <mx:List id="<%= class_name.downcase_first_letter.pluralize %>List"
104
- width="100%" height="100%"
105
- dataProvider="{Ruboss.models.index(<%= class_name %>)}"
106
- change="on<%= class_name %>Select()"/>
107
- <mx:ControlBar width="100%">
108
- <mx:Button label="New <%= class_name %>" width="100%" height="30"
109
- click="new<%= class_name %>()"/>
110
- </mx:ControlBar>
111
- </mx:Panel>
112
- <mx:Panel title="Edit <%= class_name %>" width="75%" height="100%">
113
- <mx:Form width="100%" height="100%">
114
- <% for attribute in attributes -%>
115
- <mx:FormItem label="<%= attribute.flex_name.capitalize_without_downcasing %>" width="100%">
116
- <% if attribute.type == :boolean -%>
117
- <mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
118
- <% elsif attribute.type == :string -%>
119
- <mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
120
- <% elsif attribute.type == :text -%>
121
- <mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
122
- <% elsif attribute.type == :datetime || attribute.type == :time -%>
123
- <rcomponents:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
124
- <% elsif attribute.type == :date -%>
125
- <mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
126
- <% else -%>
127
- <mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
128
- <% end -%>
129
- </mx:FormItem>
130
- <% end -%>
131
- <% for model in belongs_tos -%>
132
- <mx:FormItem label="<%= model.camelcase %>" width="100%">
133
- <mx:ComboBox id="<%= model.camelcase(:lower) %>ComboBox" width="200"
134
- labelField="{<%= model.camelcase %>.LABEL}"
135
- dataProvider="{Ruboss.models.index(<%= model.camelcase %>)}" prompt="<%= model.camelcase %> ..."
136
- selectedItem="{_<%= class_name.downcase_first_letter %>.<%= model.camelcase(:lower) %>}" />
137
- </mx:FormItem>
138
- <% end -%>
139
- </mx:Form>
140
- <mx:ControlBar width="100%">
141
- <mx:Button label="Save <%= class_name %>" width="50%" height="30"
142
- click="save<%= class_name %>()"/>
143
- <mx:Button label="Delete <%= class_name %>" width="50%" height="30"
144
- enabled="{canDelete<%= class_name %>(_<%= class_name.downcase_first_letter %>)}"
145
- click="destroy<%= class_name %>()"/>
146
- </mx:ControlBar>
147
- </mx:Panel>
148
- </mx:HBox>