scaffold_pico 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -47
- data/lib/scaffold/cli.rb +16 -4
- data/lib/scaffold/erb_context.rb +11 -0
- data/lib/scaffold/generators/base_generator.rb +74 -0
- data/lib/scaffold/generators/controller_generator.rb +27 -0
- data/lib/scaffold/generators/fabricator_generator.rb +26 -0
- data/lib/scaffold/generators/locales_generator.rb +42 -0
- data/lib/scaffold/generators/models_generator.rb +53 -0
- data/lib/scaffold/generators/routes_generator.rb +48 -0
- data/lib/scaffold/generators/views_generator.rb +57 -0
- data/lib/scaffold/main.rb +15 -6
- data/lib/scaffold/models/resource.rb +66 -0
- data/lib/scaffold/rails.rb +54 -0
- data/lib/scaffold/services/controller.rb +112 -0
- data/lib/scaffold/services/nested_in_resources.rb +42 -0
- data/lib/scaffold/services/path.rb +72 -0
- data/lib/scaffold/services/resource.rb +73 -0
- data/lib/scaffold/services/route.rb +20 -0
- data/lib/scaffold/services/view.rb +14 -0
- data/lib/scaffold_pico.rb +6 -7
- data/lib/templates/pico/controller.rb.erb +34 -26
- data/lib/templates/pico/fabricators/fabrication.rb.erb +4 -4
- data/lib/templates/pico/locales/bg.scaffold_pico.yml.erb +35 -0
- data/lib/templates/pico/locales/en.scaffold_pico.yml.erb +35 -0
- data/lib/templates/pico/model.rb.erb +2 -2
- data/lib/templates/pico/search.rb.erb +12 -12
- data/lib/templates/pico/views/materialize/slim/_form.html.slim.erb +1 -4
- data/lib/templates/pico/views/materialize/slim/edit.html.slim.erb +9 -7
- data/lib/templates/pico/views/materialize/slim/index.html.slim.erb +15 -15
- data/lib/templates/pico/views/materialize/slim/new.html.slim.erb +7 -5
- data/lib/templates/pico/views/materialize/slim/show.html.slim.erb +10 -10
- data/lib/templates/pico/views/zurb/slim/_form.html.slim.erb +2 -5
- data/lib/templates/pico/views/zurb/slim/edit.html.slim.erb +8 -6
- data/lib/templates/pico/views/zurb/slim/index.html.slim.erb +14 -14
- data/lib/templates/pico/views/zurb/slim/new.html.slim.erb +6 -4
- data/lib/templates/pico/views/zurb/slim/show.html.slim.erb +7 -7
- metadata +22 -10
- data/lib/scaffold/base_generator.rb +0 -60
- data/lib/scaffold/controller_generator.rb +0 -24
- data/lib/scaffold/fabricator_generator.rb +0 -25
- data/lib/scaffold/models_generator.rb +0 -51
- data/lib/scaffold/params.rb +0 -174
- data/lib/scaffold/routes_generator.rb +0 -29
- data/lib/scaffold/views_generator.rb +0 -52
@@ -0,0 +1,20 @@
|
|
1
|
+
module Scaffold
|
2
|
+
module Services
|
3
|
+
class Route
|
4
|
+
def initialize rails
|
5
|
+
@rails = rails
|
6
|
+
end
|
7
|
+
|
8
|
+
# resources :company_ownerships
|
9
|
+
def resource_name
|
10
|
+
@rails.resource.collection_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def nested?
|
14
|
+
@rails.nested_in_resources.present?
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/scaffold_pico.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'active_support/inflector'
|
2
2
|
require 'active_support/core_ext/object/blank'
|
3
3
|
require 'ostruct'
|
4
|
+
|
5
|
+
require 'scaffold/rails'
|
4
6
|
require 'scaffold/main'
|
5
|
-
require 'scaffold/
|
6
|
-
|
7
|
-
require 'scaffold/
|
8
|
-
|
9
|
-
require 'scaffold/views_generator'
|
10
|
-
require 'scaffold/routes_generator'
|
11
|
-
require 'scaffold/fabricator_generator'
|
7
|
+
require 'scaffold/erb_context' # I hate this erb
|
8
|
+
|
9
|
+
require 'scaffold/models/resource.rb'
|
10
|
+
|
12
11
|
require 'scaffold/template_engines/slim'
|
13
12
|
require 'erb'
|
14
13
|
require 'fileutils'
|
@@ -1,37 +1,45 @@
|
|
1
|
-
class <%= @
|
1
|
+
class <%= @rails.controller.class_name %> < <%= @rails.controller.base_controller %>
|
2
|
+
|
3
|
+
<% @rails.nested_in_resources.each do |resource| -%>
|
4
|
+
def <%= resource.name %>
|
5
|
+
<%= resource.instance_name %> ||= <%= resource.class_name_with_modules %>.find(params[:<%= resource.param_name %>])
|
6
|
+
end
|
7
|
+
helper_method :<%= resource.name %>
|
8
|
+
|
9
|
+
<% end %>
|
2
10
|
|
3
11
|
def index
|
4
|
-
<%= "@#{@collection_name}_search = #{@
|
12
|
+
<%= "@#{@rails.resource.collection_name}_search = #{@rails.resource.search_class_name}.new(search_#{@rails.resource.collection_name}_params)" %>
|
5
13
|
<%=
|
6
|
-
active_record = ["@#{@collection_name}_search"]
|
14
|
+
active_record = ["@#{@rails.resource.collection_name}_search"]
|
7
15
|
active_record << [ "results" ]
|
8
|
-
active_record << [ "includes(#{@
|
9
|
-
active_record << [ "joins(#{@
|
16
|
+
active_record << [ "includes(#{@rails.controller.index_includes.lazy.map(&:strip).map{|v| v.gsub(',', '')}.to_a.join(', ')})" ] if @rails.controller.index_includes and !@rails.controller.index_includes.empty?
|
17
|
+
active_record << [ "joins(#{@rails.controller.index_joins.join(', ')})" ] if @rails.controller.index_joins and !@rails.controller.index_joins.empty?
|
10
18
|
active_record << [ "page(params[:page])", "per(params[:per])" ]
|
11
19
|
active_record << [ "all" ]
|
12
|
-
"@#{@collection_name} = #{active_record.join('.')}"
|
20
|
+
"@#{@rails.resource.collection_name} = #{active_record.join('.')}"
|
13
21
|
%>
|
14
22
|
end
|
15
23
|
|
16
24
|
def show
|
17
|
-
@<%= @
|
25
|
+
@<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
|
18
26
|
end
|
19
27
|
|
20
28
|
def new
|
21
|
-
@<%= @
|
29
|
+
@<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.new
|
22
30
|
end
|
23
31
|
|
24
32
|
def edit
|
25
|
-
@<%= @
|
33
|
+
@<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
|
26
34
|
end
|
27
35
|
|
28
36
|
def create
|
29
|
-
@<%= @
|
37
|
+
@<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.new(<%= @rails.resource.collection_name %>_params)
|
30
38
|
|
31
39
|
respond_to do |format|
|
32
|
-
if @<%= @
|
33
|
-
<%= "message = t('create', scope: [:scaffold, :notices, :success], model: #{@
|
34
|
-
format.html { redirect_to <%= @
|
40
|
+
if @<%= @rails.resource.name %>.save
|
41
|
+
<%= "message = t('create', scope: [:scaffold, :notices, :success], model: #{@rails.resource.class_name}.model_name.human.mb_chars.downcase)" %>
|
42
|
+
format.html { redirect_to <%= @rails.path.collection %>, notice: message }
|
35
43
|
else
|
36
44
|
format.html { render :new }
|
37
45
|
end
|
@@ -39,11 +47,11 @@ class <%= @controller_class_name %> < <%= @base_controller %>
|
|
39
47
|
end
|
40
48
|
|
41
49
|
def update
|
42
|
-
@<%= @
|
50
|
+
@<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
|
43
51
|
respond_to do |format|
|
44
|
-
if @<%= @
|
45
|
-
<%= "message = t('update', scope: [:scaffold, :notices, :success], model: #{@
|
46
|
-
format.html { redirect_to <%= @
|
52
|
+
if @<%= @rails.resource.name %>.update(<%= @rails.resource.collection_name %>_params)
|
53
|
+
<%= "message = t('update', scope: [:scaffold, :notices, :success], model: #{@rails.resource.class_name}.model_name.human.mb_chars.downcase)" %>
|
54
|
+
format.html { redirect_to <%= @rails.path.collection %>, notice: message }
|
47
55
|
else
|
48
56
|
format.html { render :edit }
|
49
57
|
end
|
@@ -51,22 +59,22 @@ class <%= @controller_class_name %> < <%= @base_controller %>
|
|
51
59
|
end
|
52
60
|
|
53
61
|
def destroy
|
54
|
-
@<%= @
|
55
|
-
@<%= @
|
62
|
+
@<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
|
63
|
+
@<%= @rails.resource.name %>.destroy
|
56
64
|
respond_to do |format|
|
57
|
-
<%= "message = t('destroy', scope: [:scaffold, :notices, :success], model: #{@
|
58
|
-
format.html { redirect_to <%= @
|
65
|
+
<%= "message = t('destroy', scope: [:scaffold, :notices, :success], model: #{@rails.resource.class_name}.model_name.human.mb_chars.downcase)" %>
|
66
|
+
format.html { redirect_to <%= @rails.path.collection %>, notice: message }
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
62
70
|
private
|
63
|
-
def <%= @collection_name %>_params
|
64
|
-
params[:<%= @
|
71
|
+
def <%= @rails.resource.collection_name %>_params
|
72
|
+
params[:<%= @rails.resource.name %>].permit(<%= @rails.controller.permitted_fields.keys.map{|field| ":#{field}"}.join(', ') %>)
|
65
73
|
end
|
66
74
|
|
67
|
-
def search_<%= @collection_name %>_params
|
68
|
-
return {} if params[:<%= @collection_name %>_search].blank?
|
69
|
-
params[:<%= @collection_name %>_search].permit(<%= @
|
75
|
+
def search_<%= @rails.resource.collection_name %>_params
|
76
|
+
return {} if params[:<%= @rails.resource.collection_name %>_search].blank?
|
77
|
+
params[:<%= @rails.resource.collection_name %>_search].permit(<%= @rails.controller.permitted_search_fields.collect{|field| ":#{field}"}.join(', ') %>)
|
70
78
|
end
|
71
79
|
|
72
80
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<% if @modules.empty? -%>
|
2
|
-
Fabricator(:<%= @
|
1
|
+
<% if @rails.resource.modules.empty? -%>
|
2
|
+
Fabricator(:<%= @rails.resource.name %>) do
|
3
3
|
<% else -%>
|
4
|
-
Fabricator(:<%= @
|
4
|
+
Fabricator(:<%= @rails.resource.name %>, class_name: '<%= @rails.resource.class_name_with_modules -%>') do
|
5
5
|
<% end -%>
|
6
|
-
<% @fields.each_pair do |field_name, kind| -%>
|
6
|
+
<% @rails.resource.fields.each_pair do |field_name, kind| -%>
|
7
7
|
<% if kind == 'belongs_to' -%>
|
8
8
|
<%= field_name %>
|
9
9
|
<% elsif kind == 'text' -%>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
bg:
|
2
|
+
scaffold:
|
3
|
+
confirm: 'Сигурни ли сте?'
|
4
|
+
notices:
|
5
|
+
success:
|
6
|
+
create: Създадохме %{model}
|
7
|
+
update: Обновихме %{model}
|
8
|
+
destroy: Изтрихме %{model}
|
9
|
+
failed:
|
10
|
+
create: Неуспешно създаване на %{model}
|
11
|
+
update: Неуспешно обновяване на %{model}
|
12
|
+
destroy: Неуспешно изтриване на %{model}
|
13
|
+
new:
|
14
|
+
title: "Нов %{model}"
|
15
|
+
show:
|
16
|
+
title: "%{model}"
|
17
|
+
edit:
|
18
|
+
title: "Редакция %{model}"
|
19
|
+
index:
|
20
|
+
title: "%{model}"
|
21
|
+
edit: Редакция
|
22
|
+
show: Преглед
|
23
|
+
destroy: Изтрии
|
24
|
+
actions: Действия
|
25
|
+
search:
|
26
|
+
header: Търсене
|
27
|
+
button: Търси
|
28
|
+
reset: Ново
|
29
|
+
|
30
|
+
actions:
|
31
|
+
index: Списък %{model}
|
32
|
+
actions: 'Действия'
|
33
|
+
new: Нов %{model}
|
34
|
+
edit: Редакция %{model}
|
35
|
+
create: "Създай %{model}"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
en:
|
2
|
+
scaffold:
|
3
|
+
confirm: 'Are you sure?'
|
4
|
+
notices:
|
5
|
+
success:
|
6
|
+
create: Was successfully created %{model}
|
7
|
+
update: Was successfully updated %{model}
|
8
|
+
destroy: Was successfully destroyed %{model}
|
9
|
+
failed:
|
10
|
+
create: Fail creating %{model}
|
11
|
+
update: Fail updating %{model}
|
12
|
+
destroy: Fail destroying %{model}
|
13
|
+
new:
|
14
|
+
title: "New %{model}"
|
15
|
+
show:
|
16
|
+
title: "%{model}"
|
17
|
+
edit:
|
18
|
+
title: "Edit %{model}"
|
19
|
+
index:
|
20
|
+
title: "%{model}"
|
21
|
+
edit: Edit
|
22
|
+
show: Show
|
23
|
+
destroy: Delete
|
24
|
+
actions: Action
|
25
|
+
search:
|
26
|
+
header: Search
|
27
|
+
button: Search
|
28
|
+
reset: Reset
|
29
|
+
|
30
|
+
actions:
|
31
|
+
index: List %{model}
|
32
|
+
actions: 'Actions'
|
33
|
+
new: New %{model}
|
34
|
+
edit: Edit %{model}
|
35
|
+
create: "Create %{model}"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class <%= @
|
2
|
-
<% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| -%>
|
1
|
+
class <%= @rails.resource.class_name_with_modules %> < ApplicationRecord
|
2
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| -%>
|
3
3
|
<% if field_type == 'belongs_to' -%>
|
4
4
|
belongs_to :<%= field_name %>
|
5
5
|
<% end -%>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class <%= @
|
1
|
+
class <%= @rails.resource.search_class_name %>
|
2
2
|
include ActiveModel::Model
|
3
3
|
|
4
4
|
attr_accessor(
|
5
|
-
<% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
5
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
6
6
|
<% if field_type == 'belongs_to' -%>
|
7
7
|
:<%= field_name %>_id,
|
8
8
|
<% else %>
|
@@ -11,37 +11,37 @@ class <%= @search_modulized_resource_class_name %>
|
|
11
11
|
<% end %>
|
12
12
|
)
|
13
13
|
|
14
|
-
<% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
14
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
15
15
|
<%- if field_type == "integer" %>
|
16
16
|
validates :<%= field_name -%>, numericality: { only_integer: true }, allow_blank: true
|
17
17
|
<%- end %>
|
18
18
|
<%- end %>
|
19
19
|
|
20
20
|
def initialize *args
|
21
|
-
@relation = <%= @
|
21
|
+
@relation = <%= @rails.resource.class_name_with_modules %>
|
22
22
|
super *args
|
23
23
|
end
|
24
24
|
|
25
25
|
def results
|
26
|
-
<%= @
|
26
|
+
<%= @rails.resource.name %> = @relation
|
27
27
|
|
28
|
-
<%= @
|
28
|
+
<%= @rails.resource.name %> = @relation.order("updated_at") if <%= @rails.resource.class_name_with_modules %>.respond_to?(:updated_at)
|
29
29
|
|
30
30
|
if valid?
|
31
|
-
<% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
31
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
32
32
|
<% if ['string', 'text'].include?(field_type) -%>
|
33
|
-
<%= @
|
33
|
+
<%= @rails.resource.name %> = <%= @rails.resource.name %>.where("<%= field_name %> LIKE ?", "%#{<%= field_name %>}%") if self.<%= field_name %>.present?
|
34
34
|
<% elsif field_type == "boolean" -%>
|
35
|
-
<%= @
|
35
|
+
<%= @rails.resource.name %> = <%= @rails.resource.name %>.where(<%= field_name -%>: <%= field_name -%>=='1') if self.<%= field_name %>.present?
|
36
36
|
<% elsif field_type == 'belongs_to' -%>
|
37
|
-
<%= @
|
37
|
+
<%= @rails.resource.name %> = <%= @rails.resource.name %>.where(<%= field_name %>_id: <%= field_name %>_id) if self.<%= field_name %>_id.present?
|
38
38
|
<% else -%>
|
39
|
-
<%= @
|
39
|
+
<%= @rails.resource.name %> = <%= @rails.resource.name %>.where(<%= field_name %>: <%= field_name %>) if self.<%= field_name %>.present?
|
40
40
|
<% end -%>
|
41
41
|
<% end -%>
|
42
42
|
end
|
43
43
|
|
44
|
-
<%= @
|
44
|
+
<%= @rails.resource.name %>
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
= form.error_notification
|
2
2
|
.form-inputs
|
3
|
-
<% @fields.each_pair do |field_name, kind| -%>
|
3
|
+
<% @rails.resource.fields.each_pair do |field_name, kind| -%>
|
4
4
|
<% if kind == 'file' -%>
|
5
5
|
= form.input :<%= field_name -%>, as: :file
|
6
6
|
<% elsif kind == 'belongs_to' -%>
|
@@ -13,6 +13,3 @@
|
|
13
13
|
= form.input :<%= field_name %>
|
14
14
|
<% end -%>
|
15
15
|
<% end -%>
|
16
|
-
|
17
|
-
.form-actions
|
18
|
-
= form.button :button, 'Reset Password', :class => 'btn btn-large waves-effect waves'
|
@@ -1,20 +1,22 @@
|
|
1
|
-
h1 = t('scaffold.edit.title', model: <%= @
|
1
|
+
h1 = t('scaffold.edit.title', model: <%= @rails.resource.class_name %>.model_name.human(count: 1).mb_chars.downcase)
|
2
2
|
|
3
3
|
.section
|
4
4
|
.left
|
5
|
-
= link_to <%= @
|
5
|
+
= link_to <%= @rails.path.collection %>, class: 'waves-effect waves-light btn' do
|
6
6
|
i.material-icons.right view_list
|
7
|
-
= t('scaffold.show.actions.index', model: <%= @
|
7
|
+
= t('scaffold.show.actions.index', model: <%= @rails.resource.class_name %>.model_name.human(count: 2).mb_chars.downcase)
|
8
8
|
|
9
9
|
|
10
10
|
.right
|
11
|
-
= link_to <%= @
|
11
|
+
= link_to <%= @rails.path.new_resource %>, class: 'btn waves-effect waves-light' do
|
12
12
|
i.material-icons.right add
|
13
|
-
= t('scaffold.actions.new', model: <%= @
|
13
|
+
= t('scaffold.actions.new', model: <%= @rails.resource.class_name %>.model_name.human(count: 1).mb_chars.downcase)
|
14
14
|
|
15
15
|
.clearfix
|
16
16
|
|
17
17
|
.card
|
18
18
|
.card-content
|
19
|
-
= simple_form_for <%= @
|
20
|
-
= render 'form', form: form
|
19
|
+
= simple_form_for <%= @rails.path.instance_resource %> do |form|
|
20
|
+
= render 'form', form: form
|
21
|
+
.form-actions
|
22
|
+
= form.button :button, t('scaffold.actions.update', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 1)), :class => 'btn btn-large waves-effect waves'
|
@@ -1,9 +1,9 @@
|
|
1
|
-
h1 = t('scaffold.index.title', model: <%= @
|
1
|
+
h1 = t('scaffold.index.title', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 2))
|
2
2
|
|
3
3
|
.fixed-action-btn style="bottom: 45px; right: 24px;"
|
4
|
-
= link_to <%= @
|
4
|
+
= link_to <%= @rails.path.new_resource %>, class: 'btn-floating btn-large waves-effect waves-light red' do
|
5
5
|
i.material-icons.right add
|
6
|
-
= t('scaffold.actions.new', model: <%= @
|
6
|
+
= t('scaffold.actions.new', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 1).mb_chars.downcase)
|
7
7
|
|
8
8
|
|
9
9
|
|
@@ -14,32 +14,32 @@ h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.mode
|
|
14
14
|
table.striped.highlight.responsive-table
|
15
15
|
thead
|
16
16
|
tr
|
17
|
-
<% @fields.select {|k,v| @index_fields.include?(k) }.keys.each do |field_name| %>
|
18
|
-
th = <%= @
|
17
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.index_fields.include?(k) }.keys.each do |field_name| %>
|
18
|
+
th = <%= @rails.resource.class_name_with_modules -%>.human_attribute_name(:<%= field_name -%>)
|
19
19
|
<% end %>
|
20
20
|
th colspan=3 = t('scaffold.index.actions')
|
21
21
|
|
22
22
|
tbody
|
23
|
-
- @<%= @collection_name %>.each do |<%= @
|
23
|
+
- @<%= @rails.resource.collection_name %>.each do |<%= @rails.resource.name %>|
|
24
24
|
tr
|
25
|
-
<% @fields.select {|k,v| @index_fields.include?(k) }.keys.each do |field_name| %>
|
26
|
-
td = <%= @
|
25
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.index_fields.include?(k) }.keys.each do |field_name| %>
|
26
|
+
td = <%= @rails.resource.name %>.<%= field_name -%>
|
27
27
|
<% end %>
|
28
|
-
td = link_to t('scaffold.index.show'), <%= @
|
29
|
-
td = link_to t('scaffold.index.edit'), <%= @
|
30
|
-
td = link_to t('scaffold.index.destroy'), <%= @
|
28
|
+
td = link_to t('scaffold.index.show'), <%= @rails.path.resource %>
|
29
|
+
td = link_to t('scaffold.index.edit'), <%= @rails.path.edit_resource %>
|
30
|
+
td = link_to t('scaffold.index.destroy'), <%= @rails.path.resource %>, data: {:confirm => t('scaffold.confirm')}, :method => :delete
|
31
31
|
.card-action
|
32
|
-
= paginate @<%= @collection_name %>
|
32
|
+
= paginate @<%= @rails.resource.collection_name %>
|
33
33
|
|
34
34
|
.col.s12.m3
|
35
35
|
|
36
36
|
aside.card.search
|
37
|
-
= simple_form_for <%= "@#{@collection_name}_search" %>, as: :<%= @collection_name %>_search, url: <%= @
|
37
|
+
= simple_form_for <%= "@#{@rails.resource.collection_name}_search" %>, as: :<%= @rails.resource.collection_name %>_search, url: <%= @rails.path.collection %>, method: :get do |form|
|
38
38
|
.card-content
|
39
39
|
h5 = t('scaffold.index.search.header')
|
40
40
|
= form.error_notification
|
41
41
|
|
42
|
-
<% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
42
|
+
<% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
43
43
|
<% if field_type == 'belongs_to' -%>
|
44
44
|
= form.input :<%= field_name -%>_id
|
45
45
|
<% elsif ['date', 'datetime'].include?(field_type) -%>
|
@@ -52,6 +52,6 @@ h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.mode
|
|
52
52
|
<% end %>
|
53
53
|
|
54
54
|
.card-action
|
55
|
-
= link_to t('scaffold.index.search.reset'), url_for(<%= @
|
55
|
+
= link_to t('scaffold.index.search.reset'), url_for(<%= @rails.path.collection %>), class: 'waves-effect waves-light btn lime lighten-5 black-text'
|
56
56
|
= form.submit t('scaffold.index.search.button'), class: 'right waves-effect waves-light btn'
|
57
57
|
.clearfix
|
@@ -1,14 +1,16 @@
|
|
1
|
-
h1 = t('scaffold.new.title', model: <%= @
|
1
|
+
h1 = t('scaffold.new.title', model: <%= @rails.resource.class_name %>.model_name.human(count: 1).mb_chars.downcase)
|
2
2
|
|
3
3
|
.section
|
4
4
|
.left
|
5
|
-
= link_to <%= @
|
5
|
+
= link_to <%= @rails.path.collection %>, class: 'waves-effect waves-light btn' do
|
6
6
|
i.material-icons.right view_list
|
7
|
-
= t('scaffold.show.actions.index', model: <%= @
|
7
|
+
= t('scaffold.show.actions.index', model: <%= @rails.resource.class_name %>.model_name.human(count: 2).mb_chars.downcase)
|
8
8
|
|
9
9
|
.clearfix
|
10
10
|
|
11
11
|
.card
|
12
12
|
.card-content
|
13
|
-
= simple_form_for <%= @
|
14
|
-
= render 'form', form: form
|
13
|
+
= simple_form_for <%= @rails.path.instance_resource %> do |form|
|
14
|
+
= render 'form', form: form
|
15
|
+
.form-actions
|
16
|
+
= form.button :button, t('scaffold.actions.create', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 1)), :class => 'btn btn-large waves-effect waves'
|