c80_map 0.1.0.2 → 0.1.0.10
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 +4 -4
- data/README.md +19 -1
- data/app/assets/javascripts/buttons/admin_buttons/button_area_link.js +88 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_back_to_map.js +2 -4
- data/app/assets/javascripts/buttons/admin_buttons/button_cancel_remove.js +23 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_edit.js +16 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_remove.js +23 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_save.js +32 -4
- data/app/assets/javascripts/c80_map.js.coffee +4 -1
- data/app/assets/javascripts/map_objects/area.js +20 -9
- data/app/assets/javascripts/map_objects/building.js +2 -3
- data/app/assets/javascripts/src/main.js +74 -10
- data/app/assets/javascripts/src/state_controller.js +97 -23
- data/app/assets/javascripts/src/utils/map_utils.js +23 -0
- data/app/assets/javascripts/src/utils/opacity_buttons_utils.js +15 -0
- data/app/assets/javascripts/src/{utils.js → utils/utils.js} +13 -0
- data/app/assets/javascripts/svg_elements/area_label.js +25 -0
- data/app/assets/javascripts/svg_elements/polygon.js +3 -1
- data/app/assets/stylesheets/map.scss +148 -66
- data/app/assets/stylesheets/view/modal_window.scss +13 -0
- data/app/controllers/c80_map/map_ajax_controller.rb +5 -1
- data/app/models/c80_map/area.rb +1 -0
- data/app/models/c80_map/area_representator.rb +75 -0
- data/app/models/c80_map/map_json.rb +28 -14
- data/app/views/c80_map/_map_row_index.html.erb +1 -0
- data/app/views/c80_map/shared/_modal_window.html.erb +28 -0
- data/db/migrate/{20160620040202_create_c80_map_areas.rb → 20160620040225_create_c80_map_areas.rb} +4 -1
- data/lib/c80_map/version.rb +1 -1
- metadata +14 -5
- /data/db/migrate/{20160620040206_create_c80_map_buildings.rb → 20160620040217_create_c80_map_buildings.rb} +0 -0
@@ -2,7 +2,7 @@ module C80Map
|
|
2
2
|
class MapAjaxController < ApplicationController
|
3
3
|
|
4
4
|
def save_map_data
|
5
|
-
Rails.logger.debug "<MapAjaxController.save_map_data> params = #{params}"
|
5
|
+
# Rails.logger.debug "<MapAjaxController.save_map_data> params = #{params}"
|
6
6
|
|
7
7
|
#{ "buildings"=>{"0"=>{"coords"=>["2496.5894495412845",...]}} }
|
8
8
|
#{ "areas"=>{"0"=>{"coords"=>["2496.5894495412845",...]}} }
|
@@ -20,6 +20,7 @@ module C80Map
|
|
20
20
|
updated_locations_json: nil
|
21
21
|
}
|
22
22
|
|
23
|
+
# сначала создадим здания
|
23
24
|
if params[:buildings].present?
|
24
25
|
params[:buildings].each_key do |key|
|
25
26
|
new_building_options = params[:buildings][key]
|
@@ -36,6 +37,7 @@ module C80Map
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
40
|
+
# затем создадим области
|
39
41
|
if params[:areas].present?
|
40
42
|
params[:areas].each_key do |key|
|
41
43
|
new_area_options = params[:areas][key]
|
@@ -55,6 +57,8 @@ module C80Map
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
60
|
+
result[:updated_locations_json] = MapJson.fetch_json
|
61
|
+
|
58
62
|
puts "<MapAjaxController.save_map_data> result = #{result.to_json}"
|
59
63
|
|
60
64
|
respond_to do |format|
|
data/app/models/c80_map/area.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
module C80Map
|
2
|
+
|
3
|
+
module AreaRepresentator
|
4
|
+
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# ERROR: Cannot define multiple 'included' blocks for a Concern
|
8
|
+
# included do
|
9
|
+
#
|
10
|
+
# end
|
11
|
+
|
12
|
+
def self.included(klass)
|
13
|
+
klass.extend ClassMethods
|
14
|
+
klass.send(:include, InstanceMethods)
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
|
19
|
+
def acts_as_map_area_representator
|
20
|
+
class_eval do
|
21
|
+
|
22
|
+
has_many :map_areas, :as => :area_representator, :class_name => 'C80Map::Area', :dependent => :destroy
|
23
|
+
after_save :update_json
|
24
|
+
|
25
|
+
def self.unlinked_areas
|
26
|
+
res = []
|
27
|
+
self.all.each do |area|
|
28
|
+
if area.map_areas.count == 0
|
29
|
+
res << area
|
30
|
+
end
|
31
|
+
end
|
32
|
+
res
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_json
|
36
|
+
MapJson.update_json
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module InstanceMethods
|
44
|
+
|
45
|
+
def to_hash
|
46
|
+
res = {
|
47
|
+
id: id,
|
48
|
+
title: title,
|
49
|
+
props: {
|
50
|
+
square: square,
|
51
|
+
floor_height: floor_height,
|
52
|
+
gate_type: gate_type,
|
53
|
+
desc: desc,
|
54
|
+
# column_step: column_step,
|
55
|
+
# communications: communications,
|
56
|
+
price: price_string
|
57
|
+
}
|
58
|
+
}
|
59
|
+
res
|
60
|
+
end
|
61
|
+
|
62
|
+
# свободна ли площадь, привязанная к полигону на карте
|
63
|
+
def is_free?
|
64
|
+
res = true
|
65
|
+
if map_areas.count > 0
|
66
|
+
res = map_areas.first.is_free?
|
67
|
+
end
|
68
|
+
res
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
ActiveRecord::Base.send :include, C80Map::AreaRepresentator
|
@@ -2,6 +2,7 @@ module C80Map
|
|
2
2
|
|
3
3
|
class MapJson < ActiveRecord::Base
|
4
4
|
|
5
|
+
# этот метод вызовается после update Area
|
5
6
|
def self.update_json
|
6
7
|
locations_path = Rails.root.join("public", "locations.json")
|
7
8
|
locs = File.read(locations_path)
|
@@ -17,25 +18,32 @@ module C80Map
|
|
17
18
|
# сначала соберём детей - Area
|
18
19
|
childs = []
|
19
20
|
b.areas.each do |area|
|
20
|
-
Rails.logger.debug "<MapJson.update_json> area #{area}"
|
21
|
+
# Rails.logger.debug "<MapJson.update_json> area #{area}"
|
22
|
+
|
23
|
+
har = {}
|
24
|
+
if area.area_representator.present?
|
25
|
+
har = area.area_representator.to_hash
|
26
|
+
har["is_free"] = area.area_representator.is_free?
|
27
|
+
end
|
21
28
|
|
22
29
|
ab = {
|
23
30
|
id: area.id,
|
24
31
|
object_type: 'area',
|
25
32
|
coords: area.coords.split(','),
|
26
|
-
area_hash:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
33
|
+
area_hash: har
|
34
|
+
# area_hash: {
|
35
|
+
# id: 2,
|
36
|
+
# title: "Площадь #{area.id}.#{area.id}",
|
37
|
+
# is_free: true,
|
38
|
+
# props: {
|
39
|
+
# square: "124 кв.м.",
|
40
|
+
# floor_height: "6 кв. м",
|
41
|
+
# column_step: "2 м",
|
42
|
+
# gate_type: "распашные",
|
43
|
+
# communications: "Интернет, электричество, водоснабжение",
|
44
|
+
# price: "от 155 руб/кв.м в месяц"
|
45
|
+
# }
|
46
|
+
# }
|
39
47
|
}
|
40
48
|
childs << ab
|
41
49
|
end
|
@@ -80,6 +88,12 @@ module C80Map
|
|
80
88
|
end
|
81
89
|
end
|
82
90
|
|
91
|
+
def self.fetch_json
|
92
|
+
locations_path = Rails.root.join("public", "locations.json")
|
93
|
+
locs = File.read(locations_path)
|
94
|
+
JSON.parse(locs)
|
95
|
+
end
|
96
|
+
|
83
97
|
end
|
84
98
|
|
85
99
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= link_to 'Показать modal window',
|
2
|
+
'#modal_window',
|
3
|
+
:data => {
|
4
|
+
:toggle => 'modal'
|
5
|
+
},
|
6
|
+
:class => 'hidden2 show_modal_window',
|
7
|
+
:title => 'Показать modal window'
|
8
|
+
%>
|
9
|
+
|
10
|
+
<div class="modal fade" id="modal_window" tabindex="-1" role="dialog" aria-labelledby="modalShowWindow" aria-hidden="true">
|
11
|
+
<div class="modal-dialog">
|
12
|
+
<div class="modal-content">
|
13
|
+
|
14
|
+
<div class="modal-header">
|
15
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
16
|
+
<h4 class="modal-title" id="myModalLabel">%modal-title%</h4>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="modal-body">
|
20
|
+
%modal-body%
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="modal-footer">
|
24
|
+
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</div>
|
data/db/migrate/{20160620040202_create_c80_map_areas.rb → 20160620040225_create_c80_map_areas.rb}
RENAMED
@@ -1,8 +1,11 @@
|
|
1
1
|
class CreateC80MapAreas < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :c80_map_areas, :options => 'COLLATE=utf8_unicode_ci' do |t|
|
4
|
-
t.
|
4
|
+
t.text :tag
|
5
|
+
t.text :coords
|
5
6
|
t.references :building, index: true
|
7
|
+
t.string :area_representator_type, :default => 'Rent::Area'
|
8
|
+
t.references :area_representator, index: true
|
6
9
|
t.timestamps
|
7
10
|
end
|
8
11
|
end
|
data/lib/c80_map/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c80_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C80609A
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,11 +68,14 @@ files:
|
|
68
68
|
- Rakefile
|
69
69
|
- app/admin/c80_map/buildings.rb
|
70
70
|
- app/admin/c80_map/settings.rb
|
71
|
+
- app/assets/javascripts/buttons/admin_buttons/button_area_link.js
|
71
72
|
- app/assets/javascripts/buttons/admin_buttons/button_back_to_map.js
|
72
73
|
- app/assets/javascripts/buttons/admin_buttons/button_cancel_create.js
|
74
|
+
- app/assets/javascripts/buttons/admin_buttons/button_cancel_remove.js
|
73
75
|
- app/assets/javascripts/buttons/admin_buttons/button_complete_create.js
|
74
76
|
- app/assets/javascripts/buttons/admin_buttons/button_edit.js
|
75
77
|
- app/assets/javascripts/buttons/admin_buttons/button_new.js
|
78
|
+
- app/assets/javascripts/buttons/admin_buttons/button_remove.js
|
76
79
|
- app/assets/javascripts/buttons/admin_buttons/button_save.js
|
77
80
|
- app/assets/javascripts/buttons/zoom_buttons.js
|
78
81
|
- app/assets/javascripts/c80_map.js.coffee
|
@@ -82,17 +85,22 @@ files:
|
|
82
85
|
- app/assets/javascripts/map_objects/dot.js
|
83
86
|
- app/assets/javascripts/src/main.js
|
84
87
|
- app/assets/javascripts/src/state_controller.js
|
85
|
-
- app/assets/javascripts/src/utils.js
|
88
|
+
- app/assets/javascripts/src/utils/map_utils.js
|
89
|
+
- app/assets/javascripts/src/utils/opacity_buttons_utils.js
|
90
|
+
- app/assets/javascripts/src/utils/utils.js
|
91
|
+
- app/assets/javascripts/svg_elements/area_label.js
|
86
92
|
- app/assets/javascripts/svg_elements/helper.js
|
87
93
|
- app/assets/javascripts/svg_elements/polygon.js
|
88
94
|
- app/assets/javascripts/view/save_preloader.js
|
89
95
|
- app/assets/stylesheets/c80_map.scss
|
90
96
|
- app/assets/stylesheets/map.scss
|
97
|
+
- app/assets/stylesheets/view/modal_window.scss
|
91
98
|
- app/assets/stylesheets/view/save_preloader.scss
|
92
99
|
- app/controllers/c80_map/application_controller.rb
|
93
100
|
- app/controllers/c80_map/map_ajax_controller.rb
|
94
101
|
- app/helpers/c80_map/application_helper.rb
|
95
102
|
- app/models/c80_map/area.rb
|
103
|
+
- app/models/c80_map/area_representator.rb
|
96
104
|
- app/models/c80_map/building.rb
|
97
105
|
- app/models/c80_map/map_json.rb
|
98
106
|
- app/models/c80_map/setting.rb
|
@@ -100,14 +108,15 @@ files:
|
|
100
108
|
- app/uploaders/c80_map/map_image_uploader.rb
|
101
109
|
- app/views/c80_map/_map_row.html.erb
|
102
110
|
- app/views/c80_map/_map_row_index.html.erb
|
111
|
+
- app/views/c80_map/shared/_modal_window.html.erb
|
103
112
|
- app/views/c80_map/shared/_save_preloader.html.erb
|
104
113
|
- bin/console
|
105
114
|
- bin/setup
|
106
115
|
- c80_map.gemspec
|
107
116
|
- config/routes.rb
|
108
117
|
- db/migrate/20160617130000_create_c80_map_settings.rb
|
109
|
-
- db/migrate/
|
110
|
-
- db/migrate/
|
118
|
+
- db/migrate/20160620040217_create_c80_map_buildings.rb
|
119
|
+
- db/migrate/20160620040225_create_c80_map_areas.rb
|
111
120
|
- db/seeds/801_fill_map_settings.rb
|
112
121
|
- lib/c80_map.rb
|
113
122
|
- lib/c80_map/engine.rb
|
File without changes
|