lolita 3.0.7 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GUIDELINE +4 -0
- data/README.rdoc +50 -0
- data/VERSION +1 -1
- data/app/controllers/lolita/rest_controller.rb +27 -11
- data/app/helpers/components/lolita/configuration/list_component.rb +11 -0
- data/app/helpers/lolita_helper.rb +1 -1
- data/app/views/components/lolita/configuration/field/_display.html.erb +9 -0
- data/app/views/components/lolita/configuration/field/_label.html.erb +1 -0
- data/app/views/components/lolita/{field → configuration/field}/_object.html.erb +0 -0
- data/app/views/components/lolita/configuration/field/array/_display.html.erb +5 -0
- data/app/views/components/lolita/configuration/field/array/habtm/_display.html.erb +26 -0
- data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +5 -0
- data/app/views/components/lolita/configuration/field/big_decimal/_display.html.erb +1 -0
- data/app/views/components/lolita/{field/_boolean.html.erb → configuration/field/boolean/_display.html.erb} +0 -0
- data/app/views/components/lolita/configuration/field/date/_display.html.erb +1 -0
- data/app/views/components/lolita/{field/_string.html.erb → configuration/field/float/_display.html.erb} +0 -0
- data/app/views/components/lolita/configuration/field/integer/_display.html.erb +1 -0
- data/app/views/components/lolita/configuration/field/string/_display.html.erb +5 -0
- data/app/views/components/lolita/{field/_disabled.html.erb → configuration/field/string/disabled/_display.html.erb} +0 -0
- data/app/views/components/lolita/{field/_password.html.erb → configuration/field/string/password/_display.html.erb} +0 -0
- data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +34 -0
- data/app/views/components/lolita/configuration/field/time/_display.html.erb +1 -0
- data/app/views/components/lolita/{field_set → configuration/field_set}/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/list/_body.html.erb +5 -0
- data/app/views/components/lolita/{list → configuration/list}/_body_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_checkbox_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_checkbox_header.html.erb +0 -0
- data/app/views/components/lolita/configuration/list/_display.html.erb +12 -0
- data/app/views/components/lolita/configuration/list/_filter.html.erb +8 -0
- data/app/views/components/lolita/configuration/list/_header.html.erb +9 -0
- data/app/views/components/lolita/{list → configuration/list}/_header_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_new_resource.html.erb +0 -0
- data/app/views/components/lolita/configuration/list/_paginator.html.erb +3 -0
- data/app/views/components/lolita/configuration/list/_row.html.erb +7 -0
- data/app/views/components/lolita/{list → configuration/list}/_title.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_tool_cell.html.erb +0 -0
- data/app/views/components/lolita/{list → configuration/list}/_tool_header.html.erb +0 -0
- data/app/views/components/lolita/configuration/tab/_display.html.erb +17 -0
- data/app/views/components/lolita/configuration/tab/_fields.html.erb +7 -0
- data/app/views/components/lolita/configuration/tab/content/_display.html.erb +1 -0
- data/app/views/components/lolita/configuration/tab/default/_display.html.erb +9 -0
- data/app/views/components/lolita/{tabs → configuration/tabs}/_display.html.erb +4 -3
- data/app/views/{lolita/layouts → layouts/lolita}/application.html.erb +0 -0
- data/app/views/{lolita/layouts → layouts/lolita}/application.html.erb_spec.rb +0 -0
- data/author +1 -1
- data/lib/lolita.rb +31 -12
- data/lib/lolita/adapter/active_record.rb +16 -5
- data/lib/lolita/adapter/mongoid.rb +2 -2
- data/lib/lolita/base_configuration.rb +44 -2
- data/lib/lolita/builder.rb +31 -14
- data/lib/lolita/configuration/column.rb +92 -86
- data/lib/lolita/configuration/columns.rb +65 -65
- data/lib/lolita/configuration/factory.rb +8 -8
- data/lib/lolita/configuration/field.rb +156 -100
- data/lib/lolita/configuration/field/array.rb +74 -0
- data/lib/lolita/configuration/field/big_decimal.rb +12 -0
- data/lib/lolita/configuration/field/boolean.rb +7 -5
- data/lib/lolita/configuration/field/date.rb +13 -0
- data/lib/lolita/configuration/field/integer.rb +7 -5
- data/lib/lolita/configuration/field/string.rb +8 -6
- data/lib/lolita/configuration/field/time.rb +13 -0
- data/lib/lolita/configuration/fields.rb +36 -0
- data/lib/lolita/configuration/filter.rb +63 -0
- data/lib/lolita/configuration/list.rb +101 -91
- data/lib/lolita/configuration/page.rb +1 -0
- data/lib/lolita/configuration/tab.rb +137 -131
- data/lib/lolita/configuration/tab/content.rb +14 -12
- data/lib/lolita/configuration/tab/default.rb +15 -13
- data/lib/lolita/configuration/tabs.rb +2 -2
- data/lib/lolita/controllers/component_helpers.rb +26 -14
- data/lib/lolita/controllers/internal_helpers.rb +14 -0
- data/lib/lolita/controllers/url_helpers.rb +47 -10
- data/lib/lolita/dbi/base.rb +50 -50
- data/lib/lolita/errors.rb +2 -2
- data/lib/lolita/hooks.rb +298 -0
- data/lib/lolita/hooks/named_hook.rb +122 -0
- data/lib/lolita/lazy_loader.rb +46 -46
- data/lib/lolita/mapping.rb +3 -2
- data/lib/lolita/navigation.rb +48 -0
- data/lib/lolita/observed_array.rb +7 -0
- data/lib/lolita/rails/routes.rb +29 -3
- data/lolita.gemspec +65 -48
- data/public/javascripts/lolita/tab.js +5 -0
- data/public/javascripts/rails.js +137 -137
- data/public/stylesheets/lolita/style.css +3 -1
- data/spec/builder_spec.rb +42 -0
- data/spec/configuration/field_spec.rb +29 -18
- data/spec/configuration/filter_spec.rb +60 -0
- data/spec/configuration/tab_spec.rb +28 -20
- data/spec/configuration/tabs_spec.rb +8 -4
- data/spec/controllers/lolita_rest_spec.rb +15 -0
- data/spec/hooks_spec.rb +191 -0
- data/spec/lolita_spec.rb +6 -4
- data/spec/navigation/tree_spec.rb +59 -0
- data/spec/rails_app/app/mongoid/post.rb +2 -0
- data/spec/rails_app/app/views/components/lolita/{list → configuration/list}/_body_cell.html.erb +0 -0
- data/spec/rails_app/config/application.rb +1 -0
- data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +14 -0
- data/spec/simple_spec_helper.rb +1 -0
- data/spec/spec_helper.rb +1 -2
- metadata +66 -49
- data/README.md +0 -5
- data/app/helpers/components/lolita/list_component.rb +0 -9
- data/app/views/components/lolita/field/_collection.html.erb +0 -5
- data/app/views/components/lolita/field/_date.html.erb +0 -1
- data/app/views/components/lolita/field/_datetime.html.erb +0 -1
- data/app/views/components/lolita/field/_display.html.erb +0 -6
- data/app/views/components/lolita/field/_integer.html.erb +0 -1
- data/app/views/components/lolita/field/_label.html.erb +0 -1
- data/app/views/components/lolita/field/_select.html.erb +0 -1
- data/app/views/components/lolita/field/_text.html.erb +0 -27
- data/app/views/components/lolita/list/_body.html.erb +0 -5
- data/app/views/components/lolita/list/_display.html.erb +0 -11
- data/app/views/components/lolita/list/_header.html.erb +0 -9
- data/app/views/components/lolita/list/_paginator.html.erb +0 -4
- data/app/views/components/lolita/list/_row.html.erb +0 -7
- data/app/views/components/lolita/tab/_content.html.erb +0 -1
- data/app/views/components/lolita/tab/_default.html.erb +0 -11
- data/app/views/components/lolita/tab/_display.html.erb +0 -7
- data/app/views/components/lolita/tab/_fields.html.erb +0 -7
- data/lib/lolita/configuration/field/collection.rb +0 -71
- data/lib/lolita/configuration/field/datetime.rb +0 -10
- data/lib/lolita/configuration/field/disabled.rb +0 -10
- data/lib/lolita/configuration/field/password.rb +0 -10
- data/lib/lolita/configuration/field/text.rb +0 -10
- data/lib/lolita/hooks/base.rb +0 -58
- data/lib/lolita/hooks/component.rb +0 -15
- data/lib/lolita/hooks/hooks.rb +0 -15
@@ -1,11 +0,0 @@
|
|
1
|
-
<div class="box">
|
2
|
-
<%= render_component :"lolita/list", :title %>
|
3
|
-
<%= render_component :"lolita/list", :new_resource%>
|
4
|
-
<div class="list">
|
5
|
-
<table>
|
6
|
-
<%= render_component :"lolita/list", :header, :columns=>list.columns %>
|
7
|
-
<%= render_component :"lolita/list", :body, :page=>page,:columns=>list.columns %>
|
8
|
-
</table>
|
9
|
-
</div>
|
10
|
-
<%= render_component :"lolita/list", :paginator,:page=>page, :columns=>list.columns %>
|
11
|
-
</div>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<tr class="<%= @class_name %>">
|
2
|
-
<%= render_component :"lolita/list", :checkbox_cell, :record=>record %>
|
3
|
-
<% columns.each do |column| %>
|
4
|
-
<%= render_component :"lolita/list",:body_cell, :value=>column.with_format(record.send(column.name.to_sym)) %>
|
5
|
-
<% end %>
|
6
|
-
<%= render_component :"lolita/list", :tool_cell,:record=>record %>
|
7
|
-
</tr>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render_component :"lolita/tab", :default, :tab=>tab %>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<% #
|
2
|
-
# PĀRNEST ĀRĀ, LAI IR ATSEVIŠĶA VIETA, KUR DAŽĀDA TIPA TABI GLABĀJAS
|
3
|
-
# piemēram, /tab_types/
|
4
|
-
#
|
5
|
-
%>
|
6
|
-
<%= form_tag "#", :id=>"tab-form-#{tab.__id__}" do |form| %>
|
7
|
-
<div class="tab-content">
|
8
|
-
<%#= error_messages_for resource #TODO removed in Rails 3, now available as plugin .. %>
|
9
|
-
<%= render_component :"lolita/tab", :fields, :tab=>tab %>
|
10
|
-
</div>
|
11
|
-
<% end %>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<div class="tab box" id="tab_<%=tab.__id__%>">
|
2
|
-
<div class="tab-title boxtitle black" data-closed="false">
|
3
|
-
<h1><%= tab.title %></h1>
|
4
|
-
<div class="arrow"></div> <%# FIXME more DRY solution is needed for .arrow within .boxtitle, maybe box helper %>
|
5
|
-
</div>
|
6
|
-
<%= render_component :"lolita/tab", tab.type, :tab=>tab %>
|
7
|
-
</div>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<% tab.fields_with_field_set do |fields_or_field,field_set| %>
|
2
|
-
<% if field_set %>
|
3
|
-
<%= render_component :"lolita/field_set", :display, :fields=>fields_or_field,:field_set=>field_set %>
|
4
|
-
<% else %>
|
5
|
-
<%= render_component :"lolita/field", :display,:field=>fields_or_field %>
|
6
|
-
<% end %>
|
7
|
-
<% end %>
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Lolita
|
2
|
-
module Configuration
|
3
|
-
class CollectionField < Lolita::Configuration::Field
|
4
|
-
lolita_accessor :conditions,:text_method,:value_method,:find_options,:association_type,:include_blank
|
5
|
-
|
6
|
-
|
7
|
-
def initialize *args,&block
|
8
|
-
@type="collection"
|
9
|
-
@association_type=:one
|
10
|
-
@include_blank=true
|
11
|
-
super
|
12
|
-
set_association_type
|
13
|
-
end
|
14
|
-
|
15
|
-
def options_for_select=(value=nil)
|
16
|
-
@options_for_select=value
|
17
|
-
end
|
18
|
-
|
19
|
-
def options_for_select value=nil, &block
|
20
|
-
@options_for_select=value || block if value || block_given?
|
21
|
-
@options_for_select
|
22
|
-
end
|
23
|
-
|
24
|
-
# Collect values for collection type field.
|
25
|
-
# Uses <code>text_method</code> for content. By default it search for
|
26
|
-
# first _String_ type field in DB. Uses <code>value_method</code> for value,
|
27
|
-
# by default it it is <code>id</code>. Use <code>conditions</code> or
|
28
|
-
# <code>find_options</code> for advanced search. When <code>find_options</code>
|
29
|
-
# is used, than <code>conditions</code> is ignored.
|
30
|
-
def association_values() #TODO test
|
31
|
-
@association_values||=if options_for_select
|
32
|
-
options_for_select
|
33
|
-
elsif @association
|
34
|
-
klass=@dbi.association_class_name(@association).camelize.constantize
|
35
|
-
current_text_method=@text_method || default_text_method(klass)
|
36
|
-
current_value_method=@value_method || :id
|
37
|
-
options=@find_options || {}
|
38
|
-
options[:conditions]||=@conditions
|
39
|
-
|
40
|
-
klass.find(:all,options).map{|r|
|
41
|
-
[r.send(current_text_method),r.send(current_value_method)]
|
42
|
-
}
|
43
|
-
else
|
44
|
-
[]
|
45
|
-
end
|
46
|
-
@association_values
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def set_association_type #TODO test
|
52
|
-
if @association
|
53
|
-
@association_type||=@dbi.association_macro(@association)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def default_text_method(klass)
|
58
|
-
assoc_dbi=Lolita::DBI::Base.new(klass)
|
59
|
-
field=assoc_dbi.fields.detect{|f| f[:type].downcase=="string"}
|
60
|
-
if field
|
61
|
-
field[:name]
|
62
|
-
else
|
63
|
-
raise Lolita::FieldTypeError, %^
|
64
|
-
Can't find any content field in #{assoc_dbi.klass}.
|
65
|
-
Use text_method in #{klass} to set one.
|
66
|
-
^
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/lib/lolita/hooks/base.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
module Lolita
|
2
|
-
module Hooks
|
3
|
-
class Base
|
4
|
-
|
5
|
-
class << self
|
6
|
-
def get(name)
|
7
|
-
@collection||={}
|
8
|
-
@collection[name]||=self.new(name)
|
9
|
-
@collection[name]
|
10
|
-
end
|
11
|
-
|
12
|
-
def define_callback *names
|
13
|
-
names.each do |name|
|
14
|
-
self.class_eval <<-CALLBACK,__FILE__,__LINE__+1
|
15
|
-
def #{name}(*args,&block)
|
16
|
-
@callbacks||={}
|
17
|
-
@callbacs[:#{name}]||={}
|
18
|
-
@callbacks[:#{name}][:methods]=args || []
|
19
|
-
@callbacks[:#{name}][:block]=block if block_given?
|
20
|
-
end
|
21
|
-
|
22
|
-
def run_#{name} scope, &block
|
23
|
-
self.run(scope,:"#{name}",&block)
|
24
|
-
end
|
25
|
-
CALLBACK
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# To wrap around some content, for example, html code,
|
31
|
-
# call run with block.
|
32
|
-
# ====Example
|
33
|
-
# # in other view
|
34
|
-
# Lolita::Hooks.component(:"lolita/list").replace_with do
|
35
|
-
# # my new html code
|
36
|
-
# end
|
37
|
-
# # in view
|
38
|
-
# Lolita::Hooks.component(:"lolita/list").run(self,:replace_with) do
|
39
|
-
# # your old html here
|
40
|
-
# end
|
41
|
-
# # After this old code will be replaced with new one
|
42
|
-
def run scope,name, &block
|
43
|
-
@callbacks[name][:methods].each do |m|
|
44
|
-
scope.send(m)
|
45
|
-
end
|
46
|
-
if @callbacks[name][:block]
|
47
|
-
if block_given?
|
48
|
-
callback[name][:block].call()
|
49
|
-
else
|
50
|
-
scope.instance_eval(&callbacks[name][:block])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
@callbacks[name]={}
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/lolita/hooks/hooks.rb
DELETED