lolita 3.1.17 → 3.1.18

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 (96) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/lolita/field_data_controller.rb +36 -0
  3. data/app/controllers/lolita/info_controller.rb +12 -1
  4. data/app/controllers/lolita/rest_controller.rb +8 -3
  5. data/app/helpers/lolita_helper.rb +12 -1
  6. data/app/views/components/lolita/configuration/column/_display.html.erb +1 -1
  7. data/app/views/components/lolita/configuration/column/_header.html.erb +1 -1
  8. data/app/views/components/lolita/configuration/column/_sort.html.erb +7 -4
  9. data/app/views/components/lolita/configuration/field/array/_display.html.erb +1 -1
  10. data/app/views/components/lolita/configuration/field/array/autocomplete/_display.html.haml +11 -0
  11. data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +8 -0
  12. data/app/views/components/lolita/configuration/field/array/polymorphic/_display.html.haml +6 -0
  13. data/app/views/components/lolita/configuration/field/array/polymorphic/_options_for_select.html.haml +1 -0
  14. data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +1 -1
  15. data/app/views/components/lolita/configuration/field/string/_display.html.erb +1 -5
  16. data/app/views/components/lolita/configuration/field/string/disabled/_display.html.erb +1 -1
  17. data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +1 -1
  18. data/app/views/components/lolita/configuration/list/_paginator.html.erb +1 -1
  19. data/app/views/components/lolita/configuration/list/_title.html.erb +6 -1
  20. data/app/views/components/lolita/configuration/nested_form/_display.html.erb +8 -6
  21. data/app/views/components/lolita/configuration/search/_display.html.haml +2 -0
  22. data/app/views/components/lolita/navigation/_tree.html.erb +18 -25
  23. data/app/views/components/lolita/shared/_header.html.erb +1 -1
  24. data/app/views/components/lolita/shared/_right_sidebar.html.erb +1 -6
  25. data/app/views/components/lolita/shared/_save_button.html.erb +6 -0
  26. data/config/locales/en.yml +9 -1
  27. data/config/locales/lv.yml +6 -5
  28. data/config/routes.rb +3 -1
  29. data/lib/lolita.rb +52 -35
  30. data/lib/lolita/adapter/abstract_adapter.rb +5 -5
  31. data/lib/lolita/adapter/active_record.rb +190 -84
  32. data/lib/lolita/adapter/field_helper.rb +19 -0
  33. data/lib/lolita/adapter/mongoid.rb +217 -64
  34. data/lib/lolita/builder.rb +1 -1
  35. data/lib/lolita/configuration/base.rb +17 -4
  36. data/lib/lolita/configuration/column.rb +47 -28
  37. data/lib/lolita/configuration/columns.rb +1 -1
  38. data/lib/lolita/configuration/factory/field.rb +45 -0
  39. data/lib/lolita/configuration/factory/tab.rb +18 -0
  40. data/lib/lolita/configuration/field.rb +30 -115
  41. data/lib/lolita/configuration/field/array.rb +126 -41
  42. data/lib/lolita/configuration/field/big_decimal.rb +2 -2
  43. data/lib/lolita/configuration/field/boolean.rb +2 -2
  44. data/lib/lolita/configuration/field/date.rb +2 -2
  45. data/lib/lolita/configuration/field/date_time.rb +2 -2
  46. data/lib/lolita/configuration/field/float.rb +9 -0
  47. data/lib/lolita/configuration/field/hash.rb +9 -0
  48. data/lib/lolita/configuration/field/hidden.rb +2 -2
  49. data/lib/lolita/configuration/field/integer.rb +2 -3
  50. data/lib/lolita/configuration/field/range.rb +9 -0
  51. data/lib/lolita/configuration/field/string.rb +5 -2
  52. data/lib/lolita/configuration/field/symbol.rb +9 -0
  53. data/lib/lolita/configuration/field/time.rb +2 -2
  54. data/lib/lolita/configuration/list.rb +41 -8
  55. data/lib/lolita/configuration/nested_form.rb +2 -2
  56. data/lib/lolita/configuration/search.rb +91 -0
  57. data/lib/lolita/configuration/tab.rb +11 -14
  58. data/lib/lolita/configuration/tab/content.rb +1 -2
  59. data/lib/lolita/configuration/tab/default.rb +0 -1
  60. data/lib/lolita/configuration/tabs.rb +17 -11
  61. data/lib/lolita/controller_additions.rb +15 -0
  62. data/lib/lolita/controllers/authorization_helpers.rb +56 -0
  63. data/lib/lolita/controllers/component_helpers.rb +1 -1
  64. data/lib/lolita/controllers/internal_helpers.rb +18 -4
  65. data/lib/lolita/controllers/url_helpers.rb +5 -1
  66. data/lib/lolita/controllers/user_helpers.rb +23 -11
  67. data/lib/lolita/dbi/base.rb +7 -1
  68. data/lib/lolita/hooks.rb +163 -120
  69. data/lib/lolita/lazy_loader.rb +3 -0
  70. data/lib/lolita/mapping.rb +25 -2
  71. data/lib/lolita/modules/rest.rb +1 -1
  72. data/lib/lolita/navigation/branch.rb +52 -1
  73. data/lib/lolita/navigation/tree.rb +10 -0
  74. data/lib/lolita/rails.rb +1 -2
  75. data/lib/lolita/rails/routes.rb +4 -5
  76. data/lib/lolita/search/simple.rb +76 -0
  77. data/lib/lolita/system_configuration/application.rb +7 -1
  78. data/lolita.gemspec +33 -13
  79. data/public/stylesheets/lolita/style.css +21 -0
  80. data/spec/configuration/column_spec.rb +2 -2
  81. data/spec/configuration/columns_spec.rb +1 -1
  82. data/spec/configuration/field_spec.rb +14 -43
  83. data/spec/configuration/list_spec.rb +24 -20
  84. data/spec/configuration/search_spec.rb +44 -0
  85. data/spec/configuration/tab_spec.rb +21 -31
  86. data/spec/configuration/tabs_spec.rb +2 -2
  87. data/spec/dbi/base_spec.rb +3 -9
  88. data/spec/rails_app/app/mongoid/post.rb +4 -0
  89. data/spec/rails_app/config/application.rb +12 -1
  90. data/spec/rails_app/config/environments/development.rb +6 -2
  91. data/spec/rails_app/config/environments/production.rb +5 -1
  92. data/spec/rails_app/config/environments/test.rb +5 -1
  93. data/spec/search/simple_spec.rb +48 -0
  94. data/spec/spec_helper.rb +29 -18
  95. metadata +55 -38
  96. data/spec/configuration/page_spec.rb +0 -20
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.17
1
+ 3.1.18
@@ -0,0 +1,36 @@
1
+ class Lolita::FieldDataController < ApplicationController
2
+ include Lolita::Controllers::UserHelpers
3
+
4
+ before_filter :authenticate_lolita_user!
5
+ before_filter :find_field, :except => [:autocomplete_field]
6
+
7
+ def array_polymorphic
8
+ klass = params[:class].camelize.constantize
9
+ data_collection = @field.polymorphic_association_values(:klass => klass)
10
+ @id = params[:id].to_s.to_i
11
+ @collection = [[]]+data_collection
12
+ render_component(*@field.build(:state => :options_for_select, :collection => @collection, :id => @id))
13
+ end
14
+
15
+ def find_field
16
+ @field = params[:field_class].camelize.constantize.lolita.tabs.fields.detect{|field|
17
+ field.name.to_s == params[:name].to_s
18
+ }
19
+ end
20
+
21
+ def autocomplete_field
22
+ klass = params[:field_class].camelize.constantize
23
+ field = klass.lolita.tabs.fields.detect{|field| field.name.to_s == params[:field_name]}
24
+ data = if field
25
+ (field.search || field.create_search(true)).run(params[:term],request).map do |record|
26
+ {
27
+ :id => record.id,
28
+ :value => record.send(field.current_text_method(field.association.klass)),
29
+ :name => "#{params[:field_class].downcase}[#{params[:field_name].singularize}_ids][]",
30
+ :delete_link => I18n.t("lolita.shared.delete")
31
+ }
32
+ end
33
+ end
34
+ render :json => data || {}
35
+ end
36
+ end
@@ -1,9 +1,16 @@
1
1
  class Lolita::InfoController < ApplicationController
