itsf_backend 2.1.0 → 2.2.0

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: 1377cac6270de3ab9cdfcc629ad0060bc69d9cda
4
- data.tar.gz: a85dc898f14824c69a99f6c62224f50efde3ca26
3
+ metadata.gz: bd571360f20a7f653a3b04e73e27818fad6f23d4
4
+ data.tar.gz: 86762817f6b50c73bb2bf70254e593e545feded1
5
5
  SHA512:
6
- metadata.gz: d0ccb6de223660f65de4c4d21c5b0b20173c92fd3e43804c3db0bc66779dd1dfd0ee48027b02e7d22c164d025320debebb3cfda3e1f12ad25aa544f0b53e605b
7
- data.tar.gz: c2d629d70cbc71b21b391cfb039ea27d96a723fcb49cdce617193a0ed59f5cd591e0c03d4ce4d3cc847b3a04f2728ffd640e6763f5855382283ecb8f821c399e
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 !Itsf::Backend.features?(:pundit) || policy(resource).show?
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 !Itsf::Backend.features?(:pundit) || policy(resource).edit?
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 !Itsf::Backend.features?(:pundit) || policy(resource).destroy?
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= Itsf::Backend.features?(:kaminari) ? "#{@collection.total_count}/#{resource_class.count}" : @collection.count
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 !Itsf::Backend.features?(:pundit) || policy(resource_class).new?
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 Itsf::Backend.features?(:kaminari)
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 Itsf::Backend.features?(:ransack)
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 Itsf::Backend.features?(:kaminari)
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 !Itsf::Backend.features?(:pundit) || policy(resource_class).destroy?
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 !Itsf::Backend.features?(:pundit) || policy(resource_class).edit?
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 !Itsf::Backend.features?(:pundit) || policy(service_class).invoke?
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)
@@ -1,5 +1,5 @@
1
1
  module Itsf
2
2
  module Backend
3
- VERSION = '2.1.0'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
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.1.0
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