c80_map_floors 0.1.0.7 → 0.1.0.8
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 +29 -7
- data/app/assets/javascripts/buttons/admin_buttons/button_building_link.js +19 -1
- data/app/assets/javascripts/buttons/admin_buttons/button_edit.js +17 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_floor_link.js +6 -5
- data/app/assets/javascripts/buttons/admin_buttons/button_save.js +1 -1
- data/app/assets/javascripts/c80_map_floors.js.coffee +8 -5
- data/app/assets/javascripts/map_objects/building.js +32 -3
- data/app/assets/javascripts/src/main.js +179 -41
- data/app/assets/javascripts/src/state_controller.js +16 -1
- data/app/assets/javascripts/svg_elements/admin_building_label.js +61 -0
- data/app/assets/javascripts/svg_elements/polygon.js +25 -8
- data/app/assets/stylesheets/c80_map_floors.scss +6 -2
- data/app/assets/stylesheets/map.scss +24 -11
- data/app/assets/stylesheets/view/modal_window.scss +5 -0
- data/app/controllers/c80_map_floors/ajax_controller.rb +59 -18
- data/app/models/c80_map_floors/area_representator.rb +13 -2
- data/app/models/c80_map_floors/building_representator.rb +13 -0
- data/app/models/c80_map_floors/floor_representator.rb +20 -10
- data/app/views/c80_map_floors/ajax/fetch_unlinked_areas.js.erb +4 -2
- data/app/views/c80_map_floors/ajax/fetch_unlinked_buildings.js.erb +2 -0
- data/app/views/c80_map_floors/ajax/fetch_unlinked_floors.js.erb +3 -1
- data/app/views/c80_map_floors/ajax/shared/_select_list_unlinked_areas.html.erb +6 -4
- data/app/views/c80_map_floors/ajax/shared/_select_list_unlinked_buildings.html.erb +9 -8
- data/app/views/c80_map_floors/ajax/shared/_select_list_unlinked_floors.html.erb +8 -3
- data/config/routes.rb +7 -0
- data/lib/c80_map_floors/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c7da30384334272686359b100a6f88785e8bf3
|
4
|
+
data.tar.gz: 48d8272466a5594ea7b10f87fa4769ef8cf36b36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1459b0de09e7f77bbe55758537bea23b6b00a10ee75d496f65e304e60e1120dfc6eccece12dbd52ec16c98acecc65f4af5a0004a8c38f83d9b88adb2ff416391
|
7
|
+
data.tar.gz: e68b313b3553f958e0be706cfbe568cddaccbff9bd3b1f242d400839f7fbe0e48b13af391e083fcec0786a65463b24750351a82448cc685feda12f610fc061a6
|
@@ -40,15 +40,24 @@ function AreaLinkButton() {
|
|
40
40
|
|
41
41
|
};
|
42
42
|
|
43
|
-
|
43
|
+
/** функция, запрашивающая с сервера Площади (указанного Этажа).
|
44
|
+
*
|
45
|
+
* @param sfid - ID Этажа, которому должны принадлежать Площади
|
46
|
+
*/
|
47
|
+
var fetch_areas_by_floor = function (sfid) {
|
48
|
+
console.log('<ButtonAreaLink.fetch_areas_by_floor> ');
|
49
|
+
|
44
50
|
$.ajax({
|
45
51
|
url:'/ajax/fetch_unlinked_areas',
|
46
52
|
type:'POST',
|
47
|
-
data: {
|
53
|
+
data: {
|
54
|
+
sfloor_id: sfid
|
55
|
+
},
|
48
56
|
dataType:'script'
|
49
|
-
}).done(
|
57
|
+
}).done(fetch_areas_by_floor_done);
|
58
|
+
|
50
59
|
};
|
51
|
-
var
|
60
|
+
var fetch_areas_by_floor_done = function (data, result) {
|
52
61
|
_map.save_preloader_klass.hide();
|
53
62
|
show_modal_window();
|
54
63
|
};
|
@@ -61,9 +70,22 @@ function AreaLinkButton() {
|
|
61
70
|
|
62
71
|
//console.log("<AreaLinkButton.click>");
|
63
72
|
|
64
|
-
_map.save_preloader_klass.show();
|
65
|
-
|
66
|
-
|
73
|
+
//_map.save_preloader_klass.show();
|
74
|
+
//fetch_areas_by_floor();
|
75
|
+
|
76
|
+
// сначала пробуем добраться до данных Этажа картинки этажа
|
77
|
+
var floor_data = _map.current_building.json_current_floor()["data"];
|
78
|
+
|
79
|
+
if (floor_data == null || floor_data == undefined) {
|
80
|
+
alert('[ERROR] Перед тем, как назначать Площадь, необходимо назначить Этаж.');
|
81
|
+
} else {
|
82
|
+
// ID Этажа, которому должны принадлежать Площади, которые надо вывести в модальном окне
|
83
|
+
var sfid = floor_data["id"];
|
84
|
+
console.log("<ButtonAreaLink.onClick> Нажали кнопку 'Связать Площадь', запрашиваем Площади Этажа sfid = " + sfid);
|
85
|
+
_map.save_preloader_klass.show();
|
86
|
+
fetch_areas_by_floor(sfid);
|
87
|
+
}
|
88
|
+
|
67
89
|
};
|
68
90
|
|
69
91
|
_this.init = function (button_css_selector, link_to_map) {
|
@@ -56,7 +56,7 @@ function BuildingLinkButton() {
|
|
56
56
|
var $link_show_modal_window = null;
|
57
57
|
|
58
58
|
_this.onClick = function (e) {
|
59
|
-
if (_this.el.hasClass('disabled')) return;
|
59
|
+
if (_this.el.hasClass('mapplic-disabled')) return;
|
60
60
|
e.preventDefault();
|
61
61
|
|
62
62
|
//console.log("<BuildingLinkButton.click>");
|
@@ -83,9 +83,27 @@ function BuildingLinkButton() {
|
|
83
83
|
_this.el.css('display','none');
|
84
84
|
};
|
85
85
|
|
86
|
+
// При входе в режим "Редактирование Карты": кнопка должна быть неактивна, если не выбрано ни одного полигона здания.
|
87
|
+
// также этот публичный метод вызывается, когда кликаем по полигонам Зданий в режиме редактирования (переключаемся между полигонами)
|
88
|
+
_this.en_check = function () {
|
89
|
+
console.log("<en_check> [breakpoint]");
|
90
|
+
|
91
|
+
//check
|
92
|
+
var mark_dirty = _map.selected_area != null;
|
93
|
+
|
94
|
+
// enable
|
95
|
+
if (mark_dirty) {
|
96
|
+
_this.el.removeClass('mapplic-disabled');
|
97
|
+
} else {
|
98
|
+
_this.el.addClass('mapplic-disabled');
|
99
|
+
}
|
100
|
+
|
101
|
+
};
|
102
|
+
|
86
103
|
_this.show = function () {
|
87
104
|
//console.log("<BuildingLinkButton.show>");
|
88
105
|
_this.el.css('display','block');
|
106
|
+
_this.en_check();
|
89
107
|
};
|
90
108
|
|
91
109
|
}
|
@@ -70,10 +70,27 @@ function EditButton() {
|
|
70
70
|
var mark_restore_svg_overlay = false;
|
71
71
|
|
72
72
|
switch (_this.state) {
|
73
|
+
|
74
|
+
// переходим в режим "просмотра карты" из режима "редактирования карты"
|
73
75
|
case 'editing':
|
74
76
|
_this.setState('viewing');
|
77
|
+
|
78
|
+
//<editor-fold desc="// уходя из режима редактирования, чистим кое-какие переменные, связанные с назначением Зданий полигонам">
|
79
|
+
// сбросим css класс (возможно выбранного полигона)
|
80
|
+
console.log('<ButtonEdit.onClick> set viewing state, [breakpoint].');
|
81
|
+
|
82
|
+
if (_map.selected_area != undefined) {
|
83
|
+
_map.selected_area.deselect();
|
84
|
+
_map.selected_area = null;
|
85
|
+
}
|
86
|
+
|
87
|
+
// сбросим значение переменной current_building
|
88
|
+
_map.current_building = null;
|
89
|
+
//</editor-fold>
|
90
|
+
|
75
91
|
break;
|
76
92
|
|
93
|
+
// переходим в режим "редактирования карты" из режима "просмотра карты"
|
77
94
|
case 'viewing':
|
78
95
|
_this.setState('editing');
|
79
96
|
break;
|
@@ -37,11 +37,12 @@ function FloorLinkButton() {
|
|
37
37
|
|
38
38
|
// клик по кнопке "применить" вызовет _map.link_floor()
|
39
39
|
setTimeout(function () {
|
40
|
-
//console.log($cc.find("button"));
|
41
|
-
$cc.find("button")
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
//console.log($cc.find("button#submit_floor_link"));
|
41
|
+
var b = $cc.find("button#submit_floor_link");
|
42
|
+
//console.log('<breakpoint>');
|
43
|
+
b.on('click', function () {
|
44
|
+
//console.log('<ButtonFloorLink.submit_floor_link> CLICK');
|
45
|
+
_map.link_floor();
|
45
46
|
});
|
46
47
|
}, 1000);
|
47
48
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
#= require history_jquery
|
2
|
-
#= require bootstrap/transition
|
3
|
-
# require bootstrap/modal # Bootstrap Modal immediately disappearing: http://stackoverflow.com/a/13670437 # т.к. 101км это первый проект и там уже много нахуеверчено, в том числе: bootstrap.min.js лежит в папке lib/, то эту строку комментируем (только для 101km)
|
4
2
|
#= require bootstrap/tooltip
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
|
4
|
+
#-> Уехали в host app (в частности: в s101km)
|
5
|
+
# require bootstrap/modal # Bootstrap Modal immediately disappearing: http://stackoverflow.com/a/13670437 # т.к. 101км это первый проект и там уже много нахуеверчено, в том числе: bootstrap.min.js лежит в папке lib/, то эту строку комментируем (только для 101km)
|
6
|
+
# require bootstrap/transition
|
7
|
+
# require bootstrap/alert
|
8
|
+
# require bootstrap/dropdown
|
9
|
+
# require bootstrap-select
|
8
10
|
|
9
11
|
#= require_tree ./lib
|
10
12
|
|
@@ -12,6 +14,7 @@
|
|
12
14
|
#= require ./svg_elements/polygon.js
|
13
15
|
#= require ./svg_elements/area_label.js
|
14
16
|
#= require ./svg_elements/building_label.js
|
17
|
+
#= require ./svg_elements/admin_building_label.js
|
15
18
|
|
16
19
|
#= require_tree ./events
|
17
20
|
#= require_tree ./map_objects
|
@@ -27,6 +27,9 @@ function Building() {
|
|
27
27
|
// если вошли в какой-то этаж - эта переменная будет хранить ссылку на объект с данными полигона Этажа из locations.json
|
28
28
|
var _json_current_floor = null;
|
29
29
|
|
30
|
+
_this._label = null;
|
31
|
+
_this._admin_label = null;
|
32
|
+
|
30
33
|
var _zoomToMe = function () {
|
31
34
|
|
32
35
|
/* рассчитаем масштаб, при котором можно вписать прямоугольник дома в прямоугольник рабочей области */
|
@@ -148,7 +151,7 @@ function Building() {
|
|
148
151
|
|
149
152
|
};
|
150
153
|
|
151
|
-
var
|
154
|
+
var _process_floors_data = function () {
|
152
155
|
|
153
156
|
if (_options["floors"] != undefined && _options["floors"].length) {
|
154
157
|
_parse_floors(_options["floors"]);
|
@@ -158,6 +161,11 @@ function Building() {
|
|
158
161
|
|
159
162
|
};
|
160
163
|
|
164
|
+
/**
|
165
|
+
*
|
166
|
+
* @param options - Это C80MapFloors::MapBuilding.my_as_json
|
167
|
+
* @param link_to_map
|
168
|
+
*/
|
161
169
|
_this.init = function (options, link_to_map) {
|
162
170
|
|
163
171
|
if (options['coords'] != undefined && options['coords'].length) {
|
@@ -184,14 +192,21 @@ function Building() {
|
|
184
192
|
_this.options["id"] = Math.ceil((Math.random()*100000));
|
185
193
|
}
|
186
194
|
|
195
|
+
// создать полигон здания и прицепить в список отображения карты [в svg слой (т.к. is_overlay = false)]
|
187
196
|
_polygon = Polygon.createFromSaved(options, false, _map);
|
188
197
|
_polygon.building = _this;
|
189
198
|
|
190
199
|
_this._calcBBox();
|
191
200
|
|
192
|
-
// подпись над зданием - сколько свободных площадей
|
201
|
+
// TODO:: подпись над зданием - сколько свободных площадей
|
193
202
|
_this._label = new BuildingLabel(options, _map);
|
194
203
|
|
204
|
+
// подпись над полигоном показываем только админам
|
205
|
+
// UPD: не прокатит, т.к. здания инициализируются ДО того, как приходит ajax/map_edit_buttons, где IS_ADMIN=true
|
206
|
+
//if (IS_ADMIN) {
|
207
|
+
// _this._admin_label = new AdminBuildingLabel(options, _map);
|
208
|
+
//}
|
209
|
+
|
195
210
|
}
|
196
211
|
};
|
197
212
|
|
@@ -207,7 +222,7 @@ function Building() {
|
|
207
222
|
setTimeout(function () {
|
208
223
|
|
209
224
|
// запустим внутренний механизм парсинга этажей и их отрисовки
|
210
|
-
|
225
|
+
_process_floors_data();
|
211
226
|
|
212
227
|
// если у ПолигонаЗдания есть ПолигоныЭтажей - войдем в 1й этаж
|
213
228
|
if (fCalcObjSize(_map_floors_hash) > 0) {
|
@@ -365,4 +380,18 @@ function Building() {
|
|
365
380
|
return result;
|
366
381
|
};
|
367
382
|
|
383
|
+
// показать/скрыть админские лейблы
|
384
|
+
this.admin_label_show = function () {
|
385
|
+
if (_this._admin_label == null) {
|
386
|
+
console.log('<Building.admin_label_show> Показать админский лейбл полигона Здания id=' + _this.id);
|
387
|
+
_this._admin_label = new AdminBuildingLabel(_options, _map, {cx:_cx, cy:_cy});
|
388
|
+
}
|
389
|
+
};
|
390
|
+
this.admin_label_hide = function () {
|
391
|
+
if (_this._admin_label != null) {
|
392
|
+
console.log('<Building.admin_label_hide> Уничтожить админский лейбл.');
|
393
|
+
_this._admin_label.destroy();
|
394
|
+
_this._admin_label = null;
|
395
|
+
}
|
396
|
+
};
|
368
397
|
}
|
@@ -392,17 +392,23 @@ var InitMap = function (params) {
|
|
392
392
|
return false;
|
393
393
|
}; // IE drag fix
|
394
394
|
|
395
|
+
/* после запуска приложения - всегда слушаем нажатия мышью на полигоны и вершины */
|
395
396
|
function onSvgMousedown(e) {
|
396
397
|
|
397
398
|
//#-> Убрал 'edit_building', т.к. мы не можем ничего нарисовать в этом режиме - картинки этажей добавляются через админку
|
398
399
|
if (self.mode === 'editing' || self.mode === 'edit_area' || self.mode === 'edit_floor') { // || self.mode === "edit_building"
|
399
400
|
if (e.target.parentNode.tagName === 'g') {
|
400
|
-
console.log("<onSvgMousedown>
|
401
|
+
console.log("<onSvgMousedown> Нажали мышью на полигон или вершину.");
|
401
402
|
//console.log(e.pageX);
|
402
403
|
//console.log("<mouseDown> e.target.parentNode.tagName = " + e.target.parentNode.tagName);
|
403
404
|
//console.log(e.target);
|
404
405
|
//info.unload();
|
405
406
|
|
407
|
+
// если ДО этого нажатия уже была "выбранная" область - "снимем" с неё css класс
|
408
|
+
if (self.selected_area != null && self.selected_area != undefined) {
|
409
|
+
self.selected_area.deselect();
|
410
|
+
}
|
411
|
+
|
406
412
|
// запомним ссылку на "выбранную" область
|
407
413
|
self.selected_area = e.target.parentNode.obj;
|
408
414
|
|
@@ -417,27 +423,44 @@ var InitMap = function (params) {
|
|
417
423
|
'y': e.pageY
|
418
424
|
};
|
419
425
|
|
420
|
-
|
426
|
+
//#-> a) Определяем, что хотим подвинуть мышкой методом drag-n-drop
|
427
|
+
|
428
|
+
// если хотим подвинуть вершину
|
421
429
|
if (utils.hasClass(e.target, 'helper')) {
|
422
430
|
var helper = e.target;
|
423
|
-
//console.log("<mouseDown> helper.action = ");
|
424
|
-
//console.log(helper.action);
|
425
431
|
self.edit_type = helper.action; // pointMove
|
426
432
|
|
427
433
|
if (helper.n >= 0) { // if typeof selected_area == polygon
|
428
434
|
self.selected_area.selected_point = helper.n;
|
429
435
|
}
|
430
436
|
|
431
|
-
|
432
|
-
|
433
|
-
.addEvent(self.el[0], 'mouseup', self.
|
434
|
-
}
|
437
|
+
//#-> b) После этого вешаем слушатели
|
438
|
+
self.addEvent(self.el[0], 'mousemove', self.onMouseMove)
|
439
|
+
.addEvent(self.el[0], 'mouseup', self.onMouseUp);
|
435
440
|
|
441
|
+
}
|
442
|
+
// если хотим подвинуть фигуру
|
443
|
+
//#-> отменили dnd фигур 20161227
|
436
444
|
else if (e.target.tagName === 'rect' || e.target.tagName === 'circle' || e.target.tagName === 'polygon') {
|
437
|
-
self.edit_type = 'move';
|
438
|
-
|
439
|
-
|
445
|
+
//self.edit_type = 'move';
|
446
|
+
|
447
|
+
// если это полигон здания - фиксируем его
|
448
|
+
var selected_area_building = self.selected_area.building;
|
449
|
+
if (selected_area_building != undefined && selected_area_building != null) {
|
450
|
+
self.current_building = selected_area_building; // фиксируем полигон здания в режиме "редактирования карты" при клике по полигону на карте
|
451
|
+
console.log("<self.onSvgMousedown> Это не Drag-n-drop, а обычный клик по полигону Здания c id=" + self.current_building.options["id"]);
|
452
|
+
|
453
|
+
// включим кнопку "связать Здание"
|
454
|
+
self.building_link_button_klass.en_check();
|
455
|
+
|
456
|
+
} else {
|
457
|
+
console.log("<self.onSvgMousedown> Это не Drag-n-drop, а обычный клик по фигуре.");
|
458
|
+
}
|
459
|
+
|
440
460
|
}
|
461
|
+
|
462
|
+
// когда реализуем корректный механизм dnd фигур, тут должен очутиться (b)
|
463
|
+
|
441
464
|
} else {
|
442
465
|
//app.deselectAll();
|
443
466
|
//info.unload();
|
@@ -452,7 +475,7 @@ var InitMap = function (params) {
|
|
452
475
|
// Drag & drop
|
453
476
|
function onDragNdrop(event) {
|
454
477
|
//console.log("<mousedown> edit_type = " + self.edit_type);
|
455
|
-
console.log("<mousedown> mode = " + self.mode + " dnd_enable = " + self.o.dnd_enable);
|
478
|
+
console.log("<mousedown> mode = " + self.mode + ", dnd_enable = " + self.o.dnd_enable + ', edit_type = ' + self.edit_type);
|
456
479
|
//console.log(event);
|
457
480
|
|
458
481
|
// если в данный момент не редактируем фигуру (т.е. не двигаем вершину фигуры)
|
@@ -506,7 +529,7 @@ var InitMap = function (params) {
|
|
506
529
|
|
507
530
|
console.log("<mouseup> Отпустили мышь после клика, текущий режим карты: mode = " + self.mode);
|
508
531
|
|
509
|
-
// исключаем случайный dnd дрожащей рукой
|
532
|
+
// исключаем случайный dnd дрожащей рукой [xdnd?]
|
510
533
|
var dx = map.data('startX') - map.data('lastX');
|
511
534
|
var dy = map.data('startY') - map.data('lastY');
|
512
535
|
var delta = Math.sqrt(dx*dx + dy*dy);
|
@@ -533,7 +556,7 @@ var InitMap = function (params) {
|
|
533
556
|
if (p.obj && p.obj.building) {
|
534
557
|
var building = p.obj.building;
|
535
558
|
console.log("<mouseup> Текущий mode карты 'viewing' => Входим в здание (а потом building сам решит, входить ли на 1й этаж).");
|
536
|
-
self.current_building = building;
|
559
|
+
self.current_building = building; /* когда вошли в здание, определили переменную */
|
537
560
|
building.enter();
|
538
561
|
}
|
539
562
|
|
@@ -933,21 +956,62 @@ var InitMap = function (params) {
|
|
933
956
|
|
934
957
|
};
|
935
958
|
|
936
|
-
|
959
|
+
//<editor-fold desc="// двигаем фигуру мышкой методом drag-n-drop">
|
960
|
+
self.onMouseMove = function (e) { // мышь нажата и двигается
|
937
961
|
|
938
|
-
//console.log("<Polygon.prototype.
|
939
|
-
//console.log("<Polygon.prototype.
|
962
|
+
//console.log("<Polygon.prototype.onMouseMove> _s_f = " + _s_f);
|
963
|
+
//console.log("<Polygon.prototype.onMouseMove> e = ");
|
940
964
|
//console.log(_s_f);
|
941
965
|
//console.log(e.pageX);
|
942
966
|
|
943
967
|
var selected_area = self.selected_area;
|
944
968
|
var edit_type = self.edit_type;
|
945
|
-
//console.log("<Polygon.prototype.
|
969
|
+
//console.log("<Polygon.prototype.onMouseMove> edit_type = " + edit_type);
|
946
970
|
|
947
971
|
selected_area.dynamicEdit(selected_area[edit_type](e.pageX - selected_area.delta.x, e.pageY - selected_area.delta.y));
|
948
972
|
selected_area.delta.x = e.pageX;
|
949
973
|
selected_area.delta.y = e.pageY;
|
950
974
|
};
|
975
|
+
self.onMouseUp = function (e) { // отпустили мышь (другими словами - закончили drag'n'drop)
|
976
|
+
console.log("<self.onMouseUp> [for_breakpoint] Отпустили мышь.");
|
977
|
+
|
978
|
+
var _s_f = self.selected_area;
|
979
|
+
var edit_type = self.edit_type;
|
980
|
+
|
981
|
+
//#-> определим, был ли drag-n-drop вообще? Код работает неверно, поэтому и закомментирован
|
982
|
+
|
983
|
+
var dx = e.pageX - _s_f.delta.x;
|
984
|
+
var dy = e.pageY - _s_f.delta.y;
|
985
|
+
|
986
|
+
//var delta = Math.sqrt(dx*dx + dy*dy);
|
987
|
+
//var is_real_dragging = delta > 2;
|
988
|
+
//
|
989
|
+
// Если dnd был - двигаем фигуру
|
990
|
+
//if (is_real_dragging) {
|
991
|
+
// console.log("<self.onMouseUp> Drag-n-drop detected.");
|
992
|
+
var aa = _s_f[edit_type](dx, dy);
|
993
|
+
var bb = _s_f.dynamicEdit(aa);
|
994
|
+
_s_f.setParams(bb);
|
995
|
+
//}
|
996
|
+
//
|
997
|
+
// если dnd не было - справляемся о режиме и в случае редактирования карты (т.е. когда допустимо назначать
|
998
|
+
// Здания полигонам зданий) в current_building положим ссылку на фигуру, по которой был клик
|
999
|
+
//else {
|
1000
|
+
|
1001
|
+
// если это полигон здания - фиксируем его
|
1002
|
+
//var selected_area_building = self.selected_area.building;
|
1003
|
+
//if (selected_area_building != undefined && selected_area_building != null) {
|
1004
|
+
// self.current_building = selected_area_building;
|
1005
|
+
// console.log("<self.onMouseUp> Это не Drag-n-drop, а обычный клик по полигону Здания c id=" + self.current_building.options.id);
|
1006
|
+
//} else {
|
1007
|
+
// console.log("<self.onMouseUp> Это не Drag-n-drop, а обычный клик по фигуре.");
|
1008
|
+
//}
|
1009
|
+
//console.log('<breakpoint>');
|
1010
|
+
//}
|
1011
|
+
|
1012
|
+
self.removeAllEvents();
|
1013
|
+
};
|
1014
|
+
//</editor-fold>
|
951
1015
|
|
952
1016
|
self.onDrawStop = function (e) {
|
953
1017
|
console.log("<Map.onDrawStop> Закончили рисовать.");
|
@@ -973,8 +1037,8 @@ var InitMap = function (params) {
|
|
973
1037
|
if (self.prev_mode == "edit_floor") {
|
974
1038
|
console.log("<Map.onDrawStop> Создаём Area.");
|
975
1039
|
|
976
|
-
var bo = self.current_building.options;
|
977
|
-
var fo = self.current_building.json_current_floor();
|
1040
|
+
//var bo = self.current_building.options;
|
1041
|
+
var fo = self.current_building.json_current_floor(); // когда нарисовали полигон Площади - определяем Этаж родитель
|
978
1042
|
var a = new Area();
|
979
1043
|
a.init({ coords:_n_f.params }, fo, self);
|
980
1044
|
//a.is_new = true;
|
@@ -1002,16 +1066,6 @@ var InitMap = function (params) {
|
|
1002
1066
|
self.setMode('editing');
|
1003
1067
|
};
|
1004
1068
|
|
1005
|
-
self.onEditStop = function (e) {
|
1006
|
-
//console.log("<Polygon.prototype.onEditStop>");
|
1007
|
-
var _s_f = self.selected_area,
|
1008
|
-
edit_type = self.edit_type;
|
1009
|
-
|
1010
|
-
_s_f.setParams(_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y)));
|
1011
|
-
|
1012
|
-
self.removeAllEvents();
|
1013
|
-
};
|
1014
|
-
|
1015
1069
|
self.registerJustDrownArea = function (area) {
|
1016
1070
|
self.drawn_areas.push(area);
|
1017
1071
|
};
|
@@ -1377,9 +1431,9 @@ var InitMap = function (params) {
|
|
1377
1431
|
var $s = $m.find('select');
|
1378
1432
|
|
1379
1433
|
// извлекаем значения
|
1380
|
-
var
|
1381
|
-
var
|
1382
|
-
|
1434
|
+
var area_id = $s.val();
|
1435
|
+
var apolygon_id = self.current_area.id;
|
1436
|
+
console.log("<Map.link_area> Связать Площадь area_id = " + area_id + " c полигоном apolygon_id = " + apolygon_id);
|
1383
1437
|
|
1384
1438
|
// нажимаем кнопку "закрыть"
|
1385
1439
|
$b.click();
|
@@ -1393,8 +1447,8 @@ var InitMap = function (params) {
|
|
1393
1447
|
url:'/ajax/link_area',
|
1394
1448
|
type:'POST',
|
1395
1449
|
data: {
|
1396
|
-
|
1397
|
-
|
1450
|
+
area_id: area_id,
|
1451
|
+
apolygon_id: apolygon_id
|
1398
1452
|
},
|
1399
1453
|
dataType:"json"
|
1400
1454
|
}).done(function (data, result) {
|
@@ -1404,9 +1458,40 @@ var InitMap = function (params) {
|
|
1404
1458
|
|
1405
1459
|
};
|
1406
1460
|
|
1407
|
-
// взять C80MapFloors::current_floor и назначить ему
|
1461
|
+
// взять C80MapFloors::current_floor и назначить ему sfloor_id выбранный в окне _modal_window.html.erb
|
1408
1462
|
self.link_floor = function () {
|
1409
|
-
|
1463
|
+
|
1464
|
+
// фиксируем компоненты модального окна
|
1465
|
+
var $m = $('#modal_window');
|
1466
|
+
var $b = $m.find('.modal-footer').find('.btn');
|
1467
|
+
var $s = $m.find('select');
|
1468
|
+
|
1469
|
+
// извлекаем значения
|
1470
|
+
var sfloor_id = $s.val(); // id Этажа
|
1471
|
+
var current_floor_id = self.current_building.json_current_floor()["id"]; // id Картинки Этажа (связываем Этаж с картинкой)
|
1472
|
+
console.log('<link_floor> Связать Этаж sfloor_id=' + sfloor_id + ' с Картинкой Этажа current_floor_id=' + current_floor_id + '.');
|
1473
|
+
|
1474
|
+
// нажимаем кнопку "закрыть"
|
1475
|
+
$b.click();
|
1476
|
+
|
1477
|
+
// показываем прелоадер
|
1478
|
+
self.save_preloader_klass.show();
|
1479
|
+
|
1480
|
+
// отправляем запрос на сервер
|
1481
|
+
// TODO_MY:: реализовать обработчик ошибок
|
1482
|
+
$.ajax({
|
1483
|
+
url:'/ajax/link_floor',
|
1484
|
+
type:'POST',
|
1485
|
+
data: {
|
1486
|
+
sfloor_id: sfloor_id,
|
1487
|
+
floor_id: current_floor_id
|
1488
|
+
},
|
1489
|
+
dataType:"json"
|
1490
|
+
}).done(function (data, result) {
|
1491
|
+
self.save_preloader_klass.hide();
|
1492
|
+
self.data = data["updated_locations_json"];
|
1493
|
+
});
|
1494
|
+
|
1410
1495
|
};
|
1411
1496
|
|
1412
1497
|
// взять C80MapFloors::current_building и назначить ему Rent::building.id,
|
@@ -1420,9 +1505,9 @@ var InitMap = function (params) {
|
|
1420
1505
|
var $s = $m.find('select');
|
1421
1506
|
|
1422
1507
|
// извлекаем значения
|
1423
|
-
var
|
1424
|
-
var map_building_id = self.current_building
|
1425
|
-
|
1508
|
+
var building_id = $s.val();
|
1509
|
+
var map_building_id = self.current_building["id"]; //#-> [iddqd]
|
1510
|
+
console.log("<Map.link_area> building_id = " + building_id + "; map_building_id = " + map_building_id);
|
1426
1511
|
|
1427
1512
|
// нажимаем кнопку "закрыть"
|
1428
1513
|
$b.click();
|
@@ -1436,7 +1521,7 @@ var InitMap = function (params) {
|
|
1436
1521
|
url:'/ajax/link_building',
|
1437
1522
|
type:'POST',
|
1438
1523
|
data: {
|
1439
|
-
|
1524
|
+
building_id: building_id,
|
1440
1525
|
map_building_id: map_building_id
|
1441
1526
|
},
|
1442
1527
|
dataType:"json"
|
@@ -1459,6 +1544,59 @@ var InitMap = function (params) {
|
|
1459
1544
|
|
1460
1545
|
};
|
1461
1546
|
|
1547
|
+
// показать/скрыть все админские лейблы всех полигонов, которые отображены в данный момент на экране
|
1548
|
+
self.admin_label_show_all = function () {
|
1549
|
+
if (IS_ADMIN) {
|
1550
|
+
|
1551
|
+
var s = self.svg;
|
1552
|
+
var c = s.children();
|
1553
|
+
var l = c.length;
|
1554
|
+
var i, ig;
|
1555
|
+
|
1556
|
+
console.log('<admin_label_show_all> Показать все админские лейблы полигонов в кол-ве ' + l + ' шт.');
|
1557
|
+
|
1558
|
+
for (i=0; i<l; i++) {
|
1559
|
+
ig = s[0].children[i]; // именно [0]
|
1560
|
+
//console.log(ig['obj']); // => Polygon
|
1561
|
+
if (ig != undefined) { // такое тоже бывает
|
1562
|
+
if (ig['obj'] != undefined) { //
|
1563
|
+
if (ig['obj']['building'] != undefined) { // добираемся до класса Building.js
|
1564
|
+
ig['obj']['building'].admin_label_show(); // показываем админский лейбл
|
1565
|
+
}
|
1566
|
+
}
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
}
|
1570
|
+
|
1571
|
+
}
|
1572
|
+
};
|
1573
|
+
self.admin_label_hide_all = function () {
|
1574
|
+
if (IS_ADMIN) {
|
1575
|
+
|
1576
|
+
var s = self.svg;
|
1577
|
+
var c = s.children();
|
1578
|
+
var l = c.length;
|
1579
|
+
var i, ig;
|
1580
|
+
|
1581
|
+
console.log('<admin_label_hide_all> Скрыть все админские лейблы полигонов в кол-ве ' + l + ' шт.');
|
1582
|
+
|
1583
|
+
for (i=0; i<l; i++) {
|
1584
|
+
ig = s[0].children[i]; // именно [0]
|
1585
|
+
//console.log(ig['obj']); // => Polygon
|
1586
|
+
if (ig != undefined) { // такое тоже бывает
|
1587
|
+
if (ig['obj'] != undefined) { //
|
1588
|
+
if (ig['obj']['building'] != undefined) { // добираемся до класса Building.js
|
1589
|
+
ig['obj']['building'].admin_label_hide(); // скрываем админский лейбл
|
1590
|
+
}
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
}
|
1597
|
+
};
|
1598
|
+
|
1599
|
+
|
1462
1600
|
};
|
1463
1601
|
|
1464
1602
|
// Create a jQuery plugin
|