lipsiadmin 5.1.6 → 5.1.7

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.
Files changed (65) hide show
  1. data/lib/access_control/authentication.rb +20 -20
  2. data/lib/access_control/base.rb +40 -40
  3. data/lib/controller/ext.rb +27 -27
  4. data/lib/controller/lipsiadmin_controller.rb +3 -3
  5. data/lib/controller/pdf_builder.rb +33 -31
  6. data/lib/controller/rescue.rb +12 -12
  7. data/lib/controller/responds_to_parent.rb +5 -5
  8. data/lib/data_base/attachment.rb +60 -60
  9. data/lib/data_base/attachment/attach.rb +18 -18
  10. data/lib/data_base/attachment/geometry.rb +7 -7
  11. data/lib/data_base/attachment/iostream.rb +1 -1
  12. data/lib/data_base/attachment/processor.rb +2 -2
  13. data/lib/data_base/attachment/storage.rb +11 -11
  14. data/lib/data_base/attachment/thumbnail.rb +2 -2
  15. data/lib/data_base/attachment_table.rb +27 -27
  16. data/lib/data_base/translate_attributes.rb +9 -9
  17. data/lib/data_base/utility_scopes.rb +7 -7
  18. data/lib/data_base/without_table.rb +10 -10
  19. data/lib/generator.rb +4 -4
  20. data/lib/loops.rb +77 -77
  21. data/lib/loops/base.rb +2 -2
  22. data/lib/loops/daemonize.rb +5 -5
  23. data/lib/loops/process_manager.rb +3 -3
  24. data/lib/loops/worker.rb +1 -1
  25. data/lib/loops/worker_pool.rb +1 -1
  26. data/lib/mailer/exception_notifier.rb +5 -5
  27. data/lib/mailer/pdf_builder.rb +20 -18
  28. data/lib/utils/literal.rb +6 -6
  29. data/lib/utils/pdf_builder.rb +10 -10
  30. data/lib/version.rb +1 -1
  31. data/lib/view/helpers/backend_helper.rb +123 -123
  32. data/lib/view/helpers/ext/button.rb +7 -7
  33. data/lib/view/helpers/ext/column_model.rb +18 -18
  34. data/lib/view/helpers/ext/component.rb +50 -50
  35. data/lib/view/helpers/ext/configuration.rb +5 -5
  36. data/lib/view/helpers/ext/grid.rb +46 -46
  37. data/lib/view/helpers/ext/store.rb +14 -14
  38. data/lib/view/helpers/ext/tool_bar.rb +6 -6
  39. data/lib/view/helpers/ext_helper.rb +21 -21
  40. data/lib/view/helpers/frontend_helper.rb +5 -5
  41. data/lib/view/helpers/pdf_helper.rb +7 -7
  42. data/lib/view/helpers/view_helper.rb +28 -28
  43. data/lipsiadmin_generators/attachment/attachment_generator.rb +7 -7
  44. data/lipsiadmin_generators/attachment/templates/controller.rb +13 -13
  45. data/lipsiadmin_generators/attachment/templates/migration.rb +1 -1
  46. data/lipsiadmin_generators/backend/backend_generator.rb +9 -9
  47. data/lipsiadmin_generators/backend/templates/controllers/backend/accounts_controller.rb +10 -10
  48. data/lipsiadmin_generators/backend/templates/controllers/backend/sessions_controller.rb +2 -2
  49. data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +2 -2
  50. data/lipsiadmin_generators/backend/templates/migrations/create_accounts.rb +5 -5
  51. data/lipsiadmin_generators/backend/templates/models/account.rb +16 -16
  52. data/lipsiadmin_generators/backend/templates/models/account_access.rb +11 -11
  53. data/lipsiadmin_generators/backend/templates/models/notifier.rb +2 -2
  54. data/lipsiadmin_generators/backend_page/backend_page_generator.rb +22 -22
  55. data/lipsiadmin_generators/backend_page/templates/controller.rb +9 -9
  56. data/lipsiadmin_generators/backend_page/templates/functional_test.rb +10 -10
  57. data/lipsiadmin_generators/frontend/frontend_generator.rb +5 -5
  58. data/lipsiadmin_generators/frontend/templates/controllers/frontend/sessions_controller.rb +3 -3
  59. data/lipsiadmin_generators/loops/loops_generator.rb +2 -2
  60. data/lipsiadmin_generators/pdf/pdf_generator.rb +7 -7
  61. data/lipsiadmin_generators/state_session/state_session_generator.rb +9 -9
  62. data/lipsiadmin_generators/state_session/templates/controller.rb +2 -2
  63. data/lipsiadmin_generators/state_session/templates/migration.rb +2 -2
  64. data/resources/rdoc/horo.rb +3 -3
  65. metadata +4 -4
