dynamic_scaffold 0.1.4 → 0.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
  SHA256:
3
- metadata.gz: d48485314bb42e9b6356dd8f066b11240da9f4ee6bf49896184f4bf74445ba70
4
- data.tar.gz: ec9b824bee1d0a4843800896ce10ec995a501718f6acdc7c00d61114576eb784
3
+ metadata.gz: 4df99a86cf96d23a10ad4baf8d9a0ddcf7b77151f6a7ffd267a893db393731da
4
+ data.tar.gz: 505ba47d9f0fb48248e41836a5920015aaaf62c8fc2190df5db384d1ea1c61dd
5
5
  SHA512:
6
- metadata.gz: d658ffcdf4f6c1f9329d4c84d59ed3805cdbfa7c2ffcd363990b647c7092db730b6b141b1b24a3097d40553abe0917563175713fbc00e714cde65debaa53e123
7
- data.tar.gz: 03ba4213bd03bd27914032fd74b2d56124956e01e24b035a556a2795ec48663a6e537c7fd21d2a71cd970e40fe8f593b2d786de926d1b45cc54e411543645aa7
6
+ metadata.gz: d44a8b591d80bd49958fc1e54d1a0caf4e97d0edb62ff73233e4dcaceda200f89d960e7a058788acfa58a65858b2734e2e89594bf4a1671ff6927926928cc49f
7
+ data.tar.gz: d85b5dcbf9c5a49e602b2d972b6a47ec49cd79aede4ff7e357e48f27daff14f61f14fcab11f8a21925eb7e2ba6fa694f6032d7523906a8a0859ac507c58c0ea6
data/README.md CHANGED
@@ -79,6 +79,39 @@ rails generate dynamic_scaffold namespace/plural_model
79
79
  rails generate dynamic_scaffold namespace/controller Model
