kuppayam 0.1.21 → 0.1.22
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/helpers/resource_view_helper.rb +84 -2
- data/app/models/concerns/readable.rb +48 -0
- data/app/models/image/base.rb +1 -1
- data/lib/kuppayam/action_view/form_helper.rb +4 -4
- data/lib/kuppayam/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be6cbb25ee32833e06b3e99c4f554775348d805d
|
|
4
|
+
data.tar.gz: a84d5028640bc8be933ff4b523d35ebd054717ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a37a44f8feeea1709bd235ce270fc4c9403c6e38619828706a8f1a35b5078db30920d2474af6ab0d77ef2a78aa5f2938bd98e467c77c309326c376f39f22693e
|
|
7
|
+
data.tar.gz: e536eb62ca62ca2c6d18b2fffb66f56e3e2d67f24761df91a8117ece4bd3bd0d6d576ab0fd3c85bd765eb16ea112b8c162b163afcd8fe41f289783320f3f17ac
|
|
@@ -31,7 +31,7 @@ module ResourceViewHelper
|
|
|
31
31
|
|
|
32
32
|
def display_featured(object, **options)
|
|
33
33
|
options.reverse_merge!(
|
|
34
|
-
span_class: '
|
|
34
|
+
span_class: 'mr-5 mt-5 label',
|
|
35
35
|
)
|
|
36
36
|
if object.featured?
|
|
37
37
|
content_tag(:span, "Featured", class: "#{options[:span_class]} label-warning")
|
|
@@ -42,12 +42,20 @@ module ResourceViewHelper
|
|
|
42
42
|
|
|
43
43
|
def display_publishable_status(object, **options)
|
|
44
44
|
options.reverse_merge!(
|
|
45
|
-
span_class: '
|
|
45
|
+
span_class: 'mr-5 mt-5 label',
|
|
46
46
|
)
|
|
47
47
|
label_class = Publishable::STATUS_UI_CLASS[object.status]
|
|
48
48
|
content_tag(:span, object.display_status, class: "#{options[:span_class]} label-#{label_class}")
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def display_readable_status(object, **options)
|
|
52
|
+
options.reverse_merge!(
|
|
53
|
+
span_class: 'mr-5 mt-5 label',
|
|
54
|
+
)
|
|
55
|
+
label_class = Readable::STATUS_UI_CLASS[object.status]
|
|
56
|
+
content_tag(:span, object.display_status, class: "#{options[:span_class]} label-#{label_class}")
|
|
57
|
+
end
|
|
58
|
+
|
|
51
59
|
def display_publishable_links(object, **options)
|
|
52
60
|
options.reverse_merge!(
|
|
53
61
|
publish_icon: 'fa fa-check-square',
|
|
@@ -85,6 +93,43 @@ module ResourceViewHelper
|
|
|
85
93
|
raw(links.join(""))
|
|
86
94
|
end
|
|
87
95
|
|
|
96
|
+
def display_readable_links(object, **options)
|
|
97
|
+
options.reverse_merge!(
|
|
98
|
+
read_icon: 'fa fa-check-square-o',
|
|
99
|
+
unread_icon: 'fa fa-square-o',
|
|
100
|
+
remove_icon: 'fa fa-trash',
|
|
101
|
+
archive_icon: 'fa fa-archive',
|
|
102
|
+
|
|
103
|
+
read_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "read"),
|
|
104
|
+
unread_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "unread"),
|
|
105
|
+
remove_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "removed"),
|
|
106
|
+
archive_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "archived"),
|
|
107
|
+
|
|
108
|
+
read_text: "Read",
|
|
109
|
+
unread_text: "Unread",
|
|
110
|
+
remove_text: "Remove",
|
|
111
|
+
archive_text: "Archive",
|
|
112
|
+
|
|
113
|
+
read_class: "",
|
|
114
|
+
unread_class: "",
|
|
115
|
+
remove_class: "delete",
|
|
116
|
+
archive_class: "",
|
|
117
|
+
|
|
118
|
+
has_permission_to_edit: true
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if @current_permission
|
|
122
|
+
options[:has_permission_to_edit] = @current_permission.can_update?
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
links = []
|
|
126
|
+
links << link_to(raw("<i class=\"#{options[:read_icon]} mr-5\"></i> #{options[:read_text]}"), options[:read_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:read_class]) if object.can_read? && options[:has_permission_to_edit]
|
|
127
|
+
links << link_to(raw("<i class=\"#{options[:unread_icon]} mr-5\"></i> #{options[:unread_text]}"), options[:unread_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:unread_class]) if object.can_unread? && options[:has_permission_to_edit]
|
|
128
|
+
links << link_to(raw("<i class=\"#{options[:remove_icon]} mr-5\"></i> #{options[:remove_text]}"), options[:remove_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:remove_class]) if object.can_remove? && options[:has_permission_to_edit]
|
|
129
|
+
links << link_to(raw("<i class=\"#{options[:archive_icon]} mr-5\"></i> #{options[:archive_text]}"), options[:archive_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:archive_class]) if object.can_archive? && options[:has_permission_to_edit]
|
|
130
|
+
raw(links.join(""))
|
|
131
|
+
end
|
|
132
|
+
|
|
88
133
|
def display_featurable_links(object, **options)
|
|
89
134
|
options.reverse_merge!(
|
|
90
135
|
feature_icon: 'fa fa-star',
|
|
@@ -178,6 +223,43 @@ module ResourceViewHelper
|
|
|
178
223
|
raw(links.join(""))
|
|
179
224
|
end
|
|
180
225
|
|
|
226
|
+
def display_readable_buttons(object, **options)
|
|
227
|
+
options.reverse_merge!(
|
|
228
|
+
read_icon: 'fa fa-check-square-o',
|
|
229
|
+
unread_icon: 'fa fa-square-o',
|
|
230
|
+
remove_icon: 'fa fa-trash',
|
|
231
|
+
archive_icon: 'fa fa-archive',
|
|
232
|
+
|
|
233
|
+
read_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "read"),
|
|
234
|
+
unread_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "unread"),
|
|
235
|
+
remove_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "removed"),
|
|
236
|
+
archive_link: url_for(action: 'update_status', controller: object.class.to_s.tableize, id: object.id, status: "archived"),
|
|
237
|
+
|
|
238
|
+
read_text: "Mark as Read",
|
|
239
|
+
unread_text: "Mark as Unread",
|
|
240
|
+
remove_text: "Remove",
|
|
241
|
+
archive_text: "Archive",
|
|
242
|
+
|
|
243
|
+
read_class: "btn btn-block btn-success btn-only-hover",
|
|
244
|
+
unread_class: "btn btn-block btn-gray btn-only-hover",
|
|
245
|
+
remove_class: "btn btn-block btn-danger btn-only-hover",
|
|
246
|
+
archive_class: "btn btn-block btn-gray btn-only-hover",
|
|
247
|
+
|
|
248
|
+
has_permission_to_edit: true
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
if @current_permission
|
|
252
|
+
options[:has_permission_to_edit] = @current_permission.can_update?
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
links = []
|
|
256
|
+
links << link_to(raw("<i class=\"#{options[:read_icon]} mr-5\"></i> #{options[:read_text]}"), options[:read_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:read_class]) if object.can_read? && options[:has_permission_to_edit]
|
|
257
|
+
links << link_to(raw("<i class=\"#{options[:unread_icon]} mr-5\"></i> #{options[:unread_text]}"), options[:unread_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:unread_class]) if object.can_unread? && options[:has_permission_to_edit]
|
|
258
|
+
links << link_to(raw("<i class=\"#{options[:remove_icon]} mr-5\"></i> #{options[:remove_text]}"), options[:remove_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:remove_class]) if object.can_remove? && options[:has_permission_to_edit]
|
|
259
|
+
links << link_to(raw("<i class=\"#{options[:archive_icon]} mr-5\"></i> #{options[:archive_text]}"), options[:archive_link], method: 'PUT', remote: true, role: "menuitem", tabindex: "-1", class: options[:archive_class]) if object.can_archive? && options[:has_permission_to_edit]
|
|
260
|
+
raw(links.join(""))
|
|
261
|
+
end
|
|
262
|
+
|
|
181
263
|
def display_featurable_buttons(object, **options)
|
|
182
264
|
options.reverse_merge!(
|
|
183
265
|
feature_icon: 'fa fa-star',
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Readable
|
|
2
|
+
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
# Constants
|
|
6
|
+
NEW = "new"
|
|
7
|
+
UNREAD = "unread"
|
|
8
|
+
READ = "read"
|
|
9
|
+
ARCHIVED = "archived"
|
|
10
|
+
REMOVED = "removed"
|
|
11
|
+
|
|
12
|
+
STATUS = {"New" => NEW, "Unread" => UNREAD, "Read" => READ, "Archived" => ARCHIVED, "Removed" => REMOVED}
|
|
13
|
+
STATUS_REVERSE = {NEW => "New", UNREAD => "Unread", READ => "Read",ARCHIVED => "Archived", REMOVED => "Removed"}
|
|
14
|
+
STATUS_UI_CLASS = {NEW => "success", UNREAD => "info", READ => "default", ARCHIVED => "default", REMOVED => "danger"}
|
|
15
|
+
|
|
16
|
+
included do
|
|
17
|
+
|
|
18
|
+
validates :status, :presence=> true, :inclusion => {:in => STATUS_REVERSE.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
|
|
19
|
+
|
|
20
|
+
state_machine :status, initial: NEW do
|
|
21
|
+
event :read do
|
|
22
|
+
transition [NEW, UNREAD] => READ
|
|
23
|
+
end
|
|
24
|
+
event :unread do
|
|
25
|
+
transition [READ, ARCHIVED, REMOVED] => UNREAD
|
|
26
|
+
end
|
|
27
|
+
event :remove do
|
|
28
|
+
transition [NEW, READ, UNREAD, ARCHIVED] => REMOVED
|
|
29
|
+
end
|
|
30
|
+
event :archive do
|
|
31
|
+
transition [NEW, READ, UNREAD, REMOVED] => ARCHIVED
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
scope :new_ones, -> { where(status: NEW) }
|
|
36
|
+
scope :read, -> { where(status: READ) }
|
|
37
|
+
scope :unread, -> { where(status: UNREAD) }
|
|
38
|
+
scope :removed, -> { where(status: REMOVED) }
|
|
39
|
+
scope :archived, -> { where(status: ARCHIVED) }
|
|
40
|
+
|
|
41
|
+
scope :status, lambda { |status| where("LOWER(status)='#{status}'") }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def display_status
|
|
45
|
+
STATUS_REVERSE[self.status]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
data/app/models/image/base.rb
CHANGED
|
@@ -50,7 +50,7 @@ class Image::Base < Kuppayam::ApplicationRecord
|
|
|
50
50
|
def self.image_configuration
|
|
51
51
|
{
|
|
52
52
|
max_upload_limit: 10485760,
|
|
53
|
-
min_upload_limit:
|
|
53
|
+
min_upload_limit: 1,
|
|
54
54
|
resolutions: [550, 275],
|
|
55
55
|
form_upload_image_label: "Upload a new Image",
|
|
56
56
|
form_title: "Upload an Image",
|
|
@@ -247,10 +247,10 @@ module Kuppayam
|
|
|
247
247
|
# <%= f.select("proposal[:plan]", options_for_select(options_list, :selected => f.object.name), {:prompt=>true}, {:class => 'form-control'}) %>
|
|
248
248
|
# </div>
|
|
249
249
|
# </div>
|
|
250
|
-
def theme_form_select_group(
|
|
250
|
+
def theme_form_select_group(object, field_name, options_list, **options)
|
|
251
251
|
options.reverse_merge!(
|
|
252
|
-
label:
|
|
253
|
-
param_name:
|
|
252
|
+
label: field_name.to_s.titleize,
|
|
253
|
+
param_name: field_name,
|
|
254
254
|
prompt: true,
|
|
255
255
|
error_class: "has-error",
|
|
256
256
|
required: false,
|
|
@@ -266,7 +266,7 @@ module Kuppayam
|
|
|
266
266
|
end
|
|
267
267
|
|
|
268
268
|
theme_form_group(options[:label], required: options[:required], error_class: error_class, form_style: options[:form_style]) do
|
|
269
|
-
|
|
269
|
+
select_tag(options[:param_name], options_for_select(options_list, :selected => object.send(field_name)), {:prompt=>options[:prompt], :class => 'form-control'}) + error_message
|
|
270
270
|
end
|
|
271
271
|
end
|
|
272
272
|
|
data/lib/kuppayam/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kuppayam
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.22
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kpvarma
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-11-
|
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -428,6 +428,7 @@ files:
|
|
|
428
428
|
- app/models/concerns/approvable.rb
|
|
429
429
|
- app/models/concerns/featureable.rb
|
|
430
430
|
- app/models/concerns/publishable.rb
|
|
431
|
+
- app/models/concerns/readable.rb
|
|
431
432
|
- app/models/document/base.rb
|
|
432
433
|
- app/models/document/import_data_file.rb
|
|
433
434
|
- app/models/document/import_report_file.rb
|