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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +28 -0
- data/Rakefile +6 -0
- data/lib/generators/hatio/bundle/USAGE +68 -0
- data/lib/generators/hatio/bundle/bundle_generator.rb +100 -0
- data/lib/generators/hatio/bundle/templates/04_seed_entities.rb +9 -0
- data/lib/generators/hatio/bundle/templates/05_seed_common_codes.rb +8 -0
- data/lib/generators/hatio/bundle/templates/06_seed_menus.rb +6 -0
- data/lib/generators/hatio/bundle/templates/Controller.js +24 -0
- data/lib/generators/hatio/bundle/templates/Gemfile +4 -0
- data/lib/generators/hatio/bundle/templates/LICENSE.txt +22 -0
- data/lib/generators/hatio/bundle/templates/README.md +29 -0
- data/lib/generators/hatio/bundle/templates/Rakefile +1 -0
- data/lib/generators/hatio/bundle/templates/engine.rb +7 -0
- data/lib/generators/hatio/bundle/templates/gemspec +19 -0
- data/lib/generators/hatio/bundle/templates/index.js +14 -0
- data/lib/generators/hatio/bundle/templates/init.rb +1 -0
- data/lib/generators/hatio/bundle/templates/lib_bundle.rb +12 -0
- data/lib/generators/hatio/bundle/templates/locale.js +13 -0
- data/lib/generators/hatio/bundle/templates/locales.yml +27 -0
- data/lib/generators/hatio/bundle/templates/pluggable_spot.rb +3 -0
- data/lib/generators/hatio/bundle/templates/routes.rb +3 -0
- data/lib/generators/hatio/bundle/templates/seeds.rb +4 -0
- data/lib/generators/hatio/bundle/templates/task.rake +4 -0
- data/lib/generators/hatio/bundle/templates/test.rb +8 -0
- data/lib/generators/hatio/bundle/templates/test_helper.rb +3 -0
- data/lib/generators/hatio/bundle/templates/version.rb +3 -0
- data/lib/generators/hatio/resource_api/resource_api_generator.rb +92 -0
- data/lib/generators/hatio/resource_api/templates/controller.rb +7 -0
- data/lib/generators/hatio/resource_api/templates/create.json.jbuilder +1 -0
- data/lib/generators/hatio/resource_api/templates/destroy.json.jbuilder +1 -0
- data/lib/generators/hatio/resource_api/templates/index.json.jbuilder +1 -0
- data/lib/generators/hatio/resource_api/templates/migration.rb +1 -0
- data/lib/generators/hatio/resource_api/templates/model.rb +3 -0
- data/lib/generators/hatio/resource_api/templates/show.json.jbuilder +3 -0
- data/lib/generators/hatio/resource_api/templates/update.json.jbuilder +2 -0
- data/lib/generators/hatio/resource_model/resource_model_generator.rb +52 -0
- data/lib/generators/hatio/resource_model/templates/migration.rb +1 -0
- data/lib/generators/hatio/resource_model/templates/model.rb +3 -0
- data/lib/generators/hatio/resource_view/USAGE +16 -0
- data/lib/generators/hatio/resource_view/resource_view_generator.rb +154 -0
- data/lib/generators/hatio/resource_view/templates/Model.js +19 -0
- data/lib/generators/hatio/resource_view/templates/Store.js +34 -0
- data/lib/generators/hatio/resource_view/templates/detail/Controller.js +81 -0
- data/lib/generators/hatio/resource_view/templates/detail/DetailForm.js +17 -0
- data/lib/generators/hatio/resource_view/templates/detail/DetailMain.js +26 -0
- data/lib/generators/hatio/resource_view/templates/detail/DetailPopup.js +25 -0
- data/lib/generators/hatio/resource_view/templates/detail/PopupController.js +90 -0
- data/lib/generators/hatio/resource_view/templates/detail/ViewController.js +78 -0
- data/lib/generators/hatio/resource_view/templates/item/Controller.js +81 -0
- data/lib/generators/hatio/resource_view/templates/item/ItemForm.js +19 -0
- data/lib/generators/hatio/resource_view/templates/item/ItemMain.js +18 -0
- data/lib/generators/hatio/resource_view/templates/item/ItemPopup.js +25 -0
- data/lib/generators/hatio/resource_view/templates/item/PopupController.js +90 -0
- data/lib/generators/hatio/resource_view/templates/item/ViewController.js +47 -0
- data/lib/generators/hatio/resource_view/templates/list/Controller.js +36 -0
- data/lib/generators/hatio/resource_view/templates/list/ListGrid.js +10 -0
- data/lib/generators/hatio/resource_view/templates/list/ListMain.js +20 -0
- data/lib/generators/hatio/resource_view/templates/list/ListSearch.js +9 -0
- data/lib/generators/hatio/resource_view/templates/report/Controller.js +53 -0
- data/lib/generators/hatio/resource_view/templates/report/ReportList.js +27 -0
- data/lib/generators/hatio/resource_view/templates/report/ReportMain.js +18 -0
- data/lib/generators/hatio/resource_view/templates/report/ReportSearch.js +9 -0
- data/lib/generators/hatio/util/api_util.rb +97 -0
- data/lib/generators/hatio/util/migration_util.rb +178 -0
- data/lib/generators/hatio/util/model_util.rb +77 -0
- data/lib/generators/hatio/util/report_view_util.rb +32 -0
- data/lib/generators/hatio/util/resource_view_util.rb +383 -0
- data/lib/generators/hatio/util/view_util.rb +214 -0
- data/lib/hatio-core.rb +33 -0
- data/lib/hatio-core/action_controller/search_helper.rb +332 -0
- data/lib/hatio-core/active_record/extension_logic.rb +36 -0
- data/lib/hatio-core/active_record/rem_tracker.rb +35 -0
- data/lib/hatio-core/active_record/stringified_id.rb +75 -0
- data/lib/hatio-core/active_record/stripper.rb +37 -0
- data/lib/hatio-core/active_record/userstamp.rb +48 -0
- data/lib/hatio-core/birt/birt_report.rb +42 -0
- data/lib/hatio-core/bundle/hatio_bundle.rb +37 -0
- data/lib/hatio-core/engine.rb +5 -0
- data/lib/hatio-core/exception/exceptions.rb +33 -0
- data/lib/hatio-core/patch/actionpack_hatio_patch.rb +28 -0
- data/lib/hatio-core/patch/date.rb +11 -0
- data/lib/hatio-core/patch/string_key.rb +56 -0
- data/lib/hatio-core/pluggable/pluggable_spot.rb +22 -0
- data/lib/hatio-core/util/hatio_util.rb +106 -0
- data/lib/hatio-core/version.rb +3 -0
- data/lib/tasks/hatiocore_tasks.rake +75 -0
- data/lib/utils/detect_invalid_js_format.rb +0 -0
- data/lib/utils/detect_mismatch_tags.rb +57 -0
- data/lib/utils/update_license.rb +5 -0
- data/lib/utils/upload_locale.rb +67 -0
- metadata +148 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Detail', {
|
|
2
|
+
|
|
3
|
+
extend : 'Base.abstract.Popup',
|
|
4
|
+
|
|
5
|
+
requires : [
|
|
6
|
+
'<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Form'
|
|
7
|
+
],
|
|
8
|
+
|
|
9
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>_detail',
|
|
10
|
+
|
|
11
|
+
title : T('title.<%= singular_name %>'),
|
|
12
|
+
|
|
13
|
+
items : [ {
|
|
14
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>_form'
|
|
15
|
+
} ],
|
|
16
|
+
|
|
17
|
+
setRecord : function(record) {
|
|
18
|
+
this.record = record;
|
|
19
|
+
this.down('form').loadRecord(this.record);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
getRecord : function() {
|
|
23
|
+
return this.record;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <%= class_name %>Detail controller
|
|
3
|
+
*/
|
|
4
|
+
Ext.define('<%= @bundle %>.controller.<%= singular_name %>.<%= class_name %>Detail', {
|
|
5
|
+
|
|
6
|
+
extend: 'Base.abstract.entity.DetailMainController',
|
|
7
|
+
|
|
8
|
+
requires : [
|
|
9
|
+
'<%= @bundle %>.model.<%= class_name %>',
|
|
10
|
+
'<%= @bundle %>.store.<%= class_name %>',
|
|
11
|
+
'<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Detail'
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
models : ['<%= @bundle %>.model.<%= class_name %>'],
|
|
15
|
+
|
|
16
|
+
stores: ['<%= @bundle %>.store.<%= class_name %>'],
|
|
17
|
+
|
|
18
|
+
views : ['<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Detail'],
|
|
19
|
+
|
|
20
|
+
refs: [ { ref : '<%= class_name %>Detail', selector : '<%= @bundle.downcase %>_<%= singular_name %>_detail' } ],
|
|
21
|
+
|
|
22
|
+
init: function() {
|
|
23
|
+
this.callParent(arguments);
|
|
24
|
+
|
|
25
|
+
this.control({
|
|
26
|
+
'<%= @bundle.downcase %>_<%= singular_name %>_detail' : {
|
|
27
|
+
paramschange : this.onParamsChange,
|
|
28
|
+
after_detail_loaded : this.afterDetailLoaded
|
|
29
|
+
},
|
|
30
|
+
' <%= @bundle.downcase %>_<%= singular_name %>_form' : {
|
|
31
|
+
click_close : this.onClickClose,
|
|
32
|
+
click_save : this.onFormSave,
|
|
33
|
+
click_delete : this.onFormDelete,
|
|
34
|
+
after_form_saved : this.afterFormSaved,
|
|
35
|
+
after_form_deleted : this.afterFormDeleted,
|
|
36
|
+
validitychange: this.onFormValidityChange
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/****************************************************************
|
|
42
|
+
** 여기는 customizing area **
|
|
43
|
+
****************************************************************/
|
|
44
|
+
// Customized code here ...
|
|
45
|
+
|
|
46
|
+
/****************************************************************
|
|
47
|
+
** Override 구현 **
|
|
48
|
+
****************************************************************/
|
|
49
|
+
/**
|
|
50
|
+
* override
|
|
51
|
+
*/
|
|
52
|
+
afterDetailLoaded : function(record, operation) {
|
|
53
|
+
var mainView = this.getMainView();
|
|
54
|
+
mainView.setRecord(record);
|
|
55
|
+
mainView.down(' #back').hide();
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* override
|
|
60
|
+
*/
|
|
61
|
+
afterFormSaved : function(form, newRecord) {
|
|
62
|
+
this.getMainView().setRecord(newRecord);
|
|
63
|
+
HF.show('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>', {}, {});
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* override
|
|
68
|
+
*/
|
|
69
|
+
afterFormDeleted : function(form, newRecord) {
|
|
70
|
+
this.getMainView().close();
|
|
71
|
+
HF.show('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>', {}, {});
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/****************************************************************
|
|
75
|
+
** abstract method, 필수 구현 **
|
|
76
|
+
****************************************************************/
|
|
77
|
+
/**
|
|
78
|
+
* main view를 리턴
|
|
79
|
+
*/
|
|
80
|
+
getMainView : function() {
|
|
81
|
+
return this.get<%= class_name %>Detail();
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 팝업 close
|
|
86
|
+
*/
|
|
87
|
+
onClickClose : function(view) {
|
|
88
|
+
view.up().close();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <%= class_name %>Detail controller
|
|
3
|
+
*/
|
|
4
|
+
Ext.define('<%= @bundle %>.controller.<%= singular_name %>.<%= class_name %>Item', {
|
|
5
|
+
|
|
6
|
+
extend : 'Frx.controller.ItemController',
|
|
7
|
+
|
|
8
|
+
requires : [
|
|
9
|
+
'<%= @bundle %>.model.<%= class_name %>',
|
|
10
|
+
'<%= @bundle %>.store.<%= class_name %>',
|
|
11
|
+
'<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Item'
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
mixins : [
|
|
15
|
+
'Frx.mixin.lifecycle.FormLifeCycle'
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
models : ['<%= @bundle %>.model.<%= class_name %>'],
|
|
19
|
+
|
|
20
|
+
stores : ['<%= @bundle %>.store.<%= class_name %>'],
|
|
21
|
+
|
|
22
|
+
views : ['<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Item'],
|
|
23
|
+
|
|
24
|
+
init : function() {
|
|
25
|
+
this.callParent(arguments);
|
|
26
|
+
|
|
27
|
+
this.control({
|
|
28
|
+
'<%= @bundle.downcase %>_<%= singular_name %>_item' : this.EntryPoint(),
|
|
29
|
+
'<%= @bundle.downcase %>_<%= singular_name %>_form' : this.FormEventHandler()
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
/****************************************************************
|
|
34
|
+
** 여기는 customizing area **
|
|
35
|
+
****************************************************************/
|
|
36
|
+
// Customized code here ...
|
|
37
|
+
|
|
38
|
+
/****************************************************************
|
|
39
|
+
** Override 구현 **
|
|
40
|
+
****************************************************************/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/****************************************************************
|
|
44
|
+
** abstract method, 필수 구현 **
|
|
45
|
+
****************************************************************/
|
|
46
|
+
|
|
47
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <%= class_name %> controller
|
|
3
|
+
*/
|
|
4
|
+
Ext.define('<%= @bundle %>.controller.<%= singular_name %>.<%= class_name %>', {
|
|
5
|
+
|
|
6
|
+
extend : 'Frx.controller.ListController',
|
|
7
|
+
<% if(options.use_attachment == 'y') %>
|
|
8
|
+
mixins : { slideshow : 'Base.mixin.lifecycle.ListSlideShow' },
|
|
9
|
+
<% end %>
|
|
10
|
+
requires : [
|
|
11
|
+
'<%= @bundle %>.model.<%= class_name %>',
|
|
12
|
+
'<%= @bundle %>.store.<%= class_name %>',
|
|
13
|
+
'<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>'
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
models : ['<%= @bundle %>.model.<%= class_name %>'],
|
|
17
|
+
|
|
18
|
+
stores : ['<%= @bundle %>.store.<%= class_name %>'],
|
|
19
|
+
|
|
20
|
+
views : ['<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>'],
|
|
21
|
+
|
|
22
|
+
init : function() {
|
|
23
|
+
this.callParent(arguments);
|
|
24
|
+
|
|
25
|
+
this.control({
|
|
26
|
+
'<%= @bundle.downcase %>_<%= singular_name %>' : this.EntryPoint(),
|
|
27
|
+
'<%= @bundle.downcase %>_<%= singular_name %> #goto_item' : {
|
|
28
|
+
click : this.onGotoItem
|
|
29
|
+
}<% if(options.use_attachment == 'y') %>,
|
|
30
|
+
'<%= @bundle.downcase %>_<%= singular_name %> #slideshow' : {
|
|
31
|
+
click : this.onSlideShow
|
|
32
|
+
}<% end %>
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>List', {
|
|
2
|
+
|
|
3
|
+
extend : 'Base.abstract.entity.ListGridView',
|
|
4
|
+
|
|
5
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>_list',
|
|
6
|
+
|
|
7
|
+
store : '<%= @bundle %>.store.<%= class_name %>',
|
|
8
|
+
|
|
9
|
+
<%= Hatio::Generators::ResourceViewUtil.generate_grid(@domain, singular_name, @columns, nil, nil) %>
|
|
10
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>', {
|
|
2
|
+
|
|
3
|
+
extend : 'Frx.common.ListView',
|
|
4
|
+
|
|
5
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>',
|
|
6
|
+
|
|
7
|
+
title : T('menu.<%= class_name %>'),
|
|
8
|
+
|
|
9
|
+
store : '<%= @bundle %>.store.<%= class_name %>',
|
|
10
|
+
|
|
11
|
+
<%= Hatio::Generators::ResourceViewUtil.generate_grid(@domain, singular_name, @columns, options, nil) %>
|
|
12
|
+
|
|
13
|
+
dockedItems : [ {
|
|
14
|
+
xtype : 'searchform',
|
|
15
|
+
<%= Hatio::Generators::ResourceViewUtil.generate_search_items(@domain, class_name, @columns, nil, nil) %>
|
|
16
|
+
}, {
|
|
17
|
+
xtype : 'controlbar',
|
|
18
|
+
items : ['->', 'import', 'export', 'add', 'save', 'delete']
|
|
19
|
+
} ]
|
|
20
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Search', {
|
|
2
|
+
|
|
3
|
+
extend : 'Base.abstract.entity.ListSearchView',
|
|
4
|
+
|
|
5
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>_search',
|
|
6
|
+
|
|
7
|
+
<%= Hatio::Generators::ResourceViewUtil.generate_search_items(@domain, class_name, @columns, nil, nil) %>
|
|
8
|
+
|
|
9
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <%= class_name %> controller
|
|
3
|
+
*/
|
|
4
|
+
Ext.define('<%= @bundle %>.controller.<%= singular_name %>.<%= class_name %>', {
|
|
5
|
+
|
|
6
|
+
extend: 'Base.abstract.entity.ReportMainController',
|
|
7
|
+
|
|
8
|
+
requires : ['<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>'],
|
|
9
|
+
|
|
10
|
+
models : [],
|
|
11
|
+
|
|
12
|
+
stores: [],
|
|
13
|
+
|
|
14
|
+
views : ['<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>'],
|
|
15
|
+
|
|
16
|
+
refs: [ { ref : '<%= class_name %>', selector : '<%= @bundle.downcase %>_<%= singular_name %>' } ],
|
|
17
|
+
|
|
18
|
+
init: function() {
|
|
19
|
+
this.callParent(arguments);
|
|
20
|
+
|
|
21
|
+
this.control({
|
|
22
|
+
'<%= @bundle.downcase %>_<%= singular_name %>' : {
|
|
23
|
+
paramschange : this.onParamsChange
|
|
24
|
+
},
|
|
25
|
+
'<%= @bundle.downcase %>_<%= singular_name %>_search' : {
|
|
26
|
+
click_search : this.onSearchClick,
|
|
27
|
+
click_reset : this.onResetClick
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/****************************************************************
|
|
33
|
+
** 여기는 customizing area **
|
|
34
|
+
****************************************************************/
|
|
35
|
+
|
|
36
|
+
onParamsChange : function(view, params) {
|
|
37
|
+
var grid = this.getGridView();
|
|
38
|
+
var store = grid.getStore();
|
|
39
|
+
store.getProxy().extraParams = params;
|
|
40
|
+
grid.getStore().load();
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/****************************************************************
|
|
44
|
+
** 여기서 부터는 abstract method, 필수 구현 **
|
|
45
|
+
****************************************************************/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* main view를 리턴
|
|
49
|
+
*/
|
|
50
|
+
getMainView : function() {
|
|
51
|
+
return this.get<%= class_name %>();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>List', {
|
|
2
|
+
|
|
3
|
+
extend : 'Base.abstract.entity.ReportGridView',
|
|
4
|
+
|
|
5
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>_list',
|
|
6
|
+
|
|
7
|
+
store : Ext.create('Ext.data.Store', {
|
|
8
|
+
|
|
9
|
+
<%= Hatio::Generators::ReportViewUtil.generateStore(@domain, @out_params) %>,
|
|
10
|
+
|
|
11
|
+
autoLoad : false,
|
|
12
|
+
|
|
13
|
+
remoteFilter : true,
|
|
14
|
+
|
|
15
|
+
// TODO url : shoot.json, method : post
|
|
16
|
+
proxy : {
|
|
17
|
+
type : 'ajax',
|
|
18
|
+
url : <%= @service_url %>,
|
|
19
|
+
format : 'json',
|
|
20
|
+
reader : {
|
|
21
|
+
type : 'json'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
<%= Hatio::Generators::ReportViewUtil.generateColumns(@domain, @out_params) %>
|
|
27
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>', {
|
|
2
|
+
|
|
3
|
+
extend: 'Base.abstract.entity.ListMainView',
|
|
4
|
+
|
|
5
|
+
requires : [
|
|
6
|
+
'<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Search',
|
|
7
|
+
'<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>List'
|
|
8
|
+
],
|
|
9
|
+
|
|
10
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>',
|
|
11
|
+
|
|
12
|
+
title : T('title.<%= singular_name %>'),
|
|
13
|
+
|
|
14
|
+
searchView : '<%= @bundle.downcase %>_<%= singular_name %>_search',
|
|
15
|
+
|
|
16
|
+
gridView : '<%= @bundle.downcase %>_<%= singular_name %>_list'
|
|
17
|
+
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Ext.define('<%= @bundle %>.view.<%= singular_name %>.<%= class_name %>Search', {
|
|
2
|
+
|
|
3
|
+
extend : 'Base.abstract.entity.ListSearchView',
|
|
4
|
+
|
|
5
|
+
xtype : '<%= @bundle.downcase %>_<%= singular_name %>_search',
|
|
6
|
+
|
|
7
|
+
<%= Hatio::Generators::ReportViewUtil.generate_search_items(@domain, @in_params) %>
|
|
8
|
+
|
|
9
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module Hatio
|
|
2
|
+
module Generators
|
|
3
|
+
class ApiUtil
|
|
4
|
+
#
|
|
5
|
+
# index template 생성
|
|
6
|
+
#
|
|
7
|
+
def self.generate_index_template(singular_name, columns)
|
|
8
|
+
output = "json.items do |json|\n"
|
|
9
|
+
output << "\tjson.array!(@collection) do |#{singular_name}|\n"
|
|
10
|
+
output << generate_index_json_builder(singular_name, columns)
|
|
11
|
+
ref_columns = columns.select { |column| column.name != 'domain_id' && column.ref_type == 'Entity' && column.ref_name }
|
|
12
|
+
|
|
13
|
+
ref_columns.each do |ref_column|
|
|
14
|
+
next if (!ref_column.list_rank || ref_column.list_rank <= 0)
|
|
15
|
+
ref_singular_name = ref_column.ref_name.underscore
|
|
16
|
+
|
|
17
|
+
if(ref_column.name == 'creator_id')
|
|
18
|
+
output << "\n\t\tjson.creator do"
|
|
19
|
+
output << "\n\t\t\tjson.id #{singular_name}.creator_id"
|
|
20
|
+
output << "\n\t\t\tjson.name #{singular_name}.creator ? #{singular_name}.creator.name : ''"
|
|
21
|
+
output << "\n\t\tend\n"
|
|
22
|
+
elsif(ref_column.name == 'updater_id')
|
|
23
|
+
output << "\n\t\tjson.updater do"
|
|
24
|
+
output << "\n\t\t\tjson.id #{singular_name}.updater_id"
|
|
25
|
+
output << "\n\t\t\tjson.name #{singular_name}.updater ? #{singular_name}.updater.name : ''"
|
|
26
|
+
output << "\n\t\tend\n"
|
|
27
|
+
elsif(ref_column.name.ends_with?('_id'))
|
|
28
|
+
output << "\n\t\tjson.#{ref_singular_name} do"
|
|
29
|
+
output << "\n\t\t\tjson.id #{singular_name}.#{ref_column.name}"
|
|
30
|
+
output << "\n\t\t\tjson.name #{singular_name}.#{ref_singular_name} ? #{singular_name}.#{ref_singular_name}.name : ''"
|
|
31
|
+
output << "\n\t\tend\n"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
output << "\tend\n"
|
|
36
|
+
output << "end\n"
|
|
37
|
+
output << "json.total @total_count\n"
|
|
38
|
+
output << "json.success true\n"
|
|
39
|
+
output
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# create, update.json.jbuilder 에서 사용할 json builder
|
|
44
|
+
#
|
|
45
|
+
def self.generate_single_json_builder(singular_name, all_attrs)
|
|
46
|
+
all_col_str = all_attrs.map { |col| ":#{col.name}" }.join(",")
|
|
47
|
+
"json.(@#{singular_name}, #{all_col_str})"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# show.jbuilder 에서 사용할 json builder
|
|
52
|
+
#
|
|
53
|
+
def self.generate_show_json_builder(singular_name, all_attrs)
|
|
54
|
+
all_col_str = all_attrs.find_all { |col| (col.name != 'creator_id' && col.name != 'updater_id') }.map { |col| ":#{col.name}" }.join(",")
|
|
55
|
+
"json.(@#{singular_name}, #{all_col_str})"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# show.jbuilder 에서 사용할 userstamp용 json builder
|
|
60
|
+
#
|
|
61
|
+
def self.generate_userstamp_json_builder(singular_name, all_attrs)
|
|
62
|
+
output = "json.creator @#{singular_name}.creator, :id, :name if @#{singular_name}.creator\n"
|
|
63
|
+
output << "json.updater @#{singular_name}.updater, :id, :name if @#{singular_name}.updater"
|
|
64
|
+
output
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
#
|
|
68
|
+
# index.jbuilder 에서 사용할 json builder
|
|
69
|
+
#
|
|
70
|
+
def self.generate_index_json_builder(singular_name, all_attrs)
|
|
71
|
+
all_col_str = all_attrs.map { |col| ":#{col.name}" }.join(",")
|
|
72
|
+
"json.(#{singular_name}, #{all_col_str})\n"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#
|
|
76
|
+
# show.jbuilder 에서 사용, entity reference type인 경우
|
|
77
|
+
#
|
|
78
|
+
def self.generate_ref_entity_json_builder(singular_name, biz_attrs)
|
|
79
|
+
ref_columns, output = biz_attrs.select { |col| col.ref_type == 'Entity' && col.ref_name }, ""
|
|
80
|
+
ref_columns.each do |ref_column|
|
|
81
|
+
next if (!ref_column.list_rank || ref_column.list_rank <= 0)
|
|
82
|
+
ref_singular_name = ref_column.ref_name.underscore
|
|
83
|
+
ref_class = ref_column.ref_name.constantize
|
|
84
|
+
output << "\njson.#{ref_singular_name} do"
|
|
85
|
+
output << "\n\tjson.id @#{singular_name}.#{ref_column.name}"
|
|
86
|
+
output << "\n\tjson.name @#{singular_name}.#{ref_singular_name} ? @#{singular_name}.#{ref_singular_name}.name : ''"
|
|
87
|
+
if(ref_class.column_names.include?("description"))
|
|
88
|
+
output << "\n\tjson.description @#{singular_name}.#{ref_singular_name} ? @#{singular_name}.#{ref_singular_name}.description : ''"
|
|
89
|
+
end
|
|
90
|
+
output << "\nend\n"
|
|
91
|
+
end
|
|
92
|
+
output
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|