scaffold_pico 1.1.6 → 1.1.7
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14cf2648944a7e5f17fefee16207c780e92cb932
|
4
|
+
data.tar.gz: b42eaf583b52b2b40f507f5833f563a95e7612db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f4addb50eaa34fb870635bc0ecaf30b5b9db09994aa33472daf565301257c3442a4847d933bbc2c14807f4ccb0555855ebd696b9983e4a8b0471565c1bd144b
|
7
|
+
data.tar.gz: 78b7b56bf9f28549a31ce8388a92f28b54075a3386bca329d23510933516472cb9aa669a625d4896f806e044353e0aa08345f067587bce088d9d8fb3a637d3fd
|
@@ -2,20 +2,22 @@ class <%= @rails.resource.search_class_name %>
|
|
2
2
|
include ActiveModel::Model
|
3
3
|
|
4
4
|
attr_accessor(
|
5
|
-
<% @rails.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
<% @rails.controller.search_fields.map do |field_name| %>
|
6
|
+
<%=
|
7
|
+
if @rails.resource.fields[field_name] == 'belongs_to'
|
8
|
+
":#{field_name}_id,"
|
9
|
+
else
|
10
|
+
":#{field_name},"
|
11
|
+
end
|
12
|
+
-%>
|
10
13
|
<% end %>
|
11
|
-
<% end %>
|
12
14
|
)
|
13
15
|
|
14
|
-
<% @rails.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
<% @rails.controller.search_fields.select { |search_filed| @rails.resource.fields[search_filed] == 'integer' }.each do |search_filed| %>
|
17
|
+
<%=
|
18
|
+
"validates :#{field_name}, numericality: { only_integer: true }, allow_blank: true"
|
19
|
+
-%>
|
20
|
+
<% end %>
|
19
21
|
|
20
22
|
def initialize *args
|
21
23
|
@relation = <%= @rails.resource.class_name_with_modules %>
|
@@ -23,25 +25,32 @@ class <%= @rails.resource.search_class_name %>
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def results
|
26
|
-
|
27
|
-
|
28
|
-
<%= @rails.resource.name %> = @relation.order("updated_at") if <%= @rails.resource.class_name_with_modules %>.column_names.include?('updated_at')
|
28
|
+
<% resource_name = @rails.resource.name.pluralize %>
|
29
|
+
<%= resource_name -%> = @relation
|
29
30
|
|
30
31
|
if valid?
|
31
|
-
<% @rails.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
32
|
+
<% @rails.controller.search_fields.each do |field_name| %>
|
33
|
+
<%=
|
34
|
+
case @rails.resource.fields[field_name]
|
35
|
+
when 'string', 'text'
|
36
|
+
"#{resource_name} = #{resource_name}.where(\"#{field_name} LIKE ?\", \"%\#{#{field_name}}%\") if #{field_name}.present?"
|
37
|
+
when 'boolean'
|
38
|
+
"#{resource_name} = #{resource_name}.where(#{field_name}: true) if #{field_name} == '1'"
|
39
|
+
when 'belongs_to'
|
40
|
+
"#{resource_name} = #{resource_name}.where(#{field_name}_id: #{field_name}_id) if #{field_name}_id.present?"
|
41
|
+
when 'int', 'integer'
|
42
|
+
"#{resource_name} = #{resource_name}.where(#{field_name}: #{field_name}.to_i) if #{field_name}.present?"
|
43
|
+
else
|
44
|
+
"#{resource_name} = #{resource_name}.where(#{field_name}: #{field_name}) if #{field_name}.present?"
|
45
|
+
end
|
46
|
+
-%>
|
47
|
+
<% end %>
|
43
48
|
|
44
|
-
|
49
|
+
if <%= @rails.resource.class_name_with_modules -%>.attribute_names.include?('updated_at')
|
50
|
+
<%= resource_name %>.order(updated_at: :desc)
|
51
|
+
else
|
52
|
+
<%= resource_name %>
|
53
|
+
end
|
54
|
+
end
|
45
55
|
end
|
46
|
-
|
47
56
|
end
|
@@ -1,15 +1,21 @@
|
|
1
1
|
= form.error_notification
|
2
2
|
.form-inputs
|
3
|
-
<%
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
<% @rails.resource.fields.each_pair do |field_name, kind| %>
|
4
|
+
<%- next if field_name == 'id' -%>
|
5
|
+
<%=
|
6
|
+
case kind
|
7
|
+
when 'file'
|
8
|
+
"= form.input :#{field_name}, as: :file"
|
9
|
+
when 'belongs_to'
|
10
|
+
"= form.association :#{field_name}"
|
11
|
+
when 'text'
|
12
|
+
"= form.input :#{field_name}, as: :text"
|
13
|
+
when 'date', 'datetime'
|
14
|
+
"= form.input :#{field_name}, as: :date, html5: true"
|
15
|
+
when 'boolean'
|
16
|
+
"= form.input :#{field_name}, as: :boolean"
|
17
|
+
else
|
18
|
+
"= form.input :#{field_name}"
|
19
|
+
end
|
20
|
+
-%>
|
21
|
+
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffold_pico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gudata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|