usman 0.1.0 → 0.1.1
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/README.md +51 -10
- data/app/controllers/usman/admin/dashboard_controller.rb +9 -1
- data/app/controllers/usman/admin/features_controller.rb +16 -22
- data/app/controllers/usman/admin/permissions_controller.rb +15 -0
- data/app/controllers/usman/admin/resource_controller.rb +4 -0
- data/app/controllers/usman/admin/roles_controller.rb +66 -0
- data/app/controllers/usman/admin/users_controller.rb +44 -31
- data/app/controllers/usman/sessions_controller.rb +14 -3
- data/app/helpers/usman/authentication_helper.rb +23 -17
- data/app/models/feature.rb +50 -4
- data/app/models/permission.rb +49 -1
- data/app/models/role.rb +62 -0
- data/app/models/user.rb +112 -3
- data/app/models/usman/application_record.rb +2 -2
- data/app/views/layouts/kuppayam/_sidebar.html.erb +8 -4
- data/app/views/usman/admin/dashboard/index.html.erb +1 -1
- data/app/views/usman/admin/features/_action_buttons.html.erb +0 -11
- data/app/views/usman/admin/features/_index.html.erb +3 -3
- data/app/views/usman/admin/features/_row.html.erb +3 -3
- data/app/views/usman/admin/features/_show.html.erb +5 -1
- data/app/views/usman/admin/features/index.html.erb +8 -1
- data/app/views/usman/admin/features/temp/create.js.erb +29 -0
- data/app/views/usman/admin/features/{index.js.erb → temp/index.js.erb} +1 -1
- data/app/views/usman/admin/permissions/_action_buttons.html.erb +0 -11
- data/app/views/usman/admin/permissions/index.html.erb +8 -1
- data/app/views/usman/admin/permissions/temp/create.js.erb +29 -0
- data/app/views/usman/admin/permissions/temp/destroy.js.erb +22 -0
- data/app/views/usman/admin/permissions/temp/edit.js.erb +4 -0
- data/app/views/usman/admin/permissions/{index.js.erb → temp/index.js.erb} +9 -3
- data/app/views/usman/admin/permissions/temp/new.js.erb +4 -0
- data/app/views/usman/admin/permissions/temp/row.js.erb +24 -0
- data/app/views/usman/admin/permissions/temp/show.js.erb +13 -0
- data/app/views/usman/admin/permissions/temp/update.js.erb +29 -0
- data/app/views/usman/admin/roles/_form.html.erb +23 -0
- data/app/views/usman/admin/roles/_index.html.erb +48 -0
- data/app/views/usman/admin/roles/_row.html.erb +24 -0
- data/app/views/usman/admin/roles/_show.html.erb +72 -0
- data/app/views/usman/admin/roles/index.html.erb +32 -0
- data/app/views/usman/admin/users/_form.html.erb +5 -2
- data/app/views/usman/admin/users/_index.html.erb +22 -41
- data/app/views/usman/admin/users/_row.html.erb +21 -41
- data/app/views/usman/admin/users/_show.html.erb +198 -131
- data/app/views/usman/admin/users/index.html.erb +25 -1
- data/app/views/usman/sessions/_sign_in.js.erb +2 -2
- data/config/locales/kuppayam/authentication.ar.yml +25 -0
- data/config/locales/kuppayam/authentication.en.yml +25 -0
- data/config/routes.rb +4 -9
- data/db/import_data/dummy/features.csv +10 -0
- data/db/import_data/dummy/images/users/guna.neweast.png +0 -0
- data/db/import_data/dummy/images/users/junaid.ramzan.jpg +0 -0
- data/db/import_data/dummy/images/users/kpvarma.png +0 -0
- data/db/import_data/dummy/images/users/stephen.price.png +0 -0
- data/db/import_data/dummy/images/users/vinodh.jpg +0 -0
- data/db/import_data/dummy/permissions.csv +60 -0
- data/db/import_data/dummy/users.csv +7 -0
- data/db/import_data/features.csv +10 -0
- data/db/import_data/images/users/junaid.ramzan.jpg +0 -0
- data/db/import_data/images/users/kpvarma.png +0 -0
- data/db/import_data/images/users/vinodh.jpg +0 -0
- data/db/import_data/permissions.csv +30 -0
- data/db/import_data/users.csv +4 -0
- data/db/migrate/20170000000102_create_roles.rb +18 -0
- data/lib/tasks/usman/all.rake +49 -0
- data/lib/tasks/usman/features.rake +26 -0
- data/lib/tasks/usman/permissions.rake +26 -0
- data/lib/tasks/usman/users.rake +26 -0
- data/lib/usman/engine.rb +12 -1
- data/lib/usman/extras/import_error_handler.rb +79 -0
- data/lib/usman/version.rb +1 -1
- metadata +65 -55
- data/app/models/image/base.rb +0 -30
- data/app/views/usman/admin/features/create.js.erb +0 -16
- data/app/views/usman/admin/permissions/create.js.erb +0 -17
- data/app/views/usman/admin/permissions/destroy.js.erb +0 -16
- data/app/views/usman/admin/permissions/edit.js.erb +0 -7
- data/app/views/usman/admin/permissions/new.js.erb +0 -7
- data/app/views/usman/admin/permissions/row.js.erb +0 -10
- data/app/views/usman/admin/permissions/show.js.erb +0 -8
- data/app/views/usman/admin/permissions/update.js.erb +0 -16
- data/app/views/usman/admin/users/_action_buttons.html.erb +0 -11
- data/app/views/usman/admin/users/create.js.erb +0 -16
- data/app/views/usman/admin/users/destroy.js.erb +0 -16
- data/app/views/usman/admin/users/edit.js.erb +0 -7
- data/app/views/usman/admin/users/index.js.erb +0 -8
- data/app/views/usman/admin/users/new.js.erb +0 -7
- data/app/views/usman/admin/users/row.js.erb +0 -10
- data/app/views/usman/admin/users/show.js.erb +0 -8
- data/app/views/usman/admin/users/update.js.erb +0 -16
- data/config/locales/usman.en.yml +0 -61
- data/db/migrate/20131108102728_create_images.rb +0 -12
- data/lib/tasks/usman_tasks.rake +0 -4
- /data/app/views/usman/admin/features/{destroy.js.erb → temp/destroy.js.erb} +0 -0
- /data/app/views/usman/admin/features/{edit.js.erb → temp/edit.js.erb} +0 -0
- /data/app/views/usman/admin/features/{new.js.erb → temp/new.js.erb} +0 -0
- /data/app/views/usman/admin/features/{row.js.erb → temp/row.js.erb} +0 -0
- /data/app/views/usman/admin/features/{show.js.erb → temp/show.js.erb} +0 -0
- /data/app/views/usman/admin/features/{update.js.erb → temp/update.js.erb} +0 -0
- /data/db/migrate/{20140402113213_create_users.rb → 20170000000100_create_users.rb} +0 -0
- /data/db/migrate/{20140402113214_create_features.rb → 20170000000101_create_features.rb} +0 -0
data/app/models/role.rb
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
class Role < Usman::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
require 'import_error_handler.rb'
|
|
4
|
+
extend Usman::ImportErrorHandler
|
|
5
|
+
|
|
6
|
+
# Associations
|
|
7
|
+
has_and_belongs_to_many :users
|
|
8
|
+
|
|
9
|
+
# Validations
|
|
10
|
+
validates :name, presence: true
|
|
11
|
+
|
|
12
|
+
# ------------------
|
|
13
|
+
# Class Methods
|
|
14
|
+
# ------------------
|
|
15
|
+
|
|
16
|
+
# return an active record relation object with the search query in its where clause
|
|
17
|
+
# Return the ActiveRecord::Relation object
|
|
18
|
+
# == Examples
|
|
19
|
+
# >>> role.search(query)
|
|
20
|
+
# => ActiveRecord::Relation object
|
|
21
|
+
scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%')")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def self.save_row_data(row, base_path)
|
|
25
|
+
|
|
26
|
+
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
|
27
|
+
|
|
28
|
+
return if row[:name].blank?
|
|
29
|
+
|
|
30
|
+
role = Role.find_by_name(row[:name]) || Role.new
|
|
31
|
+
role.name = row[:name]
|
|
32
|
+
|
|
33
|
+
# Initializing error hash for displaying all errors altogether
|
|
34
|
+
error_object = Usman::ErrorHash.new
|
|
35
|
+
|
|
36
|
+
if role.valid?
|
|
37
|
+
role.save!
|
|
38
|
+
else
|
|
39
|
+
summary = "Error while saving role: #{role.name}"
|
|
40
|
+
details = "Error! #{role.errors.full_messages.to_sentence}"
|
|
41
|
+
error_object.errors << { summary: summary, details: details }
|
|
42
|
+
end
|
|
43
|
+
return error_object
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# * Return full name
|
|
47
|
+
# == Examples
|
|
48
|
+
# >>> role.display_name
|
|
49
|
+
# => "Products"
|
|
50
|
+
def display_name
|
|
51
|
+
"#{name}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def can_be_edited?
|
|
55
|
+
true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def can_be_deleted?
|
|
59
|
+
self.users.count > 0 ? false : true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
data/app/models/user.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
class User <
|
|
1
|
+
class User < Usman::ApplicationRecord
|
|
2
2
|
|
|
3
|
+
require 'import_error_handler.rb'
|
|
4
|
+
extend Usman::ImportErrorHandler
|
|
3
5
|
extend KuppayamValidators
|
|
4
6
|
|
|
5
7
|
# including Password Methods
|
|
@@ -27,7 +29,7 @@ class User < ActiveRecord::Base
|
|
|
27
29
|
SESSION_TIME_OUT = 30.minutes
|
|
28
30
|
|
|
29
31
|
# Validations
|
|
30
|
-
|
|
32
|
+
validates :name, presence: true
|
|
31
33
|
validate_username :username
|
|
32
34
|
validate_email :email
|
|
33
35
|
validate_password :password, condition_method: :should_validate_password?
|
|
@@ -41,6 +43,7 @@ class User < ActiveRecord::Base
|
|
|
41
43
|
has_one :profile_picture, :as => :imageable, :dependent => :destroy, :class_name => "Image::ProfilePicture"
|
|
42
44
|
has_many :permissions
|
|
43
45
|
has_many :features, through: :permissions
|
|
46
|
+
has_and_belongs_to_many :users
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
# ------------------
|
|
@@ -68,6 +71,67 @@ class User < ActiveRecord::Base
|
|
|
68
71
|
scope :approved, -> { where(status: APPROVED) }
|
|
69
72
|
scope :suspended, -> { where(status: SUSPENDED) }
|
|
70
73
|
|
|
74
|
+
def self.save_row_data(row, base_path)
|
|
75
|
+
|
|
76
|
+
image_base_path = base_path + "images/"
|
|
77
|
+
|
|
78
|
+
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
|
79
|
+
|
|
80
|
+
return if row[:name].blank?
|
|
81
|
+
|
|
82
|
+
user = User.find_by_username(row[:username]) || User.new
|
|
83
|
+
user.name = row[:name]
|
|
84
|
+
user.username = row[:username]
|
|
85
|
+
user.designation = row[:designation]
|
|
86
|
+
user.email = row[:email]
|
|
87
|
+
user.phone = row[:phone]
|
|
88
|
+
|
|
89
|
+
user.super_admin = ["true", "t","1","yes","y"].include?(row[:super_admin].to_s.downcase.strip)
|
|
90
|
+
|
|
91
|
+
user.status = row[:status]
|
|
92
|
+
user.assign_default_password
|
|
93
|
+
|
|
94
|
+
# Initializing error hash for displaying all errors altogether
|
|
95
|
+
error_object = Usman::ErrorHash.new
|
|
96
|
+
|
|
97
|
+
if user.valid?
|
|
98
|
+
user.save!
|
|
99
|
+
else
|
|
100
|
+
summary = "Error while saving user: #{user.name}"
|
|
101
|
+
details = "Error! #{user.errors.full_messages.to_sentence}"
|
|
102
|
+
error_object.errors << { summary: summary, details: details }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
## Adding a profile picture
|
|
106
|
+
begin
|
|
107
|
+
image_path = image_base_path + "users/#{user.username}.png"
|
|
108
|
+
image_path = image_base_path + "users/#{user.username}.jpg" unless File.exists?(image_path)
|
|
109
|
+
if File.exists?(image_path)
|
|
110
|
+
user.build_profile_picture
|
|
111
|
+
user.profile_picture.image = File.open(image_path)
|
|
112
|
+
if user.profile_picture.valid?
|
|
113
|
+
user.profile_picture.save
|
|
114
|
+
else
|
|
115
|
+
summary = "Error while saving user: #{user.name}"
|
|
116
|
+
details = "Error! #{user.errors.full_messages.to_sentence}"
|
|
117
|
+
details << ", #{user.profile_picture.errors.full_messages.to_sentence}" if user.profile_picture
|
|
118
|
+
error_object.errors << { summary: summary, details: details }
|
|
119
|
+
end
|
|
120
|
+
else
|
|
121
|
+
summary = "Profile Picture not found for user: #{user.name}"
|
|
122
|
+
details = "#{image_path}/png doesn't exists"
|
|
123
|
+
error_object.warnings << { summary: summary, details: details }
|
|
124
|
+
end
|
|
125
|
+
rescue => e
|
|
126
|
+
summary = "Error during processing: #{$!}"
|
|
127
|
+
details = "User: #{user.name}, Image Path: #{image_path}"
|
|
128
|
+
stack_trace = "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
|
|
129
|
+
error_object.errors << { summary: summary, details: details, stack_trace: stack_trace }
|
|
130
|
+
end if user.profile_picture.blank?
|
|
131
|
+
|
|
132
|
+
return error_object
|
|
133
|
+
end
|
|
134
|
+
|
|
71
135
|
# ------------------
|
|
72
136
|
# Instance variables
|
|
73
137
|
# ------------------
|
|
@@ -155,6 +219,14 @@ class User < ActiveRecord::Base
|
|
|
155
219
|
self.update_attributes auth_token: SecureRandom.hex, token_created_at: nil
|
|
156
220
|
end
|
|
157
221
|
|
|
222
|
+
def update_token
|
|
223
|
+
self.update_attribute(:token_created_at, Time.now)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def token_about_to_expire?
|
|
227
|
+
return self.token_created_at.nil? || (Time.now > self.token_created_at + (SESSION_TIME_OUT - 1.minute))
|
|
228
|
+
end
|
|
229
|
+
|
|
158
230
|
def assign_default_password
|
|
159
231
|
self.password = DEFAULT_PASSWORD
|
|
160
232
|
self.password_confirmation = DEFAULT_PASSWORD
|
|
@@ -216,10 +288,26 @@ class User < ActiveRecord::Base
|
|
|
216
288
|
permission && permission.can_delete?
|
|
217
289
|
end
|
|
218
290
|
|
|
219
|
-
def
|
|
291
|
+
def can_be_approved?
|
|
292
|
+
pending? or suspended?
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def can_be_marked_as_pending?
|
|
296
|
+
approved? or suspended?
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def can_be_suspended?
|
|
300
|
+
approved? or pending?
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def can_be_deleted?
|
|
220
304
|
return true
|
|
221
305
|
end
|
|
222
306
|
|
|
307
|
+
def can_be_edited?
|
|
308
|
+
!suspended?
|
|
309
|
+
end
|
|
310
|
+
|
|
223
311
|
private
|
|
224
312
|
|
|
225
313
|
def should_validate_password?
|
|
@@ -244,4 +332,25 @@ class User < ActiveRecord::Base
|
|
|
244
332
|
return feature
|
|
245
333
|
end
|
|
246
334
|
|
|
335
|
+
def get_role(role_name)
|
|
336
|
+
self.roles.find_by_id(role_name) || self.roles.find_by_name(role_name)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
def add_role(role_name)
|
|
340
|
+
role = self.get_role(role_name)
|
|
341
|
+
self.roles << role if role && role.persists?
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def remove_role(role_name)
|
|
345
|
+
role = self.get_role(role_name)
|
|
346
|
+
if role
|
|
347
|
+
self.roles.delete(role)
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def has_role?(role_name)
|
|
352
|
+
role = self.get_role(role_name)
|
|
353
|
+
role && role.persists?
|
|
354
|
+
end
|
|
355
|
+
|
|
247
356
|
end
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
<!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
|
|
39
39
|
|
|
40
40
|
<li class="<%= nav_active?('admin/dashboard') ? 'active' : '' %>">
|
|
41
|
-
<%= link_to raw("<i class=\"linecons-desktop\"></i> <span class='title'>Dashboard</span>"), admin_dashboard_url %>
|
|
41
|
+
<%= link_to raw("<i class=\"linecons-desktop\"></i> <span class='title'>Dashboard</span>"), usman.admin_dashboard_url %>
|
|
42
42
|
</li>
|
|
43
43
|
|
|
44
44
|
<li class="<%= nav_active?('admin/users') ? 'active' : '' %>">
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
|
|
51
51
|
<ul>
|
|
52
52
|
<li class="<%= nav_class("admin/users") %>">
|
|
53
|
-
<%= link_to raw("<i class=\"linecons-user\"></i> <span class='title'>Manage Users</span>"), admin_users_url %>
|
|
53
|
+
<%= link_to raw("<i class=\"linecons-user\"></i> <span class='title'>Manage Users</span>"), usman.admin_users_url %>
|
|
54
54
|
</li>
|
|
55
55
|
|
|
56
56
|
<li class="<%= nav_class("admin/users") %>">
|
|
57
|
-
<%= link_to raw("<i class=\"linecons-lock\"></i> <span class='title'>Manage Permissions</span>"), admin_permissions_url %>
|
|
57
|
+
<%= link_to raw("<i class=\"linecons-lock\"></i> <span class='title'>Manage Permissions</span>"), usman.admin_permissions_url %>
|
|
58
58
|
</li>
|
|
59
59
|
</ul>
|
|
60
60
|
|
|
@@ -67,7 +67,11 @@
|
|
|
67
67
|
</a>
|
|
68
68
|
<ul>
|
|
69
69
|
<li class="">
|
|
70
|
-
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Features</span>"), admin_features_url %>
|
|
70
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Features</span>"), usman.admin_features_url %>
|
|
71
|
+
</li>
|
|
72
|
+
|
|
73
|
+
<li class="">
|
|
74
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Roles</span>"), usman.admin_roles_url %>
|
|
71
75
|
</li>
|
|
72
76
|
</ul>
|
|
73
77
|
</li>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<div class="row">
|
|
2
|
-
<div class="col-md-4">
|
|
3
|
-
<%= link_to raw("<i class='fa fa-plus mr-10'></i><span class='btn-text'> New Feature</span>"), new_admin_feature_path, :class=>"btn btn-primary pull-left mb-5", :remote=>true %>
|
|
4
|
-
</div>
|
|
5
|
-
<div class="col-md-8">
|
|
6
|
-
<%= search_form_kuppayam(Feature, admin_features_path, text: @filters[:query]) %>
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
<tr id="tr_feature_<%= feature.id %>">
|
|
18
18
|
|
|
19
19
|
<td class="feature-image">
|
|
20
|
-
|
|
21
|
-
<%= display_image(feature, "
|
|
22
|
-
|
|
20
|
+
<%= link_to(admin_feature_path(feature), remote: true) do %>
|
|
21
|
+
<%= display_image(feature, "feature_image.image.small.url", width: "32", height: "auto", class: "img-rectangle", alt: feature.display_name) %>
|
|
22
|
+
<% end %>
|
|
23
23
|
</td>
|
|
24
24
|
|
|
25
25
|
<td class="feature-name"><%= link_to feature.name, admin_feature_path(feature), remote: true %></td>
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
<tr id="tr_feature_<%= feature.id %>">
|
|
5
5
|
|
|
6
6
|
<td class="feature-image">
|
|
7
|
-
|
|
8
|
-
<%= display_image(feature, "
|
|
9
|
-
|
|
7
|
+
<%= link_to(admin_feature_path(feature), remote: true) do %>
|
|
8
|
+
<%= display_image(feature, "feature_image.image.small.url", width: "32", height: "auto", class: "img-rectangle", alt: feature.display_name) %>
|
|
9
|
+
<% end %>
|
|
10
10
|
</td>
|
|
11
11
|
|
|
12
12
|
<td class="feature-name"><%= link_to feature.name, admin_feature_path(feature), remote: true %></td>
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
<div class="media <%= status_hash[@feature.status.to_sym] %>">
|
|
4
4
|
|
|
5
5
|
<div class="pull-left pt-10 pr-10 pb-10" style="width:30%;">
|
|
6
|
-
<%= edit_image(@feature,
|
|
6
|
+
<%= edit_image(@feature,
|
|
7
|
+
"feature_image.image.large.url",
|
|
8
|
+
upload_image_link(@feature, :feature_image, nil ),
|
|
9
|
+
remove_image_link(@feature, :feature_image, nil ),
|
|
10
|
+
image_options: {assoc_name: :feature_image }) %>
|
|
7
11
|
</div>
|
|
8
12
|
|
|
9
13
|
<div class="pull-left ml-10" style="width:65%;">
|
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
<div class="tab-pane active">
|
|
9
9
|
|
|
10
10
|
<div id="div_feature_action_buttons">
|
|
11
|
-
|
|
11
|
+
<div class="row">
|
|
12
|
+
<div class="col-md-4">
|
|
13
|
+
<%= link_to raw("<i class='fa fa-plus mr-10'></i><span class='btn-text'> New Feature</span>"), new_admin_feature_path, :class=>"btn btn-primary pull-left mb-5", :remote=>true %>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="col-md-8">
|
|
16
|
+
<%= search_form_kuppayam(Feature, admin_features_path, text: @filters[:query]) %>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
12
19
|
</div>
|
|
13
20
|
<%= clear_tag(10) %>
|
|
14
21
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<% if @feature.errors.blank? %>
|
|
2
|
+
|
|
3
|
+
// Inserting the row on top of the table and highlighting it
|
|
4
|
+
$('#tr_feature_index table > tbody > tr:first').before("<%= escape_javascript(render(:partial=>'/usman/admin/features/row', locals: {feature: @feature})) %>")
|
|
5
|
+
$("#tr_feature_<%= @feature.id %>").css("background-color", "#fffddd");
|
|
6
|
+
|
|
7
|
+
// Showing the saved data in the modal
|
|
8
|
+
var heading = "<%= raw @feature.name %>";
|
|
9
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/features/show')) %>";
|
|
10
|
+
showLargeModal(heading, bodyContent, false);
|
|
11
|
+
|
|
12
|
+
// Showing Growl Like Message
|
|
13
|
+
notifySuccess("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(@notification[:message]) %>");
|
|
14
|
+
|
|
15
|
+
<% else %>
|
|
16
|
+
|
|
17
|
+
// Reload the form with errors
|
|
18
|
+
var heading = "Add a User";
|
|
19
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/features/form')) %>";
|
|
20
|
+
showLargeModal(heading, bodyContent);
|
|
21
|
+
|
|
22
|
+
// Show Main Error Message on the form
|
|
23
|
+
<% error_message = content_tag(:div, I18n.t('errors.errors_highlighted'), class: "alert alert-danger mt-20") %>
|
|
24
|
+
$("#feature_form_error").html("<%= escape_javascript(error_message) %>");
|
|
25
|
+
|
|
26
|
+
// Showing Growl Like Message
|
|
27
|
+
notifyError("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(raw(@notification[:message])) %>");
|
|
28
|
+
|
|
29
|
+
<% end %>
|
|
@@ -3,6 +3,6 @@ closeGenericModal();
|
|
|
3
3
|
// Fill the right box with first enquiry details in the list
|
|
4
4
|
$('#div_feature_index').html("<%= escape_javascript(render(:partial=>'/usman/admin/features/index')) %>");
|
|
5
5
|
<% else %>
|
|
6
|
-
var noResultsText = "<%= escape_javascript(theme_panel_message(I18n.translate('
|
|
6
|
+
var noResultsText = "<%= escape_javascript(theme_panel_message(I18n.translate('success.no_results_found')))%>";
|
|
7
7
|
$('#div_feature_index').html(noResultsText);
|
|
8
8
|
<% end %>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<div class="row">
|
|
2
|
-
<div class="col-md-4">
|
|
3
|
-
<%= link_to raw("<i class='fa fa-plus mr-10'></i><span class='btn-text'> New Permission</span>"), new_admin_permission_path, :class=>"btn btn-primary pull-left mb-5", :remote=>true %>
|
|
4
|
-
</div>
|
|
5
|
-
<div class="col-md-8">
|
|
6
|
-
<%= search_form_kuppayam(Permission, admin_permissions_path, text: @filters[:query]) %>
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
<div class="tab-pane active">
|
|
9
9
|
|
|
10
10
|
<div id="div_permission_action_buttons">
|
|
11
|
-
|
|
11
|
+
<div class="row">
|
|
12
|
+
<div class="col-md-4">
|
|
13
|
+
<%= link_to raw("<i class='fa fa-plus mr-10'></i><span class='btn-text'> New Permission</span>"), new_admin_permission_path, :class=>"btn btn-primary pull-left mb-5", :remote=>true %>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="col-md-8">
|
|
16
|
+
<%= search_form_kuppayam(Permission, admin_permissions_path, text: @filters[:query]) %>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
12
19
|
</div>
|
|
13
20
|
<%= clear_tag(10) %>
|
|
14
21
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<% if @permission.errors.blank? %>
|
|
2
|
+
|
|
3
|
+
// Inserting the row on top of the table and highlighting it
|
|
4
|
+
$('#tr_permission_index table > tbody > tr:first').before("<%= escape_javascript(render(:partial=>'/usman/admin/permissions/row', locals: {permission: @permission})) %>")
|
|
5
|
+
$("#tr_permission_<%= @permission.id %>").css("background-color", "#fffddd");
|
|
6
|
+
|
|
7
|
+
// Showing the saved data in the modal
|
|
8
|
+
var heading = "<%= raw @permission.name %>";
|
|
9
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/permissions/show')) %>";
|
|
10
|
+
showLargeModal(heading, bodyContent, false);
|
|
11
|
+
|
|
12
|
+
// Showing Growl Like Message
|
|
13
|
+
notifySuccess("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(@notification[:message]) %>");
|
|
14
|
+
|
|
15
|
+
<% else %>
|
|
16
|
+
|
|
17
|
+
// Reload the form with errors
|
|
18
|
+
var heading = "Add a Permission";
|
|
19
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/permissions/form')) %>";
|
|
20
|
+
showLargeModal(heading, bodyContent);
|
|
21
|
+
|
|
22
|
+
// Show Main Error Message on the form
|
|
23
|
+
<% error_message = content_tag(:div, I18n.t('errors.errors_highlighted'), class: "alert alert-danger mt-20") %>
|
|
24
|
+
$("#permission_form_error").html("<%= escape_javascript(error_message) %>");
|
|
25
|
+
|
|
26
|
+
// Showing Growl Like Message
|
|
27
|
+
notifyError("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(raw(@notification[:message])) %>");
|
|
28
|
+
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<% if @destroyed %>
|
|
2
|
+
|
|
3
|
+
// Removing the item from the list
|
|
4
|
+
$('#tr_permission_<%= @permission.id %>').remove();
|
|
5
|
+
|
|
6
|
+
// Closing the modal if it is opened
|
|
7
|
+
closeLargeModal();
|
|
8
|
+
|
|
9
|
+
// Showing Growl Like Message
|
|
10
|
+
notifySuccess("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(@notification[:message]) %>");
|
|
11
|
+
|
|
12
|
+
<% else %>
|
|
13
|
+
|
|
14
|
+
// Show the error in a modal
|
|
15
|
+
showMessageModal("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(@notification[:message]) %>");
|
|
16
|
+
|
|
17
|
+
// Showing Growl Like Message
|
|
18
|
+
notifyError("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(@notification[:message]) %>");
|
|
19
|
+
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// Close Modal if it is opened
|
|
2
|
+
closeLargeModal();
|
|
3
|
+
|
|
2
4
|
<% if @permissions.any? %>
|
|
3
|
-
|
|
5
|
+
|
|
6
|
+
// Refresh the list
|
|
4
7
|
$('#div_permission_index').html("<%= escape_javascript(render(:partial=>'/usman/admin/permissions/index')) %>");
|
|
8
|
+
|
|
5
9
|
<% else %>
|
|
6
|
-
|
|
10
|
+
|
|
11
|
+
var noResultsText = "<%= escape_javascript(theme_panel_message(I18n.translate('success.no_results_found')))%>";
|
|
7
12
|
$('#div_permission_index').html(noResultsText);
|
|
13
|
+
|
|
8
14
|
<% end %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<% if @permission && @permission.errors.blank? %>
|
|
2
|
+
|
|
3
|
+
// Updating the edited row and highlighting it
|
|
4
|
+
$("#tr_permission_<%= @permission.id %>").replaceWith("<%= escape_javascript(render(:partial=>'/usman/admin/permissions/row', locals: {permission: @permission, i: -1})) %>")
|
|
5
|
+
$("#tr_permission_<%= @permission.id %>").css("background-color", "#fffddd");
|
|
6
|
+
|
|
7
|
+
// Refresh the modal content if it is open
|
|
8
|
+
$("#div_permission_show").replaceWith("<%= escape_javascript(render(:partial=>'/usman/admin/permissions/show')) %>")
|
|
9
|
+
|
|
10
|
+
// Closing the modal
|
|
11
|
+
showAndHideModals();
|
|
12
|
+
|
|
13
|
+
// Showing Growl Like Message
|
|
14
|
+
notifySuccess("<%= @notification[:title] %>", "<%= @notification[:message] %>");
|
|
15
|
+
|
|
16
|
+
<% else %>
|
|
17
|
+
|
|
18
|
+
// Updating the row which got errored and highlighting it
|
|
19
|
+
$("#tr_permission_<%= params[:id] %>").css("background-color", "#ffefef");
|
|
20
|
+
|
|
21
|
+
// Showing Growl Like Message
|
|
22
|
+
notifyError("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(raw(@notification[:message])) %>");
|
|
23
|
+
|
|
24
|
+
<% end %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% if @permission %>
|
|
2
|
+
|
|
3
|
+
// Show the details in the large modal
|
|
4
|
+
var heading = "<%= raw @permission.name %>";
|
|
5
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/permissions/show')) %>";
|
|
6
|
+
showLargeModal(heading, bodyContent, false);
|
|
7
|
+
|
|
8
|
+
<% else %>
|
|
9
|
+
|
|
10
|
+
// Showing Growl Like Message
|
|
11
|
+
notifyError("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(raw(@notification[:message])) %>");
|
|
12
|
+
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<% if @permission.errors.blank? %>
|
|
2
|
+
|
|
3
|
+
// Updating the edited row and highlighting it
|
|
4
|
+
$('#tr_permission_<%= @permission.id %>').replaceWith("<%= escape_javascript(render(:partial=>'/usman/admin/permissions/row', locals: {permission: @permission})) %>");
|
|
5
|
+
$("#tr_permission_<%= @permission.id %>").css("background-color", "#fffddd");
|
|
6
|
+
|
|
7
|
+
// Showing the saved data in the modal
|
|
8
|
+
var heading = "<%= raw @permission.name %>";
|
|
9
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/permissions/show')) %>";
|
|
10
|
+
showLargeModal(heading, bodyContent, false);
|
|
11
|
+
|
|
12
|
+
// Showing Growl Like Message
|
|
13
|
+
notifySuccess("<%= @notification[:title] %>", "<%= @notification[:message] %>");
|
|
14
|
+
|
|
15
|
+
<% else %>
|
|
16
|
+
|
|
17
|
+
// Reload the form with errors
|
|
18
|
+
var heading = "Edit Permission";
|
|
19
|
+
var bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/permissions/form')) %>";
|
|
20
|
+
showLargeModal(heading, bodyContent);
|
|
21
|
+
|
|
22
|
+
// Show Main Error Message on the form
|
|
23
|
+
<% error_message = content_tag(:div, I18n.t('errors.errors_highlighted'), class: "alert alert-danger mt-20") %>
|
|
24
|
+
$("#permission_form_error").html("<%= escape_javascript(error_message) %>");
|
|
25
|
+
|
|
26
|
+
// Showing Growl Like Message
|
|
27
|
+
notifyError("<%= escape_javascript(@notification[:title]) %>", "<%= escape_javascript(raw(@notification[:message])) %>");
|
|
28
|
+
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%= form_for([:admin, @role], :html => {:id=>"form_role", :class=>"mb-0 form-horizontal", :role => "form", :method => (@role.new_record? ? :post : :put), :remote=>true}) do |f| %>
|
|
2
|
+
|
|
3
|
+
<div id="role_form_error">
|
|
4
|
+
<%= @role.errors[:base].to_sentence %>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="form-inputs mb-30 mt-30">
|
|
8
|
+
<%= theme_form_field(@role, :name) %>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
|
|
13
|
+
<%= submit_tag("Save", :class=>"btn btn-primary pull-right ml-10") %>
|
|
14
|
+
|
|
15
|
+
<%= link_to raw("<i class='fa fa-close mr-5'></i><span>Cancel</span>"), "#", onclick: "closeGenericModal();", class: "pull-right ml-10 btn btn-white" %>
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
<%= clear_tag(10) %>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<% end %>
|
|
23
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<div class="table-responsive">
|
|
2
|
+
<table class="table table-hover members-table middle-align">
|
|
3
|
+
<thead>
|
|
4
|
+
<tr>
|
|
5
|
+
<th style="text-align: center;width:20px">#</th>
|
|
6
|
+
<th>Name</th>
|
|
7
|
+
<th style="text-align: center;">Actions</th>
|
|
8
|
+
</tr>
|
|
9
|
+
</thead>
|
|
10
|
+
|
|
11
|
+
<tbody>
|
|
12
|
+
<% @roles.each_with_index do |role, i| %>
|
|
13
|
+
|
|
14
|
+
<% edit_link = edit_admin_role_path(id: role.id) %>
|
|
15
|
+
<% delete_link = admin_role_path(id: role.id) %>
|
|
16
|
+
|
|
17
|
+
<tr id="tr_role_<%= role.id %>">
|
|
18
|
+
|
|
19
|
+
<th scope="row" style="text-align: center;">
|
|
20
|
+
<% if i < 0 %>
|
|
21
|
+
<i class="fa fa-check text-success"></i>
|
|
22
|
+
<% else %>
|
|
23
|
+
<%= i + 1 + (@per_page.to_i * (@current_page.to_i - 1)) %>
|
|
24
|
+
<% end %>
|
|
25
|
+
</th>
|
|
26
|
+
|
|
27
|
+
<td class="role-name"><%= link_to role.name, admin_role_path(role), remote: true %></td>
|
|
28
|
+
|
|
29
|
+
<td class="action-links" style="width:10%">
|
|
30
|
+
|
|
31
|
+
<%= link_to raw("<i class=\"linecons-pencil\"></i> Edit Role"), edit_link, :remote=>true, class: "edit" %>
|
|
32
|
+
|
|
33
|
+
<%= 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" %>
|
|
34
|
+
|
|
35
|
+
</td>
|
|
36
|
+
|
|
37
|
+
</tr>
|
|
38
|
+
<% end %>
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div class="row">
|
|
44
|
+
<div class="col-sm-12">
|
|
45
|
+
<%= paginate_kuppayam(@roles) %>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|