hatio-core 0.0.6

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 (93) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +28 -0
  4. data/Rakefile +6 -0
  5. data/lib/generators/hatio/bundle/USAGE +68 -0
  6. data/lib/generators/hatio/bundle/bundle_generator.rb +100 -0
  7. data/lib/generators/hatio/bundle/templates/04_seed_entities.rb +9 -0
  8. data/lib/generators/hatio/bundle/templates/05_seed_common_codes.rb +8 -0
  9. data/lib/generators/hatio/bundle/templates/06_seed_menus.rb +6 -0
  10. data/lib/generators/hatio/bundle/templates/Controller.js +24 -0
  11. data/lib/generators/hatio/bundle/templates/Gemfile +4 -0
  12. data/lib/generators/hatio/bundle/templates/LICENSE.txt +22 -0
  13. data/lib/generators/hatio/bundle/templates/README.md +29 -0
  14. data/lib/generators/hatio/bundle/templates/Rakefile +1 -0
  15. data/lib/generators/hatio/bundle/templates/engine.rb +7 -0
  16. data/lib/generators/hatio/bundle/templates/gemspec +19 -0
  17. data/lib/generators/hatio/bundle/templates/index.js +14 -0
  18. data/lib/generators/hatio/bundle/templates/init.rb +1 -0
  19. data/lib/generators/hatio/bundle/templates/lib_bundle.rb +12 -0
  20. data/lib/generators/hatio/bundle/templates/locale.js +13 -0
  21. data/lib/generators/hatio/bundle/templates/locales.yml +27 -0
  22. data/lib/generators/hatio/bundle/templates/pluggable_spot.rb +3 -0
  23. data/lib/generators/hatio/bundle/templates/routes.rb +3 -0
  24. data/lib/generators/hatio/bundle/templates/seeds.rb +4 -0
  25. data/lib/generators/hatio/bundle/templates/task.rake +4 -0
  26. data/lib/generators/hatio/bundle/templates/test.rb +8 -0
  27. data/lib/generators/hatio/bundle/templates/test_helper.rb +3 -0
  28. data/lib/generators/hatio/bundle/templates/version.rb +3 -0
  29. data/lib/generators/hatio/resource_api/resource_api_generator.rb +92 -0
  30. data/lib/generators/hatio/resource_api/templates/controller.rb +7 -0
  31. data/lib/generators/hatio/resource_api/templates/create.json.jbuilder +1 -0
  32. data/lib/generators/hatio/resource_api/templates/destroy.json.jbuilder +1 -0
  33. data/lib/generators/hatio/resource_api/templates/index.json.jbuilder +1 -0
  34. data/lib/generators/hatio/resource_api/templates/migration.rb +1 -0
  35. data/lib/generators/hatio/resource_api/templates/model.rb +3 -0
  36. data/lib/generators/hatio/resource_api/templates/show.json.jbuilder +3 -0
  37. data/lib/generators/hatio/resource_api/templates/update.json.jbuilder +2 -0
  38. data/lib/generators/hatio/resource_model/resource_model_generator.rb +52 -0
  39. data/lib/generators/hatio/resource_model/templates/migration.rb +1 -0
  40. data/lib/generators/hatio/resource_model/templates/model.rb +3 -0
  41. data/lib/generators/hatio/resource_view/USAGE +16 -0
  42. data/lib/generators/hatio/resource_view/resource_view_generator.rb +154 -0
  43. data/lib/generators/hatio/resource_view/templates/Model.js +19 -0
  44. data/lib/generators/hatio/resource_view/templates/Store.js +34 -0
  45. data/lib/generators/hatio/resource_view/templates/detail/Controller.js +81 -0
  46. data/lib/generators/hatio/resource_view/templates/detail/DetailForm.js +17 -0
  47. data/lib/generators/hatio/resource_view/templates/detail/DetailMain.js +26 -0
  48. data/lib/generators/hatio/resource_view/templates/detail/DetailPopup.js +25 -0
  49. data/lib/generators/hatio/resource_view/templates/detail/PopupController.js +90 -0
  50. data/lib/generators/hatio/resource_view/templates/detail/ViewController.js +78 -0
  51. data/lib/generators/hatio/resource_view/templates/item/Controller.js +81 -0
  52. data/lib/generators/hatio/resource_view/templates/item/ItemForm.js +19 -0
  53. data/lib/generators/hatio/resource_view/templates/item/ItemMain.js +18 -0
  54. data/lib/generators/hatio/resource_view/templates/item/ItemPopup.js +25 -0
  55. data/lib/generators/hatio/resource_view/templates/item/PopupController.js +90 -0
  56. data/lib/generators/hatio/resource_view/templates/item/ViewController.js +47 -0
  57. data/lib/generators/hatio/resource_view/templates/list/Controller.js +36 -0
  58. data/lib/generators/hatio/resource_view/templates/list/ListGrid.js +10 -0
  59. data/lib/generators/hatio/resource_view/templates/list/ListMain.js +20 -0
  60. data/lib/generators/hatio/resource_view/templates/list/ListSearch.js +9 -0
  61. data/lib/generators/hatio/resource_view/templates/report/Controller.js +53 -0
  62. data/lib/generators/hatio/resource_view/templates/report/ReportList.js +27 -0
  63. data/lib/generators/hatio/resource_view/templates/report/ReportMain.js +18 -0
  64. data/lib/generators/hatio/resource_view/templates/report/ReportSearch.js +9 -0
  65. data/lib/generators/hatio/util/api_util.rb +97 -0
  66. data/lib/generators/hatio/util/migration_util.rb +178 -0
  67. data/lib/generators/hatio/util/model_util.rb +77 -0
  68. data/lib/generators/hatio/util/report_view_util.rb +32 -0
  69. data/lib/generators/hatio/util/resource_view_util.rb +383 -0
  70. data/lib/generators/hatio/util/view_util.rb +214 -0
  71. data/lib/hatio-core.rb +33 -0
  72. data/lib/hatio-core/action_controller/search_helper.rb +332 -0
  73. data/lib/hatio-core/active_record/extension_logic.rb +36 -0
  74. data/lib/hatio-core/active_record/rem_tracker.rb +35 -0
  75. data/lib/hatio-core/active_record/stringified_id.rb +75 -0
  76. data/lib/hatio-core/active_record/stripper.rb +37 -0
  77. data/lib/hatio-core/active_record/userstamp.rb +48 -0
  78. data/lib/hatio-core/birt/birt_report.rb +42 -0
  79. data/lib/hatio-core/bundle/hatio_bundle.rb +37 -0
  80. data/lib/hatio-core/engine.rb +5 -0
  81. data/lib/hatio-core/exception/exceptions.rb +33 -0
  82. data/lib/hatio-core/patch/actionpack_hatio_patch.rb +28 -0
  83. data/lib/hatio-core/patch/date.rb +11 -0
  84. data/lib/hatio-core/patch/string_key.rb +56 -0
  85. data/lib/hatio-core/pluggable/pluggable_spot.rb +22 -0
  86. data/lib/hatio-core/util/hatio_util.rb +106 -0
  87. data/lib/hatio-core/version.rb +3 -0
  88. data/lib/tasks/hatiocore_tasks.rake +75 -0
  89. data/lib/utils/detect_invalid_js_format.rb +0 -0
  90. data/lib/utils/detect_mismatch_tags.rb +57 -0
  91. data/lib/utils/update_license.rb +5 -0
  92. data/lib/utils/upload_locale.rb +67 -0
  93. metadata +148 -0
