c80_map 0.1.0.11 → 0.1.0.12
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/app/assets/javascripts/buttons/admin_buttons/button_area_link.js +4 -1
- data/app/assets/javascripts/buttons/admin_buttons/button_building_link.js +91 -0
- data/app/assets/javascripts/map_objects/building.js +2 -0
- data/app/assets/javascripts/src/main.js +63 -8
- data/app/assets/javascripts/src/state_controller.js +11 -1
- data/app/assets/stylesheets/map.scss +1 -1
- data/app/models/c80_map/building.rb +1 -0
- data/app/models/c80_map/building_representator.rb +67 -0
- data/app/models/c80_map/map_json.rb +22 -13
- data/db/migrate/20160901153030_add_building_representator_to_c80_map_buildings.rb +6 -0
- data/lib/c80_map/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9254abbdfc9c6de507a5183e0ada19557b624443
|
4
|
+
data.tar.gz: 692c738b42315b00dd16bbebc00d6ee8b8437366
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50a6b6b39e879869d52286b8f1564e38b2e53492dc333f76174ba8ee74ef7d86ca11908fd8406a7d1d0eab17ed9d378d929382c4dd85071115508e0407b7e417
|
7
|
+
data.tar.gz: f1554e684359a960e55398ca6a3a613743deaebbdc65f64015f16f62af6fbb902c074d44eedb3252ad975955149b61ecdc3e13ba090ce849586d49afbdfa5f0a
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
// при клике на эту кнопку
|
3
|
+
// при клике на эту кнопку произойдет:
|
4
|
+
// * показ прелоадера,
|
5
|
+
// * запрос за несвязанными площадями,
|
6
|
+
// * после получения ответа - показ модального окна _modal_window.html.erb куда будет подставлен %modal-title% и %modal-body%
|
4
7
|
|
5
8
|
function AreaLinkButton() {
|
6
9
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
// при клике на эту кнопку произойдет:
|
4
|
+
// * показ прелоадера,
|
5
|
+
// * запрос за несвязанными ЗДАНИЯМИ,
|
6
|
+
// * после получения ответа - показ модального окна _modal_window.html.erb куда будет подставлен %modal-title% и %modal-body%
|
7
|
+
|
8
|
+
function BuildingLinkButton() {
|
9
|
+
|
10
|
+
var _map = null;
|
11
|
+
var _this = this;
|
12
|
+
_this.el = null;
|
13
|
+
|
14
|
+
var show_modal_window = function () {
|
15
|
+
|
16
|
+
//var $dialog = $('#modal_window');
|
17
|
+
//$dialog.find("h4").text($t.data("wtitle"));
|
18
|
+
//$dialog.find("#form_comment").css('display','block');
|
19
|
+
//$dialog.find("input#comment_part_id").val(partid);
|
20
|
+
//$dialog.find("input#comment_author").val(author);
|
21
|
+
|
22
|
+
var $m = $('#modal_window');
|
23
|
+
var $cc = $m.find('.modal-body');
|
24
|
+
$m.find('.modal-title').text('Укажите здание, соответствующее полигону на карте');
|
25
|
+
|
26
|
+
setTimeout(function () {
|
27
|
+
$("select#unlinked_buildings").selectpicker({size: 50, tickIcon: 'hidden'});
|
28
|
+
}, 1);
|
29
|
+
|
30
|
+
setTimeout(function () {
|
31
|
+
//console.log($cc.find("button"));
|
32
|
+
$cc.find("button").on('click', function () {
|
33
|
+
if ($(this).attr('id') == "submit_building_link") {
|
34
|
+
_map.link_building();
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}, 1000);
|
38
|
+
|
39
|
+
$link_show_modal_window.click();
|
40
|
+
|
41
|
+
};
|
42
|
+
|
43
|
+
var fetch_free_buildings = function () {
|
44
|
+
$.ajax({
|
45
|
+
url:'/ajax/fetch_unlinked_buildings',
|
46
|
+
type:'POST',
|
47
|
+
data: {building_id:"building_id"},
|
48
|
+
dataType:'script'
|
49
|
+
}).done(fetch_free_buildings_done);
|
50
|
+
};
|
51
|
+
var fetch_free_buildings_done = function (data, result) {
|
52
|
+
_map.save_preloader_klass.hide();
|
53
|
+
show_modal_window();
|
54
|
+
};
|
55
|
+
|
56
|
+
var $link_show_modal_window = null;
|
57
|
+
|
58
|
+
_this.onClick = function (e) {
|
59
|
+
if (_this.el.hasClass('disabled')) return;
|
60
|
+
e.preventDefault();
|
61
|
+
|
62
|
+
console.log("<BuildingLinkButton.click>");
|
63
|
+
|
64
|
+
_map.save_preloader_klass.show();
|
65
|
+
|
66
|
+
fetch_free_buildings();
|
67
|
+
};
|
68
|
+
|
69
|
+
_this.init = function (button_css_selector, link_to_map) {
|
70
|
+
_map = link_to_map;
|
71
|
+
_this.el = $(button_css_selector);
|
72
|
+
_this.el.on('click', _this.onClick);
|
73
|
+
_this.hide();
|
74
|
+
|
75
|
+
// найдем кнопку, клик по которой покажет окно [_modal_window.html.erb]
|
76
|
+
$link_show_modal_window = $('.show_modal_window');
|
77
|
+
|
78
|
+
//console.log("<BuildingLinkButton.init>");
|
79
|
+
//console.log(this.el);
|
80
|
+
};
|
81
|
+
|
82
|
+
_this.hide = function () {
|
83
|
+
_this.el.css('display','none');
|
84
|
+
};
|
85
|
+
|
86
|
+
_this.show = function () {
|
87
|
+
console.log("<BuildingLinkButton.show>");
|
88
|
+
_this.el.css('display','block');
|
89
|
+
};
|
90
|
+
|
91
|
+
}
|
@@ -200,6 +200,7 @@ function Building() {
|
|
200
200
|
_map = link_to_map;
|
201
201
|
_options = options;
|
202
202
|
_this.options = options;
|
203
|
+
_this.id = options["id"];
|
203
204
|
|
204
205
|
// [56dfaw1]
|
205
206
|
for (var i=0; i<_this.options.coords.length; i++) {
|
@@ -235,6 +236,7 @@ function Building() {
|
|
235
236
|
_map.svgRemoveAllNodes();
|
236
237
|
|
237
238
|
_map.current_building = _this;
|
239
|
+
//console.log("<Building.enter> id: " + _this.id);
|
238
240
|
_map.mark_virgin = false;
|
239
241
|
|
240
242
|
};
|
@@ -225,6 +225,10 @@ var clog = function () {
|
|
225
225
|
self.area_link_button_klass = new AreaLinkButton();
|
226
226
|
self.area_link_button_klass.init('.mapplic-area-link-button', self);
|
227
227
|
|
228
|
+
// при клике на эту кнопку произойдет показ модального окна, в котором можно будет указать здание, соответствующее полигону
|
229
|
+
self.building_link_button_klass = new BuildingLinkButton();
|
230
|
+
self.building_link_button_klass.init('.mapplic-building-link-button', self);
|
231
|
+
|
228
232
|
$('[data-toggle="tooltip"]').tooltip();
|
229
233
|
|
230
234
|
});
|
@@ -951,6 +955,8 @@ var clog = function () {
|
|
951
955
|
|
952
956
|
// показать инфо о здании
|
953
957
|
self.showBuildingInfo = function (building_hash) {
|
958
|
+
console.log("<main.showBuildingInfo> id = " + building_hash.id);
|
959
|
+
|
954
960
|
//"building_hash": {
|
955
961
|
// "id": 2,
|
956
962
|
// "title": "Здание 2",
|
@@ -964,16 +970,20 @@ var clog = function () {
|
|
964
970
|
// "price": "от 155 руб/кв.м в месяц"
|
965
971
|
// }
|
966
972
|
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
$building_info.find("#" + p).find('span').text(v);
|
973
|
-
}
|
973
|
+
if (building_hash.id == undefined) {
|
974
|
+
$building_info.css('display','none');
|
975
|
+
} else {
|
976
|
+
$building_info.css('display','block');
|
977
|
+
$building_info.find("h2").text(building_hash["title"]);
|
974
978
|
|
975
|
-
|
979
|
+
var v;
|
980
|
+
for (var p in building_hash["props"]) {
|
981
|
+
v = building_hash["props"][p];
|
982
|
+
$building_info.find("#" + p).find('span').text(v);
|
983
|
+
}
|
976
984
|
|
985
|
+
$building_info.find("#square_free").css('height', 'auto');
|
986
|
+
}
|
977
987
|
};
|
978
988
|
|
979
989
|
// показать инфо о просматриваемой площади
|
@@ -1031,17 +1041,24 @@ var clog = function () {
|
|
1031
1041
|
// выбранный в окне _modal_window.html.erb
|
1032
1042
|
self.link_area = function () {
|
1033
1043
|
|
1044
|
+
// фиксируем компоненты модального окна
|
1034
1045
|
var $m = $('#modal_window');
|
1035
1046
|
var $b = $m.find('.modal-footer').find('.btn');
|
1036
1047
|
var $s = $m.find('select');
|
1037
1048
|
|
1049
|
+
// извлекаем значения
|
1038
1050
|
var rent_area_id = $s.val();
|
1039
1051
|
var map_area_id = self.current_area.id;
|
1040
1052
|
console.log("<Map.link_area> rent_area_id = " + rent_area_id + "; map_area_id = " + map_area_id);
|
1041
1053
|
|
1054
|
+
// нажимаем кнопку "закрыть"
|
1042
1055
|
$b.click();
|
1056
|
+
|
1057
|
+
// показываем прелоадер
|
1043
1058
|
self.save_preloader_klass.show();
|
1044
1059
|
|
1060
|
+
// отправляем запрос на сервер
|
1061
|
+
// TODO_MY:: реализовать обработчик ошибок
|
1045
1062
|
$.ajax({
|
1046
1063
|
url:'/ajax/link_area',
|
1047
1064
|
type:'POST',
|
@@ -1055,6 +1072,44 @@ var clog = function () {
|
|
1055
1072
|
self.data = data["updated_locations_json"];
|
1056
1073
|
});
|
1057
1074
|
|
1075
|
+
};
|
1076
|
+
|
1077
|
+
// взять C80Map::current_building и назначить ему Rent::building.id,
|
1078
|
+
// выбранный в окне _modal_window.html.erb
|
1079
|
+
self.link_building = function () {
|
1080
|
+
console.log('<Map.link_building> ');
|
1081
|
+
|
1082
|
+
// фиксируем компоненты модального окна
|
1083
|
+
var $m = $('#modal_window');
|
1084
|
+
var $b = $m.find('.modal-footer').find('.btn');
|
1085
|
+
var $s = $m.find('select');
|
1086
|
+
|
1087
|
+
// извлекаем значения
|
1088
|
+
var rent_building_id = $s.val();
|
1089
|
+
var map_building_id = self.current_building.id;
|
1090
|
+
console.log("<Map.link_area> rent_building_id = " + rent_building_id + "; map_building_id = " + map_building_id);
|
1091
|
+
|
1092
|
+
// нажимаем кнопку "закрыть"
|
1093
|
+
$b.click();
|
1094
|
+
|
1095
|
+
// показываем прелоадер
|
1096
|
+
self.save_preloader_klass.show();
|
1097
|
+
|
1098
|
+
// отправляем запрос на сервер
|
1099
|
+
// TODO_MY:: реализовать обработчик ошибок
|
1100
|
+
$.ajax({
|
1101
|
+
url:'/ajax/link_building',
|
1102
|
+
type:'POST',
|
1103
|
+
data: {
|
1104
|
+
rent_building_id: rent_building_id,
|
1105
|
+
map_building_id: map_building_id
|
1106
|
+
},
|
1107
|
+
dataType:"json"
|
1108
|
+
}).done(function (data, result) {
|
1109
|
+
self.save_preloader_klass.hide();
|
1110
|
+
self.data = data["updated_locations_json"];
|
1111
|
+
});
|
1112
|
+
|
1058
1113
|
}
|
1059
1114
|
|
1060
1115
|
};
|
@@ -186,6 +186,13 @@ function StateController() {
|
|
186
186
|
|
187
187
|
// вошли в здание
|
188
188
|
case "view_building":
|
189
|
+
|
190
|
+
// покажем кнопку "обратно на карту"
|
191
|
+
_map.back_to_map_button_klass.show();
|
192
|
+
|
193
|
+
// скроем кнопку "связать здание с полигоном"
|
194
|
+
_map.building_link_button_klass.hide();
|
195
|
+
|
189
196
|
// спрячем надписи "цена за метр" и адрес с телефоном
|
190
197
|
_this.left_side.css("top", -300);
|
191
198
|
_this.right_side.css("top", -300);
|
@@ -194,7 +201,6 @@ function StateController() {
|
|
194
201
|
_this.svg_overlay.css('display', 'block');
|
195
202
|
|
196
203
|
_this.building_info.css("top", _this.building_info.data("init"));
|
197
|
-
_map.back_to_map_button_klass.show();
|
198
204
|
_this.masked.addClass('hiddn');
|
199
205
|
|
200
206
|
_this.area_order_button.css('display', 'none');
|
@@ -215,6 +221,9 @@ function StateController() {
|
|
215
221
|
// спрячем кнопку "обратно на карту"
|
216
222
|
_map.back_to_map_button_klass.hide();
|
217
223
|
|
224
|
+
// покажем кнопку "связать здание с полигоном"
|
225
|
+
_map.building_link_button_klass.show();
|
226
|
+
|
218
227
|
// т.к. этот слой используется испключительно в помощь при рисовании обводки площадей
|
219
228
|
// и перехватывает клики при dnd, то тут он нам не нужен
|
220
229
|
_this.svg_overlay.css('display', 'none');
|
@@ -263,6 +272,7 @@ function StateController() {
|
|
263
272
|
_this.area_order_button.css('display', 'block');
|
264
273
|
_map.edit_button_klass.setState('view_area', true); // [a1x7]
|
265
274
|
|
275
|
+
// скроем кнопку "связать площадь с полигоном"
|
266
276
|
_map.area_link_button_klass.hide();
|
267
277
|
|
268
278
|
OpacityButtonsUtils.hide(_this.new_button);
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module C80Map
|
2
2
|
class Building < ActiveRecord::Base
|
3
3
|
has_many :areas, :class_name => 'C80Map::Area', :dependent => :destroy
|
4
|
+
belongs_to :building_representator, :polymorphic => true
|
4
5
|
validates :coords, uniqueness: true
|
5
6
|
after_save :update_json
|
6
7
|
mount_uploader :img_bg, C80Map::BuildingImageUploader
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module C80Map
|
2
|
+
|
3
|
+
module BuildingRepresentator
|
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_building_representator
|
20
|
+
class_eval do
|
21
|
+
|
22
|
+
has_many :map_buildings, :as => :building_representator, :class_name => 'C80Map::Building', :dependent => :destroy
|
23
|
+
after_save :update_json
|
24
|
+
|
25
|
+
def self.unlinked_buildings
|
26
|
+
res = []
|
27
|
+
self.all.each do |building|
|
28
|
+
# if building.map_buildings.count == 0
|
29
|
+
res << building
|
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
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
ActiveRecord::Base.send :include, C80Map::BuildingRepresentator
|
@@ -20,6 +20,7 @@ module C80Map
|
|
20
20
|
b.areas.each do |area|
|
21
21
|
# Rails.logger.debug "<MapJson.update_json> area #{area}"
|
22
22
|
|
23
|
+
# соберём хэш привязанной к полигону площади
|
23
24
|
har = {}
|
24
25
|
if area.area_representator.present?
|
25
26
|
har = area.area_representator.to_hash
|
@@ -48,23 +49,31 @@ module C80Map
|
|
48
49
|
childs << ab
|
49
50
|
end
|
50
51
|
|
52
|
+
# соберём хэш привязанного к полигону здания
|
53
|
+
hbu = {}
|
54
|
+
if b.building_representator.present?
|
55
|
+
hbu = b.building_representator.to_hash
|
56
|
+
# har["is_free"] = area.area_representator.is_free?
|
57
|
+
end
|
58
|
+
|
51
59
|
ob = {
|
52
60
|
id: b.id,
|
53
61
|
object_type: 'building',
|
54
62
|
coords: b.coords.split(","),
|
55
|
-
building_hash:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
63
|
+
building_hash: hbu,
|
64
|
+
# building_hash: {
|
65
|
+
# id: 2,
|
66
|
+
# title: "Здание 2",
|
67
|
+
# props: {
|
68
|
+
# square: "1234 кв.м.",
|
69
|
+
# square_free: "124 кв. м",
|
70
|
+
# floor_height: "6 кв. м",
|
71
|
+
# column_step: "2 м",
|
72
|
+
# gate_type: "рaспашные",
|
73
|
+
# communications: "Интернет, электричество, водоснабжение",
|
74
|
+
# price: "от 155 руб/кв.м в месяц"
|
75
|
+
# }
|
76
|
+
# },
|
68
77
|
img: {
|
69
78
|
bg: {
|
70
79
|
src: b.img_bg.url
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class AddBuildingRepresentatorToC80MapBuildings < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_reference :c80_map_buildings, :building_representator, index: true
|
4
|
+
add_column :c80_map_buildings, :building_representator_type, :string, :default => 'Rent::Building'
|
5
|
+
end
|
6
|
+
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.12
|
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-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- app/admin/c80_map/buildings.rb
|
70
70
|
- app/admin/c80_map/settings.rb
|
71
71
|
- app/assets/javascripts/buttons/admin_buttons/button_area_link.js
|
72
|
+
- app/assets/javascripts/buttons/admin_buttons/button_building_link.js
|
72
73
|
- app/assets/javascripts/buttons/admin_buttons/button_cancel_create.js
|
73
74
|
- app/assets/javascripts/buttons/admin_buttons/button_cancel_remove.js
|
74
75
|
- app/assets/javascripts/buttons/admin_buttons/button_complete_create.js
|
@@ -102,6 +103,7 @@ files:
|
|
102
103
|
- app/models/c80_map/area.rb
|
103
104
|
- app/models/c80_map/area_representator.rb
|
104
105
|
- app/models/c80_map/building.rb
|
106
|
+
- app/models/c80_map/building_representator.rb
|
105
107
|
- app/models/c80_map/map_json.rb
|
106
108
|
- app/models/c80_map/setting.rb
|
107
109
|
- app/uploaders/c80_map/building_image_uploader.rb
|
@@ -117,6 +119,7 @@ files:
|
|
117
119
|
- db/migrate/20160617130000_create_c80_map_settings.rb
|
118
120
|
- db/migrate/20160620040217_create_c80_map_buildings.rb
|
119
121
|
- db/migrate/20160620040225_create_c80_map_areas.rb
|
122
|
+
- db/migrate/20160901153030_add_building_representator_to_c80_map_buildings.rb
|
120
123
|
- db/seeds/801_fill_map_settings.rb
|
121
124
|
- lib/c80_map.rb
|
122
125
|
- lib/c80_map/engine.rb
|