2
2
  @@properties = []
3
+ include Lolita::Controllers::UserHelpers
4
+ include Lolita::Controllers::AuthorizationHelpers
5
+ before_filter :authenticate_lolita_user!, :only => [:index]
3
6
 
4
7
  def index
5
8
  if Lolita.mappings.any?
6
- return redirect_to(lolita_resources_path(Lolita.mappings.values.first))
9
+ available_mapping = Lolita.mappings.detect{|name,mapping|
10
+ can?(:read,mapping.to)
11
+ }
12
+ available_mapping &&= available_mapping.last
13
+ return redirect_to(lolita_resources_path(available_mapping)) if available_mapping
7
14
  end
8
15
  render :layout => false
9
16
  end
@@ -16,6 +23,10 @@ class Lolita::InfoController < ApplicationController
16
23
  end
17
24
  end
18
25
 
26
+ def is_lolita_resource?
27
+ true
28
+ end
29
+
19
30
  private
20
31
 
21
32
  def self.property(name, value = nil)
@@ -1,6 +1,5 @@
1
1
  class Lolita::RestController < ApplicationController
2
- include Lolita::Controllers::UserHelpers
3
- include Lolita::Controllers::InternalHelpers
2
+ include Lolita::ControllerAdditions
4
3
 
5
4
  include Lolita::Hooks
