knitkit 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +1 -1
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +0 -2
- data/app/models/website.rb +76 -79
- data/app/widgets/dynamic_forms/base.rb +139 -0
- data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +111 -0
- data/app/widgets/dynamic_forms/views/error.html.erb +5 -0
- data/app/widgets/dynamic_forms/views/index.html.erb +8 -0
- data/app/widgets/dynamic_forms/views/success.html.erb +4 -0
- data/app/widgets/dynamic_grid/base.rb +130 -0
- data/app/widgets/dynamic_grid/helpers/controller/dynamic_grid_controller_helper.rb +3 -0
- data/app/widgets/dynamic_grid/helpers/view/dynamic_grid_view_helper.rb +3 -0
- data/app/widgets/dynamic_grid/javascript/dynamic_grid.js +178 -0
- data/app/widgets/dynamic_grid/views/index.html.erb +14 -0
- data/app/widgets/scaffold/base.rb +83 -0
- data/app/widgets/scaffold/helpers/controller/scaffold_controller_helper.rb +3 -0
- data/app/widgets/scaffold/helpers/view/scaffold_view_helper.rb +3 -0
- data/app/widgets/scaffold/javascript/scaffold.js +339 -0
- data/app/widgets/scaffold/views/index.html.erb +15 -0
- data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +1 -1
- data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +2 -3
- data/lib/knitkit/version.rb +1 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +25 -1
- metadata +19 -10
@@ -0,0 +1,14 @@
|
|
1
|
+
<div id="dynamicGrid_<%=@uuid%>"></div>
|
2
|
+
|
3
|
+
<%=
|
4
|
+
dynamic_extjs_grid(:renderTo => "dynamicGrid_#{@uuid}",
|
5
|
+
:title => @title,
|
6
|
+
:setupUrl => build_widget_url('setup', nil, {:model_name => @model_name}),
|
7
|
+
:dataUrl => build_widget_url('data', nil, {:model_name => @model_name}),
|
8
|
+
:width => @width,
|
9
|
+
:height => @height,
|
10
|
+
:page => @page,
|
11
|
+
:pageSize => @page_size,
|
12
|
+
:displayMsg => @display_msg,
|
13
|
+
:emptyMsg => @empty_msg)
|
14
|
+
%>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Widgets
|
2
|
+
module Scaffold
|
3
|
+
class Base < ErpApp::Widgets::Base
|
4
|
+
def index
|
5
|
+
@model = params[:model]
|
6
|
+
@title = params[:grid][:title] || params[:model].pluralize
|
7
|
+
@width = params[:grid][:width] || '100%'
|
8
|
+
@height = params[:grid][:height] || 500
|
9
|
+
@page = params[:grid][:page] || true
|
10
|
+
@page_size = params[:grid][:page_size] || 10
|
11
|
+
@display_msg = params[:grid][:display_msg] || 'Displaying {0} - {1} of {2}'
|
12
|
+
@empty_msg = params[:grid][:empty_msg] || 'Empty'
|
13
|
+
@editable = params[:grid][:editable] || false
|
14
|
+
|
15
|
+
render :view => :index
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
active_ext_core = setup_active_ext_core
|
20
|
+
|
21
|
+
columns, fields, validations = ActiveExt::ExtHelpers::TableBuilder.generate_columns_and_fields(active_ext_core)
|
22
|
+
result = {
|
23
|
+
:success => true,
|
24
|
+
:use_ext_forms => active_ext_core.options[:use_ext_forms].nil? ? false : active_ext_core.options[:use_ext_forms],
|
25
|
+
:inline_edit => active_ext_core.options[:inline_edit].nil? ? false : active_ext_core.options[:inline_edit],
|
26
|
+
:columns => columns,
|
27
|
+
:fields => fields,
|
28
|
+
:validations => validations
|
29
|
+
}
|
30
|
+
render :inline => result.to_json
|
31
|
+
end
|
32
|
+
|
33
|
+
def data
|
34
|
+
active_ext_core = setup_active_ext_core
|
35
|
+
|
36
|
+
json_text = nil
|
37
|
+
|
38
|
+
if request.get?
|
39
|
+
json_text = ActiveExt::ExtHelpers::DataHelper.build_json_data(active_ext_core, :limit => params[:limit], :offset => params[:start])
|
40
|
+
elsif request.post?
|
41
|
+
json_text = ActiveExt::ExtHelpers::DataHelper.create_record(active_ext_core, :data => params[:data])
|
42
|
+
elsif request.put?
|
43
|
+
json_text = ActiveExt::ExtHelpers::DataHelper.update_record(active_ext_core, :data => params[:data], :id => params[:data][:id])
|
44
|
+
elsif request.delete?
|
45
|
+
json_text = ActiveExt::ExtHelpers::DataHelper.delete_record(active_ext_core, :data => params[:data], :id => params[:data][:id])
|
46
|
+
end
|
47
|
+
|
48
|
+
render :inline => json_text
|
49
|
+
end
|
50
|
+
|
51
|
+
def setup_active_ext_core
|
52
|
+
model_id = session[:widgets][self.uuid][:model].pluralize.singularize
|
53
|
+
default_options = {
|
54
|
+
:inline_edit => true,
|
55
|
+
:use_ext_forms => false,
|
56
|
+
:ignore_associations => true,
|
57
|
+
:show_id => true,
|
58
|
+
:show_timestamps => true,
|
59
|
+
:only => nil
|
60
|
+
}
|
61
|
+
|
62
|
+
options = default_options.merge(session[:widgets][self.uuid][:scaffold])
|
63
|
+
ActiveExt::Core.new(model_id,options)
|
64
|
+
end
|
65
|
+
|
66
|
+
#should not be modified
|
67
|
+
#modify at your own risk
|
68
|
+
def locate
|
69
|
+
File.dirname(__FILE__)
|
70
|
+
end
|
71
|
+
|
72
|
+
class << self
|
73
|
+
def title
|
74
|
+
"CompassAE Scaffold"
|
75
|
+
end
|
76
|
+
|
77
|
+
def widget_name
|
78
|
+
File.basename(File.dirname(__FILE__))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end#Base
|
82
|
+
end#Scaffold
|
83
|
+
end#Widgets
|
@@ -0,0 +1,339 @@
|
|
1
|
+
Compass.ErpApp.Widgets.Scaffold = {
|
2
|
+
addScaffoldWidget:function () {
|
3
|
+
var sm = Ext.create('Ext.selection.CheckboxModel');
|
4
|
+
|
5
|
+
Ext.create("Ext.window.Window", {
|
6
|
+
layout:'fit',
|
7
|
+
title:'Add Scaffold',
|
8
|
+
autoScroll:true,
|
9
|
+
plain:true,
|
10
|
+
buttonAlign:'center',
|
11
|
+
items:Ext.create("Ext.form.Panel", {
|
12
|
+
autoScroll:true,
|
13
|
+
width:420,
|
14
|
+
height:500,
|
15
|
+
frame:false,
|
16
|
+
bodyStyle:'padding:5px 5px 0',
|
17
|
+
items:[
|
18
|
+
{
|
19
|
+
xtype:'combo',
|
20
|
+
forceSelection:true,
|
21
|
+
store:{
|
22
|
+
model:'ScaffoldModelName',
|
23
|
+
proxy:{
|
24
|
+
url:'/erp_app/desktop/scaffold/get_models',
|
25
|
+
type:'ajax',
|
26
|
+
reader:{
|
27
|
+
type:'json',
|
28
|
+
root:'names'
|
29
|
+
}
|
30
|
+
},
|
31
|
+
fields:[
|
32
|
+
{name:'name', type:'string'}
|
33
|
+
]
|
34
|
+
},
|
35
|
+
displayField:'name',
|
36
|
+
valueField:'name',
|
37
|
+
labelWidth:125,
|
38
|
+
fieldLabel:'CompassAE Model',
|
39
|
+
value:':Party',
|
40
|
+
name:'model',
|
41
|
+
allowBlank:false,
|
42
|
+
triggerAction:'all',
|
43
|
+
listeners:{
|
44
|
+
select:function (combo, records) {
|
45
|
+
var form = combo.up('form'), grid = form.down('grid');
|
46
|
+
grid.getStore().load({params:{model:records[0].get('name')}});
|
47
|
+
grid.enable();
|
48
|
+
form.down('#scaffoldOptions').enable();
|
49
|
+
form.down('#gridOptions').enable();
|
50
|
+
}
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
xtype:'fieldset',
|
55
|
+
style:'padding:5px',
|
56
|
+
title:'Columns',
|
57
|
+
items:[
|
58
|
+
{
|
59
|
+
xtype:'grid',
|
60
|
+
selModel:sm,
|
61
|
+
loadMask:true,
|
62
|
+
disabled:true,
|
63
|
+
autoScroll:true,
|
64
|
+
columns:[
|
65
|
+
{text:"Column Name", width:200, dataIndex:'name'},
|
66
|
+
{
|
67
|
+
xtype:'checkcolumn',
|
68
|
+
header:'Required?',
|
69
|
+
dataIndex:'required',
|
70
|
+
width:70,
|
71
|
+
stopSelection:true
|
72
|
+
},
|
73
|
+
{
|
74
|
+
xtype:'checkcolumn',
|
75
|
+
header:'Readonly?',
|
76
|
+
dataIndex:'readonly',
|
77
|
+
width:70,
|
78
|
+
stopSelection:true
|
79
|
+
}
|
80
|
+
],
|
81
|
+
store:{
|
82
|
+
model:'ScaffoldColumn',
|
83
|
+
proxy:{
|
84
|
+
url:'/erp_app/desktop/scaffold/get_columns',
|
85
|
+
type:'ajax',
|
86
|
+
reader:{
|
87
|
+
type:'json',
|
88
|
+
root:'columns'
|
89
|
+
}
|
90
|
+
},
|
91
|
+
fields:[
|
92
|
+
{name:'name', type:'string'},
|
93
|
+
{name:'readonly', type:'boolean', default:false},
|
94
|
+
{name:'required', type:'boolean', default:false}
|
95
|
+
]
|
96
|
+
},
|
97
|
+
columnLines:true,
|
98
|
+
height:150,
|
99
|
+
frame:true
|
100
|
+
}
|
101
|
+
]
|
102
|
+
},
|
103
|
+
{
|
104
|
+
xtype:'fieldset',
|
105
|
+
title:'Scaffold Options',
|
106
|
+
itemId:'scaffoldOptions',
|
107
|
+
disabled:true,
|
108
|
+
defaults:{
|
109
|
+
xtype:'fieldcontainer',
|
110
|
+
defaultType:'radiofield',
|
111
|
+
width:200,
|
112
|
+
defaults:{
|
113
|
+
flex:1
|
114
|
+
},
|
115
|
+
layout:'hbox'
|
116
|
+
},
|
117
|
+
items:[
|
118
|
+
{
|
119
|
+
fieldLabel:'Ignore Associations',
|
120
|
+
items:[
|
121
|
+
{
|
122
|
+
boxLabel:'Yes',
|
123
|
+
name:'ignoreAssociations',
|
124
|
+
checked:true,
|
125
|
+
inputValue:'y'
|
126
|
+
},
|
127
|
+
{
|
128
|
+
boxLabel:'No',
|
129
|
+
name:'ignoreAssociations',
|
130
|
+
inputValue:'n'
|
131
|
+
}
|
132
|
+
]
|
133
|
+
},
|
134
|
+
{
|
135
|
+
fieldLabel:'Show ID',
|
136
|
+
items:[
|
137
|
+
{
|
138
|
+
boxLabel:'Yes',
|
139
|
+
name:'showId',
|
140
|
+
checked:true,
|
141
|
+
inputValue:'y'
|
142
|
+
},
|
143
|
+
{
|
144
|
+
boxLabel:'No',
|
145
|
+
name:'showId',
|
146
|
+
inputValue:'n'
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
{
|
151
|
+
fieldLabel:'Show Timestamps',
|
152
|
+
items:[
|
153
|
+
{
|
154
|
+
boxLabel:'Yes',
|
155
|
+
name:'showTimestamps',
|
156
|
+
checked:true,
|
157
|
+
inputValue:'y'
|
158
|
+
},
|
159
|
+
{
|
160
|
+
boxLabel:'No',
|
161
|
+
name:'showTimestamps',
|
162
|
+
inputValue:'n'
|
163
|
+
}
|
164
|
+
]
|
165
|
+
}
|
166
|
+
]
|
167
|
+
},
|
168
|
+
{
|
169
|
+
xtype:'fieldset',
|
170
|
+
title:'Grid Options',
|
171
|
+
itemId:'gridOptions',
|
172
|
+
disabled:true,
|
173
|
+
items:[
|
174
|
+
{
|
175
|
+
xtype:'textfield',
|
176
|
+
name:'title',
|
177
|
+
fieldLabel:'Title'
|
178
|
+
},
|
179
|
+
{
|
180
|
+
xtype:'textfield',
|
181
|
+
name:'width',
|
182
|
+
value:500,
|
183
|
+
fieldLabel:'Width'
|
184
|
+
},
|
185
|
+
{
|
186
|
+
xtype:'textfield',
|
187
|
+
name:'height',
|
188
|
+
value:500,
|
189
|
+
fieldLabel:'Height'
|
190
|
+
},
|
191
|
+
{
|
192
|
+
xtype:'fieldcontainer',
|
193
|
+
defaultType:'radiofield',
|
194
|
+
width:200,
|
195
|
+
defaults:{
|
196
|
+
flex:1
|
197
|
+
},
|
198
|
+
layout:'hbox',
|
199
|
+
fieldLabel:'Page Results',
|
200
|
+
toolTip:'Page results.',
|
201
|
+
items:[
|
202
|
+
{
|
203
|
+
boxLabel:'Yes',
|
204
|
+
name:'page_results',
|
205
|
+
checked:true,
|
206
|
+
inputValue:'y'
|
207
|
+
},
|
208
|
+
{
|
209
|
+
boxLabel:'No',
|
210
|
+
name:'page_results',
|
211
|
+
inputValue:'n'
|
212
|
+
}
|
213
|
+
]
|
214
|
+
},
|
215
|
+
{
|
216
|
+
xtype:'textfield',
|
217
|
+
name:'pageSize',
|
218
|
+
value:20,
|
219
|
+
fieldLabel:'Rows per Page'
|
220
|
+
},
|
221
|
+
{
|
222
|
+
xtype:'textfield',
|
223
|
+
name:'displayMsg',
|
224
|
+
value:'Displaying {0} - {1} of {2}',
|
225
|
+
fieldLabel:'Paging Display Message'
|
226
|
+
},
|
227
|
+
{
|
228
|
+
xtype:'textfield',
|
229
|
+
name:'emptyMsg',
|
230
|
+
value:'Empty',
|
231
|
+
fieldLabel:'Empty Message'
|
232
|
+
},
|
233
|
+
{
|
234
|
+
xtype:'fieldcontainer',
|
235
|
+
defaultType:'radiofield',
|
236
|
+
width:200,
|
237
|
+
defaults:{
|
238
|
+
flex:1
|
239
|
+
},
|
240
|
+
layout:'hbox',
|
241
|
+
fieldLabel:'Allow Edits',
|
242
|
+
toolTip:'Allow users to edit data.',
|
243
|
+
items:[
|
244
|
+
{
|
245
|
+
boxLabel:'Yes',
|
246
|
+
name:'editiable',
|
247
|
+
checked:true,
|
248
|
+
inputValue:'y'
|
249
|
+
},
|
250
|
+
{
|
251
|
+
boxLabel:'No',
|
252
|
+
name:'editiable',
|
253
|
+
inputValue:'n'
|
254
|
+
}
|
255
|
+
]
|
256
|
+
}
|
257
|
+
]
|
258
|
+
}
|
259
|
+
]
|
260
|
+
}),
|
261
|
+
buttons:[
|
262
|
+
{
|
263
|
+
text:'Submit',
|
264
|
+
listeners:{
|
265
|
+
'click':function (button) {
|
266
|
+
var tpl = new Ext.XTemplate("<%= render_widget :scaffold, :params => {:model => '{model}',\n",
|
267
|
+
" :scaffold => {\n",
|
268
|
+
" :ignore_associations => {ignoreAssociations:this.toBoolean},\n",
|
269
|
+
" :show_id => {showId:this.toBoolean},\n",
|
270
|
+
" :show_timestamps => {showTimestamps:this.toBoolean},\n",
|
271
|
+
" :only => [\n",
|
272
|
+
'<tpl for="columns">',
|
273
|
+
" {:{name} => {:required => {required:this.toBoolean}, :readonly => {readonly:this.toBoolean}}},\n",
|
274
|
+
'</tpl>',
|
275
|
+
" ]\n",
|
276
|
+
" },\n",
|
277
|
+
" :grid => {\n",
|
278
|
+
" :editable => {editiable:this.toBoolean},\n",
|
279
|
+
" :title => '{title}',\n",
|
280
|
+
" :width => {width},\n",
|
281
|
+
" :height => {height},\n",
|
282
|
+
" :page => {page_results:this.toBoolean},\n",
|
283
|
+
" :page_size => {pageSize},\n",
|
284
|
+
" :display_msg => '{displayMsg}',\n",
|
285
|
+
" :empty_msg => '{emptyMsg}'\n",
|
286
|
+
" }\n",
|
287
|
+
"} %>",
|
288
|
+
{
|
289
|
+
toBoolean:function (value) {
|
290
|
+
var result = 'false';
|
291
|
+
if (value == 'y') {
|
292
|
+
result = 'true';
|
293
|
+
}
|
294
|
+
return result;
|
295
|
+
}
|
296
|
+
}),
|
297
|
+
content = null,
|
298
|
+
window = button.findParentByType('window'),
|
299
|
+
formPanel = window.query('form')[0],
|
300
|
+
grid = formPanel.down('grid'),
|
301
|
+
basicForm = formPanel.getForm(),
|
302
|
+
values = basicForm.getValues();
|
303
|
+
|
304
|
+
var data = values;
|
305
|
+
data['columns'] = [];
|
306
|
+
|
307
|
+
var columns = Ext.each(grid.getSelectionModel().getSelection(), function (record) {
|
308
|
+
data['columns'].push({
|
309
|
+
name:record.get('name'),
|
310
|
+
readonly:record.get('readonly'),
|
311
|
+
required:record.get('required')
|
312
|
+
});
|
313
|
+
});
|
314
|
+
|
315
|
+
content = tpl.apply(data);
|
316
|
+
|
317
|
+
//add rendered template to center region editor
|
318
|
+
Ext.getCmp('knitkitCenterRegion').addContentToActiveCodeMirror(content);
|
319
|
+
button.up('window').close();
|
320
|
+
}
|
321
|
+
}
|
322
|
+
},
|
323
|
+
{
|
324
|
+
text:'Close',
|
325
|
+
handler:function (btn) {
|
326
|
+
btn.up('window').close();
|
327
|
+
}
|
328
|
+
}
|
329
|
+
]
|
330
|
+
}).show();
|
331
|
+
}
|
332
|
+
}
|
333
|
+
|
334
|
+
Compass.ErpApp.Widgets.AvailableWidgets.push({
|
335
|
+
name:'CompassAE Scaffold',
|
336
|
+
iconUrl:'/images/icons/grid/grid_48x48.png',
|
337
|
+
onClick:Compass.ErpApp.Widgets.Scaffold.addScaffoldWidget,
|
338
|
+
about:'Scaffold a CompassAE model'
|
339
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div id="scaffoldGrid_<%=@uuid%>"></div>
|
2
|
+
|
3
|
+
<%=
|
4
|
+
dynamic_extjs_grid(:renderTo => "scaffoldGrid_#{@uuid}",
|
5
|
+
:title => @title,
|
6
|
+
:setupUrl => build_widget_url('setup', nil, {:model => @model}),
|
7
|
+
:dataUrl => build_widget_url('data', nil, {:model => @model}),
|
8
|
+
:width => @width,
|
9
|
+
:height => @height,
|
10
|
+
:page => @page,
|
11
|
+
:pageSize => @page_size,
|
12
|
+
:displayMsg => @display_msg,
|
13
|
+
:editable => @editable,
|
14
|
+
:emptyMsg => @empty_msg)
|
15
|
+
%>
|