@@ -0,0 +1,3 @@
1
+ Hatio::PluggableSpot::add_domain_pluggable do
2
+ # HAS_MANY BEGIN BLOCK DON'T REMOVE
3
+ end
@@ -0,0 +1,3 @@
1
+ <%= class_name %>::Engine.routes.draw do
2
+ # RESOURCES BEGIN BLOCK DON'T REMOVE
3
+ end
@@ -0,0 +1,4 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'seeds', '*.rb')].sort.each do |seed|
2
+ puts "Seeding <%= class_name %> ... #{seed}"
3
+ load seed
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :<%= @bundle_name %> do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1,3 @@
1
+ module <%= class_name %>
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,92 @@
1
+ require 'generators/hatio/util/migration_util'
2
+ require 'generators/hatio/util/model_util'
3
+ require 'generators/hatio/util/api_util'
4
+
5
+ module Hatio
6
+ module Generators
7
+ class ResourceApiGenerator < Rails::Generators::NamedBase
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+ argument :model_attributes, :type => :array, :default => [], :banner => "model:attributes"
11
+ class_option :domain, :type => :string, :default => '', :desc => "Domain Name"
12
+ class_option :bundle, :type => :string, :default => '', :desc => "Bundle name"
13
+ class_option :id_type, :type => :string, :default => "uuid", :description => "id type - uuid|meaningful|auto-increment|none"
14
+ class_option :gen_type, :type => :string, :default => "all", :description => "gen type - all|model|none"
15
+ class_option :use_attachment, :type => :string, :default => 'n', :desc => 'Use attachment or not'
16
+ class_option :use_ext_prop, :type => :string, :default => 'n', :desc => 'Use extension properties or not'
17
+ class_option :del_trace, :type => :string, :default => 'n', :desc => 'Deletion Trace'
18
+ class_option :columns, :type => :string, :desc => 'Column informations'
19
+
20
+ def generate_resource_api
21
+
22
+ begin
23
+ raise "Not allowed empty bundle name" if (!options.bundle || options.bundle.empty?)
24
+ unless ['uuid', 'meaningful', 'auto-increment', 'none'].include?(options.id_type)
25
+ raise "Invalid --id-type option [uuid|meaningful|auto-increment|none]"
26
+ end
27
+
28
+ @id_type = options.id_type
29
+ @bundle_name = options.bundle
30
+ bundle_app_path = "vendor/bundles/#{@bundle_name}"
31
+ controller_path = "#{bundle_app_path}/app/controllers"
32
+ model_path = "#{bundle_app_path}/app/models"
33
+ view_path = "#{bundle_app_path}/app/views/#{table_name}"
34
+ migration_path = "#{bundle_app_path}/db/migrate"
35
+
36
+ Domain.current_domain = Domain.find_by_name(options.domain)
37
+ entity = Entity.find_by_name(class_name)
38
+ @attributes = entity.entity_columns
39
+
40
+ cols_str = options.columns
41
+ cols_str.gsub!('~', '"')
42
+ cols_str.gsub!('^', ',')
43
+ col_infos = JSON.parse(cols_str)
44
+
45
+ @attributes.each do |attr|
46
+ col = col_infos.find { |col| col["id"].to_i == attr.id }
47
+ if(col)
48
+ attr.max = col["max"] if(col.key?("max") && attr.col_type == 'integer' || attr.col_type == 'float' || attr.col_type == 'decimal')
49
+ attr.min = col["min"] if(col.key?("min") && attr.col_type == 'integer' || attr.col_type == 'float' || attr.col_type == 'decimal')
50
+ attr.editable = col["editable"] if(col.key?("editable"))
51
+ attr.trimable = col["trimable"] if(col.key?("trimable"))
52
+ attr.search_rank = col["search_rank"] if(col.key?("search_rank"))
53
+ attr.sort_rank = col["sort_rank"] if(col.key?("sort_rank"))
54
+ attr.reverse_sort = col["reverse_sort"] if(col.key?("reverse_sort"))
55
+ end
56
+ end
57
+
58
+ @common_attrs = ["id", "domain_id", "creator_id", "updater_id", "created_at", "updated_at"]
59
+ @all_attrs = @attributes.map { |attr| ':' + attr.name }.join(',')
60
+ @biz_attrs = @attributes.find_all { |attr| !@common_attrs.include?(attr.name) }
61
+
62
+ if(options.gen_type == "all" || options.gen_type == "model")
63
+ template "model.rb", "#{model_path}/#{singular_name}.rb"
64
+ template "migration.rb", "#{migration_path}/#{Hatio::Generators::MigrationUtil.next_migration_number}_create_#{table_name}.rb"
65
+ end
66
+
67
+ if(options.gen_type == "all")
68
+ template "controller.rb", "#{controller_path}/#{table_name}_controller.rb"
69
+
70
+ view_dir = File.join(Rails.root, view_path)
71
+ FileUtils.mkdir "#{view_dir}" unless File.exist?("#{view_dir}")
72
+
73
+ template "index.json.jbuilder", "#{view_path}/index.json.jbuilder"
74
+ template "show.json.jbuilder", "#{view_path}/show.json.jbuilder"
75
+ template "create.json.jbuilder", "#{view_path}/create.json.jbuilder"
76
+ template "update.json.jbuilder", "#{view_path}/update.json.jbuilder"
77
+
78
+ inject_into_file "#{bundle_app_path}/config/routes.rb", :after => "# RESOURCES BEGIN BLOCK DON'T REMOVE" do
79
+ "\n\tresources :#{table_name} do\n\t\tcollection do\n\t\t\tpost :update_multiple\n\t\t\tget :show_by_name\n\t\t\tget :export\n\t\tend\n\tend\n"
80
+ end
81
+ end
82
+
83
+ puts "\nSuccess"
84
+ rescue StandardError => e
85
+ trace_str = e.backtrace[0 .. 5].join("\n")
86
+ puts "\nError : #{e.to_s}\n#{trace_str}"
87
+ end
88
+ end
89
+
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,7 @@
1
+ class <%= class_name.pluralize %>Controller < ResourceMultiUpdateController
2
+
3
+ private
4
+ def resource_params
5
+ [ params.require(:<%= singular_name %>).permit(<%= @biz_attrs.collect { |attr| ":#{attr.name}" }.join(",") %>) ]
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ <%= Hatio::Generators::ApiUtil.generate_single_json_builder(singular_name, @attributes) %>
@@ -0,0 +1 @@
1
+ json.id @<%= singular_name %>.id
@@ -0,0 +1 @@
1
+ <%= Hatio::Generators::ApiUtil.generate_index_template(singular_name, @attributes) %>
@@ -0,0 +1 @@
1
+ <%= Hatio::Generators::MigrationUtil.create_table_migration(class_name, table_name, @attributes, options, @pkColumnName) %>
@@ -0,0 +1,3 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ <%= Hatio::Generators::ModelUtil.generate_model(options, @attributes, @biz_attrs) %>
3
+ end
@@ -0,0 +1,3 @@
1
+ <%= Hatio::Generators::ApiUtil.generate_show_json_builder(singular_name, @attributes) %>
2
+ <%= Hatio::Generators::ApiUtil.generate_ref_entity_json_builder(singular_name, @biz_attrs) %>
3
+ <%= Hatio::Generators::ApiUtil.generate_userstamp_json_builder(singular_name, @attributes) %>
@@ -0,0 +1,2 @@
1
+ <%= Hatio::Generators::ApiUtil.generate_single_json_builder(singular_name, @attributes) %>
2
+ <%= Hatio::Generators::ApiUtil.generate_ref_entity_json_builder(singular_name, @biz_attrs) %>
@@ -0,0 +1,52 @@
1
+ require 'generators/hatio/util/migration_util'
2
+ require 'generators/hatio/util/model_util'
3
+ require 'generators/hatio/util/resource_view_util'
4
+ require 'generators/hatio/util/report_view_util'
5
+
6
+ module Hatio
7
+ module Generators
8
+ class ResourceModelGenerator < Rails::Generators::NamedBase
9
+
10
+ source_root File.expand_path('../templates', __FILE__)
11
+ argument :model_attributes, type: :array, default: [], banner: "model:attributes"
12
+ class_option :bundle, :type => :string, :default => '', :desc => "Bundle name"
13
+ class_option :id_type, :type => :string, default: "none", :description => "id type - uuid|meaningful|auto-increment|none"
14
+
15
+ def generate_model
16
+ begin
17
+ raise "Not allowed empty bundle name" if (!options.bundle || options.bundle.empty?)
18
+ unless ['uuid', 'meaningful', 'auto-increment', 'none'].include?(options.id_type)
19
+ raise "Invalid --id-type option [uuid|meaningful|auto-increment|none]"
20
+ end
21
+
22
+ @id_type = options.id_type
23
+ @bundle_name = options.bundle
24
+ bundle_app_path = "vendor/bundles/#{@bundle_name}"
25
+ model_path = "#{bundle_app_path}/app/models"
26
+ migration_path = "#{bundle_app_path}/db/migrate"
27
+
28
+ entity = Entity.find_by_name(class_name)
29
+ @attributes = entity.entity_columns
30
+ @all_attrs = @attributes.map { |attr| ':' + attr.name }.join(',')
31
+ @pkColumn = @attributes.find { |attr| attr.pk == true }
32
+ @pkColumnName = @pkColumn ? @pkColumn.name : 'id'
33
+
34
+ template "model.rb", "#{model_path}/#{singular_name}.rb"
35
+ template "migration.rb", "#{migration_path}/#{Hatio::Generators::MigrationUtil.next_migration_number}_create_#{table_name}.rb"
36
+
37
+ puts "\nSuccess"
38
+ rescue StandardError => e
39
+ puts "\nError : #{e}"
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def next_migration_number
46
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1 @@
1
+ <%= Hatio::Generators::MigrationUtil.create_table_migration(class_name, table_name, @attributes, options, @pkColumnName) %>
@@ -0,0 +1,3 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ <%= Hatio::Generators::ModelUtil.generate_model(options, @attributes, @biz_attrs) %>
3
+ end
@@ -0,0 +1,16 @@
1
+ Description:
2
+ Generate view (javascript files : controller, model, store, view)
3
+
4
+ Example:
5
+ view : rails generate hatio:resource_view Supplier --bundle=Common --domain_id=1 --view_type=list-item --detail_view_type=view --parent_menu=System
6
+
7
+ This will create:
8
+ vendor/bundles/common/app/assets/javascripts/bundle/common/controller/supplier/Supplier.js
9
+ vendor/bundles/common/app/assets/javascripts/bundle/common/modle/Supplier.js
10
+ vendor/bundles/common/app/assets/javascripts/bundle/common/store/Supplier.js
11
+ vendor/bundles/common/app/assets/javascripts/bundle/common/view/supplier/Supplier.js
12
+
13
+
14
+ bundle : rails generate hatio:bundle Common --bundle_name=common
15
+
16
+ api : rails generate hatio:resource_api Supplier --id_type=auto-increment --bundle=Common --history=n --domain_name=System
@@ -0,0 +1,154 @@
1
+ require 'generators/hatio/util/migration_util'
2
+ require 'generators/hatio/util/model_util'
3
+ require 'generators/hatio/util/resource_view_util'
4
+ require 'generators/hatio/util/report_view_util'
5
+
6
+ module Hatio
7
+ module Generators
8
+ class ResourceViewGenerator < Rails::Generators::NamedBase
9
+
10
+ source_root File.expand_path('../templates', __FILE__)
11
+ argument :model_attributes, :type => :string, :default => [], :banner => "model:attributes"
12
+ class_option :domain, :type => :string, :default => '', :desc => "Domain"
13
+ class_option :bundle, :type => :string, :default => '', :desc => "Bundle name"
14
+ class_option :view_type, :type => :string, :default => 'list-detail', :desc => 'Client Screen Type'
15
+ class_option :skip_store, :type => :string, :default => 'n', :desc => 'Skip model and store generation'
16
+ class_option :detail_view_type, :type => :string, :default => 'none', :desc => 'Detail view type none|view|popup'
17
+ class_option :use_attachment, :type => :string, :default => 'n', :desc => 'Use attachment or not'
18
+ class_option :use_ext_prop, :type => :string, :default => 'n', :desc => 'Use extension properties or not'
19
+ class_option :parent_menu, :type => :string, :default => '', :desc => 'Parent menu name'
20
+ class_option :diy_selection_id, :type => :string, :default => '', :desc => 'Report service reference'
21
+ class_option :columns, :type => :string, :desc => 'Column informations'
22
+
23
+ def generate_views
24
+ begin
25
+ raise "Domain name is empty!" if(options.domain.empty?)
26
+ raise "Bundle name is empty!" if(options.bundle.empty?)
27
+
28
+ @bundle = options.bundle.camelcase
29
+ js_base_path = "vendor/bundles/#{@bundle.downcase}/app/assets/javascripts/bundle/#{@bundle.downcase}"
30
+ js_base_dir = File.join(Rails.root, js_base_path)
31
+ raise "Bundle #{@bundle} is not exist!" unless File.exist?(js_base_dir)
32
+
33
+ controller_path = "#{js_base_path}/controller/#{singular_name}"
34
+ model_path = "#{js_base_path}/model"
35
+ store_path = "#{js_base_path}/store"
36
+ view_path = "#{js_base_path}/view/#{singular_name}"
37
+
38
+ controller_dir = File.join(Rails.root, controller_path)
39
+ FileUtils.mkdir "#{controller_dir}" unless File.exist?("#{controller_dir}")
40
+
41
+ view_dir = File.join(Rails.root, view_path)
42
+ FileUtils.mkdir "#{view_dir}" unless File.exist?("#{view_dir}")
43
+
44
+ @domain = Domain.find_by_name(options.domain)
45
+ Domain.current_domain = @domain
46
+
47
+ if(options.view_type == 'report')
48
+ raise "Bundle name is empty!" if(options.diy_selection_id.empty?)
49
+ @diy_selection = DiySelection.find(options.diy_selection_id)
50
+ raise "Not found DiySelection By [#{options.diy_selection_id}]" unless @diy_selection
51
+ @service_url = "'diy_selections/#{@diy_selection.name}/query.json'"
52
+ @in_params = @diy_selection.service_in_params
53
+ @out_params = @diy_selection.service_out_params
54
+ else
55
+ entity = Entity.find_by_name(class_name)
56
+ @columns = entity.entity_columns
57
+ cols_str = options.columns
58
+ cols_str.gsub!('~', '"')
59
+ cols_str.gsub!('^', ',')
60
+ col_infos = JSON.parse(cols_str)
61
+
62
+ @columns.each do |column|
63
+ col = col_infos.find { |col| col["id"].to_i == column.id }
64
+ if(col)
65
+ column.max = col["max"] if(col.key?("max") && column.col_type == 'integer' || column.col_type == 'float' || column.col_type == 'decimal')
66
+ column.min = col["min"] if(col.key?("min") && column.col_type == 'integer' || column.col_type == 'float' || column.col_type == 'decimal')
67
+ column.editable = col["editable"] if(col.key?("editable"))
68
+ column.trimable = col["trimable"] if(col.key?("trimable"))
69
+ column.search_rank = col["search_rank"] if(col.key?("search_rank"))
70
+ column.sort_rank = col["sort_rank"] if(col.key?("sort_rank"))
71
+ column.reverse_sort = col["reverse_sort"] if(col.key?("reverse_sort"))
72
+ end
73
+ end
74
+ end
75
+
76
+ if((options.view_type != 'report') && (!options.skip_store || options.skip_store == 'n'))
77
+ template "Store.js", "#{store_path}/#{class_name}.js"
78
+ template "Model.js", "#{model_path}/#{class_name}.js"
79
+ end
80
+
81
+ if(options.view_type == 'list-detail')
82
+ template "list/Controller.js", "#{controller_path}/#{class_name}.js"
83
+ template "list/ListMain.js", "#{view_path}/#{class_name}.js"
84
+ template "list/ListGrid.js", "#{view_path}/#{class_name}List.js"
85
+ template "list/ListSearch.js", "#{view_path}/#{class_name}Search.js"
86
+
87
+ if(options.detail_view_type == 'popup')
88
+ template "detail/PopupController.js", "#{controller_path}/#{class_name}Detail.js"
89
+ template "detail/DetailPopup.js", "#{view_path}/#{class_name}Detail.js"
90
+ template "detail/DetailForm.js", "#{view_path}/#{class_name}Form.js"
91
+ else
92
+ template "detail/ViewController.js", "#{controller_path}/#{class_name}Detail.js"
93
+ template "detail/DetailMain.js", "#{view_path}/#{class_name}Detail.js"
94
+ template "detail/DetailForm.js", "#{view_path}/#{class_name}Form.js"
95
+ end
96
+
97
+ elsif(options.view_type == 'list-item')
98
+ template "list/Controller.js", "#{controller_path}/#{class_name}.js"
99
+ template "list/ListMain.js", "#{view_path}/#{class_name}.js"
100
+
101
+ if(options.detail_view_type == 'popup')
102
+ template "item/PopupController.js", "#{controller_path}/#{class_name}Item.js"
103
+ template "item/ItemPopup.js", "#{view_path}/#{class_name}Item.js"
104
+ template "item/ItemForm.js", "#{view_path}/#{class_name}Form.js"
105
+ else
106
+ template "item/ViewController.js", "#{controller_path}/#{class_name}Item.js"
107
+ template "item/ItemMain.js", "#{view_path}/#{class_name}Item.js"
108
+ template "item/ItemForm.js", "#{view_path}/#{class_name}Form.js"
109
+ end
110
+
111
+ elsif(options.view_type == 'list')
112
+ template "list/Controller.js", "#{controller_path}/#{class_name}.js"
113
+ template "list/ListMain.js", "#{view_path}/#{class_name}.js"
114
+ template "list/ListGrid.js", "#{view_path}/#{class_name}List.js"
115
+ template "list/ListSearch.js", "#{view_path}/#{class_name}Search.js"
116
+
117
+ elsif(options.view_type == 'detail')
118
+ template "detail/Controller.js", "#{controller_path}/#{class_name}Detail.js"
119
+ template "detail/DetailMain.js", "#{view_path}/#{class_name}Detail.js"
120
+ template "detail/DetailForm.js", "#{view_path}/#{class_name}Form.js"
121
+
122
+ elsif(options.view_type == 'report')
123
+ template "report/Controller.js", "#{controller_path}/#{class_name}.js"
124
+ template "report/ReportMain.js", "#{view_path}/#{class_name}.js"
125
+ template "report/ReportList.js", "#{view_path}/#{class_name}List.js"
126
+ template "report/ReportSearch.js", "#{view_path}/#{class_name}Search.js"
127
+ end
128
+
129
+ if(options.parent_menu && !options.parent_menu.empty? && 'none' != options.parent_menu)
130
+ screenId = "#{@bundle}.view.#{singular_name}.#{class_name}"
131
+ screenId << 'Detail' if(options.view_type == 'detail')
132
+ menu = Menu.find_by_template(screenId)
133
+ entityId = entity ? entity.id : ''
134
+
135
+ unless menu
136
+ parentMenu = Menu.find_by_name(options.parent_menu)
137
+ Menu.create :name => class_name, :description => class_name, :parent_id => parentMenu.id, :category => 'STANDARD', :template => screenId, :menu_type => 'SCREEN', :rank => 1000
138
+ puts "#{class_name} menu created at #{options.parent_menu} Menu!"
139
+ else
140
+ puts "#{class_name} menu already exist!"
141
+ end
142
+ end
143
+
144
+ puts "\nSuccess"
145
+
146
+ rescue StandardError => e
147
+ trace_str = e.backtrace[0 .. 5].join("\n")
148
+ puts "\nError : #{e.to_s}\n#{trace_str}"
149
+ end
150
+ end
151
+ end
152
+
153
+ end
154
+ end
@@ -0,0 +1,19 @@
1
+ Ext.define('<%= @bundle %>.model.<%= class_name %>', {
2
+
3
+ extend : 'Ext.data.Model',
4
+
5
+ <%= Hatio::Generators::ResourceViewUtil.generate_model_fields(options, @columns, "\t\t") %>,
6
+
7
+ proxy : {
8
+ type : 'rest',
9
+ url : '<%= table_name %>',
10
+ format : 'json',
11
+ reader : {
12
+ type : 'json'
13
+ },
14
+ writer : {
15
+ type : 'json',
16
+ root : '<%= singular_name %>'
17
+ }
18
+ }
19
+ });
@@ -0,0 +1,34 @@
1
+ Ext.define('<%= @bundle %>.store.<%= class_name %>', {
2
+
3
+ extend : 'Ext.data.Store',
4
+
5
+ requires : '<%= @bundle %>.model.<%= class_name %>',
6
+
7
+ model : '<%= @bundle %>.model.<%= class_name %>',
8
+
9
+ autoLoad : false,
10
+
11
+ remoteFilter : true,
12
+
13
+ remoteSort : true,
14
+
15
+ pageSize : 30,
16
+
17
+ <%= Hatio::Generators::ResourceViewUtil.grid_sort_option(@columns, "\t") %>
18
+
19
+ proxy : {
20
+ type : 'rest',
21
+ url : '<%= table_name %>',
22
+ format : 'json',
23
+ reader : {
24
+ type : 'json',
25
+ root : 'items',
26
+ successProperty : 'success',
27
+ totalProperty : 'total'
28
+ },
29
+ writer : {
30
+ type : 'json'
31
+ }
32
+ }
33
+
34
+ });