rails_generators/rx_scaffold/templates/model.as.erb in dima-restfulx-1.2.1 vs rails_generators/rx_scaffold/templates/model.as.erb in dima-restfulx-1.2.2

- old
+ new

@@ -1,14 +1,21 @@ package <%= base_package %>.models { -<% if has_manies.length > 0 -%> +<% if has_manies.length > 0 || has_many_through.length > 0 -%> import org.restfulx.collections.ModelsCollection; <% end -%> +<% if tree_model.size > 0 -%> + <% @tree_or_no_tree = 'RxTreeModel' %> + import org.restfulx.models.RxTreeModel +<% end -%> +<% unless tree_model.size > 0 -%> + <% @tree_or_no_tree = 'RxModel' %> import org.restfulx.models.RxModel; +<% end -%> [Resource(name="<%= resource_controller_name %>")] [Bindable] - public class <%= class_name %> extends RxModel { + public class <%= class_name %> extends <%= @tree_or_no_tree %> { <% if attributes && !attributes.empty? && attributes[0].flex_type != "Boolean" -%> public static const LABEL:String = "<%= attributes[0].flex_name %>"; <% else -%> public static const LABEL:String = "id"; <% end -%> @@ -23,17 +30,41 @@ <% for model in belongs_tos -%> [BelongsTo] public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>; <% end -%> +<% if tree_model.size > 0 -%> + [BelongsTo] + public var <%= tree_model[0].camelcase(:lower) %>:<%= class_name %>; + +<% end -%> +<% for model in polymorphic -%> + [BelongsTo(polymorphic="true", dependsOn="Model1, Model2")] + public var <%= model.camelcase(:lower) %>:Object; + +<% end -%> +<% if has_many_through.size > 0 -%> +<% has_many_through.each do |k,v| %> + [HasMany] + public var <%= k.camelcase(:lower) %>:ModelsCollection; + + [HasMany(through="<%= k.camelcase %>")] + public var <%= v.camelcase(:lower) %>:ModelsCollection; +<% end -%> +<% end -%> <% for model in has_ones -%> [HasOne] public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>; <% end -%> <% for model in has_manies -%> [HasMany] public var <%= model.camelcase(:lower) %>:ModelsCollection; + +<% end -%> +<% if attachment_field.size > 0 -%> + [Ignored] + public var attachmentUrl:String; <% end -%> public function <%= class_name %>() { super(LABEL); }