dhatu 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f51c750289d9a5c2e5c5285c6838e99fd8d7fa5f
4
- data.tar.gz: ba4a2da4bb22359c41521d3bb0e67638463c1a62
3
+ metadata.gz: 5a4404748dd9f2d445924425c4faad29e12a3390
4
+ data.tar.gz: 7a0bc391fa6762c9bb7e9b4fc57f90d30f4348f0
5
5
  SHA512:
6
- metadata.gz: edb42de7e28b445b175755393a13f28441b05502211d96ed6ed17acb3bd575dd97e63dd3e3b475fd977ef4eb88234fcab2ffdff5dfe18a0e33269782ffa520c4
7
- data.tar.gz: 29ba424274a5e616bf86d2a0fd1b310c5f43509c8da4041eba8e85106f8e1e02d156389bbe920c70903959aa644a73aec071282c744aa8db66334e984130dc97
6
+ metadata.gz: 176d1ad23af49d3b5d5c30af59c4935472ba2c9475885b693117965120e224e8c319877d2c3a521dfe736680b54d43fa41e3c381af537b87d43f261c1f23784e
7
+ data.tar.gz: b52b928497affa3f4cc9ebf286994e6d65ba2bf94e85a6777cd0e09627628e8dc6384182d51f1a78305e16492224a715b37cc386d54302be74ed7b04711694bf
@@ -2,7 +2,7 @@ module Dhatu
2
2
  class CategoriesController < ResourceController
3
3
 
4
4
  before_action :require_update_permission, only: [:update_status, :make_parent, :mark_as_featured, :remove_from_featured]
5
- before_action :get_features, only: [:index, :new, :edit]
5
+ before_action :get_features
6
6
 
7
7
  def update_status
8
8
  @category = @r_object = Dhatu::Category.find(params[:id])
@@ -39,6 +39,25 @@ module Dhatu
39
39
 
40
40
  private
41
41
 
42
+ def save_resource
43
+ if @r_object.valid?
44
+ previous_parent_id = @r_object.parent_id_was
45
+ @r_object.save
46
+ if @r_object.parent_id != previous_parent_id
47
+ @r_object.parent.set_end_node!
48
+ previous_category = Dhatu::Category.find_by_id(previous_parent_id)
49
+ previous_category.set_end_node!
50
+ end
51
+
52
+ get_collections if @resource_options[:layout] = :table
53
+ set_flash_message(I18n.translate("forms.save", item: default_item_name.titleize), :success)
54
+ end
55
+ set_resource_notification(@r_object)
56
+ action_name = params[:action].to_s == "create" ? "new" : "edit"
57
+ url = @r_object.persisted? ? resource_url(@r_object) : nil
58
+ render_or_redirect(@r_object.errors.any?, url, action_name)
59
+ end
60
+
42
61
  def get_features
43
62
  @features = Feature.categorisable.published.order("name ASC").all
44
63
  end
@@ -1,7 +1,7 @@
1
1
  module Dhatu
2
- class DashboardController < ApplicationController
2
+ class DashboardController < Dhatu::ApplicationController
3
3
 
4
- # GET /dashboard
4
+ # GET /dashboard
5
5
  def index
6
6
  end
7
7
 
@@ -105,7 +105,7 @@ class Dhatu::Category < Dhatu::ApplicationRecord
105
105
  end
106
106
 
107
107
  def default_image_url(size="medium")
108
- "/assets/defaults/category-#{size}.png"
108
+ "/assets/dhatu/category-#{size}.png"
109
109
  end
110
110
 
111
111
  # Permission Methods
@@ -117,7 +117,6 @@ class Dhatu::Category < Dhatu::ApplicationRecord
117
117
 
118
118
  def can_be_deleted?
119
119
  return false unless removed?
120
- return false if parent.nil?
121
120
  return false if end_node == false or self.sub_categories.any?
122
121
  true
123
122
  end
@@ -137,7 +136,6 @@ class Dhatu::Category < Dhatu::ApplicationRecord
137
136
  end
138
137
 
139
138
  def can_be_removed?
140
- return false if parent.nil?
141
139
  return false if end_node == false or self.sub_categories.any?
142
140
  published? or unpublished?
143
141
  end
@@ -146,17 +144,11 @@ class Dhatu::Category < Dhatu::ApplicationRecord
146
144
  # ------------------
147
145
 
148
146
  def set_end_node!
149
- self.update_attribute(:end_node, !self.sub_categories.any?)
147
+ self.update_column(:end_node, self.sub_categories.count < 1)
150
148
  end
151
149
 
152
150
  def set_end_node_of_parent
