cmor_core_backend 0.0.52.pre → 0.0.57.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c84968fd25137d5e99d3a0d4dc06c7d9f151fcf96241652be7ca694cd8055fc
4
- data.tar.gz: fba6f9cf4b61af51d6718ba76e5a1b583579693903f9751fa10c91f8d1ed4558
3
+ metadata.gz: 7d1297dd8868a455a11f983d7fc1d55b6350fbf440d3835c752c32719bfa090c
4
+ data.tar.gz: b1c3fa08a678e177be305ce3e020fe53a0fc661956fa5dc7a6dce5ffb4458fdb
5
5
  SHA512:
6
- metadata.gz: 93391289b966d0290b476364186c6083f2cc6e18792099f0505eeac3e4106ff4fe1c740cacdead95253fd5eaf1be99f218d9bb6030acb8f32ca04ddc39989bbb
7
- data.tar.gz: 38460daf62811fb2901d1123dfe374ab61d4277adabfc082cd97765420b65b03a91a827c0c75c80ab54807f0f56d23a53bbf4e6d3ec68d6adf707232850ad7d7
6
+ metadata.gz: b6195403c1ffa41b2bd33e9b7e4016d408cf7009596050d32d66faba1fd08e8f377fd77e2599f70f94370a8232ec9e0c562fcb77e10c6851d24a9ebe1251dfe7
7
+ data.tar.gz: 2faa45bc9091de1090165fb7ca025ec49b43d6cc8a59d3fe69a289840388ee5b48753cae6c91e33e52f6a2634be51b0e7ca7f355d1262a99e4f2136de3c82a7e
@@ -3,6 +3,10 @@ module Cmor
3
3
  module Backend
4
4
  module ResourcesController
5
5
  class Base < Administrador::ResourcesController::Base
