padrino-admin 0.6.7 → 0.7.0
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/README.rdoc +46 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/padrino-admin.rb +6 -0
- data/lib/padrino-admin/generators/admin_app.rb +2 -5
- data/lib/padrino-admin/generators/admin_uploader.rb +6 -4
- data/lib/padrino-admin/generators/app/public/stylesheets/standard.css +4 -9
- data/lib/padrino-admin/generators/app/views/javascripts/admin.js.erb +47 -39
- data/lib/padrino-admin/generators/templates/page/views/edit.haml.tt +1 -1
- data/lib/padrino-admin/generators/templates/page/views/new.haml.tt +1 -1
- data/lib/padrino-admin/generators/templates/uploader/lib/uploader.rb +1 -1
- data/lib/padrino-admin/generators/templates/uploader/views/grid.js.erb +1 -0
- data/lib/padrino-admin/helpers/authentication.rb +1 -1
- data/lib/padrino-admin/helpers/view.rb +23 -17
- data/lib/padrino-admin/locale/admin/en.yml +1 -0
- data/padrino-admin.gemspec +11 -8
- data/test/test_active_record.rb +7 -0
- data/test/test_data_mapper.rb +7 -0
- metadata +14 -4
data/README.rdoc
CHANGED
@@ -89,7 +89,52 @@ All upload definitions are defined in lib/uploader.rb, here you can preproces yo
|
|
89
89
|
|
90
90
|
See http://github.com/jnicklas/carrierwave
|
91
91
|
|
92
|
-
|
92
|
+
==== Attach Many Uploads to a Model
|
93
|
+
|
94
|
+
If you want attach in a model ex: Account many uploads you can do that in a simple way add a habtm relation!
|
95
|
+
|
96
|
+
# app/models/account.rb
|
97
|
+
has n, :uploads
|
98
|
+
|
99
|
+
or for ActiveRecord
|
100
|
+
|
101
|
+
# app/models/account.rb
|
102
|
+
has_and_belongs_to_many :uploads
|
103
|
+
|
104
|
+
Now edit the form and add these lines:
|
105
|
+
|
106
|
+
# admin/views/accounts/_form.haml
|
107
|
+
%tr
|
108
|
+
%td=f.label :uploads
|
109
|
+
%td=f.open_window_grid :upload_ids, :with => :uploads, :get => :id, :show => :file, :multiple => true, :item => :panel
|
110
|
+
|
111
|
+
*open_window_grid* is a padrino-admin method that open an extjs window contains your +grids+ so in this case:
|
112
|
+
|
113
|
+
open window grid for :+account+ model in method :+upload_ids+ with the help of controller :+uploads+ and
|
114
|
+
get as a value the :+id+ and display :+file+.
|
115
|
+
|
116
|
+
:+multiple+ indicate that we need more than one :+id+.
|
117
|
+
:+item+ tell to the grid who is the container, we need to explicit this because we have two container in our upload.js
|
118
|
+
|
119
|
+
See view helpers[http://github.com/padrino/padrino-framework/blob/master/padrino-admin/lib/padrino-admin/helpers/view.rb#L145] for more docs.
|
120
|
+
|
121
|
+
That's all! Now run mingrations and browse accounts for see our uploader.
|
122
|
+
|
123
|
+
==== Attach One Upload to a Model
|
124
|
+
|
125
|
+
The process is the same as above you need only define in your model:
|
126
|
+
|
127
|
+
# app/models/account.rb
|
128
|
+
belongs_to :upload
|
129
|
+
|
130
|
+
and add this to your account form:
|
131
|
+
|
132
|
+
# admin/views/accounts/_form.haml
|
133
|
+
%tr
|
134
|
+
%td=f.label :upload
|
135
|
+
%td=f.open_window_grid :upload_id, :with => :uploads, :get => :id, :show => :file, :item => :panel
|
136
|
+
|
137
|
+
Remember to run migrations before start your server.
|
93
138
|
|
94
139
|
== Copyright
|
95
140
|
|
data/Rakefile
CHANGED
@@ -15,6 +15,7 @@ begin
|
|
15
15
|
gem.add_runtime_dependency "json_pure", ">= 1.2.0"
|
16
16
|
gem.add_runtime_dependency "padrino-core", "= #{GEM_VERSION}"
|
17
17
|
gem.add_runtime_dependency "padrino-gen", "= #{GEM_VERSION}"
|
18
|
+
gem.add_runtime_dependency "padrino-helpers", "= #{GEM_VERSION}"
|
18
19
|
gem.add_runtime_dependency "tilt", ">= 0.4"
|
19
20
|
gem.add_development_dependency "haml", ">= 2.2.1"
|
20
21
|
gem.add_development_dependency "shoulda", ">= 0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/lib/padrino-admin.rb
CHANGED
@@ -2,6 +2,7 @@ require 'tilt'
|
|
2
2
|
require 'thor'
|
3
3
|
require 'padrino-core'
|
4
4
|
require 'padrino-gen'
|
5
|
+
require 'padrino-helpers'
|
5
6
|
|
6
7
|
Dir[File.dirname(__FILE__) + '/padrino-admin/*.rb'].each {|file| require file }
|
7
8
|
Dir[File.dirname(__FILE__) + '/padrino-admin/{helpers,orm,generators,middleware,utils}/*.rb'].each {|file| require file }
|
@@ -23,6 +24,11 @@ Padrino::Application.send(:access_control=, Class.new(Padrino::AccessControl::Ba
|
|
23
24
|
#
|
24
25
|
CarrierWave.root = Padrino.root if defined?(CarrierWave)
|
25
26
|
|
27
|
+
##
|
28
|
+
# Extend Abastract Form builder
|
29
|
+
#
|
30
|
+
Padrino::Helpers::FormBuilder::AbstractFormBuilder.send(:include, Padrino::Admin::Helpers::AbstractFormBuilder)
|
31
|
+
|
26
32
|
##
|
27
33
|
# Load our Padrino::Admin locales
|
28
34
|
#
|
@@ -53,11 +53,8 @@ module Padrino
|
|
53
53
|
-----------------------------------------------------------------
|
54
54
|
Your admin now is installed, now follow this steps:
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
- run padrino rake seed
|
59
|
-
|
60
|
-
That's all
|
56
|
+
1) Run migrations
|
57
|
+
2) That's all!!
|
61
58
|
-----------------------------------------------------------------
|
62
59
|
|
63
60
|
TEXT
|
@@ -67,10 +67,12 @@ module Padrino
|
|
67
67
|
|
68
68
|
say (<<-TEXT).gsub(/ {10}/,'')
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
--------------------------------------------------------
|
71
|
+
Your admin uploader is installed, now follow this steps:
|
72
|
+
|
73
|
+
1) Run migrations
|
74
|
+
2) That's all!!
|
75
|
+
--------------------------------------------------------
|
74
76
|
|
75
77
|
TEXT
|
76
78
|
else
|
@@ -1,10 +1,3 @@
|
|
1
|
-
/*
|
2
|
-
* Lipsiasadmin
|
3
|
-
* Copyright(c) 2007-2008, LipsiaSoft s.r.l.
|
4
|
-
* info@lipsiasoft.com
|
5
|
-
*
|
6
|
-
* http://www.lipsiasoft.com
|
7
|
-
*/
|
8
1
|
body { font-size:12px; font-family:"Myriad Pro","Myriad Web","Tahoma","Helvetica","Arial",sans-serif; padding:0; margin:0; color:#222; }
|
9
2
|
table { font-size:12px; font-family:"Myriad Pro","Myriad Web","Tahoma","Helvetica","Arial",sans-serif; }
|
10
3
|
table.form { padding:10px; }
|
@@ -63,5 +56,7 @@ input,textarea{margin:0;font:normal 12px tahoma,arial,helvetica,sans-serif;width
|
|
63
56
|
input,textarea{padding:1px 3px;background:#fff url(../images/ext/default/form/text-bg.gif) repeat-x 0 0;border:1px solid #B5B8C8;}
|
64
57
|
input{height:22px;line-height:18px;vertical-align:middle;}
|
65
58
|
/* Errors */
|
66
|
-
.
|
67
|
-
.
|
59
|
+
.field-errors{border:2px solid red;background-color:#ECEBC3;padding:10px;margin-top:5px;margin-bottom:5px;}
|
60
|
+
.field-errors h2{font-size:1.2em}
|
61
|
+
.field-errors ul{list-style-type: disc;margin-left:25px;margin-top:10px;display:block;}
|
62
|
+
.field-errors ul li{margin-left:0px;padding-top:5px;margin:0px;}
|
@@ -91,6 +91,14 @@ Admin.app = function(){
|
|
91
91
|
this.cleanScripts();
|
92
92
|
this.clean();
|
93
93
|
Ext.History.add(url, true);
|
94
|
+
// Enable this for debug errors:
|
95
|
+
// // We append the js into the head so we can easy inspect errors
|
96
|
+
// var hd = document.getElementsByTagName("head")[0];
|
97
|
+
// var s = document.createElement("script");
|
98
|
+
// s.src = url;
|
99
|
+
// s.type = 'text/javascript';
|
100
|
+
// // Now we can append the child.
|
101
|
+
// hd.appendChild(s);
|
94
102
|
Ext.Ajax.request({ url: url, nocache:true });
|
95
103
|
} else if (ext == 'html'){
|
96
104
|
this.loadWidget(url);
|
@@ -222,7 +230,7 @@ Admin.app = function(){
|
|
222
230
|
defaults: { autoScroll:true, layout:'fit' }
|
223
231
|
});
|
224
232
|
|
225
|
-
this.tabPanel
|
233
|
+
this.addItem(this.tabPanel);
|
226
234
|
}
|
227
235
|
|
228
236
|
this.fireEvent('contentLoaded');
|
@@ -264,7 +272,6 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
264
272
|
title: 'Grid',
|
265
273
|
baseUrl: '',
|
266
274
|
region: "center",
|
267
|
-
viewConfig: { forceFit: true },
|
268
275
|
border: false,
|
269
276
|
buttons: ['add', 'edit', 'remove'],
|
270
277
|
search: true,
|
@@ -275,65 +282,50 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
275
282
|
|
276
283
|
initComponent: function(){
|
277
284
|
// Prepare our View/Cm/Sm
|
278
|
-
this.view = new Ext.grid.GroupingView({ forceFit: true })
|
279
|
-
this.
|
280
|
-
this.column_fields.unshift(
|
281
|
-
this.
|
285
|
+
this.view = new Ext.grid.GroupingView({ forceFit: true });
|
286
|
+
this.selModel = new Ext.grid.CheckboxSelectionModel();
|
287
|
+
this.column_fields.unshift(this.selModel);
|
288
|
+
this.colModel = new Ext.grid.ColumnModel({ columns: this.column_fields });
|
282
289
|
// Toolbar
|
283
290
|
if (this.buttons.length > 0 || this.search){ this.tbar = new Ext.Toolbar() };
|
284
291
|
// Add Buttons
|
285
292
|
Ext.each(this.buttons, function(button){
|
286
293
|
switch(button){
|
287
294
|
case 'add':
|
288
|
-
this.tbar.addButton({
|
295
|
+
this.btnAdd = this.tbar.addButton({
|
289
296
|
handler: this.addRecord,
|
290
297
|
text: Admin.locale.buttons.add,
|
291
298
|
disabled: false,
|
292
299
|
scope: this,
|
293
300
|
cls: "x-btn-text-icon add",
|
294
|
-
|
301
|
+
name: "add"
|
295
302
|
});
|
296
303
|
break;
|
297
304
|
case 'edit':
|
298
|
-
this.tbar.addButton({
|
305
|
+
this.btnEdit = this.tbar.addButton({
|
299
306
|
handler: this.editRecord,
|
300
307
|
text: Admin.locale.buttons.edit,
|
301
308
|
disabled: true,
|
302
309
|
scope: this,
|
303
310
|
cls: "x-btn-text-icon edit",
|
304
|
-
|
311
|
+
name: "edit"
|
305
312
|
});
|
306
|
-
break
|
313
|
+
break;
|
307
314
|
case 'remove':
|
308
|
-
this.tbar.addButton({
|
315
|
+
this.btnRemove = this.tbar.addButton({
|
309
316
|
handler: this.removeRecord,
|
310
317
|
text: Admin.locale.buttons.remove,
|
311
318
|
disabled: true,
|
312
319
|
scope: this,
|
313
320
|
cls: "x-btn-text-icon remove",
|
314
|
-
|
321
|
+
name: "remove"
|
315
322
|
});
|
323
|
+
break;
|
316
324
|
}
|
317
325
|
}, this);
|
318
326
|
this.buttons = undefined; // Remove all bbar buttons, we don't want them in the bottom of grid.
|
319
|
-
// Now we need to add some handlers for activate/deactivate buttons
|
320
|
-
this.sm.on('selectionchange', function(){
|
321
|
-
var n = this.getSelectionModel().getSelected();
|
322
|
-
var btns = this.getTopToolbar().items.map;
|
323
|
-
if(!n){
|
324
|
-
if (btns.remove){ btns.remove.disable() };
|
325
|
-
if (btns.edit){ btns.edit.disable() };
|
326
|
-
} else {
|
327
|
-
if (btns.remove){ btns.remove.enable() };
|
328
|
-
if (btns.edit){ btns.edit.enable() };
|
329
|
-
}
|
330
|
-
}, this);
|
331
327
|
// Add search functions
|
332
328
|
if (this.search){ this.plugins = [new Ext.grid.Search()] };
|
333
|
-
// Add dblclick
|
334
|
-
this.on("dblclick", function() {
|
335
|
-
if (this.getTopToolbar().items.map.edit){ this.editRecord() }
|
336
|
-
}, this);
|
337
329
|
// Build our store
|
338
330
|
this.store = new Ext.data.GroupingStore({
|
339
331
|
remoteSort: true,
|
@@ -346,8 +338,6 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
346
338
|
id: "id"
|
347
339
|
})
|
348
340
|
});
|
349
|
-
this.store.on('beforeload', function(){ this.el.mask(); }, this);
|
350
|
-
this.store.on('load', function(){ this.el.unmask(); }, this);
|
351
341
|
// Build bbar
|
352
342
|
this.bbar = new Ext.PagingToolbar({
|
353
343
|
pageSize: 50,
|
@@ -356,8 +346,23 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
356
346
|
});
|
357
347
|
// Call our superclass
|
358
348
|
Admin.grid.superclass.initComponent.call(this);
|
359
|
-
// Now we
|
349
|
+
// Now we need to add some handlers for activate/deactivate buttons
|
360
350
|
this.on('render', function(){ this.store.load() }, this);
|
351
|
+
this.selModel.on('selectionchange', function(){
|
352
|
+
var n = this.selModel.getSelected();
|
353
|
+
if(!n){
|
354
|
+
if (this.btnRemove){ this.btnRemove.disable() };
|
355
|
+
if (this.btnEdit){ this.btnEdit.disable() };
|
356
|
+
} else {
|
357
|
+
if (this.btnRemove){ this.btnRemove.enable() };
|
358
|
+
if (this.btnEdit){ this.btnEdit.enable() };
|
359
|
+
}
|
360
|
+
}, this);
|
361
|
+
this.on("dblclick", function() {
|
362
|
+
if (this.btnEdit){ this.editRecord() }
|
363
|
+
}, this);
|
364
|
+
this.store.on('beforeload', function(){ this.el.mask(); }, this);
|
365
|
+
this.store.on('load', function(){ this.el.unmask(); }, this);
|
361
366
|
}, // initComponent
|
362
367
|
|
363
368
|
addRecord: function(){
|
@@ -365,17 +370,22 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
365
370
|
}, // addRecord
|
366
371
|
|
367
372
|
editRecord: function(){
|
368
|
-
|
369
|
-
|
370
|
-
Admin.
|
371
|
-
}
|
373
|
+
var selections = this.selModel.getSelections();
|
374
|
+
if (selections.length > 10) {
|
375
|
+
Admin.showAlert(Admin.locale.messages.alert.tooMany);
|
376
|
+
} else {
|
377
|
+
Ext.each(selections, function(selection){
|
378
|
+
var id = this.baseUrl + '-edit-' + selection.id;
|
379
|
+
Admin.app.loadWidget(this.baseUrl + '/edit/' + selection.id);
|
380
|
+
}, this);
|
381
|
+
}
|
372
382
|
}, // editRecord
|
373
383
|
|
374
384
|
removeRecord: function(){
|
375
385
|
Ext.Msg.confirm(Admin.locale.messages.confirm.title, String.format(Admin.locale.messages.confirm.message, this.getSelectionModel().getCount()), function(btn, text){
|
376
386
|
if (btn == 'yes'){
|
377
387
|
Admin.app.mask();
|
378
|
-
var records = this.
|
388
|
+
var records = this.selModel.getSelections();
|
379
389
|
var store = this.store;
|
380
390
|
Ext.Ajax.request({
|
381
391
|
url: this.baseUrl + '/destroy.json',
|
@@ -403,7 +413,6 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
403
413
|
Admin.window = Ext.extend(Ext.Window, {
|
404
414
|
width: 700,
|
405
415
|
layout: 'fit',
|
406
|
-
autoScroll: true,
|
407
416
|
maximizable: true,
|
408
417
|
bodyStyle: 'background-color:#FFF',
|
409
418
|
grid: undefined,
|
@@ -422,7 +431,6 @@ Admin.window = Ext.extend(Ext.Window, {
|
|
422
431
|
handler: this[this.closeAction].createDelegate(this, [])
|
423
432
|
});
|
424
433
|
if (this.grid){
|
425
|
-
this.border = false;
|
426
434
|
this.addButton({
|
427
435
|
text: Admin.locale.buttons.select,
|
428
436
|
handler: this.closeWithSelections.createDelegate(this, [])}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
=title "Edit <%= @model_name %>"
|
2
|
-
-form_for
|
2
|
+
-form_for :<%= @model_singular %>, url(:<%= @model_plural %>_update, :id => @<%= @model_singular %>.id, :format => :js), :method => :put, :remote => true do |f|
|
3
3
|
=partial '<%= @model_plural %>/form', :locals => { :f => f }
|
@@ -1,3 +1,3 @@
|
|
1
1
|
=title "New <%= @model_plural %>"
|
2
|
-
-form_for
|
2
|
+
-form_for :<%= @model_singular %>, url(:<%= @model_plural %>_create, :format => :js), :remote => true do |f|
|
3
3
|
=partial '<%= @model_plural %>/form', :locals => { :f => f }
|
@@ -67,7 +67,7 @@ module Padrino
|
|
67
67
|
# if the account is not allowed/logged return it to a default page
|
68
68
|
#
|
69
69
|
def redirect_back_or_default(default)
|
70
|
-
|
70
|
+
redirect(session[:return_to] || default)
|
71
71
|
session[:return_to] = nil
|
72
72
|
end
|
73
73
|
|
@@ -21,7 +21,7 @@ module Padrino
|
|
21
21
|
def show_messages_for(*objects)
|
22
22
|
options = objects.extract_options!.symbolize_keys
|
23
23
|
count = objects.inject(0) {|sum, object| sum + object.errors.count }
|
24
|
-
error_cleaner = objects.map{|object| object.class.properties.map{|k| "
|
24
|
+
error_cleaner = objects.map{|object| object.class.properties.map {|k| "var x = parent.body.select('*[id=#{object.class.to_s.downcase}_#{k.name}]').first(); if (x) { x.removeClass('x-form-invalid') };" } }.join("\n")
|
25
25
|
|
26
26
|
unless count.zero?
|
27
27
|
html = {}
|
@@ -37,12 +37,13 @@ module Padrino
|
|
37
37
|
end
|
38
38
|
message = escape_javascript(options.include?(:message) ? options[:message] : locale.t(:body))
|
39
39
|
error_messages = objects.map {|object| object.errors.full_messages.map {|msg| content_tag(:li, escape_javascript(msg)) } }.join
|
40
|
-
error_highlighter = objects.map {|object| object.errors_keys.map{ |k| "
|
40
|
+
error_highlighter = objects.map {|object| object.errors_keys.map{ |k| "var x = parent.body.select('*[id=#{object.class.to_s.downcase}_#{k}]').first(); x.addClass('x-form-invalid');" } }.join("\n")
|
41
41
|
contents = ''
|
42
42
|
contents << content_tag(:p, message) if message.present?
|
43
43
|
contents << content_tag(:ul, error_messages, :class => :list)
|
44
|
-
|
44
|
+
|
45
45
|
(<<-JAVASCRIPT).gsub(/ {14}/, '')
|
46
|
+
var parent = Ext.WindowMgr.getActive();
|
46
47
|
#{error_cleaner}
|
47
48
|
Ext.Msg.show({
|
48
49
|
title: '#{header_message}',
|
@@ -55,6 +56,7 @@ module Padrino
|
|
55
56
|
end
|
56
57
|
else
|
57
58
|
(<<-JAVASCRIPT).gsub(/ {12}/, '')
|
59
|
+
var parent = Ext.WindowMgr.getActive();
|
58
60
|
#{error_cleaner}
|
59
61
|
Ext.Msg.alert(Admin.locale.messages.compliments.title, Admin.locale.messages.compliments.message);
|
60
62
|
JAVASCRIPT
|
@@ -71,16 +73,9 @@ module Padrino
|
|
71
73
|
# tab :settings do
|
72
74
|
# ...
|
73
75
|
#
|
74
|
-
|
75
|
-
#
|
76
|
-
# Third argument is an hash that accepts:
|
77
|
-
#
|
78
|
-
# :id:: The id of the tab
|
79
|
-
# :style:: Custom style of the tab
|
80
|
-
#
|
81
|
-
def tab(name, padding=true, options={}, &block)
|
76
|
+
def tab(name, options={}, &block)
|
82
77
|
options[:id] ||= name.to_s.downcase.gsub(/[^a-z0-9]+/, '_').gsub(/-+$/, '').gsub(/^-+$/, '')
|
83
|
-
options[:style]
|
78
|
+
options[:style] = "padding:10px;#{options[:style]}"
|
84
79
|
options[:title] = name.is_a?(Symbol) ? I18n.t("admin.tabs.#{name.to_s.downcase}", :default => name.to_s.humanize) : name
|
85
80
|
options[:tabbed] = true
|
86
81
|
options[:class] = "x-hide-display"
|
@@ -225,7 +220,8 @@ module Padrino
|
|
225
220
|
end
|
226
221
|
|
227
222
|
# And we add our link for add new records
|
228
|
-
|
223
|
+
li_link = content_tag(:li, link_to(options[:prompt], "#", :onclick => "#{options[:function]}(); return false;"), :class => :clean)
|
224
|
+
collection << li_link
|
229
225
|
|
230
226
|
# Now we have the final container
|
231
227
|
container = content_tag(:ul, collection.join.gsub("\\",""), :id => "#{object_name}_#{method}", :class => "open-window-grid")
|
@@ -234,30 +230,33 @@ module Padrino
|
|
234
230
|
show = "data['#{controller}.#{options[:show]}']" if options[:show].is_a?(Symbol)
|
235
231
|
get = options[:get].is_a?(Symbol) && options[:get] != :id ? "data['#{controller}.#{options[:get]}']" : options[:get]
|
236
232
|
|
233
|
+
# Updater handler
|
237
234
|
update_function = if options[:multiple]
|
238
235
|
(<<-JAVASCRIPT).gsub(/ {12}/, "")
|
236
|
+
var parent = win.parent.body.select("*[id=#{object_name}_#{method}]").first();
|
239
237
|
Ext.each(selections, function(selection){
|
240
238
|
var template = String.format('#{template.gsub(/\n/,"")}', selection.#{show}, selection.#{get});
|
241
|
-
|
239
|
+
parent.insertHtml('afterBegin', template);
|
242
240
|
});
|
243
241
|
JAVASCRIPT
|
244
242
|
else
|
245
243
|
(<<-JAVASCRIPT).gsub(/ {12}/, "")
|
246
244
|
var selection = selections.first();
|
247
|
-
var template = String.format('#{template.gsub(/\n/,"")}', selection.#{show}, selection.#{get});
|
248
|
-
|
245
|
+
var template = String.format('#{template.gsub(/\n/,"")}', selection.#{show}, selection.#{get}) + '#{li_link}';
|
246
|
+
win.parent.body.select("*[id=#{object_name}_#{method}]").first().update(template);
|
249
247
|
JAVASCRIPT
|
250
248
|
end
|
251
249
|
|
252
250
|
# Now we build the update function (if not present)
|
253
251
|
javascript = (<<-JAVASCRIPT).gsub(/ {10}/, '')
|
254
252
|
function #{options[:function]}(){
|
253
|
+
var me = Ext.WindowMgr.getActive();
|
255
254
|
Ext.Ajax.request({
|
256
255
|
url: '#{options[:url]}',
|
257
256
|
scripts: false,
|
258
257
|
success: function(response){
|
259
258
|
try { eval(response.responseText) } catch(e) { Admin.app.error(e) };
|
260
|
-
var win = new Admin.window({ grid: #{options[:grid]}, item: #{options[:item]}, width: 800, height:
|
259
|
+
var win = new Admin.window({ grid: #{options[:grid]}, item: #{options[:item]}, width: 800, height:600, modal: true, parent:me });
|
261
260
|
win.on('selected', function(win, selections){
|
262
261
|
#{update_function}
|
263
262
|
});
|
@@ -270,6 +269,13 @@ module Padrino
|
|
270
269
|
# Now we return our html code
|
271
270
|
[content_tag(:script, javascript, :type => 'text/javascript'), container, tag(:div, :class => :clear)].join("\n")
|
272
271
|
end
|
272
|
+
|
273
|
+
module AbstractFormBuilder
|
274
|
+
# f.open_window_grid :upload_ids, :brand_ids, :with => :brands, :get => :id, :show => :name
|
275
|
+
def open_window_grid(field, options={})
|
276
|
+
@template.open_window_grid object_name, field, options
|
277
|
+
end
|
278
|
+
end
|
273
279
|
end # Helpers
|
274
280
|
end # Admin
|
275
281
|
end # Padrino
|
@@ -66,6 +66,7 @@ en:
|
|
66
66
|
message: "There are some connection issues.<br />Contact tecnical support."
|
67
67
|
notConfigured: "This fatures is not ready yet.<br />Contact tecnical support."
|
68
68
|
notSelected: "You must select at least one record"
|
69
|
+
tooMany: "You have selected too many records. Maximum is 10!"
|
69
70
|
print:
|
70
71
|
footer:
|
71
72
|
page: "Page"
|
data/padrino-admin.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{padrino-admin}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-31}
|
13
13
|
s.description = %q{Admin View for Padrino applications}
|
14
14
|
s.email = %q{nesquena@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -355,8 +355,9 @@ Gem::Specification.new do |s|
|
|
355
355
|
|
356
356
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
357
357
|
s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
|
358
|
-
s.add_runtime_dependency(%q<padrino-core>, ["= 0.
|
359
|
-
s.add_runtime_dependency(%q<padrino-gen>, ["= 0.
|
358
|
+
s.add_runtime_dependency(%q<padrino-core>, ["= 0.7.0"])
|
359
|
+
s.add_runtime_dependency(%q<padrino-gen>, ["= 0.7.0"])
|
360
|
+
s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.7.0"])
|
360
361
|
s.add_runtime_dependency(%q<tilt>, [">= 0.4"])
|
361
362
|
s.add_development_dependency(%q<haml>, [">= 2.2.1"])
|
362
363
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
@@ -365,8 +366,9 @@ Gem::Specification.new do |s|
|
|
365
366
|
s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
|
366
367
|
else
|
367
368
|
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
368
|
-
s.add_dependency(%q<padrino-core>, ["= 0.
|
369
|
-
s.add_dependency(%q<padrino-gen>, ["= 0.
|
369
|
+
s.add_dependency(%q<padrino-core>, ["= 0.7.0"])
|
370
|
+
s.add_dependency(%q<padrino-gen>, ["= 0.7.0"])
|
371
|
+
s.add_dependency(%q<padrino-helpers>, ["= 0.7.0"])
|
370
372
|
s.add_dependency(%q<tilt>, [">= 0.4"])
|
371
373
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
372
374
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
@@ -376,8 +378,9 @@ Gem::Specification.new do |s|
|
|
376
378
|
end
|
377
379
|
else
|
378
380
|
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
379
|
-
s.add_dependency(%q<padrino-core>, ["= 0.
|
380
|
-
s.add_dependency(%q<padrino-gen>, ["= 0.
|
381
|
+
s.add_dependency(%q<padrino-core>, ["= 0.7.0"])
|
382
|
+
s.add_dependency(%q<padrino-gen>, ["= 0.7.0"])
|
383
|
+
s.add_dependency(%q<padrino-helpers>, ["= 0.7.0"])
|
381
384
|
s.add_dependency(%q<tilt>, [">= 0.4"])
|
382
385
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
383
386
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
data/test/test_active_record.rb
CHANGED
@@ -33,6 +33,7 @@ class TestActiveRecord < Test::Unit::TestCase
|
|
33
33
|
assert_respond_to account, :new_record?
|
34
34
|
assert_respond_to account, :to_param
|
35
35
|
assert_respond_to account, :update_attributes
|
36
|
+
assert_respond_to Account, :properties
|
36
37
|
assert_respond_to Account, :count
|
37
38
|
end
|
38
39
|
|
@@ -42,6 +43,12 @@ class TestActiveRecord < Test::Unit::TestCase
|
|
42
43
|
assert_equal [:email, :role, :password, :password_confirmation], account.errors_keys
|
43
44
|
end
|
44
45
|
|
46
|
+
should 'have columns names' do
|
47
|
+
property = Account.properties.first
|
48
|
+
assert_respond_to property, :name
|
49
|
+
assert_equal "id", property.name
|
50
|
+
end
|
51
|
+
|
45
52
|
should 'have table name' do
|
46
53
|
assert_equal "accounts", Account.table_name
|
47
54
|
end
|
data/test/test_data_mapper.rb
CHANGED
@@ -37,6 +37,7 @@ class TestDataMapper < Test::Unit::TestCase
|
|
37
37
|
assert_respond_to account, :new_record?
|
38
38
|
assert_respond_to account, :to_param
|
39
39
|
assert_respond_to account, :update_attributes
|
40
|
+
assert_respond_to Account, :properties
|
40
41
|
assert_respond_to Account, :count
|
41
42
|
end
|
42
43
|
|
@@ -53,6 +54,12 @@ class TestDataMapper < Test::Unit::TestCase
|
|
53
54
|
assert_equal [:email, :role, :password, :password_confirmation], account.errors_keys
|
54
55
|
end
|
55
56
|
|
57
|
+
should 'have columns names' do
|
58
|
+
property = Account.properties.first
|
59
|
+
assert_respond_to property, :name
|
60
|
+
assert_equal :id, property.name
|
61
|
+
end
|
62
|
+
|
56
63
|
should 'have table name' do
|
57
64
|
assert_equal "accounts", Account.table_name
|
58
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2010-01-
|
15
|
+
date: 2010-01-31 00:00:00 +01:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.7.0
|
37
37
|
version:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: padrino-gen
|
@@ -43,7 +43,17 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.7.0
|
47
|
+
version:
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: padrino-helpers
|
50
|
+
type: :runtime
|
51
|
+
version_requirement:
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.7.0
|
47
57
|
version:
|
48
58
|
- !ruby/object:Gem::Dependency
|
49
59
|
name: tilt
|