153
- if self.parent
154
- if self.parent.sub_categories.any?
155
- self.parent.update_attribute(:end_node, false)
156
- else
157
- self.parent.update_attribute(:end_node, true)
158
- end
159
- end
151
+ self.parent.set_end_node! if self.parent && self.parent_id_changed?
160
152
  end
161
153
 
162
154
  protected
@@ -12,7 +12,7 @@
12
12
 
13
13
  <% options_list = Array[*@features.collect {|f| [f.display_name, f.name] }].sort %>
14
14
 
15
- <%= theme_form_select_group(@category, :category_type, options_list, param_name: "dhatu/category[category_type]", label: "Choose Type", prompt: true) %>
15
+ <%= theme_form_select_group(@category, :category_type, options_list, param_name: "dhatu/category[category_type]", label: "Choose Type", prompt: "Select Category Type") %>
16
16
 
17
17
  <%= theme_form_field(@category, :one_liner, required: false) %>
18
18
  <%= theme_form_field(@category, :description, required: false, html_options: {type: :textarea}) %>
@@ -20,7 +20,10 @@
20
20
 
21
21
  <%
22
22
  @category.parent_id = params[:parent_id] if params[:parent_id]
23
- categories = Dhatu::Category.select("id, name").order("name ASC").all
23
+ relation = Dhatu::Category.select("id, name").order("name ASC")
24
+ relation = relation.where("category_type = '#{@category.category_type}'") if @category.category_type
25
+ relation = relation.where("id != '#{@category.id}'") if @category.id
26
+ categories = relation.all
24
27
  %>
25
28
 
26
29
  <% options = {assoc_collection: categories, required: false, editable: true, assoc_display_method: :name} %>
@@ -3,7 +3,7 @@
3
3
  <div class="col-md-6">
4
4
 
5
5
  <% if @current_category %>
6
- <%= theme_button('Back', 'arrow-left', categories_path(parent_id: @current_category.parent_id), classes: "pull-left mr-10", btn_type: "white") %>
6
+ <%= theme_button('Back', 'arrow-left', categories_path(parent_id: @current_category.try(:parent_id), category_type: @category_type), classes: "pull-left mr-10", btn_type: "white") %>
7
7
  <% end %>
8
8
 
9
9
  <%= theme_button('Refresh', 'refresh', categories_path(parent_id: @current_category.try(:id), category_type: @category_type), classes: "pull-left mr-10", btn_type: "white") %>
@@ -75,80 +75,20 @@
75
75
  <td class="category-name"><%= category.display_name %></td>
76
76
  <% else %>
77
77
  <td class="category-name">
78
- <%= link_to raw("<i class=\"fa fa-caret-right\"></i> #{category.display_name}"), categories_path(parent_id: category.id), remote: true %></td>
78
+ <%= link_to raw("<i class=\"fa fa-caret-right\"></i> #{category.display_name}"), categories_path(parent_id: category.id, category_type: @category_type), remote: true %></td>
79
79
  <% end %>
80
80
 
81
- <td><%= category.category_type %></td>
81
+ <td><%= category.display_category_type %></td>
82
82
 
83
- <!--
84
- <%# if category.parent == @current_category %>
85
- <td class="category-name"><%#= category.parent.display_name if category.parent %></td>
86
- <%# else %>
87
- <td class="category-name"><%#= link_to category.parent.display_name, categories_path(parent_id: category.parent.id), remote: true if category.parent %></td>
88
- <%# end %>
83
+ <td class="hidden-sm hidden-xs"><%= display_publishable_status(category) %></td>
89
84
 
90
- <%# if category.top_parent == @current_category %>
91
- <td class="category-name"><%#= category.top_parent.display_name if category.top_parent %></td>
92
- <%# else %>
93
- <td class="category-name"><%#= link_to category.top_parent.display_name, categories_path(parent_id: category.top_parent.id), remote: true if category.top_parent %></td>
94
- <%# end %>
95
- -->
85
+ <% if display_manage_links? %>
86
+ <td class="action-links hidden-sm hidden-xs" style="width:10%"><%= display_publishable_links(category) %></td>
96
87
 