6
+ if Cmor::Core.features?(:transports)
7
+ include Cmor::Transports::ResourcesController::ExportConcern
8
+ view_helper Cmor::Transports::ExportViewHelper, as: :export_helper
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -0,0 +1,90 @@
1
+ module Cmor
2
+ module Core
3
+ module Backend
4
+ module Routing
5
+ # You can add routes to resources based an any condition that is based
6
+ # on the controller or resource class that a route is used for.
7
+ #
8
+ # This is useful when writing modules that conditionally add actions to
9
+ # resources based on the capabilities of the controller or resource class.
10
+ #
11
+ # Example:
12
+ #
13
+ # # lib/cmor/audits/engine.rb (in the Cmor::Audits Engine)
14
+ # module Cmor::Audits
15
+ # class Engine < ::Rails::Engine
16
+ # config.to_prepare do
17
+ # Cmor::Core::Backend.configure do |config|
18
+ # config.add_resources_routes(
19
+ # :cmor_audits,
20
+ # condition: ->{ resource_class.ancestors.map(&:to_s).include?("PaperTrail::Model::InstanceMethods") },
21
+ # routes: ->{
22
+ # get "versions/:version_id", on: :member, action: :version
23
+ # get "versions_at(/:version_at)", on: :member, action: :version_at
24
+ # get "versions", on: :member, action: :versions
25
+ # }
26
+ # )
27
+ # end
28
+ # end
29
+ # end
30
+ # end
31
+ #
32
+ # # config/routes.rb ( in the Cmor::Cms::Backend Engine)
33
+ # Cmor::Cms::Backend::Engine.routes.draw do
34
+ # resources :pages do
35
+ # Cmor::Core::Backend::Routing::ResourcesRoutes.inject_routes(self)
36
+ # end
37
+ # end
38
+ #
39
+ #
40
+ # This will add the routes for the versioning to the pages resource
41
+ # routing if the resource class of the pages controller includes the
42
+ # PaperTrail::Model::InstanceMethods module.
43
+ #
44
+ class ResourcesRoutes
45
+ def self.inject_routes(router, options = {})
46
+ new(router, options).inject_routes
47
+ end
48
+
49
+ def initialize(router, options = {})
50
+ @router = router
51
+ @options = options
52
+ end
53
+
54
+ def inject_routes
55
+ routes.each do |name, options|
56
+ if instance_exec(&options[:condition])
57
+ @router.instance_exec(&options[:routes])
58
+ end
59
+ end
60
+ end
61
+
62
+ def controller_class
63
+ @controller_class ||= begin
64
+ __controller = @router.instance_variable_get(:@scope).instance_variable_get(:@hash)[:controller]
65
+ __namespaces = []
66
+ __actual_scope = @router.instance_variable_get(:@scope)
67
+ while __actual_scope.instance_variable_get(:@parent).present?
68
+ __namespace = __actual_scope.instance_variable_get(:@parent).instance_variable_get(:@hash).try(:[], :module)
69
+ if __namespace.present? && !__namespaces.any? { |n| n&.start_with?(__namespace) }
70
+ __namespaces << __actual_scope.instance_variable_get(:@parent).instance_variable_get(:@hash).try(:[], :module)
71
+ end
72
+ __actual_scope = __actual_scope.instance_variable_get(:@parent)
73
+ end
74
+ __namespace = __namespaces.uniq.reverse.compact.join("/")
75
+ "#{__namespace}/#{__controller}_controller".camelize.constantize
76
+ end
77
+ end
78
+
79
+ def resource_class
80
+ controller_class.resource_class
81
+ end
82
+
83
+ def routes
84
+ @routes ||= Cmor::Core::Backend::Configuration.resources_routes
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,7 @@
1
+ .ml-auto
2
+ - if Cmor::Core.features?(:cmor_transports) && controller.class.available_rest_actions.include?(:export)
3
+ = link_to(export_path, class: 'btn btn-secondary btn-circle btn-lg') do
4
+ %i.fas.fa-file-export
5
+ - if available_rest_actions.include?(:new)
6
+ = link_to({ action: :new }, class: 'btn btn-success btn-circle btn-lg') do
7
+ %i.fas.fa-plus
@@ -0,0 +1,16 @@
1
+ = link_to({ action: :index }, class: 'btn btn-light btn-responsive') do
2
+ %i.fas.fa-arrow-left
3
+ %span.btn-text= t('.back')
4
+
5
+ .ml-auto
6
+ - if Cmor::Core.features?(:cmor_audits) && available_rest_actions.include?(:versions)
7
+ = link_to([:versions, resource_namespace, resource], class: 'btn btn-secondary btn-circle btn-lg') do
8
+ %i.fas.fa-history
9
+
10
+ - if available_rest_actions.include?(:destroy)
11
+ = link_to([resource_namespace, resource], class: 'destroy btn btn-danger btn-circle btn-lg', method: :delete, 'data-confirm': I18n.t('administrador.controller.confirmations.destroy')) do
12
+ %i.fas.fa-fire
13
+
14
+ - if available_rest_actions.include?(:edit)
15
+ = link_to([:edit, resource_namespace, resource], class: 'btn btn-success btn-circle btn-lg') do
16
+ %i.fas.fa-edit
@@ -1,6 +1,13 @@
1
1
  de:
2
2
  classes:
3
3
  cmor/core/backend/engine: Core
4
+ cmor:
5
+ core:
6
+ backend:
7
+ resources_controller:
8
+ base:
9
+ show_actions:
10
+ back: Zurück
4
11
  routes:
5
12
  cmor-core-backend-engine: core
6
13
  or: oder
@@ -1,6 +1,13 @@
1
1
  en:
2
2
  classes:
3
3
  cmor/core/backend/engine: Core
4
+ cmor:
5
+ core:
6
+ backend:
7
+ resources_controller:
8
+ base:
9
+ show_actions:
10
+ back: Back
4
11
  routes:
5
12
  cmor-core-backend-engine: core
6
13
  or: or
@@ -5,6 +5,8 @@ module Cmor
5
5
  module Core
6
6
  module Backend
7
7
  module Configuration
8
+ extend self
9
+
8
10
  def configure
9
11
  yield self
10
12
  end
@@ -16,8 +18,36 @@ module Cmor
16
18
  }
17
19
  }
18
20
 
