coprl 3.0.0.beta.6 → 3.0.0.beta.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +35 -0
- data/Gemfile.lock +9 -13
- data/coprl.gemspec +0 -1
- data/lib/coprl/presenters/api/app.rb +7 -2
- data/lib/coprl/presenters/dsl/components/base.rb +0 -1
- data/lib/coprl/presenters/dsl/definition.rb +2 -2
- data/lib/coprl/presenters/dsl/user_interface.rb +2 -2
- data/lib/coprl/presenters/helpers/rails/routes.rb +14 -0
- data/lib/coprl/presenters/helpers/rails.rb +8 -6
- data/lib/coprl/presenters/rails/concerns/coprl_partial.rb +51 -0
- data/lib/coprl/presenters/rails/engine.rb +5 -0
- data/lib/coprl/presenters/rails/railtie.rb +6 -14
- data/lib/coprl/presenters/rails/reloader.rb +15 -0
- data/lib/coprl/presenters/version.rb +1 -1
- data/lib/coprl/presenters/web_client/plugin_views_path.rb +5 -5
- data/lib/generators/pom/controller/controller_generator.rb +15 -0
- data/lib/generators/pom/controller/templates/view.html.pom +2 -0
- data/lib/generators/pom/scaffold/scaffold_generator.rb +27 -0
- data/lib/generators/pom/scaffold/templates/_form.html.pom +10 -0
- data/lib/generators/pom/scaffold/templates/edit.html.pom +19 -0
- data/lib/generators/pom/scaffold/templates/index.html.pom +33 -0
- data/lib/generators/pom/scaffold/templates/new.html.pom +17 -0
- data/lib/generators/pom/scaffold/templates/show.html.pom +21 -0
- data/rails-engine/app/controllers/coprl_controller.rb +0 -17
- data/rails-engine/config/initializers/presenters.rb +4 -2
- data/rails-engine/config/initializers/routes.rb +5 -0
- metadata +15 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e31bf11c84ed9cd6321131d9053436c610e5e193124c12503d8fead966b7347
|
4
|
+
data.tar.gz: 9e3f161bf2de8462f6a7234923f9ddb17e38ab31098ead2ea6bdbb59b3102796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0deb84df0f2d9e38dd7e16ae62203c887154c2b6d86c0ee862de96b29aa8ab9018b8893e2e121152395d8bfeb1ae3239bc2b49832fde8008e72eef88e066763e
|
7
|
+
data.tar.gz: ff24bd5e388206523e917bb678276a780f0d17cbba4afb229fe7db6a345f31efb3bffb3d0593770d1f8187202737c789e7ac44d0306f42de8c926e691b15d8c6
|
data/.circleci/config.yml
CHANGED
@@ -7,7 +7,7 @@ jobs:
|
|
7
7
|
build:
|
8
8
|
docker:
|
9
9
|
# specify the version you desire here
|
10
|
-
- image: circleci/ruby:2.7.
|
10
|
+
- image: circleci/ruby:2.7.4-node-browsers
|
11
11
|
|
12
12
|
# Specify service dependencies here if necessary
|
13
13
|
# CircleCI maintains a library of pre-built images
|
@@ -24,6 +24,7 @@ jobs:
|
|
24
24
|
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
|
25
25
|
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
|
26
26
|
- v1-gem-cache-{{ arch }}-
|
27
|
+
- run: gem install bundler:2.2.20
|
27
28
|
- run: bundle install
|
28
29
|
- run: bundle clean --force
|
29
30
|
- save_cache:
|
data/.ruby-version
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.4
|
2
2
|
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1
|
+
# [3.0.0-beta.10](https://github.com/rx/presenters/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-09-21)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* added POM scaffolding generators ([1323b32](https://github.com/rx/presenters/commit/1323b322f83fd9e9519740d9aa7ace4ef8d63b61))
|
7
|
+
|
8
|
+
# [3.0.0-beta.9](https://github.com/rx/presenters/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2021-09-21)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* added support for api base base_url ([8f69979](https://github.com/rx/presenters/commit/8f699793de899a450df5cfb8b95015a832200178))
|
14
|
+
* fixed bug in context prep for api client ([d0558cf](https://github.com/rx/presenters/commit/d0558cf3966a9bdc91bd9d106dcb0a7ab6f56c34))
|
15
|
+
|
16
|
+
# [3.0.0-beta.8](https://github.com/rx/presenters/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-09-17)
|
17
|
+
|
18
|
+
|
19
|
+
### Bug Fixes
|
20
|
+
|
21
|
+
* added check for engine coprl_presenters_rails_engine_url ([d2ee7b5](https://github.com/rx/presenters/commit/d2ee7b5900a256c30e6715d1246639dec682ff08))
|
22
|
+
|
23
|
+
# [3.0.0-beta.7](https://github.com/rx/presenters/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-07-09)
|
24
|
+
|
25
|
+
|
26
|
+
### Bug Fixes
|
27
|
+
|
28
|
+
* Rails routes automatically made available as helpers ([#322](https://github.com/rx/presenters/issues/322)) ([abb0031](https://github.com/rx/presenters/commit/abb00311940fda8741459f8aafe29cd7bf074b88))
|
29
|
+
* view paths issue when using partials with Rails Engine ([#321](https://github.com/rx/presenters/issues/321)) ([2a917e7](https://github.com/rx/presenters/commit/2a917e7076895037e5a069e77525ef53d2ca45f1))
|
30
|
+
|
31
|
+
|
32
|
+
### Features
|
33
|
+
|
34
|
+
* switch to use Rails built-in watchers and reloader ([#320](https://github.com/rx/presenters/issues/320)) ([53e0ee4](https://github.com/rx/presenters/commit/53e0ee49caa663ce93ff731c280bcd754da73fc1))
|
35
|
+
|
1
36
|
# [3.0.0-beta.6](https://github.com/rx/presenters/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-06-23)
|
2
37
|
|
3
38
|
|
data/Gemfile.lock
CHANGED
@@ -80,11 +80,10 @@ GIT
|
|
80
80
|
PATH
|
81
81
|
remote: .
|
82
82
|
specs:
|
83
|
-
coprl (
|
83
|
+
coprl (3.0.0.beta.10)
|
84
84
|
dry-configurable (> 0.1, <= 7.0)
|
85
85
|
dry-container (~> 0.6)
|
86
86
|
dry-inflector (~> 0.1)
|
87
|
-
filewatcher (~> 1.1.1)
|
88
87
|
ice_nine (~> 0.11)
|
89
88
|
redcarpet (~> 3.4)
|
90
89
|
sinatra (>= 1.4, < 3.0)
|
@@ -102,17 +101,15 @@ GEM
|
|
102
101
|
diff-lcs (1.4.4)
|
103
102
|
docile (1.3.1)
|
104
103
|
dotenv (2.7.6)
|
105
|
-
dry-configurable (0.
|
104
|
+
dry-configurable (0.13.0)
|
106
105
|
concurrent-ruby (~> 1.0)
|
107
|
-
dry-core (~> 0.
|
108
|
-
dry-container (0.
|
106
|
+
dry-core (~> 0.6)
|
107
|
+
dry-container (0.9.0)
|
109
108
|
concurrent-ruby (~> 1.0)
|
110
|
-
dry-configurable (~> 0.
|
111
|
-
dry-core (0.
|
109
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
110
|
+
dry-core (0.7.1)
|
112
111
|
concurrent-ruby (~> 1.0)
|
113
|
-
dry-inflector (0.2.
|
114
|
-
filewatcher (1.1.1)
|
115
|
-
optimist (~> 3.0)
|
112
|
+
dry-inflector (0.2.1)
|
116
113
|
ice_nine (0.11.2)
|
117
114
|
json (2.3.1)
|
118
115
|
method_source (0.9.0)
|
@@ -125,7 +122,6 @@ GEM
|
|
125
122
|
racc (~> 1.4)
|
126
123
|
nokogiri (1.11.7-x86_64-darwin)
|
127
124
|
racc (~> 1.4)
|
128
|
-
optimist (3.0.1)
|
129
125
|
pry (0.11.3)
|
130
126
|
coderay (~> 1.1.0)
|
131
127
|
method_source (~> 0.9.0)
|
@@ -163,7 +159,7 @@ GEM
|
|
163
159
|
rspec-support (3.10.2)
|
164
160
|
rspec_junit_formatter (0.4.1)
|
165
161
|
rspec-core (>= 2, < 4, != 2.12.0)
|
166
|
-
ruby2_keywords (0.0.
|
162
|
+
ruby2_keywords (0.0.5)
|
167
163
|
rubyzip (2.3.0)
|
168
164
|
selenium-webdriver (3.142.7)
|
169
165
|
childprocess (>= 0.5, < 4.0)
|
@@ -239,7 +235,7 @@ DEPENDENCIES
|
|
239
235
|
webdrivers (~> 4.1)
|
240
236
|
|
241
237
|
RUBY VERSION
|
242
|
-
ruby 2.7.
|
238
|
+
ruby 2.7.4p191
|
243
239
|
|
244
240
|
BUNDLED WITH
|
245
241
|
2.2.20
|
data/coprl.gemspec
CHANGED
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_runtime_dependency 'tzinfo', '>=1.1', '< 3.0'
|
29
29
|
spec.add_runtime_dependency 'tzinfo-data', '~>1.2018'
|
30
30
|
spec.add_runtime_dependency 'redcarpet', '~>3.4'
|
31
|
-
spec.add_runtime_dependency 'filewatcher', '~> 1.1.1'
|
32
31
|
spec.add_runtime_dependency 'zeitwerk', '~> 2.1'
|
33
32
|
|
34
33
|
spec.add_development_dependency 'thor', '~> 1.1.0'
|
@@ -66,9 +66,9 @@ module Coprl
|
|
66
66
|
|
67
67
|
def prepare_context(base_params = params)
|
68
68
|
prepare_context = Presenters::Settings.config.presenters.web_client.prepare_context.dup
|
69
|
-
prepare_context.push(method(:scrub_context))
|
69
|
+
prepare_context.push(method(:scrub_context)).push(method(:base_url_context))
|
70
70
|
context = base_params.dup
|
71
|
-
prepare_context.reduce(context) do |params, context_proc|
|
71
|
+
context = prepare_context.reduce(context) do |params, context_proc|
|
72
72
|
context_proc.call(params, session, env)
|
73
73
|
end
|
74
74
|
context
|
@@ -80,6 +80,11 @@ module Coprl
|
|
80
80
|
end
|
81
81
|
params
|
82
82
|
end
|
83
|
+
|
84
|
+
def base_url_context(params, _session, env)
|
85
|
+
params[:base_url] = "#{request.base_url}#{env['SCRIPT_NAME']}"
|
86
|
+
params
|
87
|
+
end
|
83
88
|
end
|
84
89
|
end
|
85
90
|
end
|
@@ -17,8 +17,8 @@ module Coprl
|
|
17
17
|
self
|
18
18
|
end
|
19
19
|
|
20
|
-
def expand(router: , context:{}, &block)
|
21
|
-
presenter = UserInterface.new(router: router, context: context,
|
20
|
+
def expand(router: , context:{}, plugins: [], &block)
|
21
|
+
presenter = UserInterface.new(router: router, context: context, plugins: plugins, name: @name, namespace: @namespace, &@block)
|
22
22
|
yield(presenter) if block
|
23
23
|
presenter.expand_instance
|
24
24
|
end
|
@@ -25,7 +25,7 @@ module Coprl
|
|
25
25
|
private :context, :router, :namespace
|
26
26
|
alias params context
|
27
27
|
|
28
|
-
def initialize(context:, parent: nil, router: nil, name: nil, namespace: [], &block)
|
28
|
+
def initialize(context:, parent: nil, router: nil, name: nil, plugins: [], namespace: [], &block)
|
29
29
|
@parent = parent
|
30
30
|
@router = router || @parent&.send(:router)
|
31
31
|
@context = context || {}
|
@@ -36,7 +36,7 @@ module Coprl
|
|
36
36
|
@footer = nil
|
37
37
|
@name = name
|
38
38
|
@namespace = namespace
|
39
|
-
@plugins = []
|
39
|
+
@plugins = plugins || []
|
40
40
|
@csrf_meta_tags = authenticity_token_meta_tags(@context.fetch(:session, nil))
|
41
41
|
add_global_helpers
|
42
42
|
initialize_plugins
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Coprl
|
2
|
+
module Presenters
|
3
|
+
module Helpers
|
4
|
+
module Rails
|
5
|
+
module Routes
|
6
|
+
include ::Rails.application.routes.url_helpers
|
7
|
+
def default_url_options
|
8
|
+
::Rails.application.config.action_controller.default_url_options || { :host => context[:base_url] ? context[:base_url] : context[:request].host_with_port }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -6,18 +6,20 @@ if defined?(Rails)
|
|
6
6
|
include ActionView::Helpers::AssetUrlHelper
|
7
7
|
include Coprl::Presenters::Helpers::Rails::Currency
|
8
8
|
include Coprl::Presenters::Helpers::Rails::ModelTable
|
9
|
+
include Coprl::Presenters::Helpers::Rails::Routes
|
9
10
|
include Namespace
|
10
11
|
|
11
|
-
def default_url_options
|
12
|
-
{}
|
13
|
-
end
|
14
|
-
|
15
12
|
def presenters_path(presenter, host: false, **params)
|
16
13
|
presenter = _expand_namespace_(presenter, namespace)
|
17
14
|
presenter = presenter.gsub(':', '/')
|
18
15
|
|
19
|
-
path =
|
20
|
-
|
16
|
+
path = if defined?(coprl_presenters_rails_engine_url)
|
17
|
+
host ? coprl_presenters_rails_engine_url(params, host: router.base_url) :
|
18
|
+
coprl_presenters_rails_engine_path(params)
|
19
|
+
else
|
20
|
+
host ? coprl_presenters_web_client_app_url(params, host: router.base_url) :
|
21
|
+
coprl_presenters_web_client_app_path(params)
|
22
|
+
end
|
21
23
|
|
22
24
|
if path.include?('?')
|
23
25
|
path = path.sub('?', "#{presenter}?")
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Coprl
|
2
|
+
module Presenters
|
3
|
+
module Rails
|
4
|
+
module Concerns
|
5
|
+
module CoprlPartial
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
before_action :set_view_path
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
@plugins = []
|
14
|
+
def presenter_plugin(*plugins)
|
15
|
+
@plugins += Array(plugins)
|
16
|
+
end
|
17
|
+
|
18
|
+
def plugins
|
19
|
+
@plugins
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_view_path
|
24
|
+
paths = Coprl::Presenters::WebClient::PluginViewsPath.new(pom: nil, plugins: self.class.plugins).render
|
25
|
+
paths.each do |path|
|
26
|
+
prepend_view_path path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepare_context(base_params = params)
|
31
|
+
prepare_context = Coprl::Presenters::Settings.config.presenters.web_client.prepare_context.dup
|
32
|
+
prepare_context.push(method(:scrub_context))
|
33
|
+
context = base_params.dup.to_unsafe_hash
|
34
|
+
prepare_context.reduce(context) do |params, context_proc|
|
35
|
+
context = context_proc.call(params, session, request.env)
|
36
|
+
end
|
37
|
+
context
|
38
|
+
end
|
39
|
+
|
40
|
+
def scrub_context(params, _session, _env)
|
41
|
+
%i(grid_nesting input_tag).each do |key|
|
42
|
+
params.delete(key) {params.delete(key.to_s)}
|
43
|
+
end
|
44
|
+
params
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -12,6 +12,11 @@ module Coprl
|
|
12
12
|
# TODO: should rename these since they are common names that are likely going to collide
|
13
13
|
app.middleware.use ::ActionDispatch::Static, File.join(root, '..', 'public')
|
14
14
|
end
|
15
|
+
|
16
|
+
ActiveSupport.on_load(:action_controller) do
|
17
|
+
include Concerns::CoprlPartial
|
18
|
+
end
|
19
|
+
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'filewatcher'
|
2
|
-
|
3
1
|
module Coprl
|
4
2
|
module Presenters
|
5
3
|
module Rails
|
@@ -15,20 +13,14 @@ module Coprl
|
|
15
13
|
|
16
14
|
WATCH = -> {
|
17
15
|
return unless ::Rails.env.development?
|
16
|
+
|
18
17
|
path = ::Rails.root.join('app', '**', '*.pom')
|
19
|
-
|
20
|
-
|
21
|
-
Thread.new(filewatcher) do |fw|
|
22
|
-
fw.watch do |f|
|
23
|
-
puts "Detected updated POM file: #{f}"
|
24
|
-
begin
|
25
|
-
BOOT.call
|
26
|
-
rescue Exception => exc
|
27
|
-
puts exc.backtrace
|
28
|
-
puts exc.message
|
29
|
-
end
|
30
|
-
end
|
18
|
+
file_watcher = ActiveSupport::FileUpdateChecker.new(Dir[path]) do
|
19
|
+
BOOT.call
|
31
20
|
end
|
21
|
+
|
22
|
+
::Rails.application.reloaders << Reloader.new(file_watcher)
|
23
|
+
|
32
24
|
} unless defined?(WATCH)
|
33
25
|
|
34
26
|
config.after_initialize do
|
@@ -8,17 +8,17 @@ module Coprl
|
|
8
8
|
extend Pluggable
|
9
9
|
include_plugins(:WebClientComponents)
|
10
10
|
|
11
|
-
def initialize(pom:)
|
11
|
+
def initialize(pom: nil, plugins: nil)
|
12
12
|
@pom = pom
|
13
|
+
@plugins = plugins || []
|
13
14
|
initialize_plugins
|
14
15
|
end
|
15
16
|
|
16
17
|
def render
|
17
18
|
results = []
|
18
|
-
(
|
19
|
+
(@plugins + Coprl::Presenters::Settings.config.presenters.plugins).each do |plugin|
|
19
20
|
view_dir_method = :"view_dir_#{plugin}"
|
20
|
-
results << send(view_dir_method,
|
21
|
-
@pom) if respond_to?(view_dir_method)
|
21
|
+
results << send(view_dir_method, @pom) if respond_to?(view_dir_method)
|
22
22
|
end
|
23
23
|
results
|
24
24
|
end
|
@@ -26,7 +26,7 @@ module Coprl
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def initialize_plugins
|
29
|
-
@plugins
|
29
|
+
@plugins += @pom.send(:plugins) if @pom
|
30
30
|
self.class.include_plugins(:WebClientComponents, plugins: @plugins)
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/erb/controller/controller_generator'
|
2
|
+
|
3
|
+
module Pom
|
4
|
+
module Generators
|
5
|
+
class ControllerGenerator < Erb::Generators::ControllerGenerator
|
6
|
+
source_root File.expand_path(File.join('..', 'templates'), __FILE__)
|
7
|
+
|
8
|
+
protected
|
9
|
+
def handler
|
10
|
+
:pom
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rails/generators/erb/scaffold/scaffold_generator'
|
2
|
+
|
3
|
+
module Pom
|
4
|
+
module Generators
|
5
|
+
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
6
|
+
source_root File.expand_path(File.join('..', 'templates'), __FILE__)
|
7
|
+
|
8
|
+
def copy_view_files
|
9
|
+
available_views.each do |view|
|
10
|
+
filename = filename_with_extensions view
|
11
|
+
template "#{view}.html.pom", File.join('app', 'views', controller_file_path, filename)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
hook_for :form_builder, as: :scaffold
|
16
|
+
|
17
|
+
protected
|
18
|
+
def available_views
|
19
|
+
['index', 'edit', 'show', 'new', '_form']
|
20
|
+
end
|
21
|
+
|
22
|
+
def handler
|
23
|
+
:pom
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Coprl::Presenters.define("_form", namespace: :<%= plural_table_name %>) do
|
2
|
+
helpers <%= controller_class_name %>Helper
|
3
|
+
|
4
|
+
<% attributes.each do |attribute| -%>
|
5
|
+
text_field name: :<%= attribute.name %> do
|
6
|
+
label :<%= attribute.name %>
|
7
|
+
value <%= singular_table_name %>.<%= attribute.name %> if params[:<%= singular_table_name %>_id]
|
8
|
+
end
|
9
|
+
<% end -%>
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Coprl::Presenters.define(:edit, namespace: :<%= plural_table_name %>) do
|
2
|
+
helpers <%= controller_class_name %>Helper
|
3
|
+
grid do
|
4
|
+
column 1
|
5
|
+
column 5 do
|
6
|
+
heading 'Editing <%= human_name %>'
|
7
|
+
content do
|
8
|
+
attach '_form'
|
9
|
+
button 'Update' do
|
10
|
+
event :click do
|
11
|
+
updates <%= url_helper_prefix %>_path(<%= singular_table_name %>)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
link 'Show', presenter_path(:show, <%= singular_table_name %>_id: <%= singular_table_name %>.id)
|
16
|
+
link 'Back', presenter_path(:index)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Coprl::Presenters.define(:index, namespace: :<%= plural_table_name %>) do
|
2
|
+
helpers <%= controller_class_name %>Helper
|
3
|
+
snackbar params[:notice] if params[:notice]
|
4
|
+
grid do
|
5
|
+
column 1
|
6
|
+
column 5 do
|
7
|
+
heading '<%= human_name %>'
|
8
|
+
list do
|
9
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
10
|
+
line <%= attributes.first ? "#{singular_table_name}.#{attributes.first.name}" : "\"#{human_name}\"" %> do
|
11
|
+
actions do
|
12
|
+
icon :edit do
|
13
|
+
event :click do
|
14
|
+
loads :edit, <%= singular_table_name %>_id: <%= singular_table_name %>.id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
icon :delete do
|
18
|
+
event :click do
|
19
|
+
dialog "are_you_sure#{<%= singular_table_name %>.id}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
event :click do
|
24
|
+
loads :show, <%= singular_table_name %>_id: <%= singular_table_name %>.id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
link 'New <%= human_name %>', presenter_path(:new)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
confirm_delete_dialog
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Coprl::Presenters.define(:new, namespace: :<%= plural_table_name %>) do
|
2
|
+
grid do
|
3
|
+
column 1
|
4
|
+
column 5 do
|
5
|
+
heading 'New <%= human_name %>'
|
6
|
+
content do
|
7
|
+
attach '_form'
|
8
|
+
button 'Create' do
|
9
|
+
event :click do
|
10
|
+
creates <%= index_helper %>_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
link 'Back', presenter_path(:index)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Coprl::Presenters.define(:show, namespace: :<%= plural_table_name %>) do
|
2
|
+
helpers <%= controller_class_name %>Helper
|
3
|
+
|
4
|
+
snackbar params[:notice] if params[:notice]
|
5
|
+
grid do
|
6
|
+
column 1
|
7
|
+
column 5 do
|
8
|
+
card do
|
9
|
+
<% attributes.each_with_index do |attribute,index| -%>
|
10
|
+
<% if index == 0 -%>
|
11
|
+
heading <%= singular_table_name %>.<%= attribute.name %>
|
12
|
+
<% else -%>
|
13
|
+
body <%= singular_table_name %>.<%= attribute.name %>
|
14
|
+
<% end -%>
|
15
|
+
<% end -%>
|
16
|
+
end
|
17
|
+
link 'Edit', presenter_path(:edit,<%= singular_table_name %>_id: params[:<%= singular_table_name %>_id])
|
18
|
+
link 'Back', presenter_path(:index)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -23,21 +23,4 @@ class CoprlController < ApplicationController
|
|
23
23
|
prepend_view_path path
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
def prepare_context(base_params = params)
|
28
|
-
prepare_context = Coprl::Presenters::Settings.config.presenters.web_client.prepare_context.dup
|
29
|
-
prepare_context.push(method(:scrub_context))
|
30
|
-
context = base_params.dup.to_unsafe_hash
|
31
|
-
prepare_context.reduce(context) do |params, context_proc|
|
32
|
-
context = context_proc.call(params, session, request.env)
|
33
|
-
end
|
34
|
-
context
|
35
|
-
end
|
36
|
-
|
37
|
-
def scrub_context(params, _session, _env)
|
38
|
-
%i(grid_nesting input_tag).each do |key|
|
39
|
-
params.delete(key) {params.delete(key.to_s)}
|
40
|
-
end
|
41
|
-
params
|
42
|
-
end
|
43
26
|
end
|
@@ -28,9 +28,11 @@ class CoprlTemplateHandler
|
|
28
28
|
# otherwise we need to get the presenter name built from params
|
29
29
|
presenter_name = local_assigns[:presenter] ? presenter : namespaced_presenter(params)
|
30
30
|
presenter = Coprl::Presenters::App[presenter_name].call
|
31
|
-
context =
|
31
|
+
context = self.controller.prepare_context(params)
|
32
32
|
router = Coprl::Presenters::WebClient::Router.new(base_url: request.base_url)
|
33
|
-
|
33
|
+
plugins = self.controller.class.plugins
|
34
|
+
|
35
|
+
@pom = presenter.expand(router: router, context: context, plugins: plugins)
|
34
36
|
end
|
35
37
|
#{source}
|
36
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coprl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Edens
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ice_nine
|
@@ -140,20 +140,6 @@ dependencies:
|
|
140
140
|
- - "~>"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '3.4'
|
143
|
-
- !ruby/object:Gem::Dependency
|
144
|
-
name: filewatcher
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
146
|
-
requirements:
|
147
|
-
- - "~>"
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 1.1.1
|
150
|
-
type: :runtime
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
requirements:
|
154
|
-
- - "~>"
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
version: 1.1.1
|
157
143
|
- !ruby/object:Gem::Dependency
|
158
144
|
name: zeitwerk
|
159
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -597,14 +583,17 @@ files:
|
|
597
583
|
- lib/coprl/presenters/helpers/rails.rb
|
598
584
|
- lib/coprl/presenters/helpers/rails/currency.rb
|
599
585
|
- lib/coprl/presenters/helpers/rails/model_table.rb
|
586
|
+
- lib/coprl/presenters/helpers/rails/routes.rb
|
600
587
|
- lib/coprl/presenters/helpers/redact.rb
|
601
588
|
- lib/coprl/presenters/helpers/route.rb
|
602
589
|
- lib/coprl/presenters/helpers/time.rb
|
603
590
|
- lib/coprl/presenters/namespace.rb
|
604
591
|
- lib/coprl/presenters/pluggable.rb
|
605
592
|
- lib/coprl/presenters/plugins.rb
|
593
|
+
- lib/coprl/presenters/rails/concerns/coprl_partial.rb
|
606
594
|
- lib/coprl/presenters/rails/engine.rb
|
607
595
|
- lib/coprl/presenters/rails/railtie.rb
|
596
|
+
- lib/coprl/presenters/rails/reloader.rb
|
608
597
|
- lib/coprl/presenters/registry.rb
|
609
598
|
- lib/coprl/presenters/router.rb
|
610
599
|
- lib/coprl/presenters/settings.rb
|
@@ -653,6 +642,14 @@ files:
|
|
653
642
|
- lib/coprl/serializer.rb
|
654
643
|
- lib/coprl/symbol/to_str.rb
|
655
644
|
- lib/coprl/trace.rb
|
645
|
+
- lib/generators/pom/controller/controller_generator.rb
|
646
|
+
- lib/generators/pom/controller/templates/view.html.pom
|
647
|
+
- lib/generators/pom/scaffold/scaffold_generator.rb
|
648
|
+
- lib/generators/pom/scaffold/templates/_form.html.pom
|
649
|
+
- lib/generators/pom/scaffold/templates/edit.html.pom
|
650
|
+
- lib/generators/pom/scaffold/templates/index.html.pom
|
651
|
+
- lib/generators/pom/scaffold/templates/new.html.pom
|
652
|
+
- lib/generators/pom/scaffold/templates/show.html.pom
|
656
653
|
- lib/hash_ext/traverse.rb
|
657
654
|
- public/bundle.css
|
658
655
|
- public/bundle.js
|
@@ -685,6 +682,7 @@ files:
|
|
685
682
|
- rails-engine/app/views/layouts/coprl.html.erb
|
686
683
|
- rails-engine/config.ru
|
687
684
|
- rails-engine/config/initializers/presenters.rb
|
685
|
+
- rails-engine/config/initializers/routes.rb
|
688
686
|
- rails-engine/config/initializers/session.rb
|
689
687
|
- rails-engine/config/routes.rb
|
690
688
|
- scripts/build.sh
|
@@ -949,7 +947,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
949
947
|
- !ruby/object:Gem::Version
|
950
948
|
version: 1.3.1
|
951
949
|
requirements: []
|
952
|
-
rubygems_version: 3.1.
|
950
|
+
rubygems_version: 3.1.6
|
953
951
|
signing_key:
|
954
952
|
specification_version: 4
|
955
953
|
summary: COmmon PResenter Language - A Ruby gem for joyfully writing modern user interfaces
|