itsf_backend 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/controller/feature_flags_concern.rb +35 -0
- data/app/controllers/itsf/backend/resource/base_controller.rb +1 -0
- data/app/views/itsf/backend/resource/base/_table_actions.html.haml +3 -3
- data/app/views/itsf/backend/resource/base/index.html.haml +5 -5
- data/app/views/itsf/backend/resource/base/show.html.haml +2 -2
- data/app/views/itsf/backend/service/base/index.html.haml +1 -1
- data/lib/itsf/backend/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd571360f20a7f653a3b04e73e27818fad6f23d4
|
4
|
+
data.tar.gz: 86762817f6b50c73bb2bf70254e593e545feded1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccb557d90efaa0299263d661cb57480d549a4aba0b71c18d00cc9c9aa97b955f318aceb29fcb4ecb15aba7dc714a4927efd8776740a62d9809e3914222917c2f
|
7
|
+
data.tar.gz: 2fbcd18c6956583ab379394d217a404e5c3f9044fbad14c9149ef4e833098f1e1175f08aa0fd62fc2bd37ad346ecacb7dcf2934fab62e9e1f270aa0d502529c8
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Controller
|
2
|
+
# Adds an api to toggle features at controller level.
|
3
|
+
#
|
4
|
+
# Assume you have ransack enabled globally (Itsf::Backend.features?(:ransach) == true),
|
5
|
+
# but you can't use ransack in a specific controller, than you overwrite disabled_features
|
6
|
+
# in the controller and make it return an array with :ransack inside of it:
|
7
|
+
#
|
8
|
+
# def disabled_features
|
9
|
+
# [:ransack]
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# Then you can ask features?(:ransack) in the view and it will return false,
|
13
|
+
# although ransack is enabled globally.
|
14
|
+
#
|
15
|
+
module FeatureFlagsConcern
|
16
|
+
extend ActiveSupport::Concern
|
17
|
+
|
18
|
+
included do
|
19
|
+
helper_method :features?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# Ask featuers?(:foo) in the controller or your views to find out, if a
|
25
|
+
# feature is enabled in this controller.
|
26
|
+
def features?(what)
|
27
|
+
Itsf::Backend.features?(what) && !disabled_features.include?(what)
|
28
|
+
end
|
29
|
+
|
30
|
+
# overwrite this method, to disable features.
|
31
|
+
def disabled_features
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -17,6 +17,7 @@ module Itsf::Backend
|
|
17
17
|
include Controller::RansackConcern if Itsf::Backend.features?(:ransack)
|
18
18
|
include Controller::PaginationConcern if Itsf::Backend.features?(:kaminari)
|
19
19
|
include Controller::JsonApiConcern
|
20
|
+
include Controller::FeatureFlagsConcern
|
20
21
|
helper Itsf::Backend::ApplicationHelper
|
21
22
|
helper MultiClientHelper if Itsf::Backend.features?(:multi_client)
|
22
23
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
= table.column(:actions) do |resource|
|
2
2
|
- id_base = "link-to-#{controller.class.name.underscore.gsub('_controller', '').gsub(/[\/_]/, '-')}-#{resource.to_param}"
|
3
3
|
.btn-group
|
4
|
-
- if !
|
4
|
+
- if !features?(:pundit) || policy(resource).show?
|
5
5
|
- begin
|
6
6
|
= link_to(resource_path(resource), id: "#{id_base}-show", class: 'btn btn-xs btn-responsive btn-default') do
|
7
7
|
%span.glyphicon.glyphicon-eye-open
|
8
8
|
%span.btn-text= t('.show')
|
9
9
|
- rescue ActionController::UrlGenerationError
|
10
|
-
- if !
|
10
|
+
- if !features?(:pundit) || policy(resource).edit?
|
11
11
|
- begin
|
12
12
|
= link_to(edit_resource_path(resource), id: "#{id_base}-edit", class: 'btn btn-xs btn-responsive btn-default') do
|
13
13
|
%span.glyphicon.glyphicon-pencil
|
14
14
|
%span.btn-text= t('.edit')
|
15
15
|
- rescue ActionController::UrlGenerationError
|
16
|
-
- if !
|
16
|
+
- if !features?(:pundit) || policy(resource).destroy?
|
17
17
|
- begin
|
18
18
|
= link_to(resource_path(resource), id: "#{id_base}-destroy", class: 'btn btn-xs btn-responsive btn-danger', method: :delete, data: { confirm: I18n.t('.confirmations.delete') }) do
|
19
19
|
%span.glyphicon.glyphicon-fire
|
@@ -3,24 +3,24 @@
|
|
3
3
|
.col-xs-8
|
4
4
|
%h1
|
5
5
|
= t('.title', inflections)
|
6
|
-
%span.label.label-default=
|
6
|
+
%span.label.label-default= features?(:kaminari) ? "#{@collection.total_count}/#{resource_class.count}" : @collection.count
|
7
7
|
.col-xs-4
|
8
8
|
#page-actions.btn-container-right
|
9
9
|
.btn-group
|
10
10
|
- begin
|
11
|
-
- if !
|
11
|
+
- if !features?(:pundit) || policy(resource_class).new?
|
12
12
|
= link_to new_resource_path, id: "link-to-#{controller.class.name.underscore.gsub('_controller', '').gsub(/[\/_]/, '-')}-new", class: 'btn btn-success btn-responsive' do
|
13
13
|
%span.glyphicon.glyphicon-plus
|
14
14
|
%span.btn-text= t('.new', inflections)
|
15
15
|
- rescue ActionController::UrlGenerationError
|
16
16
|
|
17
17
|
.panel.panel-default.panel-with-actions
|
18
|
-
- if
|
18
|
+
- if features?(:kaminari)
|
19
19
|
.panel-heading
|
20
20
|
.pull-right.form-inline
|
21
21
|
= select_tag(:per_page, options_for_select({ '1': 1, '5': 5, '10': 10, '15': 15, '20': 20, '50': 50, '100': 100, t('.all') => 'all' }, (params[:per_page] || Itsf::Backend::Configuration.default_pagination_size)), 'data-select-pagination-size': true, id: 'pagination-size', class: 'form-control input-xs')
|
22
22
|
= button_tag(t('.reset_column_order'), class: 'btn btn-default btn-xs', data: { 'reset-column-order': true})
|
23
|
-
- if
|
23
|
+
- if features?(:ransack)
|
24
24
|
.panel-body
|
25
25
|
#filter
|
26
26
|
= search_form_for(@q, url: collection_path, class: 'form-inline', html: { 'data-auto-submit': true }) do |f|
|
@@ -41,7 +41,7 @@
|
|
41
41
|
= render 'table_actions', table: table
|
42
42
|
|
43
43
|
.panel-footer
|
44
|
-
- if
|
44
|
+
- if features?(:kaminari)
|
45
45
|
.row
|
46
46
|
.col-md-4
|
47
47
|
.col-md-4
|
@@ -6,7 +6,7 @@
|
|
6
6
|
%h1= @resource.try_all(*Itsf::Backend::Configuration.resource_title_methods)
|
7
7
|
.col-xs-4
|
8
8
|
#page-actions.btn-container-right
|
9
|
-
- if !
|
9
|
+
- if !features?(:pundit) || policy(resource_class).destroy?
|
10
10
|
= link_to(resource_path(@resource), method: :delete, class: 'btn btn-danger btn-responsive', 'data-confirm': I18n.t('confirmations.delete')) do
|
11
11
|
%span.glyphicon.glyphicon-fire
|
12
12
|
%span.btn-text= t('.destroy')
|
@@ -28,7 +28,7 @@
|
|
28
28
|
%span.btn-text= t('.back')
|
29
29
|
- rescue ActionController::UrlGenerationError
|
30
30
|
- begin
|
31
|
-
- if !
|
31
|
+
- if !features?(:pundit) || policy(resource_class).edit?
|
32
32
|
= link_to(edit_resource_path(@resource), class: 'btn btn-primary btn-responsive') do
|
33
33
|
%span.glyphicon.glyphicon-pencil
|
34
34
|
%span.btn-text= t('.edit')
|
@@ -6,7 +6,7 @@
|
|
6
6
|
.col-xs-4
|
7
7
|
#page-actions.btn-container-right
|
8
8
|
.btn-group
|
9
|
-
- if !
|
9
|
+
- if !features?(:pundit) || policy(service_class).invoke?
|
10
10
|
= link_to invoke_service_path, id: "link-to-#{controller.class.name.underscore.gsub('_controller', '').gsub(/[\/_]/, '-')}-new", class: 'btn btn-success btn-responsive' do
|
11
11
|
%span.glyphicon.glyphicon-play-circle
|
12
12
|
%span.btn-text= t('.invoke', inflections)
|
data/lib/itsf/backend/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itsf_backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
@@ -504,6 +504,7 @@ files:
|
|
504
504
|
- app/controllers/concerns/controller/acts_as_list_concern.rb
|
505
505
|
- app/controllers/concerns/controller/acts_as_published_concern.rb
|
506
506
|
- app/controllers/concerns/controller/awesome_nested_set_concern.rb
|
507
|
+
- app/controllers/concerns/controller/feature_flags_concern.rb
|
507
508
|
- app/controllers/concerns/controller/pagination_concern.rb
|
508
509
|
- app/controllers/concerns/controller/pundit_authorization_failure_handling_concern.rb
|
509
510
|
- app/controllers/concerns/controller/pundit_namespaced_authorize_concern.rb
|