dhatu 0.1.19 → 0.1.20
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.
- checksums.yaml +4 -4
- data/app/controllers/dhatu/blog_posts_controller.rb +81 -14
- data/app/controllers/dhatu/bookings_controller.rb +51 -5
- data/app/controllers/dhatu/branches_controller.rb +42 -8
- data/app/controllers/dhatu/categories_controller.rb +86 -47
- data/app/controllers/dhatu/events_controller.rb +79 -9
- data/app/controllers/dhatu/meta_tags_controller.rb +96 -0
- data/app/controllers/dhatu/offers_controller.rb +83 -10
- data/app/controllers/dhatu/pages_controller.rb +130 -0
- data/app/controllers/dhatu/prices_controller.rb +78 -12
- data/app/controllers/dhatu/projects_controller.rb +78 -22
- data/app/controllers/dhatu/promotion_enquiries_controller.rb +69 -7
- data/app/controllers/dhatu/promotions_controller.rb +46 -2
- data/app/controllers/dhatu/resource_controller.rb +4 -0
- data/app/controllers/dhatu/sections_controller.rb +41 -8
- data/app/controllers/dhatu/services_controller.rb +78 -18
- data/app/controllers/dhatu/team_members_controller.rb +41 -8
- data/app/controllers/dhatu/testimonials_controller.rb +41 -9
- data/app/models/dhatu/blog_post.rb +6 -2
- data/app/models/dhatu/category.rb +3 -3
- data/app/models/dhatu/event.rb +4 -0
- data/app/models/dhatu/meta_tag.rb +48 -0
- data/app/models/dhatu/offer.rb +4 -0
- data/app/models/dhatu/page.rb +50 -0
- data/app/models/dhatu/project.rb +7 -3
- data/app/models/dhatu/promotion.rb +1 -0
- data/app/models/dhatu/section.rb +8 -12
- data/app/models/dhatu/service.rb +7 -3
- data/app/models/image/og_image.rb +3 -0
- data/app/uploaders/og_image_uploader.rb +15 -0
- data/app/views/dhatu/blog_posts/_form.html.erb +1 -1
- data/app/views/dhatu/blog_posts/_index.html.erb +1 -1
- data/app/views/dhatu/blog_posts/_row.html.erb +1 -1
- data/app/views/dhatu/blog_posts/_show.html.erb +1 -1
- data/app/views/dhatu/bookings/_index.html.erb +7 -8
- data/app/views/dhatu/bookings/_row.html.erb +11 -7
- data/app/views/dhatu/bookings/index.html.erb +20 -12
- data/app/views/dhatu/branches/_index.html.erb +8 -12
- data/app/views/dhatu/branches/_show.html.erb +75 -69
- data/app/views/dhatu/branches/index.html.erb +13 -8
- data/app/views/dhatu/categories/_category_types.html.erb +27 -0
- data/app/views/dhatu/categories/_form.html.erb +2 -2
- data/app/views/dhatu/categories/_index.html.erb +114 -89
- data/app/views/dhatu/categories/_index_list.html.erb +118 -0
- data/app/views/dhatu/categories/_row.html.erb +27 -31
- data/app/views/dhatu/categories/_row_list.html.erb +34 -0
- data/app/views/dhatu/categories/_show.html.erb +101 -74
- data/app/views/dhatu/categories/choose_category_type.html.erb +20 -0
- data/app/views/dhatu/categories/index.html.erb +1 -19
- data/app/views/dhatu/dashboard/_index.html.erb +53 -42
- data/app/views/dhatu/events/_index.html.erb +1 -1
- data/app/views/dhatu/events/_row.html.erb +1 -1
- data/app/views/dhatu/events/_show.html.erb +99 -75
- data/app/views/dhatu/events/index.html.erb +14 -9
- data/app/views/dhatu/meta_tags/_form.html.erb +48 -0
- data/app/views/dhatu/meta_tags/_index.html.erb +59 -0
- data/app/views/dhatu/meta_tags/_row.html.erb +32 -0
- data/app/views/dhatu/meta_tags/create.js.erb +29 -0
- data/app/views/dhatu/offers/_index.html.erb +8 -8
- data/app/views/dhatu/offers/_row.html.erb +1 -1
- data/app/views/dhatu/offers/_show.html.erb +85 -81
- data/app/views/dhatu/offers/index.html.erb +14 -8
- data/app/views/dhatu/pages/_form.html.erb +44 -0
- data/app/views/dhatu/pages/_index.html.erb +57 -0
- data/app/views/dhatu/pages/_row.html.erb +47 -0
- data/app/views/dhatu/pages/_show.html.erb +99 -0
- data/app/views/dhatu/pages/index.html.erb +59 -0
- data/app/views/dhatu/pages/show.html.erb +12 -0
- data/app/views/dhatu/prices/_index.html.erb +6 -6
- data/app/views/dhatu/prices/_row.html.erb +3 -2
- data/app/views/dhatu/prices/_show.html.erb +34 -45
- data/app/views/dhatu/prices/index.html.erb +14 -25
- data/app/views/dhatu/projects/_form.html.erb +15 -16
- data/app/views/dhatu/projects/_index.html.erb +6 -7
- data/app/views/dhatu/projects/_row.html.erb +4 -4
- data/app/views/dhatu/projects/_show.html.erb +108 -97
- data/app/views/dhatu/projects/index.html.erb +13 -19
- data/app/views/dhatu/projects/show.html.erb +12 -0
- data/app/views/dhatu/promotion_attributes/_index.html.erb +1 -7
- data/app/views/dhatu/promotion_attributes/_row.html.erb +1 -4
- data/app/views/dhatu/promotion_enquiries/_index.html.erb +11 -11
- data/app/views/dhatu/promotion_enquiries/_row.html.erb +7 -5
- data/app/views/dhatu/promotion_enquiries/_show.html.erb +35 -43
- data/app/views/dhatu/promotion_enquiries/index.html.erb +20 -12
- data/app/views/dhatu/promotions/_index.html.erb +13 -15
- data/app/views/dhatu/promotions/_row.html.erb +10 -9
- data/app/views/dhatu/promotions/_show.html.erb +190 -93
- data/app/views/dhatu/promotions/index.html.erb +0 -8
- data/app/views/dhatu/{section_types → section_types1}/_form.html.erb +0 -0
- data/app/views/dhatu/{section_types → section_types1}/_index.html.erb +0 -0
- data/app/views/dhatu/{section_types → section_types1}/_row.html.erb +0 -0
- data/app/views/dhatu/{section_types → section_types1}/_show.html.erb +0 -0
- data/app/views/dhatu/{section_types → section_types1}/index.html.erb +0 -0
- data/app/views/dhatu/sections/_form.html.erb +116 -11
- data/app/views/dhatu/sections/_index.html.erb +6 -3
- data/app/views/dhatu/sections/_row.html.erb +5 -2
- data/app/views/dhatu/sections/_show.html.erb +168 -132
- data/app/views/dhatu/sections/index.html.erb +10 -2
- data/app/views/dhatu/services/_form.html.erb +16 -17
- data/app/views/dhatu/services/_index.html.erb +6 -7
- data/app/views/dhatu/services/_row.html.erb +4 -4
- data/app/views/dhatu/services/_show.html.erb +107 -96
- data/app/views/dhatu/services/index.html.erb +13 -19
- data/app/views/dhatu/team_members/_index.html.erb +5 -6
- data/app/views/dhatu/team_members/_row.html.erb +3 -3
- data/app/views/dhatu/team_members/_show.html.erb +70 -58
- data/app/views/dhatu/team_members/index.html.erb +13 -8
- data/app/views/dhatu/testimonials/_index.html.erb +3 -6
- data/app/views/dhatu/testimonials/_row.html.erb +2 -3
- data/app/views/dhatu/testimonials/_show.html.erb +63 -93
- data/app/views/dhatu/testimonials/index.html.erb +13 -8
- data/app/views/layouts/kuppayam/_sidebar.html.erb +63 -48
- data/app/views/usman/dashboard/_super_admin_index.html.erb +22 -0
- data/config/routes.rb +12 -1
- data/db/data/dummy/services.csv +1 -1
- data/db/migrate/20180101093435_create_pages.rb +14 -0
- data/db/migrate/20180101093436_create_meta_tags.rb +19 -0
- data/db/migrate/20180101093437_add_page_id_to_sections.rb +5 -0
- data/db/migrate/20180101093438_add_priority_to_pages_and_sections.rb +6 -0
- data/db/migrate/20180101093439_add_a_ton_of_boolean_fields_to_sections.rb +34 -0
- data/db/migrate/20180101093440_add_code_to_sections.rb +19 -0
- data/db/migrate/20180101093441_rename_meta_description_all_over.rb +7 -0
- data/db/migrate/20180101093442_add_name_to_sections.rb +19 -0
- data/lib/dhatu/version.rb +1 -1
- metadata +43 -14
- data/db/migrate/20171203114529_add_meta_description_to_services.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ca0bd76d3e2830b603f692a4758bd8757984cceca3caf8f2e5c366340bc5a400
|
|
4
|
+
data.tar.gz: 60bfc25d39b31268ebf620dbe180337401f913912aeca547ab387aafcb0582e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1cd21dba9cb6ade7f8dffe115ae9e0ca6a66c6e71181a3d51818bf0dec7732010d2d0190815da29bf5892c5ae0125c3e6f32648338167191a8e62fe674e9a72d
|
|
7
|
+
data.tar.gz: 34b075a08759dab72493ecae37194bda0392e1eb4e14ed93a7b890610d4acd314ac541979c536932adbdde9ea855d4f06f9f3ec6fc9e6503c3ee5581e0cd4e1f
|
|
@@ -10,26 +10,45 @@ module Dhatu
|
|
|
10
10
|
private
|
|
11
11
|
|
|
12
12
|
def permitted_params
|
|
13
|
-
params.require("dhatu/blog_post").permit(:title, :slug, :author, :
|
|
13
|
+
params.require("dhatu/blog_post").permit(:title, :slug, :author, :short_description, :description, :posted_at, :tags, :category_id)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load_nested_categories
|
|
17
|
+
# Checkout the method get_category_filters before using this method
|
|
18
|
+
category_ids = Dhatu::BlogPost.distinct.pluck(:category_id)
|
|
19
|
+
@categories = Dhatu::Category.where(id: category_ids).to_a
|
|
20
|
+
@categories.unshift(Dhatu::Category.new(id: -1, name: "All"))
|
|
14
21
|
end
|
|
15
22
|
|
|
16
23
|
def get_collections
|
|
24
|
+
# Checkout the method get_category_filters before using this method
|
|
25
|
+
# load_nested_categories
|
|
26
|
+
|
|
17
27
|
get_category_filters("Dhatu::BlogPost")
|
|
18
|
-
@relation = Dhatu::BlogPost.includes(:cover_image).where("")
|
|
28
|
+
@relation = Dhatu::BlogPost.includes(:cover_image, :category).where("")
|
|
29
|
+
|
|
19
30
|
parse_filters
|
|
20
31
|
apply_filters
|
|
32
|
+
|
|
21
33
|
@blog_posts = @r_objects = @relation.page(@current_page).per(@per_page)
|
|
22
34
|
return true
|
|
23
35
|
end
|
|
24
36
|
|
|
25
37
|
def apply_filters
|
|
26
|
-
if @category
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
if @category.is_a?(String)
|
|
39
|
+
@category = Dhatu::Category.new(id: -2, name: "IS NOT SET")
|
|
40
|
+
elsif @category.blank?
|
|
41
|
+
@category = Dhatu::Category.new(id: -1, name: "All")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if @category
|
|
45
|
+
if @category.persisted?
|
|
30
46
|
@relation = @relation.where("category_id = ?", @category.id)
|
|
47
|
+
elsif @category.id == -2
|
|
48
|
+
@relation = @relation.where("category_id IS NULL")
|
|
31
49
|
end
|
|
32
50
|
end
|
|
51
|
+
|
|
33
52
|
@relation = @relation.search(@query) if @query
|
|
34
53
|
@relation = @relation.status(@status) if @status
|
|
35
54
|
@order_by = "posted_at desc, created_at desc" unless @order_by
|
|
@@ -43,7 +62,9 @@ module Dhatu
|
|
|
43
62
|
{ filter_name: :status }
|
|
44
63
|
],
|
|
45
64
|
boolean_filters: [],
|
|
46
|
-
reference_filters: [
|
|
65
|
+
reference_filters: [
|
|
66
|
+
{ filter_name: :category, filter_class: Dhatu::Category },
|
|
67
|
+
],
|
|
47
68
|
variable_filters: [],
|
|
48
69
|
}
|
|
49
70
|
end
|
|
@@ -52,27 +73,73 @@ module Dhatu
|
|
|
52
73
|
@filter_ui_settings = {
|
|
53
74
|
status: {
|
|
54
75
|
object_filter: false,
|
|
55
|
-
select_label: "
|
|
56
|
-
display_hash: Dhatu::BlogPost::
|
|
76
|
+
select_label: "Filter by Status",
|
|
77
|
+
display_hash: Dhatu::BlogPost::STATUS_REVERSE,
|
|
57
78
|
current_value: @status,
|
|
58
|
-
values: Dhatu::BlogPost::
|
|
79
|
+
values: Dhatu::BlogPost::STATUS,
|
|
59
80
|
current_filters: @filters,
|
|
60
81
|
filters_to_remove: [],
|
|
61
82
|
filters_to_add: {},
|
|
62
83
|
url_method_name: 'blog_posts_url',
|
|
63
84
|
show_all_filter_on_top: true
|
|
85
|
+
},
|
|
86
|
+
category: {
|
|
87
|
+
object_filter: true,
|
|
88
|
+
select_label: 'Select Category Type',
|
|
89
|
+
current_value: @category,
|
|
90
|
+
values: Dhatu::Category.filter_by_category_type("Dhatu::BlogPost").published.order("priority ASC, name ASC").all,
|
|
91
|
+
current_filters: @filters,
|
|
92
|
+
url_method_name: 'blog_posts_url',
|
|
93
|
+
filters_to_remove: [],
|
|
94
|
+
filters_to_add: {},
|
|
95
|
+
show_null_filter_on_top: true,
|
|
96
|
+
show_all_filter_on_top: true
|
|
64
97
|
}
|
|
65
98
|
}
|
|
66
99
|
end
|
|
67
100
|
|
|
68
101
|
def resource_controller_configuration
|
|
69
102
|
{
|
|
70
|
-
page_title: "Blog",
|
|
71
|
-
|
|
72
|
-
|
|
103
|
+
page_title: "Manage Blog",
|
|
104
|
+
current_nav: "dhatu/blog_posts",
|
|
105
|
+
|
|
106
|
+
# Resource Names
|
|
107
|
+
class: Dhatu::BlogPost,
|
|
73
108
|
collection_name: :blog_posts,
|
|
74
109
|
item_name: :blog_post,
|
|
75
|
-
|
|
110
|
+
|
|
111
|
+
# Conditions
|
|
112
|
+
get_collections_after_save_resource: false,
|
|
113
|
+
show_modal_after_create: true,
|
|
114
|
+
show_modal_after_update: true,
|
|
115
|
+
|
|
116
|
+
# Model Size can be large or generic
|
|
117
|
+
form_model_size: :large,
|
|
118
|
+
show_model_size: :large,
|
|
119
|
+
|
|
120
|
+
# Layout can be table or feed
|
|
121
|
+
# table uses html tables and feed uses div based boxes
|
|
122
|
+
layout: :table,
|
|
123
|
+
|
|
124
|
+
# "/kuppayam/workflows/default"
|
|
125
|
+
#
|
|
126
|
+
# Default partial opens show and form partial according to the model_size configuration
|
|
127
|
+
# It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
|
|
128
|
+
|
|
129
|
+
# "/kuppayam/workflows/peacock"
|
|
130
|
+
# "/kuppayam/workflows/parrot"
|
|
131
|
+
#
|
|
132
|
+
# Peacock & Parrot are old ways of doing things and it respects certail configurations
|
|
133
|
+
# Peacock opens show and form partials in large popup where as Parrot opens it in small
|
|
134
|
+
# Both Peacock and Parrot expect table based layout and will reload a single row after create / update
|
|
135
|
+
|
|
136
|
+
# Rendering Paths
|
|
137
|
+
view_path: "dhatu/blog_posts",
|
|
138
|
+
js_view_path: "/kuppayam/workflows/default",
|
|
139
|
+
|
|
140
|
+
# Additional Configurations
|
|
141
|
+
load_wysihtml5: true,
|
|
142
|
+
tagsinput: false
|
|
76
143
|
}
|
|
77
144
|
end
|
|
78
145
|
|
|
@@ -38,24 +38,70 @@ module Dhatu
|
|
|
38
38
|
],
|
|
39
39
|
|
|
40
40
|
boolean_filters: [],
|
|
41
|
-
|
|
42
41
|
reference_filters: [],
|
|
43
42
|
variable_filters: [],
|
|
44
43
|
}
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
def configure_filter_ui_settings
|
|
48
|
-
@filter_ui_settings = {
|
|
47
|
+
@filter_ui_settings = {
|
|
48
|
+
status: {
|
|
49
|
+
object_filter: false,
|
|
50
|
+
select_label: "Filter by Status",
|
|
51
|
+
display_hash: Dhatu::Booking::STATUS_REVERSE,
|
|
52
|
+
current_value: @status,
|
|
53
|
+
values: Dhatu::Booking::STATUS,
|
|
54
|
+
current_filters: @filters,
|
|
55
|
+
filters_to_remove: [],
|
|
56
|
+
filters_to_add: {},
|
|
57
|
+
url_method_name: 'bookings_url',
|
|
58
|
+
show_all_filter_on_top: true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
49
61
|
end
|
|
50
62
|
|
|
51
63
|
def resource_controller_configuration
|
|
52
64
|
{
|
|
53
65
|
page_title: "Bookings",
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
current_nav: "dhatu/bookings",
|
|
67
|
+
|
|
68
|
+
# Resource Names
|
|
69
|
+
class: Dhatu::Booking,
|
|
56
70
|
collection_name: :bookings,
|
|
57
71
|
item_name: :booking,
|
|
58
|
-
|
|
72
|
+
|
|
73
|
+
# Conditions
|
|
74
|
+
get_collections_after_save_resource: false,
|
|
75
|
+
show_modal_after_create: true,
|
|
76
|
+
show_modal_after_update: true,
|
|
77
|
+
|
|
78
|
+
# Model Size can be large or generic
|
|
79
|
+
form_model_size: :large,
|
|
80
|
+
show_model_size: :large,
|
|
81
|
+
|
|
82
|
+
# Layout can be table or feed
|
|
83
|
+
# table uses html tables and feed uses div based boxes
|
|
84
|
+
layout: :table,
|
|
85
|
+
|
|
86
|
+
# "/kuppayam/workflows/default"
|
|
87
|
+
#
|
|
88
|
+
# Default partial opens show and form partial according to the model_size configuration
|
|
89
|
+
# It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
|
|
90
|
+
|
|
91
|
+
# "/kuppayam/workflows/peacock"
|
|
92
|
+
# "/kuppayam/workflows/parrot"
|
|
93
|
+
#
|
|
94
|
+
# Peacock & Parrot are old ways of doing things and it respects certail configurations
|
|
95
|
+
# Peacock opens show and form partials in large popup where as Parrot opens it in small
|
|
96
|
+
# Both Peacock and Parrot expect table based layout and will reload a single row after create / update
|
|
97
|
+
|
|
98
|
+
# Rendering Paths
|
|
99
|
+
view_path: "dhatu/bookings",
|
|
100
|
+
js_view_path: "/kuppayam/workflows/default",
|
|
101
|
+
|
|
102
|
+
# Additional Configurations
|
|
103
|
+
load_wysihtml5: true,
|
|
104
|
+
tagsinput: false
|
|
59
105
|
}
|
|
60
106
|
end
|
|
61
107
|
|
|
@@ -41,7 +41,7 @@ module Dhatu
|
|
|
41
41
|
|
|
42
42
|
def get_collections
|
|
43
43
|
@relation = Dhatu::Branch.where("")
|
|
44
|
-
params[:st] = "published" if params[:st].nil?
|
|
44
|
+
# params[:st] = "published" if params[:st].nil?
|
|
45
45
|
parse_filters
|
|
46
46
|
apply_filters
|
|
47
47
|
@branches = @r_objects = @relation.page(@current_page).per(@per_page)
|
|
@@ -74,10 +74,10 @@ module Dhatu
|
|
|
74
74
|
@filter_ui_settings = {
|
|
75
75
|
status: {
|
|
76
76
|
object_filter: false,
|
|
77
|
-
select_label: "
|
|
78
|
-
display_hash: Dhatu::Branch::
|
|
77
|
+
select_label: "Filter by Status",
|
|
78
|
+
display_hash: Dhatu::Branch::STATUS_REVERSE,
|
|
79
79
|
current_value: @status,
|
|
80
|
-
values: Dhatu::Branch::
|
|
80
|
+
values: Dhatu::Branch::STATUS,
|
|
81
81
|
current_filters: @filters,
|
|
82
82
|
filters_to_remove: [],
|
|
83
83
|
filters_to_add: {},
|
|
@@ -89,12 +89,46 @@ module Dhatu
|
|
|
89
89
|
|
|
90
90
|
def resource_controller_configuration
|
|
91
91
|
{
|
|
92
|
-
page_title: "
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
page_title: "Manage Branchs",
|
|
93
|
+
current_nav: "dhatu/branches",
|
|
94
|
+
|
|
95
|
+
# Resource Names
|
|
96
|
+
class: Dhatu::Branch,
|
|
95
97
|
collection_name: :branches,
|
|
96
98
|
item_name: :branch,
|
|
97
|
-
|
|
99
|
+
|
|
100
|
+
# Conditions
|
|
101
|
+
get_collections_after_save_resource: false,
|
|
102
|
+
show_modal_after_create: true,
|
|
103
|
+
show_modal_after_update: true,
|
|
104
|
+
|
|
105
|
+
# Model Size can be large or generic
|
|
106
|
+
form_model_size: :large,
|
|
107
|
+
show_model_size: :large,
|
|
108
|
+
|
|
109
|
+
# Layout can be table or feed
|
|
110
|
+
# table uses html tables and feed uses div based boxes
|
|
111
|
+
layout: :table,
|
|
112
|
+
|
|
113
|
+
# "/kuppayam/workflows/default"
|
|
114
|
+
#
|
|
115
|
+
# Default partial opens show and form partial according to the model_size configuration
|
|
116
|
+
# It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
|
|
117
|
+
|
|
118
|
+
# "/kuppayam/workflows/peacock"
|
|
119
|
+
# "/kuppayam/workflows/parrot"
|
|
120
|
+
#
|
|
121
|
+
# Peacock & Parrot are old ways of doing things and it respects certail configurations
|
|
122
|
+
# Peacock opens show and form partials in large popup where as Parrot opens it in small
|
|
123
|
+
# Both Peacock and Parrot expect table based layout and will reload a single row after create / update
|
|
124
|
+
|
|
125
|
+
# Rendering Paths
|
|
126
|
+
view_path: "dhatu/branches",
|
|
127
|
+
js_view_path: "/kuppayam/workflows/default",
|
|
128
|
+
|
|
129
|
+
# Additional Configurations
|
|
130
|
+
load_wysihtml5: false,
|
|
131
|
+
tagsinput: false
|
|
98
132
|
}
|
|
99
133
|
end
|
|
100
134
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module Dhatu
|
|
2
2
|
class CategoriesController < ResourceController
|
|
3
3
|
|
|
4
|
+
before_action :get_filters
|
|
4
5
|
before_action :require_update_permission, only: [:update_status, :make_parent, :mark_as_featured, :remove_from_featured]
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
def choose_category_type
|
|
8
|
+
end
|
|
6
9
|
|
|
7
10
|
def update_status
|
|
8
11
|
@category = @r_object = Dhatu::Category.find(params[:id])
|
|
@@ -39,17 +42,21 @@ module Dhatu
|
|
|
39
42
|
|
|
40
43
|
private
|
|
41
44
|
|
|
45
|
+
def get_filters
|
|
46
|
+
@features = Feature.categorisable.published.order("name ASC").all
|
|
47
|
+
end
|
|
48
|
+
|
|
42
49
|
def save_resource
|
|
43
50
|
if @r_object.valid?
|
|
44
51
|
previous_parent_id = @r_object.parent_id_was
|
|
45
52
|
@r_object.save
|
|
46
53
|
if @r_object.parent_id != previous_parent_id
|
|
47
|
-
@r_object.parent.set_end_node!
|
|
54
|
+
@r_object.parent.set_end_node! if @r_object.parent
|
|
48
55
|
previous_category = Dhatu::Category.find_by_id(previous_parent_id)
|
|
49
56
|
previous_category.set_end_node! if previous_category
|
|
50
57
|
end
|
|
51
58
|
|
|
52
|
-
get_collections if @resource_options[:layout]
|
|
59
|
+
get_collections if @resource_options[:layout] == :table
|
|
53
60
|
set_flash_message(I18n.translate("forms.save", item: default_item_name.titleize), :success)
|
|
54
61
|
end
|
|
55
62
|
set_resource_notification(@r_object)
|
|
@@ -58,59 +65,41 @@ module Dhatu
|
|
|
58
65
|
render_or_redirect(@r_object.errors.any?, url, action_name)
|
|
59
66
|
end
|
|
60
67
|
|
|
61
|
-
def get_features
|
|
62
|
-
@features = Feature.categorisable.published.order("name ASC").all
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def permitted_params
|
|
66
|
-
params[:category].permit(:name, :permalink, :one_liner, :description, :parent_id, :priority, :category_type)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def set_navs
|
|
70
|
-
set_nav("admin/categories")
|
|
71
|
-
end
|
|
72
|
-
|
|
73
68
|
def get_collections
|
|
69
|
+
|
|
74
70
|
@current_category = Dhatu::Category.find_by_id(params[:parent_id])
|
|
75
71
|
|
|
76
72
|
filter_param_mapping
|
|
73
|
+
|
|
77
74
|
parse_filters
|
|
78
75
|
|
|
79
|
-
if @
|
|
80
|
-
@
|
|
76
|
+
if @feature.blank? && @current_category
|
|
77
|
+
@feature = Feature.find_by_name(@current_category.category_type)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if @current_category
|
|
81
|
+
@relation = @current_category.sub_categories.includes(:parent)
|
|
81
82
|
else
|
|
82
|
-
|
|
83
|
-
@relation = @current_category.sub_categories.includes(:parent)
|
|
84
|
-
else
|
|
85
|
-
@relation = Dhatu::Category.where("parent_id IS NULL")
|
|
86
|
-
end
|
|
83
|
+
@relation = Dhatu::Category.where("parent_id IS NULL")
|
|
87
84
|
end
|
|
88
|
-
|
|
89
|
-
@relation = @relation.order("priority ASC, name ASC")
|
|
85
|
+
|
|
90
86
|
apply_filters
|
|
87
|
+
|
|
88
|
+
@relation = @relation.order("priority ASC, name ASC")
|
|
89
|
+
|
|
91
90
|
@categories = @r_objects = @relation.page(@current_page).per(@per_page)
|
|
92
91
|
return true
|
|
93
92
|
end
|
|
94
93
|
|
|
95
94
|
def apply_filters
|
|
96
|
-
@
|
|
97
|
-
case @category_type
|
|
98
|
-
when "none"
|
|
99
|
-
@relation = @relation.joins("LEFT JOIN features f on f.name = categories.category_type").where("f.name is NULL")
|
|
100
|
-
when "all_including_children"
|
|
101
|
-
@relation = Dhatu::Category.where("")
|
|
102
|
-
when "All"
|
|
103
|
-
@relation = @relation.where("")
|
|
104
|
-
else
|
|
105
|
-
@relation = @relation.where("category_type = ?", params[:category_type])
|
|
106
|
-
end
|
|
95
|
+
@relation = @relation.where("category_type = ?", @feature.name) if @feature
|
|
107
96
|
@relation = @relation.search(@query) if @query
|
|
108
97
|
@relation = @relation.status(@status) if @status
|
|
109
|
-
@relation = @relation.featured(@featured) unless @featured.nil?
|
|
98
|
+
# @relation = @relation.featured(@featured) unless @featured.nil?
|
|
110
99
|
end
|
|
111
100
|
|
|
112
|
-
def
|
|
113
|
-
@
|
|
101
|
+
def configure_filter_settings
|
|
102
|
+
@filter_settings = {
|
|
114
103
|
boolean_filters: [
|
|
115
104
|
{ filter_name: :featured }
|
|
116
105
|
],
|
|
@@ -118,19 +107,72 @@ module Dhatu
|
|
|
118
107
|
{ filter_name: :query },
|
|
119
108
|
{ filter_name: :status }
|
|
120
109
|
],
|
|
121
|
-
reference_filters: [
|
|
110
|
+
reference_filters: [
|
|
111
|
+
{ filter_name: :feature, filter_class: Feature },
|
|
112
|
+
],
|
|
122
113
|
variable_filters: [],
|
|
123
114
|
}
|
|
124
115
|
end
|
|
125
116
|
|
|
126
117
|
def resource_controller_configuration
|
|
127
118
|
{
|
|
128
|
-
page_title: "Categories",
|
|
129
|
-
|
|
130
|
-
|
|
119
|
+
page_title: "Manage Categories",
|
|
120
|
+
current_nav: "dhatu/categories",
|
|
121
|
+
|
|
122
|
+
# Resource Names
|
|
123
|
+
class: Dhatu::Category,
|
|
131
124
|
collection_name: :categories,
|
|
132
125
|
item_name: :category,
|
|
133
|
-
|
|
126
|
+
|
|
127
|
+
# Conditions
|
|
128
|
+
get_collections_after_save_resource: false,
|
|
129
|
+
show_modal_after_create: true,
|
|
130
|
+
show_modal_after_update: true,
|
|
131
|
+
|
|
132
|
+
# Model Size can be large or generic
|
|
133
|
+
form_model_size: :generic,
|
|
134
|
+
show_model_size: :generic,
|
|
135
|
+
|
|
136
|
+
# Layout can be table or feed
|
|
137
|
+
# table uses html tables and feed uses div based boxes
|
|
138
|
+
layout: :feed,
|
|
139
|
+
|
|
140
|
+
# "/kuppayam/workflows/default"
|
|
141
|
+
#
|
|
142
|
+
# Default partial opens show and form partial according to the model_size configuration
|
|
143
|
+
# It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
|
|
144
|
+
|
|
145
|
+
# "/kuppayam/workflows/peacock"
|
|
146
|
+
# "/kuppayam/workflows/parrot"
|
|
147
|
+
#
|
|
148
|
+
# Peacock & Parrot are old ways of doing things and it respects certail configurations
|
|
149
|
+
# Peacock opens show and form partials in large popup where as Parrot opens it in small
|
|
150
|
+
# Both Peacock and Parrot expect table based layout and will reload a single row after create / update
|
|
151
|
+
|
|
152
|
+
# Rendering Paths
|
|
153
|
+
view_path: "dhatu/categories",
|
|
154
|
+
js_view_path: "/kuppayam/workflows/default",
|
|
155
|
+
|
|
156
|
+
# Additional Configurations
|
|
157
|
+
load_wysihtml5: false,
|
|
158
|
+
tagsinput: false
|
|
159
|
+
}
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def configure_filter_ui_settings
|
|
163
|
+
@filter_ui_settings = {
|
|
164
|
+
feature: {
|
|
165
|
+
object_filter: true,
|
|
166
|
+
select_label: 'Select Category Type',
|
|
167
|
+
current_value: @feature,
|
|
168
|
+
values: Feature.published.where("categorisable = true").order("name ASC").all,
|
|
169
|
+
current_filters: @filters,
|
|
170
|
+
url_method_name: 'categories_url',
|
|
171
|
+
filters_to_remove: [],
|
|
172
|
+
filters_to_add: {},
|
|
173
|
+
show_null_filter_on_top: false,
|
|
174
|
+
show_all_filter_on_top: true
|
|
175
|
+
}
|
|
134
176
|
}
|
|
135
177
|
end
|
|
136
178
|
|
|
@@ -147,10 +189,7 @@ module Dhatu
|
|
|
147
189
|
def permitted_params
|
|
148
190
|
params.require("dhatu/category").permit(:name, :one_liner, :description, :priority, :parent_id, :category_type)
|
|
149
191
|
end
|
|
150
|
-
|
|
151
|
-
def set_navs
|
|
152
|
-
set_nav("dhatu/categories")
|
|
153
|
-
end
|
|
192
|
+
|
|
154
193
|
|
|
155
194
|
end
|
|
156
195
|
end
|