@@ -1,9 +1,9 @@
1
1
  module Lipsiadmin
2
2
  module Ext
3
3
  # Generate a new Ext.Button
4
- #
4
+ #
5
5
  # This component is usefull for ex in toolbars
6
- #
6
+ #
7
7
  # # Generates:
8
8
  # #{
9
9
  # # buttons: [{
@@ -39,7 +39,7 @@ module Lipsiadmin
39
39
  # tbar.add_button :text => "Backend.locale.buttons.print".to_l, :id => "print", :disabled => false, :cls => "x-btn-text-icon print" do |menu|
40
40
  # menu.add_button :text => "Test Me"
41
41
  # menu.add_button :text => "IM a sub Menu"
42
- # end
42
+ # end
43
43
  #
44
44
  class Button < Component
45
45
 
@@ -47,16 +47,16 @@ module Lipsiadmin
47
47
  super("Ext.Button", options)
48
48
  yield self if block_given?
49
49
  end
50
-
50
+
51
51
  # Add new Button to the menu of this one
52
- #
52
+ #
53
53
  # # Generates: { handler: show, text: "Add", other: "...", icon: "..." }
54
54
  # add_button :text => "Add", :handler => "show".to_l, :icon => "...", :other => "..."
55
- #
55
+ #
56
56
  def add_button(options, &block)
57
57
  config[:menu] ||= []
58
58
  config[:menu] << (options.is_a?(String) ? options : Button.new(options, &block).config)
59
59
  end
60
60
  end
61
61
  end
62
- end
62
+ end
@@ -3,7 +3,7 @@ module Lipsiadmin
3
3
  # Generate a new Ext.grid.ColumnModel
4
4
  #
5
5
  # Examples:
6
- #
6
+ #
7
7
  # var columnModel = new Ext.grid.ColumnModel({
8
8
  # columns: [{
9
9
  # header: "Name",
@@ -19,32 +19,32 @@ module Lipsiadmin
19
19
  # header: "Created At",
20
20
  # dataIndex: "created_at"
21
21
  # }]});
22
- #
22
+ #
23
23
  # ColumnModel.new do |columns|
24
24
  # columns.add :name, "Name"
25
25
  # columns.add :category_name, "Category", :dataIndex => "categories.name"
26
26
  # columns.add :date, "Date"
27
27
  # columns.add :created_at, "Created At"
28
28
  # end
29
- #
30
- class ColumnModel < Component
29
+ #
30
+ class ColumnModel < Component
31
31
  def initialize(options={}, &block)#:nodoc:
32
32
  super("Ext.grid.ColumnModel", { :columns => [] }.merge(options))
33
33
  yield self if block_given?
34
34
  end
35
-
35
+
36
36
  # This add automatically fields from an array
37
37
  def fields(fields)
38
38
  fields.each { |options| add_column(nil, nil, options); }
39
39
  end
40
-
40
+
41
41
  # Add columns to a Ext.grid.ColumnModel
42
42
  #
43
43
  # # Generates: { header: "Created At", dataIndex: "accounts.datetime", sortable => true }
44
44
  # add "Created At", "accounts.datetime", :sortable => true
45
- #
45
+ #
46
46
  # You can pass :renderer
47
- #
47
+ #
48
48
  # # Generates: Ext.util.Format.dateRenderer()
49
49
  # :render => :time_to_date # This render a datetime to a date
50
50
  # # Generates: Ext.util.Format.dateRenderer()
@@ -66,11 +66,11 @@ module Lipsiadmin
66
66
  # :render => :trim
67
67
  # :render => :undef
68
68
  # :render => :upcase
69
- #
69
+ #
70
70
  # For more see http://extjs.com/deploy/dev/docs/?class=Ext.util.Format
71
- #
71
+ #
72
72
  # You can pass :editor
73
- #
73
+ #
74
74
  # # Generates: { checkbox: true }
