cmor_core_backend 0.0.54.pre → 0.0.59.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: c4a4209700fe91102f7ed1d49dd833fdcec99b3634a37d8877183a2d0c51d657
4
- data.tar.gz: 1e5fdcc11aa292999479a57b3422d06f8e10ef09ab932fbaa03943186939323b
3
+ metadata.gz: 925e3d7bda5476d85081338125e0b78da7b8f573b8306c52c376fb035ba0193b
4
+ data.tar.gz: '083e3e7dbcca0a2eebab31930c1ef88687d108e22e81dd6dca581478a2668f2c'
5
5
  SHA512:
6
- metadata.gz: 2ce678f1b70de03a2d6554efeda7200a7413a1422cfca6c696e7074e23b00d22df9b7890314dee768754450aa12ffa419f3a585684db066c3bed42f18c356b11
7
- data.tar.gz: ef49da05856a99bdff97f78e6cd31be2f55e5b4630e9044450cdeb5985904299910879521048cc808a6911a769f145de642cf636b819d04eb108c264586bc43c
6
+ metadata.gz: 94522c8c5064cc109f42b744f0af791acdf506918be919a9feaf75b5c4936d94f569741223f3e6e58fda7fab16084746b331e07bec23011d79da044c9aecb5a2
7
+ data.tar.gz: 41c27deb1dbbcb3ca386620fe95669e5b8d08a82285056665bf67febdf6d23097d61bab92309853d9cd5cbacf1802decd3bdd98e9dbc19dc8b74066476a544d2
@@ -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) && 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.54.pre
4
+ version: 0.0.59.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-05-20 00:00:00.000000000 Z
11
+ date: 2020-08-18 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.54.pre
33
+ version: 0.0.59.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.54.pre
40
+ version: 0.0.59.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.3
423
+ rubygems_version: 3.1.4
421
424
  signing_key:
422
425
  specification_version: 4
423
426
  summary: Cmor Core Module.