6
5
  add_hook :before_new, :after_new, :before_create,:after_create,:before_edit,:after_edit
@@ -12,12 +11,14 @@ class Lolita::RestController < ApplicationController
12
11
 
13
12
  def new
14
13
  self.run(:before_new)
14
+ authorize!(:create,self.resource_class)
15
15
  build_resource
16
16
  show_form
17
17
  end
18
18
 
19
19
  def create
20
20
  self.run(:before_create)
21
+ authorize!(:create,self.resource_class)
21
22
  build_resource
22
23
  save_and_redirect
23
24
  end
@@ -25,12 +26,14 @@ class Lolita::RestController < ApplicationController
25
26
  def edit
26
27
  self.run(:before_edit)
27
28
  get_resource
29
+ authorize!(:update,self.resource)
28
30
  show_form
29
31
  end
30
32
 
31
33
  def update
32
34
  self.run(:before_update)
33
35
  get_resource
36
+ authorize!(:update,self.resource)
34
37
  if self.resource
35
38
  self.resource=resource_with_attributes(self.resource,resource_attributes)
36
39
  save_and_redirect
@@ -41,6 +44,7 @@ class Lolita::RestController < ApplicationController
41
44
  def destroy
42
45
  self.run(:before_destroy)
43
46
  get_resource
47
+ authorize!(:destroy, self.resource)
44
48
  if self.resource && self.resource.destroy
45
49
  flash[:notice] = ::I18n.t "lolita.shared.destroy_notice"
46
50
  else
@@ -52,6 +56,7 @@ class Lolita::RestController < ApplicationController
52
56
 
53
57
  def index
54
58
  self.run(:before_index)
59
+ authorize!(:read,self.resource_class)
55
60
  respond_to do |format|
56
61
  format.html do
57
62
  build_response_for(:list,:page=>page)
@@ -125,6 +130,6 @@ class Lolita::RestController < ApplicationController
125
130
  end
126
131
 
127
132
  def page
128
- resource_class.lolita.list.paginate(params[:page], :params => params)
133
+ resource_class.lolita.list.paginate(params[:page],request)
129
134
  end
130
135
  end
@@ -1,5 +1,4 @@
1
1
  module LolitaHelper
2
-
3
2
  # Classes for div block that is located to the right of menu
4
3
  # This is helpful because different positionings within it exist depending on action
5
4
  def content_classes
@@ -9,4 +8,16 @@ module LolitaHelper
9
8
  end
10
9
  classes.join(" ")
11
10
  end
11
+
12
+ def include_application_assets
13
+ result = ""
14
+ Lolita.application.assets.each do |asset_name|
15
+ if attr_name.match(/\.js(\.|$)/)
16
+ result << javascript_include_tag(asset_name)
17
+ elsif attr_name.match(/\.css(\.|$)/)
18
+ result << stylesheet_link_tag(asset_name)
19
+ end
20
+ end
21
+ raw(result)
22
+ end
12
23
  end
@@ -1,4 +1,4 @@
1
1
  <td>
2
- <% value=column.formatter.with(record.send(column.name.to_sym),record,self) %>
2
+ <% value=column.formatter.with(column.value(record),record,self) %>
3
3
  <%= value.to_s %>
