sunrise-widgets 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem "rails", "3.0.
|
4
|
+
gem "rails", "3.0.10"
|
5
5
|
gem "capybara", ">= 0.4.0"
|
6
6
|
gem "sqlite3"
|
7
7
|
|
@@ -23,6 +23,7 @@ gem 'simple_form'
|
|
23
23
|
gem 'awesome_nested_set'
|
24
24
|
gem 'fastercsv'
|
25
25
|
gem 'ckeditor'
|
26
|
+
gem "has_scope"
|
26
27
|
|
27
28
|
gem 'galetahub-enum_field', '~> 0.1.4', :require => 'enum_field'
|
28
29
|
gem 'galetahub-salty_slugs', '~> 1.0.0', :require => 'salty_slugs'
|
@@ -1,13 +1,18 @@
|
|
1
1
|
class Manage::WidgetsController < Manage::BaseController
|
2
2
|
inherit_resources
|
3
3
|
defaults :route_prefix => 'manage'
|
4
|
-
|
5
|
-
before_filter :make_filter, :only=>[:index]
|
6
4
|
|
7
5
|
load_and_authorize_resource :class => Widget
|
8
|
-
|
9
6
|
cache_sweeper :widget_sweeper, :only => [:create, :update, :destroy]
|
10
7
|
|
8
|
+
with_options :only => [:index] do |i|
|
9
|
+
i.has_scope :with_title, :as => :title
|
10
|
+
i.has_scope :with_position, :as => :position
|
11
|
+
i.has_scope :with_type, :as => :type
|
12
|
+
i.has_scope :with_structure, :as => :structure
|
13
|
+
end
|
14
|
+
order_by :title, :created_at, :sort_order
|
15
|
+
|
11
16
|
def create
|
12
17
|
create!{ manage_widgets_path }
|
13
18
|
end
|
@@ -23,11 +28,6 @@ class Manage::WidgetsController < Manage::BaseController
|
|
23
28
|
protected
|
24
29
|
|
25
30
|
def collection
|
26
|
-
@widgets = (@widgets || end_of_association_chain).
|
27
|
-
end
|
28
|
-
|
29
|
-
def make_filter
|
30
|
-
@search = Sunrise::ModelFilter.new(Widget, :attributes => [:title, :widget_position_id, :widget_type_id])
|
31
|
-
@search.update_attributes(params[:search])
|
31
|
+
@widgets = (@widgets || end_of_association_chain).order(search_filter.order).includes(:structure).page(params[:page])
|
32
32
|
end
|
33
33
|
end
|
@@ -2,22 +2,31 @@
|
|
2
2
|
<div class="filt-bl">
|
3
3
|
<%= link_to_function t('manage.model_filter.title'), "Manage.toggle_element('block_filter')", :class=>"dark-arr" %>
|
4
4
|
|
5
|
+
<%= t('manage.model_filter.total_count') %>: <%= @widgets.total_count %>
|
6
|
+
|
5
7
|
<%= cookie_content_tag(:div, :id=>"block_filter", :class=>"filt") do %>
|
6
|
-
<%= form_for @search, :as => :search, :url=>manage_widgets_path, :html=>{:method=>:get, :id=>"form_filter"} do |f| %>
|
7
|
-
<%= f.label :title, t('widget.title', :scope => [:activerecord, :attributes]) %>
|
8
|
-
<%= f.text_field :title, :class=>"text" %>
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
<%= form_for search_filter, :url => manage_widgets_path, :html =>{ :method => :get } do |f| %>
|
10
|
+
<% controller.scopes_configuration.each do |key, value| %>
|
11
|
+
<% next if [:with_position, :with_type, :with_structure].include?(key) %>
|
12
|
+
<%= f.label value[:as], t(value[:as], :scope => "activerecord.attributes.widget") %>
|
13
|
+
<%= f.text_field value[:as], :class => "text", :name => value[:as] %>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= f.label :widget_position_id, t(:widget_position_id, :scope => "activerecord.attributes.widget") %>
|
17
|
+
<%= f.collection_select :position, WidgetPosition.all, :id, :title, {:include_blank => true}, {:name => "position"} %>
|
18
|
+
|
19
|
+
<%= f.label :widget_type_id, t(:widget_type_id, :scope => "activerecord.attributes.widget") %>
|
20
|
+
<%= f.collection_select :type, WidgetType.all, :id, :title, {:include_blank => true}, {:name => "type"} %>
|
21
|
+
|
22
|
+
<%= f.label :structure_id, t(:structure_id, :scope => "activerecord.attributes.widget") %>
|
23
|
+
<%= f.select :structure, nested_set_options(Structure) {|i| "#{'–' * i.depth} #{i.title}"}, {:include_blank => true}, {:name => "structure"} %>
|
12
24
|
|
13
|
-
<%= f.label :widget_type_id, t('widget.widget_type_id', :scope => [:activerecord, :attributes]) %>
|
14
|
-
<%= f.collection_select :widget_type_id, WidgetType.all, :id, :title, :include_blank => true %>
|
15
|
-
|
16
25
|
<div class="buts">
|
17
|
-
<%= content_tag(:button, :value=>"search", :type=>"submit", :name=>"commit", :class=>"gr cupid-green") do %>
|
26
|
+
<%= content_tag(:button, :value => "search", :type => "submit", :name => "commit", :class => "gr cupid-green") do %>
|
18
27
|
<%= t('manage.model_filter.search') %>
|
19
28
|
<% end %>
|
20
|
-
|
29
|
+
|
21
30
|
<%= link_to t('manage.model_filter.clear'), manage_widgets_path, :class=>"erase" %>
|
22
31
|
</div>
|
23
32
|
<% end %>
|
@@ -25,16 +34,12 @@
|
|
25
34
|
</div>
|
26
35
|
<div class="sort">
|
27
36
|
<label><%= t('manage.sort') %></label>
|
28
|
-
<div class="select-input"><%= link_to_function t(
|
37
|
+
<div class="select-input"><%= link_to_function t(search_filter.current_order, :scope => "manage.widgets.sort"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
|
29
38
|
<div id='sort_select_list' class="select-list" style='display:none;'>
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
<%= link_to_sort(t('widgets.title_asc', :scope => [:manage, :sort_columns], :default => :title_asc), :name => "title", :order_type => 'asc') %>
|
35
|
-
|
36
|
-
<%= link_to_sort(t('widgets.sort_order_desc', :scope => [:manage, :sort_columns], :default => :sort_order_desc), :name => "sort_order", :order_type => 'desc') %>
|
37
|
-
<%= link_to_sort(t('widgets.sort_order_asc', :scope => [:manage, :sort_columns], :default => :sort_order_asc), :name => "sort_order", :order_type => 'asc') %>
|
39
|
+
<% controller.orders_configuration.each do |key, value| %>
|
40
|
+
<%= link_to_sort(t("#{key}_desc", :scope => "manage.widgets.sort"), :name => key, :order_type=>'desc') %>
|
41
|
+
<%= link_to_sort(t("#{key}_asc", :scope => "manage.widgets.sort"), :name => key, :order_type=>'asc') %>
|
42
|
+
<% end %>
|
38
43
|
</div>
|
39
44
|
</div>
|
40
45
|
</div>
|
@@ -21,8 +21,10 @@ module Sunrise
|
|
21
21
|
scope :sortable, order("#{quoted_table_name}.sort_order DESC")
|
22
22
|
scope :recently, order("#{quoted_table_name}.created_at DESC")
|
23
23
|
scope :visible, where(:is_visible => true)
|
24
|
-
scope :with_type, lambda { |type| where(:widget_type_id => type.id) }
|
25
|
-
scope :with_position, lambda { |position| where(:widget_position_id => position.id) }
|
24
|
+
scope :with_type, lambda { |type| where(:widget_type_id => type.try(:id) || type) }
|
25
|
+
scope :with_position, lambda { |position| where(:widget_position_id => position.try(:id) || position) }
|
26
|
+
scope :with_title, lambda {|title| where(["#{quoted_table_name}.title LIKE ?", "%#{title}%"]) }
|
27
|
+
scope :with_structure, lambda {|structure| where(["#{quoted_table_name}.structure_id = ?", structure]) }
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunrise-widgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Igor Galeta
|
14
|
+
- Pavel Galeta
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-
|
19
|
+
date: 2011-09-15 00:00:00 +03:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +27,12 @@ dependencies:
|
|
26
27
|
requirements:
|
27
28
|
- - ">="
|
28
29
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
30
|
+
hash: 23
|
30
31
|
segments:
|
31
32
|
- 0
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version: 0.
|
33
|
+
- 2
|
34
|
+
- 0
|
35
|
+
version: 0.2.0
|
35
36
|
type: :runtime
|
36
37
|
version_requirements: *id001
|
37
38
|
description: Widgets plugin for Sunrise CMS via aimbulance
|