80
80
  ```
81
81
 
82
+ #### Options
83
+
84
+ ##### content_for
85
+
86
+ Enclose the `render` of view in `content_for`.
87
+
88
+ ```
89
+ rails generate dynamic_scaffold admin/shops --content_for admin_body
90
+ ```
91
+
92
+ ```erb
93
+ # views/admin/shops/edit.html.erb
94
+ <% content_for :admin_body do%>
95
+ <%= render 'dynamic_scaffold/bootstrap/edit' %>
96
+ <%end%>
97
+ ```
98
+
99
+ ##### controller_base
100
+
101
+ Change the base class of controller.
102
+
103
+ ```
104
+ rails generate dynamic_scaffold admin/shops --controller_base Admin::BaseController
105
+ ```
106
+
107
+ ```erb
108
+ # controllers/admin/shops_controller.rb
109
+ class Admin::ShopsController < Admin::BaseController
110
+ include DynamicScaffold::Controller
111
+ dynamic_scaffold Shop do |config|
112
+ ```
113
+
114
+
82
115
  ### Prepare CSS and Javascript
83
116
 
84
117
  You need to load the files for CSS and Javascript. Currently, we support the Bootstrap 3 and Bootstrap 4.
@@ -1,8 +1,11 @@
1
1
  @import 'common';
2
2
  @import 'resplist';
3
3
 
4
+ $dynamic_scaffold_primary: #337ab7 !default;
5
+ $dynamic_scaffold_default: #868e96 !default;
6
+
4
7
  .btn-default path{
5
- fill: #333;
8
+ fill: $dynamic_scaffold_default;
6
9
  }
7
10
 
8
11
  .btn-primary path{
@@ -14,7 +17,7 @@
14
17
  }
15
18
 
16
19
  .page-item .page-link path{
17
- fill: #337ab7;
20
+ fill: $dynamic_scaffold_primary;
18
21
  }
19
22
 
20
23
  .page-item.disabled .page-link path{
@@ -1,8 +1,16 @@
1
1
  @import 'common';
2
2
  @import 'resplist';
3
3
 
4
+ $dynamic_scaffold_primary: #007bff !default;
5
+ $dynamic_scaffold_secondary: #868e96 !default;
6
+ $dynamic_scaffold_warning: #ffc107 !default;
7
+
8
+ .btn-outline-primary, .btn-outline-secondary, .btn-outline-warning{
9
+ background-color: #fff;
10
+ }
11
+
4
12
  .btn-outline-primary path{
5
- fill: #007bff;
13
+ fill: $dynamic_scaffold_primary;
6
14
  }
7
15
 
8
16
  .btn-outline-primary:hover path {
@@ -10,7 +18,7 @@
10
18
  }
11
19
 
12
20
  .btn-outline-secondary path{
13
- fill: #868e96;
21
+ fill: $dynamic_scaffold_secondary;
14
22
  }
15
23
 
16
24
  .btn-outline-secondary:hover path{
@@ -18,17 +26,21 @@
18
26
  }
19
27
 
20
28
  .btn-outline-warning path{
21
- fill: #ffc107;
29
+ fill: $dynamic_scaffold_warning;
22
30
  }
23
31
 
24
- .btn-outline-warning:hover path{
25
- fill: #fff;
32
+ .btn-outline-warning:hover{
33
+ path{
34
+ fill: #fff;
35
+ }
36
+
37
+ color: #fff;
26
38
  }
27
39
 
28
40
  .page-item .page-link path{
29
- fill: #007bff;
41
+ fill: $dynamic_scaffold_primary;
30
42
  }
31
43
 
32
44
  .page-item.disabled .page-link path{
33
- fill: #868e96;
45
+ fill: $dynamic_scaffold_secondary;
34
46
  }
@@ -1,3 +1,3 @@
1
1
  module DynamicScaffold
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -3,6 +3,8 @@ class DynamicScaffoldGenerator < Rails::Generators::Base
3
3
 
4
4
  argument :path, type: 'string', required: true
5
5
  argument :model, type: 'string', required: false
6
+ class_option :content_for, type: :string
7
+ class_option :controller_base, type: :string, default: 'ApplicationController'
6
8
 
7
9
  def init
8
10
  @namespases = path.split('/')
@@ -11,6 +13,8 @@ class DynamicScaffoldGenerator < Rails::Generators::Base
11
13
  @model_name = model ? model : @plural_model_name.singularize
12
14
  @model_name = @model_name.camelize
13
15
  @model = @model_name.constantize
16
+ @content_for = options['content_for']
17
+ @controller_base = options['controller_base']
14
18
  end
15
19
 
16
20
  def create_controllers
@@ -1,4 +1,4 @@
1
- class <%= @class_scope.present? ? "#{@class_scope}::" : '' %><%= @plural_model_name %>Controller < ApplicationController
1
+ class <%= @class_scope.present? ? "#{@class_scope}::" : '' %><%= @plural_model_name %>Controller < <%= @controller_base %>
2
2
  include DynamicScaffold::Controller
3
3
  dynamic_scaffold <%= @model_name %> do |config|
4
4
  # If you want to use all views common variables, please call `vars`.
@@ -1 +1,4 @@
1
- <%%= render 'dynamic_scaffold/bootstrap/edit' %>
1
+ <% if @content_for %><%% content_for :<%= @content_for %> do%>
2
+ <%end -%>
3
+ <% if @content_for %> <%end%><%%= render 'dynamic_scaffold/bootstrap/edit' %>
4
+ <% if @content_for %><%% end %><%end -%>
@@ -1 +1,4 @@
1
- <%%= render 'dynamic_scaffold/bootstrap/list' %>
1
+ <% if @content_for %><%% content_for :<%= @content_for %> do%>
2
+ <%end -%>
3
+ <% if @content_for %> <%end%><%%= render 'dynamic_scaffold/bootstrap/list' %>
4
+ <% if @content_for %><%% end %><%end -%>
@@ -1 +1,4 @@
1
- <%%= render 'dynamic_scaffold/bootstrap/new' %>
1
+ <% if @content_for %><%% content_for :<%= @content_for %> do%>
2
+ <%end -%>
3
+ <% if @content_for %> <%end%><%%= render 'dynamic_scaffold/bootstrap/new' %>
4
+ <% if @content_for %><%% end %><%end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masamoto Miyata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: classnames-rails-view