ndr_ui 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/ndr_ui/bootstrap_helper.rb +40 -3
- data/config/routes.rb +3 -0
- data/lib/ndr_ui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3584658f79ff90044cc3e87c60a194ca964d7c59fb257784d90db46b3f7f87c1
|
4
|
+
data.tar.gz: 607c2995d427226512cbce4eddb889f809edaa11fb6707656bf25b9484921571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bf345b17539ac9d694ba9bb1ffc8a02b4e87effda793384be7e02f672d28fda2ef158d5c1857b8298488a43a46f08be873352972148a04596d11d8e7e980b81
|
7
|
+
data.tar.gz: 338e557549e9cd6dd5c0d249ff36e316b892830a2662371d557a2b824b8be65f1992b80d2e272d6db16b642a88e2fd7788ae3c50d26ea5e3e576688ea0382fd6
|
@@ -445,6 +445,36 @@ module NdrUi
|
|
445
445
|
content_tag(:div, capture(&block), class: 'btn-group')
|
446
446
|
end
|
447
447
|
|
448
|
+
# Creates a Boostrap 'New' link.
|
449
|
+
#
|
450
|
+
# ==== Signatures
|
451
|
+
#
|
452
|
+
# new_link(path, options = {})
|
453
|
+
#
|
454
|
+
# ==== Examples
|
455
|
+
#
|
456
|
+
# <%= new_link('#') %>
|
457
|
+
# # => <a title="New" class="btn btn-primary btn-xs" href="#">
|
458
|
+
# <span class="glyphicon glyphicon-plus-sign"></span>
|
459
|
+
# </a>
|
460
|
+
#
|
461
|
+
# <%= new_link(Post.new) %>
|
462
|
+
# # => <a title="New" class="btn btn-primary btn-xs" href="/posts/new">
|
463
|
+
# <span class="glyphicon glyphicon-plus-sign"></span>
|
464
|
+
# </a>
|
465
|
+
#
|
466
|
+
def new_link(path, options = {})
|
467
|
+
return unless options.delete(:skip_authorization) || ndr_can?(:new, path)
|
468
|
+
|
469
|
+
path = new_polymorphic_path(path) if can_generate_polymorphic_path?(path)
|
470
|
+
|
471
|
+
defaults = {
|
472
|
+
icon: 'plus-sign', title: 'New', path: path, class: 'btn btn-primary btn-xs'
|
473
|
+
}
|
474
|
+
|
475
|
+
link_to_with_icon(defaults.merge(options))
|
476
|
+
end
|
477
|
+
|
448
478
|
# Creates a Boostrap 'Details' link.
|
449
479
|
#
|
450
480
|
# ==== Signatures
|
@@ -459,7 +489,7 @@ module NdrUi
|
|
459
489
|
# </a>
|
460
490
|
#
|
461
491
|
def details_link(path, options = {})
|
462
|
-
return unless options
|
492
|
+
return unless options.delete(:skip_authorization) || ndr_can?(:read, path)
|
463
493
|
|
464
494
|
link_to_with_icon({ icon: 'share-alt', title: 'Details', path: path }.merge(options))
|
465
495
|
end
|
@@ -478,7 +508,7 @@ module NdrUi
|
|
478
508
|
# </a>
|
479
509
|
#
|
480
510
|
def edit_link(path, options = {})
|
481
|
-
return unless options
|
511
|
+
return unless options.delete(:skip_authorization) || ndr_can?(:edit, path)
|
482
512
|
|
483
513
|
path = edit_polymorphic_path(path) if path.is_a?(ActiveRecord::Base)
|
484
514
|
|
@@ -499,7 +529,7 @@ module NdrUi
|
|
499
529
|
# <span class="glyphicon glyphicon-trash icon-white"></span>
|
500
530
|
# </a>'
|
501
531
|
def delete_link(path, options = {})
|
502
|
-
return unless options
|
532
|
+
return unless options.delete(:skip_authorization) || ndr_can?(:delete, path)
|
503
533
|
|
504
534
|
defaults = {
|
505
535
|
icon: 'trash icon-white', title: 'Delete', path: path,
|
@@ -574,5 +604,12 @@ module NdrUi
|
|
574
604
|
|
575
605
|
can?(action, subject, *extra_args)
|
576
606
|
end
|
607
|
+
|
608
|
+
def can_generate_polymorphic_path?(path)
|
609
|
+
case path
|
610
|
+
when Array, ActiveRecord::Base then true
|
611
|
+
else false
|
612
|
+
end
|
613
|
+
end
|
577
614
|
end
|
578
615
|
end
|
data/config/routes.rb
CHANGED
data/lib/ndr_ui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NDR Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|