lipsiadmin 2.9 → 3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +13 -0
- data/README +11 -9
- data/Rakefile +1 -1
- data/lib/data_base/attachment.rb +6 -3
- data/lib/mailer/pdf_builder.rb +0 -1
- data/lib/version.rb +3 -3
- data/lib/view/helpers/ext/column_model.rb +2 -1
- data/lib/view/helpers/ext/component.rb +46 -20
- data/lib/view/helpers/ext/grid.rb +39 -45
- data/lib/view/helpers/ext/store.rb +3 -2
- data/lib/view/helpers/ext/tool_bar.rb +2 -1
- data/lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb +2 -1
- data/lipsiadmin_generators/backend_page/backend_page_generator.rb +4 -0
- data/lipsiadmin_generators/backend_page/templates/view_index.rjs.erb +1 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
+
2009-02-28
|
2
|
+
* Fixed a small js error on dblclick on grids
|
3
|
+
* Added for Ext::Component a new method for remove listener, remove_listener
|
4
|
+
* Added for Ext::Component a new alias for grid.on, called add_listener
|
5
|
+
* Fixed problem with generation of template for boolean cols
|
6
|
+
* Improvement in Backend.js, now mask() when clean()
|
7
|
+
* Fixed Attachment for get many styles
|
8
|
+
* Added a new method in Ext::Component for generate on the fly extjs objects
|
9
|
+
* Small refactoring in Ext::Component
|
10
|
+
* Small refactoring in Ext::Grid
|
11
|
+
* Fixed a small errror in Ext::Store
|
12
|
+
|
1
13
|
2009-02-27
|
14
|
+
* Added as default sm :checkbox
|
2
15
|
* Fixed a litte padding in firefox for datetimefield
|
3
16
|
* Fixed a typo in account.rb
|
4
17
|
* Fixed attachment creation for new records
|
data/README
CHANGED
@@ -24,18 +24,20 @@ Haml 2+
|
|
24
24
|
|
25
25
|
==Installation
|
26
26
|
|
27
|
-
|
27
|
+
$ sudo gem install lipsiadmin
|
28
|
+
|
29
|
+
Then in your config/environment.rb
|
30
|
+
|
31
|
+
config.gem "lipsiadmin", :version => "< 4.0"
|
32
|
+
|
33
|
+
Why we need to specify version?
|
28
34
|
|
29
|
-
|
35
|
+
Simply because we mantain backward compatibility until a 4.0 version.
|
36
|
+
This mean that before v 4.0 we only do small improvemets, bug fix, doc etc...
|
30
37
|
|
31
|
-
|
38
|
+
If you want install the edge version you can simply do:
|
32
39
|
|
33
|
-
|
34
|
-
config.gem "lipsiadmin"
|
35
|
-
|
36
|
-
then (if you don't have it already)
|
37
|
-
|
38
|
-
$ rake gems:install
|
40
|
+
script/plugin install git://github.com/Lipsiasoft/lipsiadmin.git
|
39
41
|
|
40
42
|
==Examples
|
41
43
|
|
data/Rakefile
CHANGED
data/lib/data_base/attachment.rb
CHANGED
@@ -174,7 +174,8 @@ module Lipsiadmin
|
|
174
174
|
# inside the dimensions and then crop the rest off (weighted at the center). The
|
175
175
|
# default value is to generate no thumbnails.
|
176
176
|
def attachment_styles_for(name, style_name, styles)
|
177
|
-
attachment_definitions[name][:styles]
|
177
|
+
attachment_definitions[name][:styles] ||= {}
|
178
|
+
attachment_definitions[name][:styles].merge!(style_name => styles)
|
178
179
|
end
|
179
180
|
|
180
181
|
# The thumbnail style that will be used by default URLs.
|
@@ -216,7 +217,8 @@ module Lipsiadmin
|
|
216
217
|
# attachment_convert_options :avatar, :all, "-strip"
|
217
218
|
# attachment_convert_options :avatar, :negative, "-negate"
|
218
219
|
def attachment_convert_options_for(name, convert_name, convert_options)
|
219
|
-
attachment_definitions[name][:convert_options]
|
220
|
+
attachment_definitions[name][:convert_options] ||= {}
|
221
|
+
attachment_definitions[name][:convert_options].merge!(convert_name => convert_options)
|
220
222
|
end
|
221
223
|
|
222
224
|
# When processing, if the spawn plugin is installed, processing can be done in
|
@@ -265,7 +267,8 @@ module Lipsiadmin
|
|
265
267
|
# options "{ :quality => :better }". This parameter may not mean anything to one
|
266
268
|
# or more or the processors, and they are free to ignore it.
|
267
269
|
def attachment_processors_for(name, processor_name, processors)
|
268
|
-
attachment_definitions[name][:processors]
|
270
|
+
attachment_definitions[name][:processors] ||= {}
|
271
|
+
attachment_definitions[name][:processors].merge!(processor_name => processor_processors)
|
269
272
|
end
|
270
273
|
|
271
274
|
# Places ActiveRecord-style validations on the size of the file assigned. The
|
data/lib/mailer/pdf_builder.rb
CHANGED
@@ -45,7 +45,6 @@ module Lipsiadmin
|
|
45
45
|
# search for images src, append full-path.
|
46
46
|
input.gsub!('src="/', 'src="' + RAILS_ROOT + '/public/')
|
47
47
|
input.gsub!('url(','url('+RAILS_ROOT+'/public')
|
48
|
-
#RAILS_DEFAULT_LOGGER.debug ('input: ' + input)
|
49
48
|
|
50
49
|
cmd = "java -Xmx512m -Djava.awt.headless=true -cp pd4ml.jar:.:#{File.dirname(__FILE__)}/#{JARPATH} Pd4Ruby '#{input}' 950 A4 #{landescape}"
|
51
50
|
|
data/lib/version.rb
CHANGED
@@ -29,7 +29,8 @@ module Lipsiadmin
|
|
29
29
|
#
|
30
30
|
class ColumnModel < Component
|
31
31
|
def initialize(options={}, &block)#:nodoc:
|
32
|
-
super("Ext.grid.ColumnModel", { :columns => [] }.merge(options)
|
32
|
+
super("Ext.grid.ColumnModel", { :columns => [] }.merge(options))
|
33
|
+
yield self if block_given?
|
33
34
|
end
|
34
35
|
|
35
36
|
# This add automatically fields from an array
|
@@ -20,7 +20,10 @@ module Lipsiadmin#:nodoc:
|
|
20
20
|
@klass = klass
|
21
21
|
@config = Configuration.new(options)
|
22
22
|
@before, @after = [], []
|
23
|
-
|
23
|
+
|
24
|
+
if self.class == Component && block_given?
|
25
|
+
yield self
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
29
|
# The id of the component
|
@@ -64,7 +67,7 @@ module Lipsiadmin#:nodoc:
|
|
64
67
|
if method.to_s.start_with?("get_")
|
65
68
|
@config[method.to_s.gsub("get_", "").to_sym]
|
66
69
|
else
|
67
|
-
|
70
|
+
add_object(method, arg)
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
@@ -73,12 +76,6 @@ module Lipsiadmin#:nodoc:
|
|
73
76
|
def before
|
74
77
|
@before
|
75
78
|
end
|
76
|
-
|
77
|
-
# Returns the javascript to add before component is rendered.
|
78
|
-
#
|
79
|
-
def before_js
|
80
|
-
@before.uniq.compact.join("\n\n") + "\n\n"
|
81
|
-
end
|
82
79
|
|
83
80
|
# Returns an array of javascripts to add afters component is rendered.
|
84
81
|
#
|
@@ -86,13 +83,6 @@ module Lipsiadmin#:nodoc:
|
|
86
83
|
@after
|
87
84
|
end
|
88
85
|
|
89
|
-
# Returns the javascript to add after component is rendered.
|
90
|
-
#
|
91
|
-
def after_js
|
92
|
-
"\n\n" + @after.uniq.compact.join("\n\n")
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
86
|
# Generates a new handler for the given component
|
97
87
|
#
|
98
88
|
# Examples:
|
@@ -111,28 +101,55 @@ module Lipsiadmin#:nodoc:
|
|
111
101
|
# end
|
112
102
|
def on(event, function=nil, scope=nil, &block)
|
113
103
|
# Remove old handlers
|
114
|
-
|
115
|
-
scope = ", #{scope}" unless scope.blank?
|
104
|
+
remove_listener(event)
|
105
|
+
scope = ", #{l(scope)}" unless scope.blank?
|
116
106
|
if function
|
117
107
|
after << "#{get_var}.on(#{event.to_json}, #{function}#{scope});"
|
118
108
|
else
|
119
109
|
generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(self, &block)
|
120
|
-
after << "#{get_var}.on(#{event.to_json}, function() {
|
110
|
+
after << "#{get_var}.on(#{event.to_json}, function() { #{generator.to_s.gsub("\n", "\n ")}\n}#{scope});"
|
121
111
|
end
|
122
112
|
end
|
113
|
+
alias_method :add_listener, :on
|
114
|
+
|
115
|
+
# Remove a listener
|
116
|
+
#
|
117
|
+
# Example: grid.remove_listener(:dblclick)
|
118
|
+
def remove_listener(event)
|
119
|
+
@after.delete_if { |s| s.start_with?("#{get_var}.on(#{event.to_json}") if s.is_a?(String) }
|
120
|
+
end
|
123
121
|
|
122
|
+
# Generates a new Component for generate on the fly ExtJs Objects
|
123
|
+
#
|
124
|
+
# Examples:
|
125
|
+
#
|
126
|
+
# # Generates:
|
127
|
+
# # var myComponent = new MyComponent({
|
128
|
+
# # default: true
|
129
|
+
# # });
|
130
|
+
# grid.my_component grid.new_component("MyComponent") { |p| p.default true }
|
131
|
+
#
|
132
|
+
def new_component(klass, options={}, &block)
|
133
|
+
Component.new(klass, options, &block)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Used by ActionView::Helpers::PrototypeHelper::JavaScriptGenerator
|
124
137
|
def with_output_buffer(buf = '')#:nodoc:
|
125
138
|
yield
|
126
139
|
end
|
127
140
|
|
128
141
|
|
129
|
-
# Returns the javascript
|
142
|
+
# Returns the javascript for current component
|
130
143
|
#
|
131
144
|
# # Generates: var rowSelectionModel = Ext.grid.RowSelectionModel();
|
132
145
|
# Component.new("Ext.grid.RowSelectionModel")
|
133
146
|
#
|
134
147
|
def to_s
|
135
|
-
|
148
|
+
script = []
|
149
|
+
script << @before.uniq.compact.join("\n\n")
|
150
|
+
script << "var #{get_var} = new #{@klass}(#{config.to_s});"
|
151
|
+
script << @after.uniq.compact.join("\n\n")
|
152
|
+
script.delete_if { |s| s.blank? }.join("\n\n")
|
136
153
|
end
|
137
154
|
|
138
155
|
def raise_error(error)#:nodoc:
|
@@ -158,6 +175,15 @@ module Lipsiadmin#:nodoc:
|
|
158
175
|
template = File.read("#{File.dirname(__FILE__)}/templates/#{template}.js.erb")
|
159
176
|
return ERB.new(template).result(binding)
|
160
177
|
end
|
178
|
+
|
179
|
+
def add_object(name, object)
|
180
|
+
if object.class == Component || object.class.superclass == Component
|
181
|
+
@before << object.to_s
|
182
|
+
@config[name.to_sym] = l(object.get_var)
|
183
|
+
else
|
184
|
+
@config[name.to_sym] = object
|
185
|
+
end
|
186
|
+
end
|
161
187
|
end
|
162
188
|
end
|
163
189
|
end
|
@@ -42,19 +42,24 @@ module Lipsiadmin
|
|
42
42
|
def initialize(options={}, &block)#:nodoc:
|
43
43
|
# Call Super Class for initialize configuration
|
44
44
|
super("Ext.grid.GridPanel", options)
|
45
|
-
|
45
|
+
|
46
46
|
# Write default configuration if not specified
|
47
47
|
config[:plugins] ||= []
|
48
|
-
viewConfig
|
49
|
-
clicksToEdit
|
50
|
-
border
|
51
|
-
bodyBorder
|
52
|
-
region "center"
|
53
|
-
sm :checkbox
|
54
|
-
add_plugin l("new Ext.grid.Search()")
|
55
|
-
view :default
|
56
|
-
on(:dblclick, :edit, l("this"))
|
48
|
+
viewConfig :forceFit => true
|
49
|
+
clicksToEdit 1
|
50
|
+
border false
|
51
|
+
bodyBorder false
|
52
|
+
region "center"
|
53
|
+
sm :checkbox
|
54
|
+
add_plugin l("new Ext.grid.Search()")
|
55
|
+
view :default
|
57
56
|
|
57
|
+
# We need to add a setTimeout because, we destroy
|
58
|
+
# the grid before loading a new page/js.
|
59
|
+
on(:dblclick) do |p|
|
60
|
+
p.delay(0.2) { p.call :edit }
|
61
|
+
end
|
62
|
+
|
58
63
|
yield self if block_given?
|
59
64
|
end
|
60
65
|
|
@@ -69,15 +74,14 @@ module Lipsiadmin
|
|
69
74
|
#
|
70
75
|
# new Ext.grid.CheckboxSelectionModel()
|
71
76
|
#
|
72
|
-
def sm(
|
73
|
-
selmodel = case
|
77
|
+
def sm(object)
|
78
|
+
selmodel = case object
|
74
79
|
when :default then Component.new("Ext.grid.CheckboxSelectionModel")
|
75
80
|
when :checkbox then Component.new("Ext.grid.CheckboxSelectionModel")
|
76
81
|
when :row then Component.new("Ext.grid.RowSelectionModel")
|
77
|
-
|
82
|
+
else object
|
78
83
|
end
|
79
|
-
|
80
|
-
config[:sm] = l(selmodel.get_var)
|
84
|
+
add_object(:sm, selmodel)
|
81
85
|
end
|
82
86
|
|
83
87
|
# Define the title of the grid
|
@@ -125,18 +129,16 @@ module Lipsiadmin
|
|
125
129
|
#
|
126
130
|
# tbar :default
|
127
131
|
#
|
128
|
-
def tbar(
|
129
|
-
tbar =
|
130
|
-
if
|
132
|
+
def tbar(object=nil, &block)
|
133
|
+
tbar = object.is_a?(ToolBar) ? object : ToolBar.new
|
134
|
+
if object == :default
|
131
135
|
tbar.add l("Backend.locale.buttons.add"), :id => "add", :disabled => literal(false), :cls => "x-btn-text-icon add", :handler => l("add")
|
132
136
|
tbar.add l("Backend.locale.buttons.edit"), :id => "edit", :disabled => literal(true), :cls => "x-btn-text-icon edit", :handler => l("edit")
|
133
137
|
tbar.add l("Backend.locale.buttons.remove"), :id => "remove", :disabled => literal(true), :cls => "x-btn-text-icon remove", :handler => l("remove")
|
134
138
|
@default_tbar = true
|
135
139
|
end
|
136
140
|
yield tbar if block_given?
|
137
|
-
|
138
|
-
after << tbar.after
|
139
|
-
config[:tbar] = l(tbar.get_var)
|
141
|
+
add_object(:tbar, tbar)
|
140
142
|
end
|
141
143
|
|
142
144
|
# Generate or set a new Ext.Toolbar
|
@@ -149,11 +151,9 @@ module Lipsiadmin
|
|
149
151
|
# })
|
150
152
|
# bbar :pageSize => params[:limit], :store => store.get_var, displayInfo: true
|
151
153
|
#
|
152
|
-
def bbar(
|
153
|
-
bbar =
|
154
|
-
|
155
|
-
after << bbar.after
|
156
|
-
config[:bbar] = l(bbar.get_var)
|
154
|
+
def bbar(object=nil, &block)
|
155
|
+
bbar = object.is_a?(Hash) ? Component.new("Ext.PagingToolbar", object) : object
|
156
|
+
add_object(:bbar, bbar)
|
157
157
|
end
|
158
158
|
|
159
159
|
# Generate or set a new Ext.grid.GroupingView
|
@@ -166,38 +166,31 @@ module Lipsiadmin
|
|
166
166
|
# })
|
167
167
|
# view :forceFit => true, :groupTextTpl => "{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Foo" : "Bar"]})"
|
168
168
|
#
|
169
|
-
def view(
|
170
|
-
if
|
169
|
+
def view(object=nil, &block)
|
170
|
+
if object == :default
|
171
171
|
view = Component.new("Ext.grid.GroupingView", { :forceFit => true })
|
172
172
|
elsif value.is_a?(Hash)
|
173
|
-
view = Component.new("Ext.grid.GroupingView", { :forceFit => true })
|
173
|
+
view = Component.new("Ext.grid.GroupingView", { :forceFit => true }.merge(object))
|
174
174
|
else
|
175
|
-
view =
|
175
|
+
view = object
|
176
176
|
end
|
177
|
-
|
178
|
-
before << view.to_s
|
179
|
-
after << view.after
|
180
|
-
config[:view] = l(view.get_var)
|
177
|
+
add_object(:view, view)
|
181
178
|
end
|
182
179
|
|
183
180
|
# Generate or set a new Ext.data.GroupingStore
|
184
|
-
def store(
|
185
|
-
|
186
|
-
|
187
|
-
after << datastore.after
|
188
|
-
config[:store] = l(datastore.get_var)
|
181
|
+
def store(object=nil, &block)
|
182
|
+
store = object.is_a?(Store) ? object : Store.new(&block)
|
183
|
+
add_object(:store, store)
|
189
184
|
end
|
190
185
|
|
191
186
|
# Generate or set new Ext.grid.ColumnModel
|
192
|
-
def columns(
|
187
|
+
def columns(object=nil, &block)
|
193
188
|
options = { :columns => [] }
|
194
189
|
if config[:sm] && before.find { |js| js.start_with?("var #{config[:sm]} = new Ext.grid.CheckboxSelectionModel") }
|
195
190
|
options[:columns] << config[:sm]
|
196
191
|
end
|
197
|
-
|
198
|
-
|
199
|
-
after << columnmodel.after
|
200
|
-
config[:cm] = l(columnmodel.get_var)
|
192
|
+
cm = object.is_a?(ColumnModel) ? value : ColumnModel.new(options, &block)
|
193
|
+
add_object(:cm, cm)
|
201
194
|
end
|
202
195
|
|
203
196
|
# The base_path used for ToolBar, it's used for generate [:new, :edit, :destory] urls
|
@@ -274,7 +267,8 @@ module Lipsiadmin
|
|
274
267
|
end
|
275
268
|
|
276
269
|
after << "Backend.app.addItem(#{get_var})"
|
277
|
-
|
270
|
+
|
271
|
+
super
|
278
272
|
end
|
279
273
|
end
|
280
274
|
end
|
@@ -40,9 +40,10 @@ module Lipsiadmin#:nodoc:
|
|
40
40
|
|
41
41
|
def initialize(options={}, &block)#:nodoc:
|
42
42
|
@items = []
|
43
|
-
super("Ext.data.GroupingStore", options
|
44
|
-
remoteSort
|
43
|
+
super("Ext.data.GroupingStore", options)
|
44
|
+
remoteSort true if config[:remoteSort].blank?
|
45
45
|
baseParams("_method" => "GET") if config[:baseParams].blank?
|
46
|
+
yield self if block_given?
|
46
47
|
end
|
47
48
|
|
48
49
|
# The url for getting the json data
|
@@ -23,7 +23,8 @@ module Lipsiadmin
|
|
23
23
|
class ToolBar < Component
|
24
24
|
attr_accessor :items
|
25
25
|
def initialize(options={}, &block)#:nodoc:
|
26
|
-
super("Ext.Toolbar", { :items => [] }.merge(options)
|
26
|
+
super("Ext.Toolbar", { :items => [] }.merge(options))
|
27
|
+
yield self if block_given?
|
27
28
|
end
|
28
29
|
|
29
30
|
# Add new items to a Ext.Toolbar
|
@@ -48,7 +48,7 @@ Backend.app = function(){
|
|
48
48
|
items: header ? [header, this.contentDynamic] : [this.contentDynamic]
|
49
49
|
});
|
50
50
|
|
51
|
-
this.contentDynamic.getUpdater().on('beforeupdate', function(){ this.clean();
|
51
|
+
this.contentDynamic.getUpdater().on('beforeupdate', function(){ this.clean(); }, this);
|
52
52
|
this.contentDynamic.getUpdater().on('update', this.inspectContent, this);
|
53
53
|
this.load(loadUrl ? loadUrl : '/backend/base/welcome');
|
54
54
|
setTimeout(function(){
|
@@ -104,6 +104,7 @@ Backend.app = function(){
|
|
104
104
|
}, // update
|
105
105
|
|
106
106
|
clean : function(){
|
107
|
+
this.mask();
|
107
108
|
this.contentDynamic.body.update('');
|
108
109
|
this.contentDynamic.removeAll(true);
|
109
110
|
this.contentDynamic.doLayout();
|
@@ -48,6 +48,10 @@ class ActionView::Helpers::InstanceTag
|
|
48
48
|
def to_time_select_tag(options = {})
|
49
49
|
"=time_select :#{@object_name}, :#{@method_name}#{options.empty? ? '' : ', '+ options.inspect}"
|
50
50
|
end
|
51
|
+
|
52
|
+
def to_boolean_select_tag(options = {})
|
53
|
+
"=check_box :#{@object_name}, :#{@method_name}#{options.empty? ? '' : ', '+ options.inspect}"
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
class BackendPageGenerator < Rails::Generator::NamedBase
|
@@ -5,6 +5,7 @@ page.grid do |grid|
|
|
5
5
|
grid.forgery_protection_token request_forgery_protection_token
|
6
6
|
grid.authenticity_token form_authenticity_token
|
7
7
|
grid.tbar :default
|
8
|
+
grid.sm :checkbox
|
8
9
|
grid.store do |store|
|
9
10
|
store.url "/backend/<%= plural_name %>.json"
|
10
11
|
store.fields @column_store.store_fields
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lipsiadmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "
|
4
|
+
version: "3.0"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide D'Agostino
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02
|
12
|
+
date: 2009-03-02 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|