4
4
  </td>
@@ -1,4 +1,4 @@
1
- <th <%=column.currently_sorting?(params) ? "class='active'" : ""%> >
1
+ <th>
2
2
  <% if column.sortable? %>
3
3
  <%= render_component column, :sort %>
4
4
  <% else %>
@@ -1,4 +1,7 @@
1
- <% param_options=params.reject{|k,v| [:controller,:action].include?(k)} %>
2
- <% options=param_options.merge(column.sort_options(params)) %>
3
- <% direction_indicator=column.currently_sorting?(params) && options[:sd].to_s=="desc" ? raw('&uArr;') : raw('&dArr;') %>
4
- <%= link_to raw("#{column.title.to_s.capitalize } #{direction_indicator}"), lolita_resources_path(options) %>
1
+ <%
2
+ sort_mapping = {"desc" => '&dArr;', "asc" => '&uArr;'}
3
+ new_params = params.reject{|k,v| ["controller","action"].include?(k.to_s)}
4
+ direction_indicator = raw(sort_mapping[column.current_sort_state(new_params)[1]])
5
+ new_params[:s] = column.sort_params(new_params)
6
+ %>
7
+ <%= link_to raw("#{column.title.to_s.capitalize} #{direction_indicator}"), lolita_resources_path(new_params) %>
@@ -1,4 +1,4 @@
1
- <% if field.association_type == :one %>
1
+ <% if field.association && field.association.macro == :one %>
2
2
  <%= render_component :"lolita/configuration/field/array/select", :display, :field=>field %>
3
3
  <% else %>
4
4
  <%= render_component :"lolita/configuration/field/array/habtm", :display, :field=>field %>
@@ -0,0 +1,11 @@
1
+ - ids_method = field.name.to_s.match(/_ids$/) ? field.name : "#{field.name.to_s.singularize}_ids"
2
+
3
+ .autocomplete-container
4
+ = hidden_field_tag "#{resource_name}[#{ids_method}][]",""
5
+ = text_field_tag :"autocomplete-#{resource_name}", nil, :"data-autocomplete-url" => autocomplete_field_path(:field_class => tab_form.object.class.to_s, :field_name => field.name)
6
+ %ul
7
+ - resource.persisted? && resource.send(field.name).each do |element|
8
+ %li
9
+ = element.send(element.class.lolita.tabs.first.fields.first.name.to_sym)
10
+ = link_to I18n.t("lolita.shared.delete").downcase, nil
11
+ = hidden_field_tag "#{resource_name}[#{ids_method}][]", element.id
@@ -0,0 +1,8 @@
1
+ - ids_method = field.name.to_s.match(/_ids$/) ? field.name : "#{field.name.to_s.singularize}_ids"
2
+ = hidden_field_tag "#{resource_name}[#{ids_method}][]",""
3
+ - field.view_values(self).each do |value|
4
+ - editors = resource.send(:"#{ids_method}")
5
+ .habtm-container
6
+ = label_tag "#{resource_name}_#{field.name}_#{value.last}",value.first, :class => "habtm-label"
7
+ = check_box_tag "#{resource_name}[#{ids_method}][]", value.last, resource.send("#{ids_method}").include?(value.last), :id => "#{resource_name}_#{field.name}_#{value.last}", :class => "habtm-checkbox"
8
+ .clear
@@ -0,0 +1,6 @@
1
+ - record = tab_form.object
2
+ - type_name = field.association.name.to_s + "_type"
3
+ - id_name = field.association.name.to_s + "_id"
4
+
5
+ = tab_form.select(type_name,field.polymorphic_classes, {:include_blank => true},{:"data-polymorphic-url" => array_field_data_collector_path(:name => field.name, :field_class => record.class.to_s, :class => "klass", :id =>record.send(id_name) || 0) })
6
+ = tab_form.select(id_name, field.polymorphic_association_values(:record => record))
@@ -1,4 +1,4 @@
1
1
  <%= tab_form.select field.name,
2
2
  (field.view_values(self)),
3
- {:include_blank => field.include_blank},
3
+ (field.options || {}).merge({:include_blank => field.include_blank}),
4
4
  field.html_options || {} %>
