erp_app 3.1.1 → 3.1.2
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.
- data/app/controllers/erp_app/desktop/scaffold/base_controller.rb +72 -72
- data/app/controllers/erp_app/desktop/security_management/capabilities_controller.rb +2 -1
- data/app/controllers/erp_app/desktop/security_management/groups_controller.rb +2 -0
- data/app/views/erp_app/desktop/base/index.erb +1 -0
- data/config/routes.rb +1 -1
- data/lib/active_ext/core.rb +88 -65
- data/lib/active_ext/data_structures/column.rb +17 -17
- data/lib/active_ext/data_structures/columns.rb +55 -52
- data/lib/active_ext/ext_helpers/table_builder.rb +58 -58
- data/lib/erp_app/engine.rb +1 -1
- data/lib/erp_app/extensions/railties/action_view/helpers/extjs_helper.rb +5 -2
- data/lib/erp_app/extensions/railties/action_view/helpers/include_helper.rb +4 -4
- data/lib/erp_app/version.rb +1 -1
- data/lib/erp_app/widgets/javascript_loader.rb +1 -1
- data/lib/erp_app/widgets/loader.rb +5 -6
- data/lib/generators/compass_ae_mobile/USAGE +9 -0
- data/lib/generators/compass_ae_mobile/compass_ae_mobile_generator.rb +35 -0
- data/lib/generators/compass_ae_mobile/templates/controllers/controller_template.erb +4 -0
- data/lib/generators/compass_ae_mobile/templates/javascripts/main_template.erb +29 -0
- data/lib/generators/compass_ae_mobile/templates/views/view_template.erb +25 -0
- data/public/javascripts/erp_app/desktop/applications/scaffold/models_tree_panel.js +11 -59
- data/public/javascripts/erp_app/desktop/applications/scaffold/module.js +37 -36
- data/public/javascripts/erp_app/shared/Ext.ux.CheckColumn.js +115 -0
- data/public/javascripts/erp_app/shared/compass_ckeditor.js +17 -0
- data/public/javascripts/erp_app/shared/compass_codemirror.js +171 -159
- data/public/javascripts/erp_app/shared/file_manager_tree.js +1 -1
- data/public/stylesheets/erp_app/shared/grid_cell.css +23 -0
- metadata +9 -9
- data/app/controllers/erp_app/desktop/scaffold/role_controller.rb +0 -23
- data/app/views/erp_app/desktop/scaffold/role/create.rhtml +0 -19
- data/app/views/erp_app/desktop/scaffold/role/edit.rhtml +0 -65
- data/app/views/erp_app/desktop/scaffold/role/new.rhtml +0 -41
- data/app/views/erp_app/desktop/scaffold/role/show.rhtml +0 -58
- data/app/views/erp_app/desktop/scaffold/role/update.rhtml +0 -1
- data/public/javascripts/erp_app/desktop/applications/scaffold/role_active_ext.js +0 -17
@@ -1,77 +1,77 @@
|
|
1
1
|
module ActiveExt
|
2
|
-
module ExtHelpers
|
3
|
-
module TableBuilder
|
2
|
+
module ExtHelpers
|
3
|
+
module TableBuilder
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def self.generate_columns_and_fields(core)
|
6
|
+
columns = self.build_columns(core)
|
7
|
+
fields = self.build_fields(core)
|
8
|
+
validations = self.build_validations(core)
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
return columns, fields, validations
|
11
|
+
end
|
12
12
|
|
13
|
-
|
13
|
+
private
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
def self.build_columns(core)
|
16
|
+
columns = []
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#build ext columns
|
24
|
-
core.columns.each do |column|
|
25
|
-
next if column.name.to_s =~ /(^id|created_at|updated_at)$/ || core.columns.exclude_column?(column.name)
|
26
|
-
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(column)
|
27
|
-
end
|
28
|
-
|
29
|
-
#add timestamp columns if showing them
|
30
|
-
if core.options[:show_timestamps]
|
31
|
-
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(core.columns[:created_at])
|
32
|
-
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(core.columns[:updated_at])
|
33
|
-
end
|
34
|
-
|
35
|
-
columns
|
36
|
-
end
|
18
|
+
#add id column if showing it
|
19
|
+
if core.options[:show_id]
|
20
|
+
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(core.columns[:id])
|
21
|
+
end
|
37
22
|
|
38
|
-
|
39
|
-
|
23
|
+
#build ext columns
|
24
|
+
core.columns.each do |column|
|
25
|
+
next if column.name.to_s =~ /(^id|created_at|updated_at)$/ || core.columns.exclude_column?(column.name)
|
26
|
+
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(column)
|
27
|
+
end
|
40
28
|
|
41
|
-
|
29
|
+
#add timestamp columns if showing them
|
30
|
+
if core.options[:show_timestamps]
|
31
|
+
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(core.columns[:created_at])
|
32
|
+
columns << ActiveExt::ExtHelpers::ColumnBuilder.build_column(core.columns[:updated_at])
|
33
|
+
end
|
42
34
|
|
43
|
-
|
44
|
-
core.columns.each do |column|
|
45
|
-
next if column.name.to_s =~ /(^created_at|updated_at)$/ || core.columns.exclude_column?(column.name)
|
46
|
-
if column.association.nil?
|
47
|
-
fields << {:name => column.name, :allowBlank => !column.options[:required]}
|
35
|
+
columns
|
48
36
|
end
|
49
|
-
end
|
50
37
|
|
51
|
-
|
52
|
-
|
53
|
-
fields << {:name => 'updated_at', :type => 'date'}
|
54
|
-
end
|
38
|
+
def self.build_fields(core)
|
39
|
+
fields = []
|
55
40
|
|
56
|
-
|
57
|
-
end
|
41
|
+
fields << {:name => 'id', :type => 'number'}
|
58
42
|
|
59
|
-
|
60
|
-
|
43
|
+
#build ext fields
|
44
|
+
core.columns.each do |column|
|
45
|
+
next if column.name.to_s =~ /(^created_at|updated_at)$/ || core.columns.exclude_column?(column.name)
|
46
|
+
if column.association.nil?
|
47
|
+
fields << {:name => column.name, :allowBlank => !column.options[:required]}
|
48
|
+
end
|
49
|
+
end
|
61
50
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if column.association.nil?
|
66
|
-
if column.options[:required]
|
67
|
-
validations << {:type => 'presence', :field => column.name}
|
51
|
+
if core.options[:show_timestamps]
|
52
|
+
fields << {:name => 'created_at', :type => 'date'}
|
53
|
+
fields << {:name => 'updated_at', :type => 'date'}
|
68
54
|
end
|
55
|
+
|
56
|
+
fields
|
69
57
|
end
|
70
|
-
end
|
71
58
|
|
72
|
-
|
73
|
-
|
59
|
+
def self.build_validations(core)
|
60
|
+
validations = []
|
74
61
|
|
75
|
-
|
76
|
-
|
62
|
+
#build ext fields
|
63
|
+
core.columns.each do |column|
|
64
|
+
next if column.name.to_s =~ /(^created_at|updated_at)$/ || core.columns.exclude_column?(column.name)
|
65
|
+
if column.association.nil?
|
66
|
+
if column.options[:required]
|
67
|
+
validations << {:type => 'presence', :field => column.name}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
validations
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
77
|
end
|
data/lib/erp_app/engine.rb
CHANGED
@@ -29,8 +29,11 @@ module ErpApp
|
|
29
29
|
output += raw "Compass.ErpApp.Utility.JsLoader.load([
|
30
30
|
'/javascripts/erp_app/shared/dynamic_editable_grid.js',
|
31
31
|
'/javascripts/erp_app/shared/dynamic_editable_grid_loader_panel.js'],
|
32
|
-
|
33
|
-
Ext.create('
|
32
|
+
function(){
|
33
|
+
var task = Ext.create('Ext.util.DelayedTask', function () {
|
34
|
+
Ext.create('Compass.ErpApp.Shared.DynamicEditableGridLoaderPanel', #{options.to_json} );
|
35
|
+
});
|
36
|
+
task.delay(200);
|
34
37
|
});"
|
35
38
|
output += raw '</script>'
|
36
39
|
|
@@ -6,11 +6,11 @@ module ErpApp
|
|
6
6
|
module IncludeHelper
|
7
7
|
|
8
8
|
def static_javascript_include_tag(*srcs)
|
9
|
-
raw srcs.flatten.map{|src| "<script type=\"text/javascript\" src=\"/javascripts/#{src}\"></script>"}.join("")
|
9
|
+
raw srcs.flatten.map{|src| "<script type=\"text/javascript\" src=\"/javascripts/#{src.include?('.js') ? src : "#{src}.js"}\"></script>"}.join("")
|
10
10
|
end
|
11
11
|
|
12
12
|
def static_stylesheet_link_tag(*srcs)
|
13
|
-
raw srcs.flatten.map{|src| "<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheets/#{src}\" />"}.join("")
|
13
|
+
raw srcs.flatten.map{|src| "<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheets/#{src.include?('.css') ? src : "#{src}.css"}\" />"}.join("")
|
14
14
|
end
|
15
15
|
|
16
16
|
def include_extjs(opt={})
|
@@ -111,7 +111,7 @@ module ErpApp
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def include_compass_ae_instance_about
|
114
|
-
compass_ae_instance = CompassAeInstance.
|
114
|
+
compass_ae_instance = CompassAeInstance.find_by_internal_identifier('base')
|
115
115
|
json_hash = {
|
116
116
|
:version => compass_ae_instance.version,
|
117
117
|
:installedAt => compass_ae_instance.created_at.strftime("%B %d, %Y at %I:%M%p"),
|
@@ -132,7 +132,7 @@ module ErpApp
|
|
132
132
|
def setSessionTimeout(warn_milli_seconds=((ErpApp::Config.session_warn_after*60)*1000),
|
133
133
|
redirect_milli_seconds=((ErpApp::Config.session_redirect_after*60)*1000),
|
134
134
|
redirect_to='/session/sign_out')
|
135
|
-
raw "<script type='text/javascript'>Compass.ErpApp.Utility.SessionTimeout.setupSessionTimeout(#{warn_milli_seconds}, #{redirect_milli_seconds}, '#{redirect_to}') </script>"
|
135
|
+
raw "<script type='text/javascript'>Compass.ErpApp.Utility.SessionTimeout.setupSessionTimeout(#{warn_milli_seconds}, #{redirect_milli_seconds}, '#{redirect_to}') </script>" if current_user
|
136
136
|
end
|
137
137
|
|
138
138
|
def load_shared_application_resources(resource_type)
|
data/lib/erp_app/version.rb
CHANGED
@@ -3,7 +3,7 @@ module ErpApp
|
|
3
3
|
class JavascriptLoader
|
4
4
|
|
5
5
|
def self.glob_javascript
|
6
|
-
files = Rails.application.config.erp_app.widgets.collect{|widget|Dir.glob(File.join(widget[:path],"javascript/*.js"))}.flatten
|
6
|
+
files = Rails.application.config.erp_app.widgets.collect{|widget|Dir.glob(File.join(widget[:path],"javascript/*.js"))}.flatten.sort{|file| file <=> file}
|
7
7
|
|
8
8
|
"<script type='text/javascript'>#{Uglifier.compile(files.collect{|file| IO.read(file)}.join(''))}</script>"
|
9
9
|
end
|
@@ -3,17 +3,16 @@ module ErpApp
|
|
3
3
|
class Loader
|
4
4
|
class << self
|
5
5
|
def load_compass_ae_widgets(config, engine)
|
6
|
-
|
6
|
+
ErpBaseErpSvcs.setup_compass_ae_callback(config, engine) do |engine|
|
7
7
|
::ErpApp::Widgets::Loader.require_widgets_and_helpers(engine.root)
|
8
8
|
::ErpApp::Widgets::Loader.load_widget_extensions(engine)
|
9
9
|
end
|
10
|
-
|
11
10
|
end
|
12
11
|
|
13
12
|
def load_root_widgets(config)
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
ErpBaseErpSvcs.setup_compass_ae_callback(config, nil) do |engine|
|
14
|
+
::ErpApp::Widgets::Loader.require_widgets_and_helpers(Rails.root.to_s)
|
15
|
+
end
|
17
16
|
end
|
18
17
|
|
19
18
|
def require_widgets_and_helpers(path)
|
@@ -129,4 +128,4 @@ module ErpApp
|
|
129
128
|
end#self
|
130
129
|
end#Loader
|
131
130
|
end#Widgets
|
132
|
-
end#ErpApp
|
131
|
+
end#ErpApp
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Description:
|
2
|
+
Used to create a Sencha Mobile application linked to CompassAE for mobile
|
3
|
+
optimized web application
|
4
|
+
|
5
|
+
Example:
|
6
|
+
rails g compass_ae_mobile [application_name] [sencha_touch_sdk_path]
|
7
|
+
|
8
|
+
This will create:
|
9
|
+
1. Sencha Touch application in /public/javascripts/[application_name]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class CompassAeMobileGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
argument :sdk_path, :type => :string
|
4
|
+
|
5
|
+
def generate_sencha_touch_application
|
6
|
+
javascripts_path = File.join(Rails.root, 'public', 'javascripts')
|
7
|
+
application_path = File.join(javascripts_path, class_name)
|
8
|
+
|
9
|
+
empty_directory(javascripts_path)
|
10
|
+
run "sencha -sdk #{@sdk_path} generate app #{class_name} #{application_path}"
|
11
|
+
|
12
|
+
%w{app.json build.xml index.html packager.json resources}.each do |file|
|
13
|
+
remove_file(File.join(application_path, file))
|
14
|
+
end
|
15
|
+
|
16
|
+
gsub_file File.join(application_path, 'app.js'), %r[^//<debug>([\s\S])+//</debug>], "Ext.Loader.setPath({'#{class_name}': 'javascripts/#{class_name}/app'});"
|
17
|
+
|
18
|
+
#replace Main.js
|
19
|
+
remove_file remove_file(File.join(application_path, 'app', 'view', 'Main.js'))
|
20
|
+
template "javascripts/main_template.erb", File.join(application_path, 'app', 'view', 'Main.js')
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_compass_ae_files
|
24
|
+
#controller
|
25
|
+
template "controllers/controller_template.erb", File.join("app/controllers","#{file_name}_controller.rb")
|
26
|
+
|
27
|
+
#view
|
28
|
+
copy_file "views/view_template.erb", File.join("app/views/#{file_name}","index.html.erb")
|
29
|
+
gsub_file File.join("app/views/#{file_name}","index.html.erb"), /CLASS_NAME_PLACE_HOLDER/, class_name
|
30
|
+
|
31
|
+
#route
|
32
|
+
route "match '/#{file_name}' => '#{file_name}#index'"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Ext.define('<%=class_name%>.view.Main', {
|
2
|
+
extend: 'Ext.tab.Panel',
|
3
|
+
xtype: 'main',
|
4
|
+
config: {
|
5
|
+
tabBarPosition: 'bottom',
|
6
|
+
|
7
|
+
items: [
|
8
|
+
{
|
9
|
+
title: 'Welcome',
|
10
|
+
iconCls: 'home',
|
11
|
+
|
12
|
+
styleHtmlContent: true,
|
13
|
+
scrollable: true,
|
14
|
+
|
15
|
+
items: {
|
16
|
+
docked: 'top',
|
17
|
+
xtype: 'titlebar',
|
18
|
+
title: 'Welcome to <%=class_name%>'
|
19
|
+
},
|
20
|
+
|
21
|
+
html: [
|
22
|
+
"You've just generated a new Sencha Touch 2 application within the CompassAE framework. What you're looking at right now is the ",
|
23
|
+
"contents of <a target='_blank' href=\"javascripts/<%=class_name%>/app/view/Main.js\">public/javascripts/<%=class_name%>/app/view/Main.js</a> - edit that file ",
|
24
|
+
"and refresh to change what's rendered here."
|
25
|
+
].join("")
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
|
3
|
+
<head>
|
4
|
+
<%= csrf_meta_tag %>
|
5
|
+
<title>CLASS_NAME_PLACE_HOLDER</title>
|
6
|
+
<%= include_sencha_touch :theme => false, :debug => (Rails.env != 'production') %>
|
7
|
+
|
8
|
+
<%= static_stylesheet_link_tag('sencha_touch/resources/css/sencha-touch.css') %>
|
9
|
+
<%= static_stylesheet_link_tag('sencha_touch/resources/css/apple.css') %>
|
10
|
+
|
11
|
+
<%= static_javascript_include_tag('erp_app/utility.js') %>
|
12
|
+
<%= static_javascript_include_tag('erp_app/mobile/mobile_base.js') %>
|
13
|
+
|
14
|
+
<%= add_authenticity_token_to_extjs %>
|
15
|
+
|
16
|
+
<%= static_javascript_include_tag('CLASS_NAME_PLACE_HOLDER/app.js') %>
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="appLoadingIndicator">
|
20
|
+
<div></div>
|
21
|
+
<div></div>
|
22
|
+
<div></div>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -9,59 +9,20 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Scaffold.ModelsTree",{
|
|
9
9
|
this.findParentByType('statuswindow').clearStatus();
|
10
10
|
},
|
11
11
|
|
12
|
-
addModel : function(){
|
13
|
-
var self = this;
|
14
|
-
Ext.MessageBox.prompt('Add Model', 'Model name:', function(btn, text){
|
15
|
-
if(btn == 'ok'){
|
16
|
-
self.setWindowStatus('Adding model to scaffold');
|
17
|
-
Ext.Ajax.request({
|
18
|
-
url:'/erp_app/desktop/scaffold/create_model',
|
19
|
-
method: 'POST',
|
20
|
-
params:{
|
21
|
-
name:text
|
22
|
-
},
|
23
|
-
success: function(response) {
|
24
|
-
self.clearWindowStatus();
|
25
|
-
var obj = Ext.decode(response.responseText);
|
26
|
-
if(obj.success){
|
27
|
-
Ext.MessageBox.confirm('Confirm', 'Page must reload for changes to take affect. Reload now?', function(btn){
|
28
|
-
if(btn == 'no'){
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
else{
|
32
|
-
window.location.reload();
|
33
|
-
}
|
34
|
-
});
|
35
|
-
}
|
36
|
-
else{
|
37
|
-
Ext.Msg.alert("Error", obj.msg);
|
38
|
-
}
|
39
|
-
},
|
40
|
-
failure: function(response) {
|
41
|
-
self.clearWindowStatus();
|
42
|
-
var obj = Ext.decode(response.responseText);
|
43
|
-
if(!Compass.ErpApp.Utility.isBlank(obj) && !Compass.ErpApp.Utility.isBlank(obj.msg)){
|
44
|
-
Ext.Msg.alert("Error", obj.msg);
|
45
|
-
}
|
46
|
-
else{
|
47
|
-
Ext.Msg.alert("Error", "Error adding model");
|
48
|
-
}
|
49
|
-
}
|
50
|
-
});
|
51
|
-
}
|
52
|
-
});
|
53
|
-
},
|
54
|
-
|
55
12
|
constructor : function(config) {
|
56
13
|
var self = this;
|
57
14
|
|
58
15
|
var store = Ext.create('Ext.data.TreeStore', {
|
59
16
|
proxy: {
|
60
17
|
type: 'ajax',
|
61
|
-
url: '/erp_app/desktop/scaffold/
|
18
|
+
url: '/erp_app/desktop/scaffold/get_models.tree',
|
19
|
+
reader:{
|
20
|
+
type:'json',
|
21
|
+
root:'names'
|
22
|
+
}
|
62
23
|
},
|
63
24
|
root: {
|
64
|
-
text: 'Models',
|
25
|
+
text: 'CompassAE Models',
|
65
26
|
draggable:false
|
66
27
|
},
|
67
28
|
fields:[
|
@@ -77,19 +38,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Scaffold.ModelsTree",{
|
|
77
38
|
animate:false,
|
78
39
|
region:'west',
|
79
40
|
autoScroll:true,
|
80
|
-
|
81
|
-
items:[
|
82
|
-
{
|
83
|
-
text:'Add Model',
|
84
|
-
iconCls:'icon-add',
|
85
|
-
scope:this,
|
86
|
-
handler:function(){
|
87
|
-
this.addModel();
|
88
|
-
}
|
89
|
-
}
|
90
|
-
]
|
91
|
-
},
|
92
|
-
enableDD:true,
|
41
|
+
enableDD:false,
|
93
42
|
containerScroll: true,
|
94
43
|
border: false,
|
95
44
|
frame:true,
|
@@ -97,12 +46,15 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Scaffold.ModelsTree",{
|
|
97
46
|
height: 300,
|
98
47
|
listeners:{
|
99
48
|
'itemclick':function(view, record){
|
100
|
-
if(record.data.leaf){
|
49
|
+
if(!record.data.leaf){
|
101
50
|
self.initialConfig.scaffold.loadModel(record.data.model);
|
102
51
|
}
|
103
52
|
},
|
104
53
|
'contextmenu':function(node, e){
|
105
54
|
e.stopEvent();
|
55
|
+
},
|
56
|
+
render:function(){
|
57
|
+
this.getRootNode().expand();
|
106
58
|
}
|
107
59
|
}
|
108
60
|
}, config);
|
@@ -1,59 +1,60 @@
|
|
1
|
-
Ext.define("Compass.ErpApp.Desktop.Applications.Scaffold",{
|
1
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.Scaffold", {
|
2
2
|
extend:"Ext.ux.desktop.Module",
|
3
3
|
id:'scaffold-win',
|
4
|
-
loadModel
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
this.modelsTabPanel.add({
|
19
|
-
xtype:modelName + '_activeextgrid',
|
20
|
-
closable:true
|
4
|
+
loadModel:function (modelName) {
|
5
|
+
var dynamicGrid = this.modelsTabPanel.down('#'+modelName);
|
6
|
+
if(Ext.isEmpty(dynamicGrid)){
|
7
|
+
dynamicGrid = Ext.create('Compass.ErpApp.Shared.DynamicEditableGridLoaderPanel', {
|
8
|
+
closable:true,
|
9
|
+
itemId:modelName,
|
10
|
+
editable:true,
|
11
|
+
title:modelName,
|
12
|
+
setupUrl:'/erp_app/desktop/scaffold/setup/' + modelName,
|
13
|
+
dataUrl:'/erp_app/desktop/scaffold/data/' + modelName,
|
14
|
+
page:true,
|
15
|
+
pageSize:30,
|
16
|
+
displayMsg:'Displaying {0} - {1} of {2}',
|
17
|
+
emptyMsg:'Empty'
|
21
18
|
});
|
22
|
-
this.modelsTabPanel.
|
19
|
+
this.modelsTabPanel.add(dynamicGrid);
|
23
20
|
}
|
21
|
+
|
22
|
+
this.modelsTabPanel.setActiveTab(dynamicGrid);
|
24
23
|
},
|
25
24
|
|
26
|
-
init
|
25
|
+
init:function () {
|
27
26
|
this.launcher = {
|
28
|
-
text:
|
27
|
+
text:'Scaffold',
|
29
28
|
iconCls:'icon-data',
|
30
|
-
handler
|
31
|
-
scope:
|
29
|
+
handler:this.createWindow,
|
30
|
+
scope:this
|
32
31
|
}
|
33
32
|
},
|
34
|
-
|
35
|
-
createWindow
|
33
|
+
|
34
|
+
createWindow:function () {
|
36
35
|
var desktop = this.app.getDesktop();
|
37
36
|
var win = desktop.getWindow('scaffold');
|
38
|
-
if(!win){
|
39
|
-
|
40
|
-
|
41
|
-
});
|
37
|
+
if (!win) {
|
38
|
+
|
39
|
+
this.modelsTabPanel = Ext.create('Ext.tab.Panel',{region:'center',items:[]});
|
42
40
|
|
43
41
|
win = desktop.createWindow({
|
44
|
-
id:
|
42
|
+
id:'scaffold',
|
45
43
|
title:'Scaffold',
|
46
44
|
width:1000,
|
47
45
|
height:550,
|
48
|
-
iconCls:
|
46
|
+
iconCls:'icon-data',
|
49
47
|
shim:false,
|
50
48
|
animCollapse:false,
|
51
49
|
constrainHeader:true,
|
52
|
-
layout:
|
53
|
-
items:[
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
layout:'border',
|
51
|
+
items:[
|
52
|
+
{
|
53
|
+
xtype:'scaffold_modelstreepanel',
|
54
|
+
scaffold:this
|
55
|
+
},
|
56
|
+
this.modelsTabPanel
|
57
|
+
]
|
57
58
|
});
|
58
59
|
}
|
59
60
|
win.show();
|
@@ -0,0 +1,115 @@
|
|
1
|
+
/**
|
2
|
+
* A Header subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.
|
3
|
+
*
|
4
|
+
* Example usage:
|
5
|
+
*
|
6
|
+
* // create the grid
|
7
|
+
* var grid = Ext.create('Ext.grid.Panel', {
|
8
|
+
* ...
|
9
|
+
* columns: [{
|
10
|
+
* text: 'Foo',
|
11
|
+
* ...
|
12
|
+
* },{
|
13
|
+
* xtype: 'checkcolumn',
|
14
|
+
* text: 'Indoor?',
|
15
|
+
* dataIndex: 'indoor',
|
16
|
+
* width: 55
|
17
|
+
* }]
|
18
|
+
* ...
|
19
|
+
* });
|
20
|
+
*
|
21
|
+
* In addition to toggling a Boolean value within the record data, this
|
22
|
+
* class adds or removes a css class <tt>'x-grid-checked'</tt> on the td
|
23
|
+
* based on whether or not it is checked to alter the background image used
|
24
|
+
* for a column.
|
25
|
+
*/
|
26
|
+
Ext.define('Ext.ux.CheckColumn', {
|
27
|
+
extend: 'Ext.grid.column.Column',
|
28
|
+
alias: 'widget.checkcolumn',
|
29
|
+
|
30
|
+
/**
|
31
|
+
* @cfg {Boolean} [stopSelection=true]
|
32
|
+
* Prevent grid selection upon mousedown.
|
33
|
+
*/
|
34
|
+
stopSelection: true,
|
35
|
+
|
36
|
+
tdCls: Ext.baseCSSPrefix + 'grid-cell-checkcolumn',
|
37
|
+
|
38
|
+
constructor: function() {
|
39
|
+
this.addEvents(
|
40
|
+
/**
|
41
|
+
* @event beforecheckchange
|
42
|
+
* Fires when before checked state of a row changes.
|
43
|
+
* The change may be vetoed by returning `false` from a listener.
|
44
|
+
* @param {Ext.ux.CheckColumn} this CheckColumn
|
45
|
+
* @param {Number} rowIndex The row index
|
46
|
+
* @param {Boolean} checked True if the box is to be checked
|
47
|
+
*/
|
48
|
+
'beforecheckchange',
|
49
|
+
/**
|
50
|
+
* @event checkchange
|
51
|
+
* Fires when the checked state of a row changes
|
52
|
+
* @param {Ext.ux.CheckColumn} this CheckColumn
|
53
|
+
* @param {Number} rowIndex The row index
|
54
|
+
* @param {Boolean} checked True if the box is now checked
|
55
|
+
*/
|
56
|
+
'checkchange'
|
57
|
+
);
|
58
|
+
this.callParent(arguments);
|
59
|
+
},
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @private
|
63
|
+
* Process and refire events routed from the GridView's processEvent method.
|
64
|
+
*/
|
65
|
+
processEvent: function(type, view, cell, recordIndex, cellIndex, e, record, row) {
|
66
|
+
var me = this,
|
67
|
+
key = type === 'keydown' && e.getKey(),
|
68
|
+
mousedown = type == 'mousedown';
|
69
|
+
|
70
|
+
if (mousedown || (key == e.ENTER || key == e.SPACE)) {
|
71
|
+
var dataIndex = me.dataIndex,
|
72
|
+
checked = !record.get(dataIndex);
|
73
|
+
|
74
|
+
// Allow apps to hook beforecheckchange
|
75
|
+
if (me.fireEvent('beforecheckchange', me, recordIndex, checked) !== false) {
|
76
|
+
record.set(dataIndex, checked);
|
77
|
+
me.fireEvent('checkchange', me, recordIndex, checked);
|
78
|
+
|
79
|
+
// Mousedown on the now nonexistent cell causes the view to blur, so stop it continuing.
|
80
|
+
if (mousedown) {
|
81
|
+
e.stopEvent();
|
82
|
+
}
|
83
|
+
|
84
|
+
// Selection will not proceed after this because of the DOM update caused by the record modification
|
85
|
+
// Invoke the SelectionModel unless configured not to do so
|
86
|
+
if (!me.stopSelection) {
|
87
|
+
view.selModel.selectByPosition({
|
88
|
+
row: recordIndex,
|
89
|
+
column: cellIndex
|
90
|
+
});
|
91
|
+
}
|
92
|
+
|
93
|
+
// Prevent the view from propagating the event to the selection model - we have done that job.
|
94
|
+
return false;
|
95
|
+
} else {
|
96
|
+
// Prevent the view from propagating the event to the selection model if configured to do so.
|
97
|
+
return !me.stopSelection;
|
98
|
+
}
|
99
|
+
} else {
|
100
|
+
return me.callParent(arguments);
|
101
|
+
}
|
102
|
+
},
|
103
|
+
|
104
|
+
// Note: class names are not placed on the prototype bc renderer scope
|
105
|
+
// is not in the header.
|
106
|
+
renderer : function(value){
|
107
|
+
var cssPrefix = Ext.baseCSSPrefix,
|
108
|
+
cls = [cssPrefix + 'grid-checkheader'];
|
109
|
+
|
110
|
+
if (value) {
|
111
|
+
cls.push(cssPrefix + 'grid-checkheader-checked');
|
112
|
+
}
|
113
|
+
return '<div class="' + cls.join(' ') + '"> </div>';
|
114
|
+
}
|
115
|
+
});
|