75
75
  # :editor => { :xtype => :checkbox, :someConfig => true }
76
76
  # # Generates: new Ext.form.ComboBox({ someConfig => true });
@@ -87,7 +87,7 @@ module Lipsiadmin
87
87
  # :editor => { :xtype => :textfield, :someConfig => true }
88
88
  # # Generates: new Ext.form.TimeField({ someConfig => true });
89
89
  # :editor => { :xtype => :timefield, :someConfig => true }
90
- #
90
+ #
91
91
  # Form components so are:
92
92
  # ---------------------------------------
93
93
  # :checkbox => Ext.form.Checkbox
@@ -98,11 +98,11 @@ module Lipsiadmin
98
98
  # :textarea => Ext.form.TextArea
99
99
  # :textfield => Ext.form.TextField
100
100
  # :timefield => Ext.form.TimeField
101
- #
101
+ #
102
102
  def add_column(name=nil, data=nil, options={})
103
103
  options[:header] = name if name
104
104
  options[:dataIndex] = data if data
105
-
105
+
106
106
  if options[:editor]
107
107
  xtype = options[:editor][:xtype]
108
108
  case xtype
@@ -117,7 +117,7 @@ module Lipsiadmin
117
117
  when :datetimefield then options.merge!(:editor => "new Ext.form.DateTimeField(#{Configuration.new(options[:editor]).to_s(3)})".to_l)
118
118
  end
119
119
  end
120
-
120
+
121
121
  case options[:renderer]
122
122
  when :time_to_date then options.merge!(:renderer => "Ext.util.Format.dateRenderer()".to_l)
123
123
  when :date then options.merge!(:renderer => "Ext.util.Format.dateRenderer()".to_l)
@@ -133,12 +133,12 @@ module Lipsiadmin
133
133
  when :undef then options.merge!(:renderer => "Ext.util.Format.undef".to_l)
134
134
  when :upcase then options.merge!(:renderer => "Ext.util.Format.uppercase".to_l)
135
135
  end
136
-
137
- raise ComponentError, "You must provide header and dataIndex for generate a column model" if options[:header].blank? ||
136
+
137
+ raise ComponentError, "You must provide header and dataIndex for generate a column model" if options[:header].blank? ||
138
138
  options[:dataIndex].blank?
139
139
 
140
140
  config[:columns] << Configuration.new(options)
141
141
  end
142
142
  end
143
143
  end
144
- end
144
+ end
@@ -1,27 +1,27 @@
1
1
  module Lipsiadmin#:nodoc:
2
2
  module Ext#:nodoc:
3
-
3
+
4
4
  class ComponentError < StandardError; end#:nodoc:
5
-
5
+
6
6
  # This is the base class of ext components
7
- #
7
+ #
8
8
  # You can generate your custom ExtJs objects like:
9
- #
10
- # # Generates:
9
+ #
10
+ # # Generates:
11
11
  # # var groupingView = Ext.grid.GroupingView({
12
12
  # # forceFit: true
13
13
  # # });
14
- #
14
+ #
15
15
  # Component.new("Ext.grid.GroupingView", { :forceFit => true });
16
- #
16
+ #
17
17
  # If you want to override our default templates you can do easly with:
18
- #
18
+ #
19
19
  # Lipsiadmin::Ext::Component.template_paths.unshift("/path/to/my/js/templates")
20
- #
21
- class Component
20
+ #
21
+ class Component
22
22
  @@template_paths = ["#{File.dirname(__FILE__)}/templates", "#{Rails.root}/app/views/backend"]
23
23
  cattr_accessor :template_paths
24
-
24
+
25
25
  def initialize(klass, options={}, &block)#:nodoc:
26
26
  @klass = klass
27
27
  @prefix = options.delete(:prefix)
@@ -30,18 +30,18 @@ module Lipsiadmin#:nodoc:
30
30
  @before, @after = [], []
31
31
  @items, @un = {}, {}
32
32
  if self.class == Component && block_given?
33
- yield self
33
+ yield self
34
34
  end
35
35
  end
36
-
36
+
37
37
  # The id of the component
38
38
  #
39
39
  def id(new_id)
40
40
  @config[:id] = new_id
41
41
  end
42
-
42
+
43
43
  # Set var used by the component
44
- #
44
+ #
45
45
  # Generates: var myVar = new Ext.Grid({...});