19
- def self.image_variant_options_for(identifier)
20
- @@image_variant_options[identifier]
21
+ mattr_accessor(:resources_routes) { {} }
22
+
23
+ def image_variant_options_for(identifier)
24
+ image_variant_options[identifier]
25
+ end
26
+
27
+ # You can add routes to resources based an any condition that can based
28
+ # on the controller or resource class that a route is used for.
29
+ #
30
+ # This is useful when writing modules that conditionally add actions to
31
+ # resources based on the capabilities of the controller or resource class.
32
+ #
33
+ # Example:
34
+ #
35
+ # config.add_resources_routes(
36
+ # :cmor_audits,
37
+ # condition: ->{ resource_class.ancestors.map(&:to_s).include?("PaperTrail::Model::InstanceMethods") },
38
+ # routes: ->{ paper_trail_resources }
39
+ # )
40
+ #
41
+ # Example:
42
+ #
43
+ # config.add_resources_routes(
44
+ # :acts_as_list,
45
+ # condition: ->{ resource_class.respond_to?(:position) },
46
+ # routes: ->{ get :toggle_position, on: :member }
47
+ # )
48
+ #
49
+ def add_resources_routes(name, options)
50
+ resources_routes[name] = options
21
51
  end
22
52
  end
23
53
  end
@@ -9,4 +9,27 @@ Cmor::Core::Backend.configure do |config|
9
9
  gallery: { resize: "640x480" },
10
10
  table: { resize: "160x120" }
11
11
  }
12
+
13
+ # You can add routes to resources based an any condition that is based
14
+ # on the controller or resource class that a route is used for.
15
+ #
16
+ # This is useful when writing modules that conditionally add actions to
17
+ # resources based on the capabilities of the controller or resource class.
18
+ #
19
+ # Example:
20
+ #
21
+ # config.add_resources_routes(
22
+ # :cmor_audits,
23
+ # condition: ->{ resource_class.ancestors.map(&:to_s).include?("PaperTrail::Model::InstanceMethods") },
24
+ # routes: ->{ paper_trail_resources }
25
+ # )
26
+ #
27
+ # Example:
28
+ #
29
+ # config.add_resources_routes(
30
+ # :acts_as_list,
31
+ # condition: ->{ resource_class.respond_to?(:position) },
32
+ # routes: ->{ get :toggle_position, on: :member }
33
+ # )
34
+ #
12
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmor_core_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52.pre
4
+ version: 0.0.57.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.52.pre
33
+ version: 0.0.57.pre
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.52.pre
40
+ version: 0.0.57.pre
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -310,14 +310,14 @@ dependencies:
310
310
  requirements:
311
311
  - - ">="
312
312
  - !ruby/object:Gem::Version
313
- version: 0.0.22.pre
313
+ version: 0.0.26.pre
314
314
  type: :runtime
315
315
  prerelease: false
316
316
  version_requirements: !ruby/object:Gem::Requirement
317
317
  requirements:
318
318
  - - ">="
319
319
  - !ruby/object:Gem::Version
320
- version: 0.0.22.pre
320
+ version: 0.0.26.pre
321
321
  description:
322
322
  email:
323
323
  - roberto@vasquez-angel.de
@@ -342,6 +342,9 @@ files:
342
342
  - app/controllers/cmor/core/backend/resource_controller/base.rb
343
343
  - app/controllers/cmor/core/backend/resources_controller/base.rb
344
344
  - app/controllers/cmor/core/backend/service_controller/base.rb
345
+ - app/routes/cmor/core/backend/routing/resources_routes.rb
346
+ - app/views/cmor/core/backend/resources_controller/base/_index_actions.html.haml
347
+ - app/views/cmor/core/backend/resources_controller/base/_show_actions.html.haml
345
348
  - config/initializers/assets.rb
346
349
  - config/locales/de.yml
347
350
  - config/locales/en.yml
@@ -417,7 +420,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
420
  - !ruby/object:Gem::Version
418
421
  version: 1.3.1
419
422
  requirements: []
420
- rubygems_version: 3.1.2
423
+ rubygems_version: 3.1.4
421
424
  signing_key:
422
425
  specification_version: 4
423
426
  summary: Cmor Core Module.