cmor_core_backend 0.0.55.pre → 0.0.56.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: 36f1fa9dbca13cec542035c909b763d9a0c41df8775d776665d34f5b753f5088
4
- data.tar.gz: 7fb67e6af21e0d5bd0b0af134e4a5745a5fddc437cc71e8bcfc29b8cd6dfc05a
3
+ metadata.gz: 706d8379a914d4d31042960f41b5e219774eba5fe936c0f11b5be66f1cbba8b6
4
+ data.tar.gz: 80be7b89718817219c0c9d6bdc943240114338afd608a77fe623e0408b479280
5
5
  SHA512:
6
- metadata.gz: cde26d27c8b9c5eaf7c9d6fcb0ab32518fbc2bdd0381780b92036b76548b8f661acc17c0c0b1f96f5c2b65b84c47c90bdabbd6fc7710945fe683d8a1d69700e5
7
- data.tar.gz: 73beb7d89f51cbdc49953fc28e8307ab2ea35cddc4975c9e90a4b8d9db8c2ddd121d7ed5a0d1794a2814cba8fe057679bb1802c74d86b0867d5d9b6cb9153764
6
+ metadata.gz: 2f1ad6f2bcdd81cdf7ba3235ccc5689627741b0bcb8e657c6a8e2bcc7c6cc0563209ae568db27290b639a1897b4f7d5e48170feab6ac439d12a3ddf452eb0350
7
+ data.tar.gz: db7b3929e2f1412a3b0dba67c18110fec69ca8991566335fecb72dafff179f4395d4cd0c664ae71553d6c94b9bfcc145ce2928f21ce87aa0c14faad5e3fba06b
@@ -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) && controller.respond_to?(: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.55.pre
4
+ version: 0.0.56.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-06-28 00:00:00.000000000 Z
11
+ date: 2020-07-14 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.55.pre
33
+ version: 0.0.56.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.55.pre
40
+ version: 0.0.56.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.25.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.25.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