46
46
  # store.var "myVar"
47
47
  #
@@ -50,26 +50,26 @@ module Lipsiadmin#:nodoc:
50
50
  end
51
51
 
52
52
  # Get the var used by the component defaults is the id of the component
53
- #
53
+ #
54
54
  def get_var
55
55
  # I will nillify obj if they are blank
56
56
  @var = nil if @var.blank?
57
57
  @config.delete(:var) if @config[:var].blank?
58
-
58
+
59
59
  # Return a correct var
60
60
  current_var = (@var || @config[:var] || build_var)
61
61
  @prefix.to_s + current_var.to_s
62
62
  end
63
63
 
64
64
  # Define the title of the component.
65
- #
66
- # Every component can have a title, because in Lipsiadmin we use it
65
+ #
66
+ # Every component can have a title, because in Lipsiadmin we use it
67
67
  # as a "pagetitle", but if you need it as a config you can provide global = false
68
- #
68
+ #
69
69
  def title(title, global=true)
70
70
  global ? (before << "Backend.app.setTitle(#{title.to_json});") : config[:title] = title
71
71
  end
72
-
72
+
73
73
  # Write the the configuration of object from an hash
74
74
  #
75
75
  def config=(options={})
@@ -81,7 +81,7 @@ module Lipsiadmin#:nodoc:
81
81
  def config
82
82
  @config
83
83
  end
84
-
84
+
85
85
  def method_missing(method, arguments=nil, &block)#:nodoc:
86
86
  if method.to_s =~ /^get_/
87
87
  @config[method.to_s.gsub(/^get_/, "").to_sym]
@@ -89,33 +89,33 @@ module Lipsiadmin#:nodoc:
89
89
  add_object(method, arguments)
90
90
  end
91
91
  end
92
-
92
+
93
93
  # Set the prefix for the var of the component.
94
- # This is usefull when for example we are using two grids
94
+ # This is usefull when for example we are using two grids
95
95
  # for solve conflict problems.
96
- #
96
+ #
97
97
  def prefix=(value)
98
98
  @prefix = value
99
99
  end
100
-
100
+
101
101
  # Returns an array of javascripts to add before component is rendered.
102
- #
102
+ #
103
103
  def before
104
104
  @before
105
105
  end
106
-
106
+
107
107
  # Returns an array of javascripts to add afters component is rendered.
108
108
  #
109
109
  def after
110
110
  @after
111
111
  end
112
-
112
+
113
113
  # Generates a new handler for the given component
114
- #
114
+ #
115
115
  # Examples:
116
- #
116
+ #
117
117
  # # Generates:
118
- # # grid.on("dblclick", function() {
118
+ # # grid.on("dblclick", function() {
119
119
  # # edit();
120
120
  # # new();
121
121
  # # Ext.Msg.alert("Hello", "world");
@@ -125,12 +125,12 @@ module Lipsiadmin#:nodoc:
125
125
  # p.call "new"
126
126
  # p.ext_alert "Hello", "world"
127
127
  # end
128
- #
128
+ #
129
129
  def on(event, function=nil, scope=nil, &block)
130
130
  # Remove old handlers
131
131
  un(event)
132
132
  @un[event.to_sym] = false # we need to reset it
133
- scope = ", #{scope.to_l}" unless scope.blank?
133
+ scope = ", #{scope.to_l}" unless scope.blank?
134
134
  if function
135
135
  after << "#{get_var}.on(#{event.to_json}, #{function}#{scope});"
136
136
  else
@@ -138,21 +138,21 @@ module Lipsiadmin#:nodoc:
138
138
  after << "#{get_var}.on(#{event.to_json}, function() { \n #{generator.to_s.gsub("\n", "\n ")}\n}#{scope});"
139
139
  end
140
140
  end
141
-
141
+
142
142
  # Remove a listener
143
- #
143
+ #
144
144
  # Example: grid.un(:dblclick)
145
- #
145
+ #
146
146
  def un(event)
147
147
  @un[event.to_sym] = true
148
148
  found = @after.delete_if { |s| s.start_with?("#{get_var}.on(#{event.to_json}") if s.is_a?(String) }
149
149
  after << "#{get_var}.un(#{event.to_json})" unless found
150
150
  end
151
-
151
+
152
152
  # Generates and add new Component for generate on the fly ExtJs Objects
