lolita 3.1.18 → 3.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -2
- data/History.rdoc +24 -0
- data/README.md +113 -0
- data/VERSION +1 -1
- data/{public → app/assets}/images/lolita/plus.png +0 -0
- data/{public → app/assets}/javascripts/lolita/application.js +0 -0
- data/{public → app/assets}/javascripts/lolita/base64.js +0 -0
- data/{public → app/assets}/javascripts/lolita/main.js +1 -0
- data/{public → app/assets}/javascripts/lolita/tab.js +0 -0
- data/{public → app/assets}/stylesheets/lolita/PIE-custom.htc +0 -0
- data/{public → app/assets}/stylesheets/lolita/PIE.htc +0 -0
- data/{public → app/assets}/stylesheets/lolita/default.css +0 -0
- data/{public → app/assets}/stylesheets/lolita/style.css +0 -21
- data/app/controllers/lolita/info_controller.rb +1 -12
- data/app/controllers/lolita/rest_controller.rb +2 -7
- data/app/helpers/lolita_helper.rb +1 -12
- data/app/views/components/lolita/configuration/column/_header.html.erb +1 -1
- data/app/views/components/lolita/configuration/column/_sort.html.erb +4 -7
- data/app/views/components/lolita/configuration/field/array/habtm/_display.html.haml +1 -1
- data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/string/disabled/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/list/_paginator.html.erb +1 -1
- data/app/views/components/lolita/configuration/list/_title.html.erb +1 -6
- data/app/views/components/lolita/configuration/nested_form/_display.html.erb +6 -8
- data/app/views/components/lolita/navigation/_tree.html.erb +25 -18
- data/app/views/components/lolita/shared/_header.html.erb +1 -1
- data/app/views/components/lolita/shared/_right_sidebar.html.erb +6 -1
- data/app/views/layouts/lolita/application.html.erb +3 -3
- data/config/locales/en.yml +24 -1
- data/config/locales/lv.yml +0 -1
- data/config/routes.rb +1 -3
- data/lib/generators/lolita/install_generator.rb +1 -5
- data/lib/lolita.rb +23 -38
- data/lib/lolita/adapter/abstract_adapter.rb +0 -1
- data/lib/lolita/adapter/active_record.rb +4 -42
- data/lib/lolita/adapter/mongoid.rb +4 -76
- data/lib/lolita/configuration/base.rb +2 -15
- data/lib/lolita/configuration/column.rb +2 -25
- data/lib/lolita/configuration/factory/field.rb +2 -10
- data/lib/lolita/configuration/field.rb +1 -6
- data/lib/lolita/configuration/field/array.rb +31 -124
- data/lib/lolita/configuration/field/integer.rb +1 -0
- data/lib/lolita/configuration/list.rb +2 -23
- data/lib/lolita/configuration/tabs.rb +0 -6
- data/lib/lolita/controllers/component_helpers.rb +1 -1
- data/lib/lolita/controllers/internal_helpers.rb +4 -18
- data/lib/lolita/controllers/user_helpers.rb +11 -23
- data/lib/lolita/hooks.rb +120 -163
- data/lib/lolita/lazy_loader.rb +0 -3
- data/lib/lolita/mapping.rb +0 -23
- data/lib/lolita/modules/rest.rb +1 -1
- data/lib/lolita/navigation/branch.rb +1 -52
- data/lib/lolita/navigation/tree.rb +0 -10
- data/lib/lolita/rails.rb +2 -1
- data/lib/lolita/rails/routes.rb +5 -4
- data/lib/lolita/system_configuration/application.rb +1 -7
- data/lolita.gemspec +83 -100
- data/spec/configuration/field_spec.rb +1 -1
- data/spec/configuration/list_spec.rb +14 -19
- data/spec/rails_app/app/mongoid/post.rb +0 -4
- data/spec/rails_app/config/application.rb +1 -12
- data/spec/rails_app/config/environments/development.rb +2 -6
- data/spec/rails_app/config/environments/production.rb +1 -5
- data/spec/rails_app/config/environments/test.rb +1 -5
- data/vendor/assets/javascripts/jquery-1.6.2.min.js +18 -0
- data/{public → vendor/assets}/javascripts/jquery-ui-1.8.13.min.js +0 -0
- data/{public → vendor/assets}/javascripts/modernizr-1.7.min.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/jquery.tinymce.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/langs/en.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/license.txt +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/about.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/anchor.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/charmap.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/color_picker.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/editor_template.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/editor_template_src.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/image.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/colorpicker.jpg +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/flash.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/icons.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/iframe.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/pagebreak.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/quicktime.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/realmedia.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/shockwave.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/trans.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/video.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/windowsmedia.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/about.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/anchor.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/charmap.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/color_picker.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/image.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/link.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/source_editor.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/langs/en.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/langs/en_dlg.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/link.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/shortcuts.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/butt2.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/button-bg.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/buttons.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/down_arrow.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/fade-butt.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/icons.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/items.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-arrow.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-check.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/progress.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/tabs.gif +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/toolbarbg.png +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/source_editor.htm +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/tiny_mce.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/tiny_mce_popup.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/utils/editable_selects.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/utils/form_utils.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/utils/mctabs.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce/utils/validate.js +0 -0
- data/{public → vendor/assets}/javascripts/tinymce_config.js +1 -1
- metadata +121 -127
- data/README.rdoc +0 -100
- data/app/controllers/lolita/field_data_controller.rb +0 -36
- data/app/views/components/lolita/configuration/field/array/autocomplete/_display.html.haml +0 -11
- data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +0 -8
- data/app/views/components/lolita/configuration/field/array/polymorphic/_display.html.haml +0 -6
- data/app/views/components/lolita/configuration/field/array/polymorphic/_options_for_select.html.haml +0 -1
- data/app/views/components/lolita/configuration/search/_display.html.haml +0 -2
- data/app/views/components/lolita/shared/_save_button.html.erb +0 -6
- data/lib/generators/lolita/assets_generator.rb +0 -19
- data/lib/lolita/configuration/factory.rb +0 -56
- data/lib/lolita/configuration/helper.rb +0 -24
- data/lib/lolita/configuration/page.rb +0 -126
- data/lib/lolita/configuration/search.rb +0 -91
- data/lib/lolita/controller_additions.rb +0 -15
- data/lib/lolita/controllers/authorization_helpers.rb +0 -56
- data/lib/lolita/search/simple.rb +0 -76
- data/public/javascripts/jquery-1.6.min.js +0 -16
- data/public/javascripts/rails.js +0 -137
- data/spec/configuration/search_spec.rb +0 -44
- data/spec/search/simple_spec.rb +0 -48
@@ -38,32 +38,9 @@ module Lolita
|
|
38
38
|
def sortable?
|
39
39
|
@sortable
|
40
40
|
end
|
41
|
-
|
42
|
-
def current_sort_state(params)
|
43
|
-
@sortable && sort_pairs(params).detect{|pair| pair[0]==self.name.to_s} || []
|
44
|
-
end
|
45
|
-
|
46
|
-
def sort_params params
|
47
|
-
if @sortable
|
48
|
-
pairs = sort_pairs(params)
|
49
|
-
found_pair = false
|
50
|
-
pairs.each_with_index{|pair,index|
|
51
|
-
if pair[0] == self.name.to_s
|
52
|
-
pairs[index][1] = pair[1] == "asc" ? "desc" : "asc"
|
53
|
-
found_pair = true
|
54
|
-
end
|
55
|
-
}
|
56
|
-
unless found_pair
|
57
|
-
pairs << [self.name.to_s,"asc"]
|
58
|
-
end
|
59
|
-
(pairs.map{|pair| pair.join(",")}).join("|")
|
60
|
-
else
|
61
|
-
""
|
62
|
-
end
|
63
|
-
end
|
64
41
|
|
65
|
-
def
|
66
|
-
|
42
|
+
def currently_sorting?(params)
|
43
|
+
@sortable && params[:sc].to_s==self.name.to_s
|
67
44
|
end
|
68
45
|
|
69
46
|
# Define format, for details see Lolita::Support::Formatter and Lolita::Support::Formater::Rails
|
@@ -16,13 +16,9 @@ module Lolita
|
|
16
16
|
name = args[0] || options[:name] || (dbi_field ? dbi_field.name : nil)
|
17
17
|
dbi_field ||= dbi.field_by_name(name)
|
18
18
|
dbi_field ||= dbi.field_by_association(name)
|
19
|
-
|
20
|
-
|
21
|
-
type = args[1] || options[:type] ||
|
22
|
-
(association ? :array : nil ) ||
|
23
|
-
(dbi_field ? dbi_field.type : nil) ||
|
24
|
-
:string
|
19
|
+
type = args[1] || options[:type] || (dbi_field ? dbi_field.type : nil) || :string
|
25
20
|
options[:dbi_field] = dbi_field
|
21
|
+
|
26
22
|
if !name || !type
|
27
23
|
raise Lolita::FieldTypeError, "type not defined. Set is as second argument or as :dbi_field where value is Adapter::[ORM]::Field object."
|
28
24
|
else
|
@@ -32,10 +28,6 @@ module Lolita
|
|
32
28
|
|
33
29
|
end
|
34
30
|
|
35
|
-
def self.detect_association(dbi,name)
|
36
|
-
dbi.associations[name.to_sym]
|
37
|
-
end
|
38
|
-
|
39
31
|
def self.field_class(name)
|
40
32
|
("Lolita::Configuration::Field::"+name.to_s.camelize).constantize
|
41
33
|
end
|
@@ -101,7 +101,7 @@ module Lolita
|
|
101
101
|
|
102
102
|
def find_dbi_field
|
103
103
|
@dbi_field ||= self.dbi.fields.detect{|field|
|
104
|
-
field.name.to_s ==
|
104
|
+
field.name.to_s == self.name.to_s || (field.association && field.association.name.to_s == self.name.to_s)
|
105
105
|
}
|
106
106
|
end
|
107
107
|
|
@@ -114,11 +114,6 @@ module Lolita
|
|
114
114
|
def set_default_values
|
115
115
|
self.options||={}
|
116
116
|
self.html_options ||= {}
|
117
|
-
@html_options[:class] = if @html_options[:class]
|
118
|
-
"#{@html_options[:class]} #{self.type}"
|
119
|
-
else
|
120
|
-
self.type.to_s
|
121
|
-
end
|
122
117
|
end
|
123
118
|
|
124
119
|
def validate
|
@@ -1,48 +1,25 @@
|
|
1
1
|
module Lolita
|
2
2
|
module Configuration
|
3
3
|
module Field
|
4
|
-
|
5
|
-
# * create select for belongs_to association or
|
6
|
-
# * has_and_belongs_to_many field for selecting all associated objects or
|
7
|
-
# * for polymorphic belongs_to associations
|
8
|
-
# ==Polymorphic builder (:polymorphic)
|
9
|
-
# Create two select boxes one of all related classes and second with related records for that class.
|
10
|
-
# Related classes can have <em>polymorphic_select_name</em> instance method, that is used to populate second
|
11
|
-
# select with visible values by default it calles <em>text_method</em>. It will fallback first content column. Class should respond to one
|
12
|
-
# of these.
|
4
|
+
|
13
5
|
class Array < Lolita::Configuration::Field::Base
|
14
6
|
lolita_accessor :conditions,:text_method,:value_method,:find_options,:association,:include_blank
|
15
|
-
lolita_accessor :related_classes
|
16
7
|
|
17
8
|
def initialize dbi,name,*args, &block
|
9
|
+
self.builder="select"
|
18
10
|
@include_blank=true
|
19
11
|
super
|
20
12
|
self.find_dbi_field unless self.dbi_field
|
21
|
-
|
22
|
-
@association ||= self.dbi_field ? self.dbi_field.association : detect_association
|
23
|
-
self.builder = detect_builder unless @builder
|
24
|
-
self.name = recognize_real_name
|
13
|
+
@association = self.dbi_field ? self.dbi_field.association : nil
|
25
14
|
end
|
26
15
|
|
27
|
-
|
28
|
-
|
29
|
-
if (args && args.any?) || block_given?
|
30
|
-
@search = create_search(*args,&block)
|
31
|
-
end
|
32
|
-
@search
|
33
|
-
end
|
34
|
-
|
35
|
-
def create_search *args, &block
|
36
|
-
Lolita::Configuration::Search.new(Lolita::DBI::Base.create(@association.klass),*args,&block)
|
37
|
-
end
|
38
|
-
|
39
|
-
def values=(value=nil)
|
40
|
-
@values=value
|
16
|
+
def options_for_select=(value=nil)
|
17
|
+
@options_for_select=value
|
41
18
|
end
|
42
19
|
|
43
|
-
def
|
44
|
-
@
|
45
|
-
@
|
20
|
+
def options_for_select value=nil, &block
|
21
|
+
@options_for_select=value || block if value || block_given?
|
22
|
+
@options_for_select
|
46
23
|
end
|
47
24
|
|
48
25
|
# Collect values for array type field.
|
@@ -51,120 +28,50 @@ module Lolita
|
|
51
28
|
# by default it it is <code>id</code>. Use <code>conditions</code> or
|
52
29
|
# <code>find_options</code> for advanced search. When <code>find_options</code>
|
53
30
|
# is used, than <code>conditions</code> is ignored.
|
54
|
-
def association_values(
|
55
|
-
@association_values=if
|
56
|
-
|
57
|
-
elsif search
|
58
|
-
search.run("")
|
59
|
-
elsif @association && @association.polymorphic?
|
60
|
-
polymorphic_association_values(record)
|
31
|
+
def association_values() #TODO test
|
32
|
+
@association_values=if options_for_select
|
33
|
+
options_for_select
|
61
34
|
elsif @association
|
62
35
|
klass=@association.klass
|
36
|
+
current_text_method=@text_method || default_text_method(klass)
|
37
|
+
current_value_method=@value_method || :id
|
63
38
|
options=@find_options || {}
|
64
39
|
options[:conditions]||=@conditions
|
65
|
-
options_array(klass.find(:all,options))
|
66
|
-
else
|
67
|
-
[]
|
68
|
-
end
|
69
|
-
@association_values
|
70
|
-
end
|
71
40
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def polymorphic_association_values(options={})
|
76
|
-
options ||= {}
|
77
|
-
options[:klass] ||= options[:record] && options[:record].send(self.name) ? options[:record].send(self.name).class : nil
|
78
|
-
if options[:klass]
|
79
|
-
options_array(options[:klass].all)
|
41
|
+
klass.find(:all,options).map{|r|
|
42
|
+
[r.send(current_text_method),r.send(current_value_method)]
|
43
|
+
}
|
80
44
|
else
|
81
45
|
[]
|
82
46
|
end
|
83
|
-
|
84
|
-
|
85
|
-
def options_array(collection)
|
86
|
-
klass = collection.last ? collection.last.class : nil
|
87
|
-
collection.map{|r|
|
88
|
-
[r.send(current_text_method(klass)),r.send(current_value_method)]
|
89
|
-
}
|
90
|
-
end
|
91
|
-
|
92
|
-
def current_text_method(klass)
|
93
|
-
@text_method || default_text_method(klass)
|
94
|
-
end
|
95
|
-
|
96
|
-
def current_value_method
|
97
|
-
@value_method || :id
|
47
|
+
@association_values
|
98
48
|
end
|
99
49
|
|
100
50
|
# used in views for shorter accessing to values
|
101
51
|
def view_values(view)
|
102
|
-
|
103
|
-
values = association_values(record)
|
52
|
+
values = association_values
|
104
53
|
if values.respond_to?(:call)
|
105
54
|
values.call(view)
|
106
55
|
else
|
107
|
-
association_values
|
56
|
+
association_values
|
108
57
|
end
|
109
58
|
end
|
110
59
|
|
111
|
-
|
112
|
-
if @association
|
113
|
-
if @association.polymorphic?
|
114
|
-
"polymorphic"
|
115
|
-
elsif @association.macro == :many_to_many
|
116
|
-
"autocomplete"
|
117
|
-
else
|
118
|
-
"select"
|
119
|
-
end
|
120
|
-
else
|
121
|
-
"select"
|
122
|
-
end
|
123
|
-
end
|
60
|
+
private
|
124
61
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
@related_classes.map do |klass|
|
136
|
-
[klass.constantize.model_name.human, klass.to_s]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def recognize_real_name
|
142
|
-
if @association && !@association.polymorphic? && @association.macro == :one
|
143
|
-
self.name = @association.key
|
144
|
-
else
|
145
|
-
@name
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
private
|
150
|
-
|
151
|
-
def default_text_method(klass)
|
152
|
-
assoc_dbi=Lolita::DBI::Base.create(klass) rescue nil
|
153
|
-
if assoc_dbi
|
154
|
-
field=assoc_dbi.fields.detect{|f| f.type.to_s=="string"}
|
155
|
-
if field
|
156
|
-
field.name
|
157
|
-
else
|
158
|
-
raise Lolita::FieldTypeError, %^
|
159
|
-
Can't find any content field in #{assoc_dbi.klass}.
|
160
|
-
Use text_method in #{klass} to set one.
|
161
|
-
^
|
162
|
-
end
|
163
|
-
else
|
164
|
-
warn("Not a ORM class (#{klass.inspect})")
|
165
|
-
end
|
62
|
+
def default_text_method(klass)
|
63
|
+
assoc_dbi=Lolita::DBI::Base.create(klass)
|
64
|
+
field=assoc_dbi.fields.detect{|f| f.type.to_s=="string"}
|
65
|
+
if field
|
66
|
+
field.name
|
67
|
+
else
|
68
|
+
raise Lolita::FieldTypeError, %^
|
69
|
+
Can't find any content field in #{assoc_dbi.klass}.
|
70
|
+
Use text_method in #{klass} to set one.
|
71
|
+
^
|
166
72
|
end
|
167
73
|
end
|
168
74
|
end
|
169
75
|
end
|
170
76
|
end
|
77
|
+
end
|
@@ -18,20 +18,6 @@ module Lolita
|
|
18
18
|
set_default_attributes
|
19
19
|
end
|
20
20
|
|
21
|
-
# For details see Lolita::Configuration::Search
|
22
|
-
def search *args, &block
|
23
|
-
if (args && args.any?) || block_given?
|
24
|
-
@search = Lolita::Configuration::Search.new(self.dbi,*args,&block)
|
25
|
-
end
|
26
|
-
@search
|
27
|
-
end
|
28
|
-
|
29
|
-
# Define or return pagination method. This method is used by DBI adapters to delegate domain specific
|
30
|
-
# pagination back to model.
|
31
|
-
# ====Example
|
32
|
-
# list do
|
33
|
-
# pagination_method :paginate_with_profiles
|
34
|
-
# end
|
35
21
|
def pagination_method(value = nil)
|
36
22
|
if value
|
37
23
|
self.pagination_method = value
|
@@ -43,15 +29,8 @@ module Lolita
|
|
43
29
|
@pagination_method = value
|
44
30
|
end
|
45
31
|
|
46
|
-
|
47
|
-
|
48
|
-
# * <tt>request (optional) </tt> - request that is passed to adapter that passes this to model when #pagination_method is defined
|
49
|
-
def paginate(current_page, request = nil)
|
50
|
-
page_criteria = dbi.paginate(current_page,@per,:request => request, :pagination_method => @pagination_method)
|
51
|
-
if self.search
|
52
|
-
page_criteria = page_criteria.merge(self.search.run(request.params[:q],request))
|
53
|
-
end
|
54
|
-
page_criteria
|
32
|
+
def paginate(current_page, request)
|
33
|
+
dbi.paginate(current_page,@per,:request => request, :pagination_method => @pagination_method)
|
55
34
|
end
|
56
35
|
|
57
36
|
# Set columns. Allowed classes are Lolita::Configuration::Columns or
|
@@ -70,7 +70,7 @@ module Lolita
|
|
70
70
|
def output_with_callbacks(partial_name,name,locals)
|
71
71
|
@component_locals ||={}
|
72
72
|
@component_locals[name] = locals
|
73
|
-
|
73
|
+
|
74
74
|
output = Lolita::Hooks.component(name).run(:before,:run_scope => self).to_s
|
75
75
|
block_output = Lolita::Hooks.component(name).run(:around, :run_scope => self) do
|
76
76
|
render(:partial => partial_name,:locals=>locals)
|
@@ -5,7 +5,7 @@ module Lolita
|
|
5
5
|
included do
|
6
6
|
helper LolitaHelper
|
7
7
|
#TODO pārnest helperus uz lolitu vai arī uz lolita app nevis likt iekš controllers iekš lolitas
|
8
|
-
helpers = %w(resource resource_name
|
8
|
+
helpers = %w(resource resource_name
|
9
9
|
resource_class lolita_mapping show_response tab_form tab_form=)
|
10
10
|
hide_action *helpers
|
11
11
|
|
@@ -21,14 +21,14 @@ module Lolita
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def resource_name
|
24
|
-
lolita_mapping.
|
24
|
+
lolita_mapping.name
|
25
25
|
end
|
26
26
|
|
27
27
|
def resource_class
|
28
28
|
lolita_mapping.to
|
29
29
|
end
|
30
30
|
|
31
|
-
def lolita_mapping
|
31
|
+
def lolita_mapping
|
32
32
|
@lolita_mapping||=request.env["lolita.mapping"]
|
33
33
|
end
|
34
34
|
|
@@ -45,19 +45,6 @@ module Lolita
|
|
45
45
|
end
|
46
46
|
@tab_form
|
47
47
|
end
|
48
|
-
|
49
|
-
def use_mapping(new_mapping)
|
50
|
-
if block_given?
|
51
|
-
begin
|
52
|
-
@old_mapping = lolita_mapping
|
53
|
-
@lolita_mapping = new_mapping
|
54
|
-
yield
|
55
|
-
ensure
|
56
|
-
@lolita_mapping = @old_mapping
|
57
|
-
@old_mapping = nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
48
|
|
62
49
|
protected
|
63
50
|
|
@@ -75,7 +62,6 @@ module Lolita
|
|
75
62
|
|
76
63
|
def is_lolita_resource?
|
77
64
|
raise ActionController::UnknownAction unless lolita_mapping
|
78
|
-
true
|
79
65
|
end
|
80
66
|
|
81
67
|
def resource=(new_resource)
|
@@ -95,7 +81,7 @@ module Lolita
|
|
95
81
|
end
|
96
82
|
|
97
83
|
def get_resource(id=nil)
|
98
|
-
self.resource
|
84
|
+
self.resource=resource_class.lolita.dbi.find_by_id(id||params[:id])
|
99
85
|
end
|
100
86
|
|
101
87
|
def build_resource(attributes=nil)
|
@@ -5,40 +5,28 @@ module Lolita
|
|
5
5
|
# Authentication should be defined through Lolita#setup.
|
6
6
|
# Method call block or send given method name to current controller
|
7
7
|
# or return True when no authentication is defined.
|
8
|
-
# Include this if authentication is neccessary for controller.
|
9
8
|
module UserHelpers
|
10
9
|
extend ActiveSupport::Concern
|
11
10
|
included do
|
12
|
-
|
13
|
-
|
14
|
-
helper_method *helpers
|
11
|
+
helper LolitaHelper
|
15
12
|
end
|
16
|
-
|
13
|
+
|
17
14
|
private
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
else
|
25
|
-
false
|
26
|
-
end
|
15
|
+
# FIXME what to do when block or method return false, and do not redirect
|
16
|
+
# need some redirect, but how to detect it?
|
17
|
+
def authenticate_lolita_user!
|
18
|
+
if auth=Lolita.authentication
|
19
|
+
if auth.is_a?(Proc)
|
20
|
+
self.instance_eval(&auth)
|
27
21
|
else
|
28
|
-
|
22
|
+
send(auth)
|
29
23
|
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def authenticate_lolita_user!
|
35
|
-
if auth = Lolita.authentication
|
36
|
-
send(auth)
|
37
24
|
else
|
38
|
-
|
25
|
+
#TODO warning
|
39
26
|
true
|
40
27
|
end
|
41
28
|
end
|
29
|
+
|
42
30
|
end
|
43
31
|
end
|
44
32
|
end
|