@@ -1,5 +1 @@
1
- <% if field.options[:native_type] == "text" %>
2
- <%= render_component :"lolita/configuration/field/string/text", :display, :field=>field %>
3
- <% else %>
4
- <%= tab_form.text_field field.name, field.html_options %>
5
- <% end %>
1
+ <%= tab_form.text_field field.name, field.html_options %>
@@ -1 +1 @@
1
- <div class="disabled-field"><%= resource.send(field.name) %></div>
1
+ <div class="disabled-field"><%= raw(tab_form.object.send(field.name)) %></div>
@@ -5,7 +5,7 @@
5
5
  <% end %>
6
6
  <% end %>
7
7
 
8
- <%= tab_form.text_area field.name, :rows=>(field.rows || 20), :"data-simple"=>field.simple %>
8
+ <%= text_area resource_name, field.name, :rows=>(field.rows || 20), :"data-simple"=>field.simple %>
9
9
  <% if @textarea_component_include_tinymce_once.nil? %>
10
10
  <script type="text/javascript">
11
11
  $(document).ready(
@@ -1 +1 @@
1
- <%= paginate page, :theme => "lolita" %>
1
+ <%= paginate page, :theme => "lolita", :params => params %>
@@ -1,5 +1,10 @@
1
1
  <div class="boxtitle">
2
- <h1 class="black"><%= resource_class.model_name.human(:count=>2) %></h1>
2
+ <h1 class="black">
3
+ <%= resource_class.model_name.human(:count=>2) %>
4
+ <% if list.search %>
5
+ <%= render_component list.search, :display %>
6
+ <% end %>
7
+ </h1>
3
8
  <div class="arrow">
4
9
  </div>
5
10
  </div>
@@ -1,12 +1,14 @@
1
- <div class="nested_form" id=<%= "nested_form_#{nested_form.__id__}" %>>
1
+ <div class="nested_form <%=nested_form.field_style%>" id=<%= "nested_form_#{nested_form.__id__}" %>>
2
2
  <% unless nested_form.field_style == :normal %>
3
3
  <%= render_component *nested_form.as_field.build(:name=>"/lolita/configuration/field", :state => :"label") %>
4
4
  <% end %>
5
- <%= tab_form.fields_for nested_form.name, resource.send(nested_form.build_method) do |form| %>
6
- <% tab_form(form) do %>
7
- <%= render_component nested_form, :fields %>
8
- <% end %>
9
- <% end %>
5
+ <div class="nested-form-fields-container">
6
+ <%= tab_form.fields_for nested_form.name, resource.send(nested_form.build_method) do |form| %>
7
+ <% tab_form(form) do %>
8
+ <%= render_component nested_form, :fields %>
9
+ <% end %>
10
+ <% end %>
11
+ </div>
10
12
  <% if nested_form.expandable? && !nested_form.update_only? %>
11
13
  <p><%= link_to_add_fields ::I18n.t("lolita.nested_form.add", :resource_name => nested_form.klass.model_name.human.downcase), tab_form, nested_form %> </p>
12
14
  <% end %>
@@ -0,0 +1,2 @@
1
+ = form_tag lolita_resources_path(), :method => :get, :class => "search" do
2
+ %input{:type => "text", :name => "q", :value => params[:q], :placeholder => t("lolita.search")}
@@ -11,29 +11,22 @@
11
11
  end
12
12
  end
13
13
  end %>
14
- <ul <%=!tree.root? ? "class='subtree'" : ""%> >
15
- <% last_branch=tree.branches.last %>
16
- <%tree.branches.each do |branch|
17
- if branch.object.is_a?(Lolita::Mapping)
18
- active=if self.respond_to?(:resource_class)
19
- branch.object ? branch.object.to==resource_class : false
20
- end
21
- end
22
- unless active
23
- active=branch.self_with_children.detect{|b|
24
- if b.options[:active].respond_to?(:call)
25
- b.options[:active].call(self,branch,b)
26
- else
27
- b.options[:url]==request.path
28
- end
29
- }
30
- end
31
- %>
32
- <li class="<%=active ? "active" : ""%> <%=branch.children.branches.any? ? "with-subtree" : ""%> <%=!tree.root? && branch==last_branch ? "last-in-subtree" : ""%>">
33
- <%= link_to branch.title, branch.options[:url] || "#" %>
34
- <% if branch.children.branches.any? %>
35
- <%= render_component(:"lolita/navigation",:tree,:tree=>branch.children) %>
14
+
15
+ <% visible ||= (tree.root? || nil) %>
16
+
17
+ <% if tree.visible?(self) %>
18
+ <ul <%= !tree.root? ? "class='subtree'" : ""%> style="display:<%=visible ? "block" : "none"%>" >
19
+ <% last_branch=tree.branches.last %>
20
+ <%tree.branches.each do |branch|
21
+ if branch.visible?(self)
22
+ active = branch.active?(self) %>
23
+ <li class="<%=active ? "active" : ""%> <%=branch.subtree? ? "with-subtree" : ""%> <%=!tree.root? && branch==last_branch ? "last-in-subtree" : ""%>">
24
+ <%= link_to branch.title, branch.options[:url] || "#", :onclick => branch.subtree? ? "$(this).next().toggle();return false;" : "" %>
25
+ <% if branch.subtree? %>
26
+ <%= render_component(:"lolita/navigation",:tree,:tree=>branch.children, :visible => active) %>
27
+ <% end %>
28
+ </li>
36
29
  <% end %>
37
- </li>
38
- <% end %>
39
- </ul>
30
+ <% end %>
31
+ </ul>
32
+ <% end %>
@@ -3,7 +3,7 @@
3
3
  <% if lolita_current_user %>
4
4
  <nav>
5
5
  <a href="<%=send(:"edit_#{lolita_current_user.class.to_s.downcase}_password_path")%>" class="username"><%=lolita_current_user.email%></a>
6
- <a href="<%=send(:"destroy_#{lolita_current_user.class.to_s.downcase}_session_path")%>" class="button grey"><%=::I18n.t("lolita.shared.log_out")%></a>
6
+ <%= link_to ::I18n.t("lolita.shared.log_out"), send(:"destroy_#{lolita_current_user.class.to_s.downcase}_session_path"), :class => "button grey", :method => Devise.sign_out_via %>
7
7
  </nav>
8
8
  <% end %>
9
9
  </header>
@@ -4,11 +4,6 @@
4
4
  <h1><%= t "lolita.tabs.save" %></h1>
5
5
  <div class="arrow"></div>
6
6
  </div>
7
- <div class="save black">
8
- <div class="last-save">
9
- <%= resource.updated_at.strftime("#{t("lolita.tabs.last_save")}: %m/%d/%Y %H:%M ") if resource.respond_to?(:updated_at) && resource.updated_at %>
10
- </div>
11
- <button class="save-all"><%=::I18n.t("lolita.tabs.save")%></button>
12
- </div>
7
+ <%= render_component "lolita/shared", :save_button%>
13
8
  </div>
14
9
  </div>
@@ -0,0 +1,6 @@
1
+ <div class="save black">
2
+ <div class="last-save">
3
+ <%= resource.updated_at.strftime("#{t("lolita.tabs.last_save")}: %m/%d/%Y %H:%M ") if resource.respond_to?(:updated_at) && resource.updated_at %>
4
+ </div>
5
+ <button class="save-all"><%=::I18n.t("lolita.tabs.save")%></button>
6
+ </div>
@@ -22,4 +22,12 @@ en:
22
22
  confirm: Are you sure you want to delete record?
23
23
  filter:
24
24
  apply_button: Apply
25
- include_blank_by_title: " -- Filter by %{title} -- "
25
+ include_blank_by_title: " -- Filter by %{title} -- "
26
+ search: "Search"
27
+ views:
28
+ pagination:
29
+ previous: "&laquo; Previous"
30
+ next: "Next &raquo;"
31
+ last: "Last"
32
+ first: "First"
33
+ truncate: "..."
@@ -7,7 +7,7 @@ lv:
7
7
  edit: Labot
8
8
  delete: Dzēst
9
9
  and: un
10
- powered: Darbojas ar Lolita (2010-%{year})
10
+ powered: Tiek darbināta ar Lolita (2010-%{year})
11
11
  nested_form:
12
12
  add: "Pievienot %{resource_name}"
13
13
  tabs:
@@ -23,10 +23,11 @@ lv:
23
23
  filter:
24
24
  apply_button: Pielietot
25
25
  include_blank_by_title: " -- Filtrēt pēc %{title} -- "
26
+ search: "Meklēt"
26
27
  views:
27
28
  pagination:
28
- previous: "&laquo; Atpakaļ"
29
- next: "Uz priekšu &raquo;"
30
- last: "Beigas"
31
- first: "Sākums"
29
+ previous: "&laquo; Iepriekšējā"
30
+ next: "Nākošā &raquo;"
31
+ last: "Pēdējā"
32
+ first: "Pirmā"
32
33
  truncate: "..."
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
  match '/lolita' => "lolita/info#index"
3
3
  match '/lolita/info/properties' => "lolita/info#properties"
4
- end
4
+ match "/lolita/array_field/:name/:field_class/:class/:id" => "lolita/field_data#array_polymorphic", :as => "array_field_data_collector"
5
+ match "/lolita/autocomplete_field/:field_class/:field_name" => "lolita/field_data#autocomplete_field", :as => "autocomplete_field"
6
+ end
data/lib/lolita.rb CHANGED
@@ -1,29 +1,23 @@
1
1
 
2
2
  $:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
3
3
  LOLITA_VERSION=File.read(File.expand_path("../../VERSION",__FILE__)).gsub(/[^.\w]/,"")
4
- puts "=> Lolita #{LOLITA_VERSION} starting#{defined?(Rails) ? " with Rails" : ""}"
5
-
6
- # TODO should allow run lolita seperated
7
- # unless (["-d","--debug"] & ARGV).empty?
8
- # require "ruby-debug"
9
- # Debugger.settings[:autoeval]=true
10
- # else
11
- # unless self.respond_to?(:debugger)
12
- # def debugger
13
- # warn "Debugger called at #{caller.first} was ignored, run lolita with -d to attatch debugger."
14
- # end
15
- # end
16
- # end
4
+ FRAMEWORK = if defined?(Rails)
5
+ " with Rails #{::Rails::VERSION::STRING}"
6
+ end
7
+ puts "=> Lolita #{LOLITA_VERSION} starting#{FRAMEWORK}"
17
8
 
9
+ require "rubygems"
18
10
  require 'abstract'
19
- require "base64"
20
- unless defined?(ActiveSupport)
21
- require 'active_support/core_ext/numeric/time'
22
- require 'active_support/core_ext/date_time/conversions'
23
- require 'active_support/concern'
24
- require 'active_support/callbacks'
25
- require 'active_support/dependencies'
26
- end
11
+
12
+ require 'active_support'
13
+ require 'active_support/core_ext/numeric/time'
14
+ require 'active_support/core_ext/date_time/conversions'
15
+ require 'active_support/concern'
16
+ require 'active_support/callbacks'
17
+ require 'active_support/dependencies'
18
+ require 'active_support/inflector'
19
+
20
+
27
21
  require 'lolita/errors'
28
22
  require "lolita/hooks"
29
23
  # Require all ruby extensions
@@ -39,6 +33,7 @@ module Lolita
39
33
  autoload(:VERSION,'lolita/version')
40
34
  autoload(:ObservedArray,'lolita/observed_array')
41
35
  autoload(:Builder,'lolita/builder')
36
+ autoload(:ControllerAdditions,'lolita/controller_additions')
42
37
  module Builder
43
38
  autoload(:Custom, 'lolita/builder')
44
39
  end
@@ -49,6 +44,7 @@ module Lolita
49
44
  end
50
45
 
51
46
  module Adapter
47
+ autoload :FieldHelper, 'lolita/adapter/field_helper'
52
48
  autoload :AbstractAdapter, 'lolita/adapter/abstract_adapter'
53
49
  autoload :ActiveRecord, 'lolita/adapter/active_record'
54
50
  autoload :Mongoid, 'lolita/adapter/mongoid'
@@ -62,34 +58,36 @@ module Lolita
62
58
  autoload :NamedHook, "lolita/hooks/named_hook"
63
59
  end
64
60
 
65
-
61
+ # Keep all configuration classes and modules, that is used to configure classes with lolita.
66
62
  module Configuration
67
- autoload :Helper, 'lolita/configuration/helper'
68
- autoload :Factory, 'lolita/configuration/factory'
63
+
69
64
  autoload :Base, 'lolita/configuration/base'
70
65
  autoload :Column, 'lolita/configuration/column'
71
66
  autoload :Columns, 'lolita/configuration/columns'
72
67
  autoload :Fields, 'lolita/configuration/fields'
73
68
  autoload :FieldSet, 'lolita/configuration/field_set'
74
69
  autoload :List, 'lolita/configuration/list'
75
- autoload :Page, 'lolita/configuration/page'
76
70
  autoload :Tabs, 'lolita/configuration/tabs'
77
71
  autoload :Filter, 'lolita/configuration/filter'
78
72
  autoload :NestedForm, 'lolita/configuration/nested_form'
73
+ autoload :Search, 'lolita/configuration/search'
79
74
 
75
+ # Module contains classes that is used to create specific type class based on given arguments.
76
+ module Factory
77
+ autoload :Field, "lolita/configuration/factory/field"
78
+ autoload :Tab, "lolita/configuration/factory/tab"
79
+ end
80
+
81
+ # Contains all supported field types. Class name is Lolita::Configuration::Field::[FieldType]
80
82
  module Field
81
- extend Lolita::Configuration::Factory
82
- autoload :Base, 'lolita/configuration/field'
83
- ["field"].each do |type|
84
- Dir["#{File.dirname(__FILE__)}/lolita/configuration/#{type}/**/*.*"].each do |path|
85
- base_name=File.basename(path,".rb")
86
- autoload :"#{base_name.camelize}", "lolita/configuration/#{type}/#{base_name}"
87
- end
83
+ autoload :Base,'lolita/configuration/field'
84
+ Dir["#{File.dirname(__FILE__)}/lolita/configuration/field/**/*.*"].each do |path|
85
+ base_name=File.basename(path,".rb")
86
+ autoload :"#{base_name.camelize}", "lolita/configuration/field/#{base_name}"
88
87
  end
89
88
  end
90
-
89
+
91
90
  module Tab
92
- extend Lolita::Configuration::Factory
93
91
  autoload :Base, 'lolita/configuration/tab'
94
92
  ["tab"].each do |type|
95
93
  Dir["#{File.dirname(__FILE__)}/lolita/configuration/#{type}/**/*.*"].each do |path|
@@ -101,6 +99,9 @@ module Lolita
101
99
 
102
100
  def self.included(base)
103
101
  base.class_eval do
102
+ include Lolita::Hooks
103
+ add_hook :after_lolita_loaded
104
+
104
105
  extend ClassMethods
105
106
  def lolita
106
107
  self.class.lolita
@@ -112,6 +113,7 @@ module Lolita
112
113
  def lolita(&block)
113
114
  Lolita::LazyLoader.lazy_load(self,:@lolita,Lolita::Configuration::Base,self,&block)
114
115
  end
116
+
115
117
  def lolita=(value)
116
118
  if value.is_a?(Lolita::Configuration::Base)
117
119
  @lolita=value
@@ -131,7 +133,7 @@ module Lolita
131
133
  autoload :UserHelpers, 'lolita/controllers/user_helpers'
132
134
  autoload :UrlHelpers, 'lolita/controllers/url_helpers'
133
135
  autoload :ComponentHelpers, 'lolita/controllers/component_helpers'
134
- autoload :ViewUserHelpers, 'lolita/controllers/view_user_helpers'
136
+ autoload :AuthorizationHelpers, 'lolita/controllers/authorization_helpers'
135
137
  end
136
138
 
137
139
  module Navigation
@@ -146,6 +148,10 @@ module Lolita
146
148
  end
147
149
  end
148
150
 
151
+ module Search
152
+ autoload :Simple, 'lolita/search/simple'
153
+ end
154
+
149
155
  @@scopes={}
150
156
 
151
157
  def self.scope name=nil
@@ -173,6 +179,13 @@ module Lolita
173
179
  end
174
180
 
175
181
  def self.method_missing method_name, *args, &block
182
+ self.class_eval <<-LOLITA_SETUP,__FILE__,__LINE__+1
183
+ class << self
184
+ def #{method_name}(*args,&block)
185
+ scope.send(:#{method_name},*args,&block)
186
+ end
187
+ end
188
+ LOLITA_SETUP
176
189
  scope.send(method_name,*args,&block)
177
190
  end
178
191
 
@@ -187,5 +200,9 @@ module Lolita
187
200
  end
188
201
 
189
202
  if Lolita.rails3?
203
+ require "base64"
204
+ require 'kaminari'
205
+ # require 'tinymce-rails'
206
+ # require 'jquery-rails'
190
207
  require 'lolita/rails/all'
191
208
  end