153
- #
153
+ #
154
154
  # Examples:
155
- #
155
+ #
156
156
  # # Generates:
157
157
  # # var panel = new Ext.Panel({
158
158
  # # id: 'testPanel',
@@ -160,27 +160,27 @@ module Lipsiadmin#:nodoc:
160
160
  # # ...
161
161
  # # })
162
162
  # # mycmp.add(panel)
163
- # #
164
- # mycmp.add "Ext.Panel" do |panel|
163
+ # #
164
+ # mycmp.add "Ext.Panel" do |panel|
165
165
  # panel.id "testPanel",
166
166
  # panel.region :center
167
167
  # ...
168
168
  # end
169
- #
169
+ #
170
170
  def add(klass, options={}, &block)
171
171
  add_object(Component.new(klass, options.merge(:prefix => get_var), &block))
172
172
  end
173
-
173
+
174
174
  # Used by ActionView::Helpers::PrototypeHelper::JavaScriptGenerator
175
175
  def with_output_buffer(buf = '')#:nodoc:
176
176
  yield
177
177
  end
178
-
178
+
179
179
  # Returns the javascript for current component
180
- #
180
+ #
181
181
  # # Generates: var rowSelectionModel = Ext.grid.RowSelectionModel();
182
182
  # Component.new("Ext.grid.RowSelectionModel").to_s
183
- #
183
+ #
184
184
  def to_s(options={})
185
185
  script = [].tap do |script|
186
186
  script << @before.uniq.compact.join("\n\n")
@@ -189,7 +189,7 @@ module Lipsiadmin#:nodoc:
189
189
  end
190
190
  script.delete_if { |s| s.blank? }.join("\n\n")
191
191
  end
192
-
192
+
193
193
  def raise_error(error)#:nodoc:
194
194
  raise ComponentError, error
195
195
  end
@@ -202,7 +202,7 @@ module Lipsiadmin#:nodoc:
202
202
  template = File.read(File.join(path, "#{template}.js.erb"))
203
203
  return ERB.new(template).result(binding)
204
204
  end
205
-
205
+
206
206
  def add_object(name, object)
207
207
  if object.class == Component || object.class.superclass == Component
208
208
  object.prefix = get_var
@@ -214,7 +214,7 @@ module Lipsiadmin#:nodoc:
214
214
  @config[name.to_sym] = object
215
215
  end
216
216
  end
217
-
217
+
218
218
  def build_var
219
219
  "".tap do |val|
220
220
  if @prefix.blank?
@@ -1,15 +1,15 @@
1
1
  module Lipsiadmin
2
2
  module Ext
3
3
  # Ext configuration used by components
4
- #
4
+ #
5
5
  # Generates: { name: 'name', handler: function(){ alert('Hello World') } }
6
6
  #
7
7
  class Configuration < Hash
8
-
8
+
9
9
  def initialize(hash)#:nodoc:
10
10
  hash.each { |k,v| self[k] = v }
11
11
  end
12
-
12
+
13
13
  # Returns the configuration as a string.
14
14
  # Optionally you can specify the indentation spaces.
15
15
  def to_s(indent=1)
@@ -19,7 +19,7 @@ module Lipsiadmin
19
19
  r = "{#{s}" + self.collect { |k,v| "#{i*2}#{k}: #{s(v)}" if k != :var }.join(",#{s}") + "#{s}#{i if i.size > 1}}"
20
20
  return r =~ /\{\s*\}/ ? "" : r
21
21
  end
22
-
22
+
23
23
  private
24
24
  def javascript_object_for(object)
25
25
  case object
@@ -34,4 +34,4 @@ module Lipsiadmin
34
34
  alias_method :s, :javascript_object_for
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -37,7 +37,7 @@ module Lipsiadmin
37
37
  # end
38
38
  # grid.bbar :store => grid.get_store, :pageSize => params[:limit]
39
39
  # end
40
- #
40
+ #
41
41
  # # Returns:
42
42
  # # var grid = new Ext.grid.EditorGridPanel({
43
43
  # # clicksToEdit: 1,
@@ -46,9 +46,9 @@ module Lipsiadmin
46
46
  # page.grid :editable => true do |grid|
47
47
  # grid.id "grid-posts"
48
48
  # ...
49
- #
49
+ #
50
50
  class Grid < Component
51
-
51
+
52
52
  def initialize(options={}, &block)#:nodoc:
53
53
  # Call Super Class for initialize configuration
54
54
  @editable = options.delete(:editable)
@@ -66,7 +66,7 @@ module Lipsiadmin
66
66
  view :default
67
67
  render true
68
68
  config[:plugins] << "new Ext.grid.Search()".to_l
69
-
69
+
70
70
  # We need to add a setTimeout because, we destroy
71
71
  # the grid before loading a new page/js.
72
72
  on(:dblclick) do |p|
@@ -75,18 +75,18 @@ module Lipsiadmin
75
75
 
76
76
  yield self if block_given?
77
77
  end
78
-
78
+
79
79
  # Define the selection model of this grid.
80
- # You can pass:
81
- #
80
+ # You can pass:
81
+ #
82
82
  # * :checkbox || :default
83
83
  # * :row
84
84
  # * custom (eg. Component.new("some"))
85
- #
85
+ #
86
86
  # It generate some like:
87
- #
87
+ #
88
88
  # new Ext.grid.CheckboxSelectionModel()
89
- #
89
+ #
90
90
  def sm(object)
91
91
  selmodel = case object
92
92
  when :default then Component.new("Ext.grid.CheckboxSelectionModel", :prefix => get_var)
@@ -96,9 +96,9 @@ module Lipsiadmin
96
96
  end
97
97
  add_object(:sm, selmodel)
98
98
  end
99
-
99
+
100
100
  # Generate or set a new Ext.Toolbar
101
- # You can pass tbar :default options that will create
101
+ # You can pass tbar :default options that will create
102
102
  # defaults buttons for add, edit and remove records, it's generate also
103
103
  # the javascript for manage them.
104
104
  # for use this you need to set for the grid the: +base_path+, +forgery_protection_token+,
@@ -126,7 +126,7 @@ module Lipsiadmin
126
126
  # }]);
127
127
  #
128
128
  # tbar :default
129
- #
129
+ #
130
130
  def tbar(object=nil, &block)
131
131
  tbar = object.is_a?(ToolBar) ? object : ToolBar.new(:prefix => get_var)
132
132
  if object == :default || object == :all
@@ -153,9 +153,9 @@ module Lipsiadmin
153
153
  yield tbar if block_given?
154
154
  add_object(:tbar, tbar)
155
155
  end
156
-
156
+
157
157
  # Generate or set a new Ext.Toolbar
158
- #
158
+ #
159
159
  # Examples:
160
160
  # bbar: new Ext.PagingToolbar({
161
161
  # pageSize: <%= params[:limit] %>,
@@ -163,7 +163,7 @@ module Lipsiadmin
163
163
  # displayInfo: true
164
164
  # })
165
165
  # bbar :pageSize => params[:limit], :store => store.get_var, displayInfo: true
166
- #
166
+ #
167
167
  def bbar(object=nil, &block)
168
168
  bbar = object.is_a?(Hash) ? Component.new("Ext.PagingToolbar", object.merge(:prefix => get_var)) : object
169
169
  add_object(:bbar, bbar)
@@ -171,14 +171,14 @@ module Lipsiadmin
171
171
 
172
172
  # Generate or set a new Ext.grid.GroupingView
173
173
  # You can pass view :default options that will autocreate a correct GroupingView
174
- #
174
+ #
175
175
  # Examples:
176
176
  # view: new Ext.grid.GroupingView({
177
177
  # forceFit:true,
178
178
  # groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Foo" : "Bar"]})'
179
179
  # })
180
180
  # view :forceFit => true, :groupTextTpl => '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Foo" : "Bar"]})'
181
- #
181
+ #
182
182
  def view(object=nil, &block)
183
183
  view = case object
184
184
  when :default then Component.new("Ext.grid.GroupingView", { :forceFit => true, :prefix => get_var })
@@ -187,13 +187,13 @@ module Lipsiadmin
187
187
  end
188
188
  add_object(:view, view)
189
189
  end
190
-
190
+
191
191
  # Generate or set a new Ext.data.GroupingStore
192
192
  def store(object=nil, &block)
193
193
  store = object.is_a?(Store) ? object : Store.new(:prefix => get_var, &block)
194
194
  add_object(:store, store)
195
195
  end
196
-
196
+
197
197
  # Generate or set new Ext.grid.ColumnModel
198
198
  def columns(object=nil, &block)
