biovision-regions 0.1.180120 → 0.1.180213
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/regions_controller.rb +12 -13
- data/app/models/region.rb +1 -1
- data/app/views/regions/_form.html.erb +114 -65
- data/app/views/regions/edit.js.erb +1 -0
- data/app/views/regions/new.js.erb +1 -0
- data/config/routes.rb +1 -1
- data/lib/biovision/regions/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f755fbc7eef074658f20b28e0bb0f96c243546d04d3657689ea70f7f16ef5ea
|
4
|
+
data.tar.gz: 14a3e6670be63ae9436316206d2115c1f41206c3ba87644124443036130a3239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3967eb3a28a68d48129cbcdfb5c1854f119fc1f9811a2b56e3d8eadc1e699de74171f8a3d7dc8920dca022f1c2a43070b83f3d3f694b01a9568656f621d1f6b9
|
7
|
+
data.tar.gz: b4a4032f4fbf8b3041522d56378680a02ce1339f91a9666e03e309f699d24b1741f6077d6e381615b0af9f84fd9a350eb3fd22fa7145c7a293ca37e32c65c472
|
@@ -6,8 +6,12 @@ class RegionsController < AdminController
|
|
6
6
|
def create
|
7
7
|
@entity = Region.new(creation_parameters)
|
8
8
|
if @entity.save
|
9
|
-
|
10
|
-
|
9
|
+
next_page = admin_region_path(@entity.id)
|
10
|
+
respond_to do |format|
|
11
|
+
format.html { redirect_to next_page }
|
12
|
+
format.json { render json: { links: { self: next_page } } }
|
13
|
+
format.js { render js: "document.location.href = '#{next_page}'" }
|
14
|
+
end
|
11
15
|
else
|
12
16
|
render :new, status: :bad_request
|
13
17
|
end
|
@@ -20,8 +24,12 @@ class RegionsController < AdminController
|
|
20
24
|
# patch /regions/:id
|
21
25
|
def update
|
22
26
|
if @entity.update(entity_parameters)
|
23
|
-
|
24
|
-
|
27
|
+
next_page = admin_region_path(@entity.id)
|
28
|
+
respond_to do |format|
|
29
|
+
format.html { redirect_to next_page, notice: t('regions.update.success') }
|
30
|
+
format.json { render json: { links: { self: next_page } } }
|
31
|
+
format.js { render js: "document.location.href = '#{next_page}'" }
|
32
|
+
end
|
25
33
|
else
|
26
34
|
render :edit, status: :bad_request
|
27
35
|
end
|
@@ -61,13 +69,4 @@ class RegionsController < AdminController
|
|
61
69
|
def creation_parameters
|
62
70
|
params.require(:region).permit(Region.creation_parameters)
|
63
71
|
end
|
64
|
-
|
65
|
-
def cache_relatives
|
66
|
-
@entity.cache_parents!
|
67
|
-
unless @entity.parent.blank?
|
68
|
-
parent = @entity.parent
|
69
|
-
parent.cache_children!
|
70
|
-
parent.save
|
71
|
-
end
|
72
|
-
end
|
73
72
|
end
|
data/app/models/region.rb
CHANGED
@@ -9,7 +9,7 @@ class Region < ApplicationRecord
|
|
9
9
|
|
10
10
|
toggleable :visible
|
11
11
|
|
12
|
-
|
12
|
+
belongs_to :country, optional: true, counter_cache: true
|
13
13
|
belongs_to :parent, class_name: Region.to_s, optional: true, touch: true
|
14
14
|
has_many :child_regions, class_name: Region.to_s, foreign_key: :parent_id
|
15
15
|
has_many :users, dependent: :nullify
|
@@ -1,73 +1,122 @@
|
|
1
|
-
<%=
|
1
|
+
<%= form_with(model: entity, html: { id: 'region-form' }) do |f| %>
|
2
|
+
<%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
|
2
3
|
|
3
|
-
|
4
|
-
<
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
<%
|
9
|
-
|
10
|
-
<%
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
4
|
+
<dl>
|
5
|
+
<dt><%= f.label :image %></dt>
|
6
|
+
<dd>
|
7
|
+
<figure class="preview" id="region-image">
|
8
|
+
<% if entity.image.blank? %>
|
9
|
+
<% image = image_tag('biovision/regions/placeholders/region_image.svg') %>
|
10
|
+
<% else %>
|
11
|
+
<% image = image_tag(entity.image.url) %>
|
12
|
+
<% end %>
|
13
|
+
<%= label_tag('region_image', image) %>
|
14
|
+
<figcaption>
|
15
|
+
<%=
|
16
|
+
f.file_field(
|
17
|
+
:image,
|
18
|
+
id: :region_image,
|
19
|
+
accept: 'image/jpeg,image/png',
|
20
|
+
data: { image: 'region-image' }
|
21
|
+
)
|
22
|
+
%>
|
23
|
+
</figcaption>
|
24
|
+
</figure>
|
25
|
+
</dd>
|
26
|
+
<dt><%= f.label :header_image %></dt>
|
27
|
+
<dd>
|
28
|
+
<figure class="preview" id="region-header-image">
|
29
|
+
<% if entity.header_image.blank? %>
|
30
|
+
<% header_image = image_tag('biovision/base/placeholders/image.svg') %>
|
31
|
+
<% else %>
|
32
|
+
<% header_image = image_tag(entity.header_image.medium.url) %>
|
33
|
+
<% end %>
|
34
|
+
<%= label_tag('region_header_image', header_image) %>
|
35
|
+
<figcaption>
|
36
|
+
<%=
|
37
|
+
f.file_field(
|
38
|
+
:header_image,
|
39
|
+
id: :region_header_image,
|
40
|
+
accept: 'image/jpeg,image/png',
|
41
|
+
data: { image: 'region-header-image' }
|
42
|
+
)
|
43
|
+
%>
|
44
|
+
<div class="guideline"><%= t('.guidelines.header_image') %></div>
|
45
|
+
</figcaption>
|
46
|
+
</figure>
|
47
|
+
</dd>
|
34
48
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
49
|
+
<dt><%= f.label :name %></dt>
|
50
|
+
<dd>
|
51
|
+
<%=
|
52
|
+
f.text_field(
|
53
|
+
:name,
|
54
|
+
id: :region_name,
|
55
|
+
required: true,
|
56
|
+
size: nil,
|
57
|
+
maxlength: Region::NAME_LIMIT
|
58
|
+
)
|
59
|
+
%>
|
60
|
+
</dd>
|
39
61
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
62
|
+
<dt><%= f.label :short_name %></dt>
|
63
|
+
<dd>
|
64
|
+
<%=
|
65
|
+
f.text_field(
|
66
|
+
:short_name,
|
67
|
+
id: :region_short_name,
|
68
|
+
required: true,
|
69
|
+
size: nil,
|
70
|
+
maxlength: Region::NAME_LIMIT
|
71
|
+
)
|
72
|
+
%>
|
73
|
+
<div class="guideline">
|
74
|
+
<%= t('.guidelines.short_name') %>
|
75
|
+
</div>
|
76
|
+
</dd>
|
47
77
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
78
|
+
<dt><%= f.label :locative %></dt>
|
79
|
+
<dd>
|
80
|
+
<%=
|
81
|
+
f.text_field(
|
82
|
+
:locative,
|
83
|
+
id: :region_locative,
|
84
|
+
required: true,
|
85
|
+
size: nil,
|
86
|
+
maxlength: Region::NAME_LIMIT,
|
87
|
+
placeholder: t('.placeholders.locative')
|
88
|
+
)
|
89
|
+
%>
|
90
|
+
<div class="guideline">
|
91
|
+
<%= t('.guidelines.locative') %>
|
92
|
+
</div>
|
93
|
+
</dd>
|
55
94
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
95
|
+
<dt><%= f.label :slug %></dt>
|
96
|
+
<dd>
|
97
|
+
<%=
|
98
|
+
f.text_field(
|
99
|
+
:slug,
|
100
|
+
id: :region_slug,
|
101
|
+
required: true,
|
102
|
+
size: nil,
|
103
|
+
maxlength: Region::SLUG_LIMIT
|
104
|
+
)
|
105
|
+
%>
|
106
|
+
<div class="guideline">
|
107
|
+
<%= t('.guidelines.slug') %>
|
108
|
+
</div>
|
109
|
+
</dd>
|
110
|
+
</dl>
|
64
111
|
|
65
|
-
|
66
|
-
|
67
|
-
|
112
|
+
<ul class="flags">
|
113
|
+
<li>
|
114
|
+
<%= f.check_box :visible, id: :region_visible %><%= f.label :visible %>
|
115
|
+
</li>
|
116
|
+
</ul>
|
68
117
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
118
|
+
<div class="buttons">
|
119
|
+
<%= f.hidden_field :parent_id if entity.id.nil? %>
|
120
|
+
<%= f.button t(:save), type: :submit, class: 'button-save' %>
|
121
|
+
</div>
|
73
122
|
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'region-form' } %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'region-form' } %>
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biovision-regions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.180213
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Khan-Magomedov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -202,7 +202,9 @@ files:
|
|
202
202
|
- app/views/layouts/biovision/regions/application.html.erb
|
203
203
|
- app/views/regions/_form.html.erb
|
204
204
|
- app/views/regions/edit.html.erb
|
205
|
+
- app/views/regions/edit.js.erb
|
205
206
|
- app/views/regions/new.html.erb
|
207
|
+
- app/views/regions/new.js.erb
|
206
208
|
- config/locales/regions-en.yml
|
207
209
|
- config/locales/regions-ru.yml
|
208
210
|
- config/routes.rb
|