97
- <td style="text-align: center;width:100px;">
98
- <% if category.unpublished? %>
99
- <span class="ml-5 mt-5 label label-default">Un-Published</span>
100
- <% elsif category.published? %>
101
- <span class="ml-5 mt-5 label label-success">Published</span>
102
- <% elsif category.removed? %>
103
- <span class="ml-5 mt-5 label label-danger">Disabled</span>
104
- <% end %>
105
- </td>
106
-
107
- <!--
108
- <td style="text-align: center;width:100px;"><%#= category.priority if category.priority %></td>
109
- <td style="text-align: center;width:120px;"><%#= category.end_node.to_s.titleize %></td>
110
- -->
111
-
112
- <% if display_manage_links? %>
113
- <% edit_link = edit_category_path(id: category.id) %>
114
- <% delete_link = category_path(id: category.id) %>
115
-
116
- <td class="action-links" style="width:10%">
117
-
118
- <% case category.status %>
119
- <% when "published" %>
120
- <!-- Un-Publish -->
121
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_category_path(:id =>category.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"category_status" if category.can_be_unpublished? %>
122
-
123
- <!-- Remove -->
124
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Remove"), update_status_category_path(:id =>category.id, :status =>'removed'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"category_status" if category.can_be_removed? %>
125
- <% when "unpublished" %>
126
- <!-- Publish -->
127
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_category_path(:id =>category.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"category_status" if category.can_be_published? %>
128
- <!-- Remove -->
129
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Remove"), update_status_category_path(:id =>category.id, :status =>'removed'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"category_status" if category.can_be_removed? %>
130
- <% when "removed" %>
131
- <!-- Un-Publish -->
132
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_category_path(:id =>category.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"category_status" if category.can_be_unpublished? %>
133
- <!-- Publish -->
134
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_category_path(:id =>category.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1",:class=>"category_status" if category.can_be_published? %>
135
- <% end %>
136
-
137
- </td>
138
-
139
- <td class="action-links" style="width:10%">
140
-
141
- <%= link_to raw("<i class=\"linecons-desktop\"></i> View Details"), category_path(category), :remote=>true, style: "color:#40bbea" %>
142
-
143
- <%= link_to raw("<i class=\"fa-plus\"></i> Add Sub Category"), new_category_path(parent_id: category.id), :remote=>true, class: "edit" %>
144
-
145
- <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit Category"), edit_link, :remote=>true, class: "edit1" if category.can_be_edited? %>
146
-
147
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if category.can_be_deleted? && display_delete_links? %>
148
-
149
- </td>
150
-
151
- <% end %>
88
+ <td class="action-links hidden-sm hidden-xs" style="width:10%">
89
+ <%= display_manage_links(category, @current_user) %>
90
+ </td>
91
+ <% end %>
152
92
 
153
93
  </tr>
154
94
  <% end %>
@@ -12,7 +12,7 @@
12
12
  <td class="category-name"><%= category.display_name %></td>
13
13
  <% else %>
14
14
  <td class="category-name">
15
- <%= link_to raw("<i class=\"fa fa-caret-right\"></i> #{category.display_name}"), categories_path(parent_id: category.id), remote: true %></td>
15
+ <%= link_to raw("<i class=\"fa fa-caret-right\"></i> #{category.display_name}"), categories_path(parent_id: category.id, category_type: @category_type), remote: true %></td>
16
16
  <% end %>
17
17
 
18
18
  <td><%= category.display_category_type %></td>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <div class="col-md-3 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
6
6
  <% if display_edit_links? %>
7
- <%= edit_image(@section,
7
+ <%= edit_image(@section,
8
8
  "cover_image.image.large.url",
9
9
  upload_image_link(@section, :cover_image, nil ),
10
10
  remove_image_link(@section, :cover_image, nil ),
@@ -1,3 +1,3 @@
1
1
  module Dhatu
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhatu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - kpvarma
@@ -107,7 +107,7 @@ dependencies:
107
107
  version: '0.1'
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.22
110
+ version: 0.1.23
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '0.1'
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 0.1.22
120
+ version: 0.1.23
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: pattana
123
123
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +147,7 @@ dependencies:
147
147
  version: '0.3'
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: 0.3.16
150
+ version: 0.3.17
151
151
  type: :runtime
152
152
  prerelease: false
153
153
  version_requirements: !ruby/object:Gem::Requirement
@@ -157,7 +157,7 @@ dependencies:
157
157
  version: '0.3'
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
- version: 0.3.16
160
+ version: 0.3.17
161
161
  - !ruby/object:Gem::Dependency
162
162
  name: bcrypt
163
163
  requirement: !ruby/object:Gem::Requirement
@@ -403,6 +403,10 @@ files:
403
403
  - README.md
404
404
  - Rakefile
405
405
  - app/assets/config/dhatu_manifest.js
406
+ - app/assets/images/dhatu/category-large.png
407
+ - app/assets/images/dhatu/category-medium.png
408
+ - app/assets/images/dhatu/category-small.png
409
+ - app/assets/images/dhatu/category-tiny.png
406
410
  - app/assets/javascripts/dhatu/application.js
407
411
  - app/assets/stylesheets/dhatu/application.css
408
412
  - app/controllers/dhatu/application_controller.rb