199
199
  options = { :columns => [] }
@@ -203,77 +203,77 @@ module Lipsiadmin
203
203
  cm = object.is_a?(ColumnModel) ? value : ColumnModel.new(options.merge(:prefix => get_var), &block)
204
204
  add_object(:cm, cm)
205
205
  end
206
-
206
+
207
207
  # Define the template to use for build grid functions (add/delete/edit)
208
- #
208
+ #
209
209
  # Default we use:
210
- #
210
+ #
211
211
  # /path/to/lipsiadmin/lib/view/helpers/ext/templates/grid_functions.js.erb
212
- #
212
+ #
213
213
  # But you can easy add your own paths like:
214
- #
214
+ #
215
215
  # Lipsiadmin::Ext::Component.template_paths.unshift("/path/to/my/js/templates")
216
- #
216
+ #
217
217
  # Or direct by grid:
218
- #
218
+ #
219
219
  # # products/show.rjs
220
220
  # page.grid :editable => true do |grid|
221
221
  # grid.id "grid-products"
222
222
  # grid.template "products/grid_functions"
223
223
  # ...
224
- #
224
+ #
225
225
  def template(value)
226
226
  @template = value == :default ? :grid_functions : value
227
227
  end
228
-
228
+
229
229
  # Define if the grid need to be added to contentDynamic
230
- #
230
+ #
231
231
  # Backend.app.addItem(#{get_var});
232
- #
232
+ #
233
233
  def render(value)
234
234
  @render = value
235
235
  end
236
-
236
+
237
237
  # The base_path used for ToolBar, it's used for generate [:new, :edit, :destory] urls
238
238
  def base_path(value)
239
239
  @base_path = value
240
240
  end
241
-
241
+
242
242
  # The path for ToolBar New Button, if none given we use the base_path
243
243
  def new_path(value)
244
244
  @new_path = value
245
245
  end
246
-
246
+
247
247
  # The path for ToolBar Edit Button, if none given we use the base_path
248
248
  def edit_path(value)
249
249
  @edit_path = value
250
250
  end
251
-
251
+
252
252
  # The path for ToolBar Delete Button, if none given we use the base_path
253
253
  def destroy_path(value)
254
254
  @destroy_path = value
255
255
  end
256
-
256
+
257
257
  # The forgery_protection_token used for ToolBar
258
258
  def forgery_protection_token(value)
259
259
  @forgery_protection_token = value
260
260
  end
261
-
261
+
262
262
  # The authenticity_token used for ToolBar
263
263
  def authenticity_token(value)
264
264
  @authenticity_token = value
265
265
  end
266
-
266
+
267
267
  # Returns getSelectionModel().getSelected()
268
- #
268
+ #
269
269
  # Examples:
270
- #
270
+ #
271
271
  # # Generates: grid.getSelectionModel().getSelected().id
272
272
  # grid.get_selected
273
- #
273
+ #
274
274
  # # Generates: getSelectionModel().getSelected().data['name']
275
275
  # grid.get_selected(:name)
276
- #
276
+ #
277
277
  def get_selected(data=:id)
278
278
  raise_error "No Column Selection Model Defined" if config[:sm].blank?
279
279
  if data.to_sym == :id
@@ -282,7 +282,7 @@ module Lipsiadmin
282
282
  "#{config[:sm]}.getSelected().data[#{data.to_json}]"
283
283
  end
284
284
  end
285
-
285
+
286
286
  # Return the javascript for create a new Ext.grid.GridPanel
287
287
  def to_s
288
288
  if @ttbar_add || @ttbar_edit || @ttbar_delete
@@ -296,9 +296,9 @@ module Lipsiadmin
296
296
  raise_error "You must provide the selection model for autobuild toolbar." if config[:sm].blank?
297
297
  raise_error "You must provide the store." if config[:store].blank?
298
298
  end
299
-
299
+
300
300
  after << render_javascript(@template, :var => get_var, :store => config[:store], :sm => config[:sm], :tbar => config[:tbar], :editable => @editable, :un => @un)
301
-
301
+
302
302
  if @render
303
303
  after << "Backend.app.addItem(#{get_var});" if @render
304
304
  if config[:store]
@@ -311,4 +311,4 @@ module Lipsiadmin
311
311
  end
312
312
  end
313
313
  end
314
- end
314
+ end