diff --git a/api/urls.py b/api/urls.py
index ac4d6e2..7519643 100755
--- a/api/urls.py
+++ b/api/urls.py
@@ -53,3 +53,9 @@ router.register(r'work-sell-photos', WorkSellPhotoViewSet)
router.register(r'work-sells', WorkSellViewSet)
urlpatterns = router.urls
+
+# urlpatterns = [
+# url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
+# ]
+#
+# urlpatterns += router.url
\ No newline at end of file
diff --git a/api/views.py b/api/views.py
index b2fae08..b520848 100755
--- a/api/views.py
+++ b/api/views.py
@@ -3,6 +3,8 @@ from django.db.models import Q, F
from rest_framework import permissions
from rest_framework.pagination import PageNumberPagination
from rest_framework.viewsets import ModelViewSet
+from rest_framework.decorators import detail_route, list_route
+from rest_framework.response import Response
from chat.filters import MessageFilterSet, NoteFilterSet, DocumentFilterSet
from chat.models import Message, Notes, Documents, NewMessage
@@ -148,9 +150,28 @@ class MessageViewSet(ModelViewSet):
class RealtyViewSet(ModelViewSet):
- queryset = Realty.objects.all()
+ queryset = Realty.objects.filter(is_virtual=False)
serializer_class = RealtySerializer
- filter_class = RealtyFilterSet
+ # filter_class = RealtyFilterSet
+
+ # TODO: довести до ума
+ def get_queryset(self):
+ # TODO: сделать универсальный фильтр
+ queryset = self.queryset
+ user_param = self.request.query_params.get('user', None)
+ if user_param:
+ queryset = queryset.filter(user=self.request.user)
+ id_param = self.request.query_params.get('id', None)
+ if id_param:
+ queryset = queryset.filter(id=id_param)
+
+ return queryset
+
+ @list_route(methods=['get'])
+ def current_user(self, request, *args, **kwargs):
+ queryset = self.queryset.filter(user=self.request.user)
+ serialiser = self.serializer_class(queryset, many=True)
+ return Response(serialiser.data)
class BuildingClassificationViewSet(ModelViewSet):
diff --git a/archilance/settings/base.py b/archilance/settings/base.py
index 712aaeb..6b27c14 100644
--- a/archilance/settings/base.py
+++ b/archilance/settings/base.py
@@ -267,19 +267,46 @@ MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(ROOT_DIR, 'static')
MEDIA_ROOT = os.path.join(ROOT_DIR, 'media')
-STATICFILES_DIRS = (
+STATICFILES_FINDERS = [
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+ 'sass_processor.finders.CssFinder',
+]
+
+STATICFILES_DIRS = [
+ os.path.join(ROOT_DIR, 'templates'),
os.path.join(ROOT_DIR, 'assets'),
-)
+ os.path.join(ROOT_DIR, 'assets/lib/proekton-components'),
+]
-# SASS_PROCESSOR_INCLUDE_DIRS = [
-# os.path.join(ROOT_DIR, 'extra-styles/scss'),
-# os.path.join(ROOT_DIR, 'node_modules'),
-# ]
+SASS_PROCESSOR_INCLUDE_DIRS = [
+ os.path.join(ROOT_DIR, 'assets/sass'),
+]
+# print("SASS = ", SASS_PROCESSOR_INCLUDE_DIRS)
# SASS_PROCESSOR_AUTO_INCLUDE = False
-SASS_PROCESSOR_INCLUDE_FILE_PATTERN = r'^.+\.scss$'
+# SASS_PROCESSOR_INCLUDE_FILE_PATTERN = r'^.+\.sass$'
SASS_PROCESSOR_ENABLED = DEBUG
# SASS_PRECISION = 8
-SASS_PROCESSOR_ROOT = os.path.join(ROOT_DIR, 'assets')
+# SASS_OUTPUT_STYLE = 'compact'
+# SASS_PROCESSOR_ROOT = os.path.join(ROOT_DIR, 'assets')
+
+# SASS_PROCESSOR_INCLUDE_DIRS = [
+# os.path.join(ROOT_DIR, 'assets'),
+# os.path.join(ROOT_DIR, 'assets/sass/modules'),
+# os.path.join(ROOT_DIR, 'templates'),
+# ]
+
+# SASS_PROCESSOR_AUTO_INCLUDE = False
+# print(SASS_PROCESSOR_INCLUDE_DIRS)
+
+# STATICFILES_FINDERS = (
+# 'django.contrib.staticfiles.finders.FileSystemFinder',
+# 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+# 'sass_processor.finders.CssFinder',
+# # 'compressor.finders.CompressorFinder',
+# )
+
+
AUTH_USER_MODEL = 'users.User'
ACCOUNT_ACTIVATION_DAYS = 7
diff --git a/archilance/views.py b/archilance/views.py
index 0ebff19..2dab7fb 100644
--- a/archilance/views.py
+++ b/archilance/views.py
@@ -13,6 +13,7 @@ from users.models import User
from work_sell.models import Picture
+
class HomeTemplateView(BaseMixin, View):
template_name = 'home.html'
diff --git a/assets/css/extra.css b/assets/css/extra.css
index 8db01b1..f2b4ec5 100644
--- a/assets/css/extra.css
+++ b/assets/css/extra.css
@@ -247,7 +247,7 @@ li a:active .count-tab, li a:hover .count-tab {
.mainContainer {
background-repeat: repeat;
- height: 100%;
+ /*height: 100%;*/
}
.nameExecutor a:link, .nameExecutor:visited, .nameExecutor a {
diff --git a/assets/css/main.css b/assets/css/main.css
index 30d3ad6..c21edf0 100644
--- a/assets/css/main.css
+++ b/assets/css/main.css
@@ -1331,7 +1331,7 @@ footer:after {
.titleResF1, div p.titleResF1 {
font-size: 14pt;
font-family: 'Arial-MT-Regular', sans-serif;
- /*font-weight: bold;*/
+ font-weight: bold;
color: #000000;
float: left;
}
@@ -1376,35 +1376,35 @@ footer:after {
margin: 33px 0 28px 0;
}
-/*label {*/
- /*width: 23px;*/
- /*height: 23px;*/
- /*display: block;*/
- /*position: relative;*/
- /*float: left;*/
- /*margin-right: 10px;*/
-/*}*/
-
-/*input[type="checkbox"] + span {*/
- /*position: absolute;*/
- /*left: 0;*/
- /*top: 0;*/
- /*width: 100%;*/
- /*height: 100%;*/
- /*background: url('../img/check.png') no-repeat center;*/
- /*background-position: 0 0;*/
- /*background-size: cover;*/
- /*cursor: pointer;*/
-/*}*/
+label {
+ width: 23px;
+ height: 23px;
+ display: block;
+ position: relative;
+ float: left;
+ margin-right: 10px;
+}
-.sro input[type="checkbox"] {
- opacity: 0;
+input[type="checkbox"] + span {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background: url('../img/check.png') no-repeat center;
+ background-position: 0 0;
+ background-size: cover;
+ cursor: pointer;
}
-/*input[type="checkbox"]:checked + span {*/
- /*background-position: 0 -23px;*/
+/*.sro input[type="checkbox"] {*/
+ /*opacity: 0;*/
/*}*/
+input[type="checkbox"]:checked + span {
+ background-position: 0 -23px;
+}
+
.sro p {
font-size: 15px;
font-family: 'Arial-MT-Regular', sans-serif;
@@ -4514,26 +4514,26 @@ footer:after {
color: #009DD9;
}
-/*label {*/
- /*width: 23px;*/
- /*height: 23px;*/
- /*display: block;*/
- /*position: relative;*/
-/*}*/
+label {
+ width: 23px;
+ height: 23px;
+ display: block;
+ position: relative;
+}
-/*input[type="checkbox"] + span {*/
- /*position: absolute;*/
- /*left: 0;*/
- /*top: 0;*/
- /*width: 100%;*/
- /*height: 100%;*/
- /*background: url('../img/check.png') no-repeat;*/
- /*cursor: pointer;*/
-/*}*/
+input[type="checkbox"] + span {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background: url('../img/check.png') no-repeat;
+ cursor: pointer;
+}
-/*input[type="checkbox"]:checked + span {*/
- /*background-position: 0 -23px;*/
-/*}*/
+input[type="checkbox"]:checked + span {
+ background-position: 0 -23px;
+}
.text-block {
width: 100%;
diff --git a/assets/css/reset.css b/assets/css/reset.css
index 35eeb3d..3c5f193 100644
--- a/assets/css/reset.css
+++ b/assets/css/reset.css
@@ -17,17 +17,17 @@ body, code, dl, dd, form, pre {
margin: 0;
}
-/*a:link {*/
- /*color: #009;*/
-/*}*/
+a:link {
+ color: #009;
+}
a:link, a:visited, ins {
text-decoration: none;
}
-/*a:visited {*/
- /*color: #505;*/
-/*}*/
+a:visited {
+ color: #505;
+}
a:link img, a:visited img, object, fieldset, abbr, acronym {
border: none;
diff --git a/assets/img/days.png b/assets/img/days.png
new file mode 100644
index 0000000..c02cb24
Binary files /dev/null and b/assets/img/days.png differ
diff --git a/assets/img/rub.png b/assets/img/rub.png
new file mode 100644
index 0000000..7793189
Binary files /dev/null and b/assets/img/rub.png differ
diff --git a/assets/js/build/create_project.js b/assets/js/build/create_project.js
new file mode 100644
index 0000000..80d2448
--- /dev/null
+++ b/assets/js/build/create_project.js
@@ -0,0 +1,249 @@
+/******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId])
+/******/ return installedModules[moduleId].exports;
+
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ exports: {},
+/******/ id: moduleId,
+/******/ loaded: false
+/******/ };
+
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+
+/******/ // Flag the module as loaded
+/******/ module.loaded = true;
+
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+
+
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "";
+
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(0);
+/******/ })
+/************************************************************************/
+/******/ ([
+/* 0 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var _file_upload = __webpack_require__(1);
+
+ var _file_upload2 = _interopRequireDefault(_file_upload);
+
+ var _extended_field = __webpack_require__(2);
+
+ var _custom_check = __webpack_require__(3);
+
+ var _read_more = __webpack_require__(4);
+
+ var _test_seeds = __webpack_require__(5);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function showHideRealry() {
+ var check = $('#checkbox-sb-realty');
+ check.on("click", function (e) {
+ var $realty = $('#sb-realty');
+ if ($(e.target).prop("checked")) {
+ $realty.show();
+ } else {
+ $realty.hide();
+ }
+ });
+ }
+
+ $(function () {
+ (0, _file_upload2.default)();
+ (0, _extended_field.extendedFieldInit)();
+ (0, _custom_check.customCheckInit)();
+ showHideRealry();
+ (0, _read_more.readMoreInit)();
+ });
+
+/***/ },
+/* 1 */
+/***/ function(module, exports) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = fileUploadInit;
+ function humanFileSize(bytes, si) {
+ var thresh = si ? 1000 : 1024;
+
+ if (Math.abs(bytes) < thresh) return bytes + ' B';
+
+ var units = si ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
+
+ var u = -1;
+
+ do {
+ bytes /= thresh;
+ ++u;
+ } while (Math.abs(bytes) >= thresh && u < units.length - 1);
+
+ return bytes.toFixed(1) + ' ' + units[u];
+ }
+
+ function fileUploadInit() {
+ var $fileUploadContainer = $('#fileUploadContainer');
+
+ $('#fileUploadAddBtn').on('click', function ($evt) {
+ $fileUploadContainer.find('.file-upload-widget').last().find('.file-upload-input').click();
+ });
+
+ $fileUploadContainer.on('change', '.file-upload-input', function ($evt) {
+ var $fileInput = $(this);
+ var $fileUploadWidget = $fileInput.closest('.file-upload-widget');
+ var filePath = $fileInput.val().replace(/\\/g, '/');
+ var fileName = path.basename(filePath);
+ //var fileExt = path.extname(filePath)
+ var fileSize = $fileInput.get(0).files && humanFileSize($fileInput.get(0).files[0].size);
+
+ if (fileName) {
+ $fileUploadWidget.find('.file-upload-label').text(fileName + ' ' + fileSize);
+
+ var $newFileUploadWidget = $fileUploadWidget.clone();
+ $newFileUploadWidget.find('.file-upload-label').text('');
+
+ $fileUploadContainer.find('ul').first().append($newFileUploadWidget);
+
+ $fileUploadWidget.css('display', 'block');
+ }
+ });
+
+ $fileUploadContainer.on('click', '.file-upload-remove-btn', function ($evt) {
+ var $btn = $(this);
+ $btn.closest('.file-upload-widget').remove();
+ });
+
+ $fileUploadContainer.on('click', '.existing-file-remove-btn', function ($evt) {
+ var $btn = $(this);
+ $btn.closest('.existing-file-widget').remove();
+ });
+ }
+
+/***/ },
+/* 2 */
+/***/ function(module, exports) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ function extendedFieldInit() {
+
+ var $buttonF1 = $('.resButton');
+ if ($('.slide').hasClass("active")) $buttonF1.css('transform', 'rotate(0deg)');
+
+ $buttonF1.on("click", function (e) {
+ e.preventDefault();
+ var $slide = $('.slide');
+ if ($slide.hasClass("active")) {
+ $buttonF1.css('transform', 'rotate(180deg)');
+ $slide.slideUp(300);
+ } else {
+ $buttonF1.css('transform', 'rotate(0deg)');
+ $slide.slideDown(300);
+ }
+ $slide.toggleClass("active");
+ });
+ }
+
+ exports.extendedFieldInit = extendedFieldInit;
+
+/***/ },
+/* 3 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ function customCheckInit() {
+ function tuneCheckBoxes($boxes) {
+ var currentState = $boxes.find("input").prop("checked") ? 'checked' : 'not-checked';
+ $boxes.find("div").hide();
+ $boxes.find("div." + currentState).show();
+ }
+
+ var $boxes = $('.custom-check');
+ tuneCheckBoxes($boxes);
+ $boxes.on("click", function (e) {
+ var inside_checkBox = $(e.target).parent().find("input");
+ inside_checkBox.prop("checked", !inside_checkBox.prop("checked"));
+ tuneCheckBoxes($boxes);
+ e.preventDefault();
+ return false;
+ });
+ }
+
+ exports.customCheckInit = customCheckInit;
+
+/***/ },
+/* 4 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ function readMoreInit() {
+
+ $('.description .more').on("click", function (e) {
+ var $target = $(e.target);
+ $target.siblings(".complete").toggle();
+ $target.toggleClass("less");
+ });
+
+ // $(".more").toggle(function () {
+ // $(this).text("less..").siblings(".complete").show();
+ // }, function () {
+ // $(this).text("more..").siblings(".complete").hide();
+ // });
+ }
+
+ exports.readMoreInit = readMoreInit;
+
+/***/ },
+/* 5 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ function print(text) {
+ console.log(text);
+ }
+
+ exports.print = print;
+
+/***/ }
+/******/ ]);
\ No newline at end of file
diff --git a/assets/js/build/init_customer_project_create.js b/assets/js/build/init_customer_project_create.js
new file mode 100644
index 0000000..3f8a4fd
--- /dev/null
+++ b/assets/js/build/init_customer_project_create.js
@@ -0,0 +1,1912 @@
+/******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId])
+/******/ return installedModules[moduleId].exports;
+
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ exports: {},
+/******/ id: moduleId,
+/******/ loaded: false
+/******/ };
+
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+
+/******/ // Flag the module as loaded
+/******/ module.loaded = true;
+
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+
+
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "";
+
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(0);
+/******/ })
+/************************************************************************/
+/******/ ([
+/* 0 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var _SelectedContainer = __webpack_require__(6);
+
+ var _SelectedContainer2 = _interopRequireDefault(_SelectedContainer);
+
+ var _SelectedContainerCreate = __webpack_require__(10);
+
+ var _SelectedContainerCreate2 = _interopRequireDefault(_SelectedContainerCreate);
+
+ var _NoTreeSelect = __webpack_require__(11);
+
+ var _NoTreeSelect2 = _interopRequireDefault(_NoTreeSelect);
+
+ var _TreeSelect = __webpack_require__(13);
+
+ var _TreeSelect2 = _interopRequireDefault(_TreeSelect);
+
+ var _SingleTreeSelect = __webpack_require__(14);
+
+ var _SingleTreeSelect2 = _interopRequireDefault(_SingleTreeSelect);
+
+ var _SelectOrCreate = __webpack_require__(15);
+
+ var _SelectOrCreate2 = _interopRequireDefault(_SelectOrCreate);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ $(function () {
+ function createSpecs(url) {
+ // SPECIALIZATIONS
+ var sb_main = new _TreeSelect2.default($('#select-box-1'), { url: url, visible: true, required: true });
+ sb_main.setHeader("Специальность");
+ var select_container = new _SelectedContainer2.default($('#selected-spec'), {
+ obj: sb_main,
+ onlyOne: true
+ });
+ sb_main.connectSelectedContainer(select_container);
+ var sb_1 = new _TreeSelect2.default($('#select-box-2'), { obj: sb_main });
+ var sb_2 = new _TreeSelect2.default($('#select-box-3'), { obj: sb_main });
+ var sb_3 = new _TreeSelect2.default($('#select-box-4'), { obj: sb_main });
+ var sb_4 = new _TreeSelect2.default($('#select-box-5'), { obj: sb_main });
+
+ select_container.on("add", function () {
+ var $container = $('#spec-value');
+ $container.html($('#selected-spec').find(".selected-element").find(".name").html());
+ });
+
+ sb_main.setNearbySelectBox(sb_1);
+ sb_1.setNearbySelectBox(sb_2, sb_main);
+ sb_2.setNearbySelectBox(sb_3, sb_1);
+ sb_3.setNearbySelectBox(sb_4, sb_2);
+ sb_4.setNearbySelectBox("", sb_3);
+ }
+
+ function createBuildingClass(url) {
+ // BUILDING-CLASSIFICATION
+ sb_build_main = new _TreeSelect2.default($('#sb-building-classification'), { url: url, visible: true });
+ sb_build_main.setHeader("Классификация здания");
+
+ var sb_build_1 = new _TreeSelect2.default($('#sb-building-sub-classification'), { obj: sb_build_main });
+
+ var select_build_container = new _SelectedContainer2.default($('#selected-building-classification'), {
+ obj: sb_build_main,
+ onlyOne: true
+ });
+ sb_build_main.connectSelectedContainer(select_build_container);
+
+ sb_build_main.setNearbySelectBox(sb_build_1);
+ sb_build_1.setNearbySelectBox("", sb_build_main);
+ }
+
+ function createConstructionType(url) {
+ sb_constr_main = new _NoTreeSelect2.default($('#sb-construction-type'), { url: url, visible: true });
+ sb_constr_main.setHeader("Вид строительства");
+ var select_constr_type = new _SelectedContainer2.default($('#selected-construction-type'), {
+ obj: sb_constr_main,
+ noTree: true,
+ onlyOne: true
+ });
+ sb_constr_main.connectSelectedContainer(select_constr_type);
+ }
+
+ function createLocations(url) {
+ sb_loc_main = new _TreeSelect2.default($('#sb-location-1'), { url: url, visible: true });
+ sb_loc_main.setHeader("Местоположение");
+ var select_loc = new _SelectedContainer2.default($('#selected-location'), {
+ obj: sb_loc_main,
+ onlyOne: true
+ });
+ sb_loc_main.connectSelectedContainer(select_loc);
+ var sb_loc_1 = new _TreeSelect2.default($('#sb-location-2'), { obj: sb_loc_main });
+ var sb_loc_2 = new _TreeSelect2.default($('#sb-location-3'), { obj: sb_loc_main });
+
+ sb_loc_main.setNearbySelectBox(sb_loc_1);
+ sb_loc_1.setNearbySelectBox(sb_loc_2, sb_loc_main);
+ sb_loc_2.setNearbySelectBox("", sb_loc_1);
+ }
+
+ function createRealty(url) {
+ var sb_realty = new _SelectOrCreate2.default($('#sb-realty'), { url: url, visible: true });
+ sb_realty.setHeader(" ");
+ var select_realty = new _SelectedContainerCreate2.default($('#selected-realty'), {
+ obj: sb_realty,
+ noTree: true,
+ onlyOne: true,
+ noHeader: true
+ });
+ sb_realty.connectSelectedContainer(select_realty);
+ sb_realty.setLinkBoxes([sb_loc_main, sb_constr_main, sb_build_main]);
+ select_realty.on("add", function () {
+ $('#checkbox-sb-realty').attr("disabled", true);
+ });
+ select_realty.on("remove", function () {
+ $('#checkbox-sb-realty').attr("disabled", false);
+ });
+ sb_realty.dataPromise.then(function () {
+ var $realty = $('#sb-realty');
+ var check = $('#checkbox-sb-realty');
+ if (!check.prop("checked")) {
+ $realty.hide();
+ console.log("hide");
+ }
+ });
+ }
+
+ var sb_loc_main = void 0,
+ sb_constr_main = void 0,
+ sb_build_main = void 0;
+
+ createSpecs('/api/specializations_flat');
+
+ createBuildingClass('/api/building_classifications');
+ createConstructionType('/api/construction_type');
+ createLocations('/api/locations_flat');
+
+ createRealty('/api/realties/current_user');
+ });
+
+/***/ },
+/* 1 */,
+/* 2 */,
+/* 3 */,
+/* 4 */,
+/* 5 */,
+/* 6 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = undefined;
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ var _desc, _value, _class; // `
+
+
+ var _DataTree = __webpack_require__(7);
+
+ var _DataTree2 = _interopRequireDefault(_DataTree);
+
+ var _NoTreeData = __webpack_require__(8);
+
+ var _NoTreeData2 = _interopRequireDefault(_NoTreeData);
+
+ var _decorators = __webpack_require__(9);
+
+ var _decorators2 = _interopRequireDefault(_decorators);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
+ var desc = {};
+ Object['ke' + 'ys'](descriptor).forEach(function (key) {
+ desc[key] = descriptor[key];
+ });
+ desc.enumerable = !!desc.enumerable;
+ desc.configurable = !!desc.configurable;
+
+ if ('value' in desc || desc.initializer) {
+ desc.writable = true;
+ }
+
+ desc = decorators.slice().reverse().reduce(function (desc, decorator) {
+ return decorator(target, property, desc) || desc;
+ }, desc);
+
+ if (context && desc.initializer !== void 0) {
+ desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
+ desc.initializer = undefined;
+ }
+
+ if (desc.initializer === void 0) {
+ Object['define' + 'Property'](target, property, desc);
+ desc = null;
+ }
+
+ return desc;
+ }
+
+ var tmpl_selectedElement = function tmpl_selectedElement(header, name, id) {
+ return '\n
\n \n
\n ' + name + '\n
\n
\n
\n';
+ };
+
+ var SelectedContainer = (_class = function () {
+ function SelectedContainer($container, _ref) {
+ var _this = this;
+
+ var obj = _ref.obj,
+ _ref$noTree = _ref.noTree,
+ noTree = _ref$noTree === undefined ? false : _ref$noTree,
+ _ref$noHeader = _ref.noHeader,
+ noHeader = _ref$noHeader === undefined ? false : _ref$noHeader,
+ _ref$onlyOne = _ref.onlyOne,
+ onlyOne = _ref$onlyOne === undefined ? false : _ref$onlyOne;
+
+ _classCallCheck(this, SelectedContainer);
+
+ // TODO: rename variables to camelCase
+ this.$self = $container;
+ this.elements_id = []; // [spec_id, spec_id, ...]
+ this.onlyOne = onlyOne;
+ this.options = { noHeader: noHeader };
+ var self = this;
+ this.$self.hide();
+
+ obj.dataPromise.then(function (data) {
+ data = data.results ? data.results : data;
+ _this.dataTree = noTree ? new _NoTreeData2.default(data) : new _DataTree2.default(data);
+ _this.$input = _this.$self.find('input[type="hidden"]');
+ if (_this.$input.length == 0) throw new URIError('input for ' + _this.$self.attr("class") + ' not found');
+
+ _this.restoreElements();
+ }).catch(self._onLoadDataError.bind(self));
+ }
+
+ _createClass(SelectedContainer, [{
+ key: 'restoreElements',
+ value: function restoreElements() {
+ var self = this;
+ if (this.$input && this.$input.val()) {
+
+ var clearString = this.$input.val().replace(/[\[\]\'\'\"\"]/g, '');
+ var data = clearString.split(',').filter(function (el) {
+ return el;
+ });
+ this.elements_id = [];
+ if (this.$input) this.$input.val(this.elements_id.join(','));
+ data.forEach(function (el) {
+ return self.add(el);
+ });
+ }
+ }
+ }, {
+ key: 'on',
+ value: function on(methodName, func) {
+ this[methodName] = this[methodName].bind(this, { func: func, bindFunc: true });
+ }
+ }, {
+ key: '_removeById',
+ value: function _removeById(id) {
+ var index = this.elements_id.indexOf(id);
+ if (index >= 0) {
+ this.elements_id.splice(index, 1);
+ }
+ this.$self.find('span[data-id=\'' + id + '\']').parents('.selected-element').remove();
+ }
+ }, {
+ key: '_onLoadDataError',
+ value: function _onLoadDataError(error) {
+ console.log("Error loading data -->", error);
+ }
+ }, {
+ key: 'removeAll',
+ value: function removeAll() {
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = this.elements_id[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var id = _step.value;
+
+ this._removeById(id);
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+ }
+ }, {
+ key: 'remove',
+ value: function remove(e) {
+ var spec_id = $(e.target).data("id");
+ this._removeById(spec_id);
+ if (this.$input) this.$input.val(this.elements_id.join(','));
+ if (!this.elements_id.length) this.$self.hide();
+ e.preventDefault();
+ }
+ }, {
+ key: 'replace',
+ value: function replace(_id, max_len) {
+ var id = Number(_id);
+ if (this.elements_id.length > 1) throw new RangeError("Replace error: more than one element");
+ // Remove old
+ this._removeById(this.elements_id[0]);
+ //Add new
+ this._addElementToHtml(id, max_len);
+ this.elements_id = [id];
+ }
+ }, {
+ key: '_addElementToHtml',
+ value: function _addElementToHtml(id, max_len) {
+ var self = this;
+ var header = SelectedContainer.getHeader(this.dataTree.getSpecChain(id), "", max_len);
+ var name = this.dataTree.getElementById(id).name;
+ this.elements_id.push(id);
+ if (this.$input) this.$input.val(this.elements_id.join(','));
+ // console.log("header = ", header);
+ this.$self.append(SelectedContainer.getTemplate(header || (this.options.noHeader ? "" : " "), name, id));
+ this.btn_remove = this.$self.find('.icon-remove');
+ this.btn_remove.on("click", this.remove.bind(self));
+ if (this.elements_id.length) this.$self.show();
+ }
+ }, {
+ key: 'add',
+ value: function add(_id, max_len) {
+ var id = Number(_id);
+ var el = this.dataTree.getElementById(id);
+ if (!el) {
+ throw new Error('\u042D\u043B\u0435\u043C\u0435\u043D\u0442 \u0441 id = ' + _id + ' \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0438 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D');
+ }
+ var self = this;
+ if (this.onlyOne) {
+ this.replace(_id, max_len);
+ return;
+ }
+
+ var has_already = this.elements_id.filter(function (el) {
+ return self.dataTree.isChild(el, id);
+ });
+
+ if (has_already.length || this.elements_id.indexOf(Number(id)) != -1) {
+ //TODO: do popup messages
+ return;
+ }
+
+ var not_valid = this.elements_id.filter(function (el) {
+ return self.dataTree.isChild(id, el);
+ });
+
+ not_valid.forEach(function (el) {
+ self._removeById(el);
+ });
+ this._addElementToHtml(id, max_len);
+ }
+ }], [{
+ key: 'getTemplate',
+ value: function getTemplate(header, name, id) {
+ return tmpl_selectedElement(header, name, id);
+ }
+ }, {
+ key: 'getHeader',
+ value: function getHeader(spec_chain, separator, max_len) {
+ function toShortString(string, max_len) {
+ return string.slice(0, max_len) + (string.length > max_len ? "..." : "");
+ }
+
+ separator = separator || ' / ';
+ var str_chain = "";
+
+ spec_chain.forEach(function (el) {
+ str_chain = (max_len ? toShortString(el.name, max_len) : el.name) + (str_chain ? separator : "") + str_chain;
+ });
+
+ return str_chain;
+ }
+ }]);
+
+ return SelectedContainer;
+ }(), (_applyDecoratedDescriptor(_class.prototype, 'remove', [_decorators2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'remove'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'add', [_decorators2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'add'), _class.prototype)), _class);
+ exports.default = SelectedContainer;
+
+/***/ },
+/* 7 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ var Node = function Node(data, tree) {
+ _classCallCheck(this, Node);
+
+ this.name = data.name;
+ this.id = data.id;
+ if (data.parent === null) {
+ this.parent = "root";
+ data.parent = { id: "root" };
+ this.name = "";
+ }
+ if (data.parent.id && data.parent.id !== 'root') {
+ var el = tree._getElementById(data.parent.id);
+ this.parent = el.node || new Node(el, tree);
+ }
+ data.node = this;
+ this.children = data.children.map(function (el_obj) {
+ var el = tree._getElementById(el_obj.id);
+ if (el.node) return el.node;
+ el.node = new Node(el, tree);
+ return el.node;
+ });
+
+ this.children = this.children || [];
+ };
+
+ var DataTree = function () {
+ function DataTree(data) {
+ _classCallCheck(this, DataTree);
+
+ this.baseData = data;
+ this._root = new Node(data[0], this);
+ }
+
+ /**
+ * получить element в базовой структуре
+ */
+
+
+ _createClass(DataTree, [{
+ key: "_getElementById",
+ value: function _getElementById(id) {
+ for (var i = 0; i < this.baseData.length; i++) {
+ if (this.baseData[i].id == id) return this.baseData[i];
+ }
+ }
+
+ /**
+ * получить element в дереве
+ */
+
+ }, {
+ key: "getElementById",
+ value: function getElementById(id) {
+ function searchInChildren(children) {
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].id == id) return children[i];
+ var res = searchInChildren(children[i].children);
+ if (res) return res;
+ }
+ }
+
+ return searchInChildren(this._root.children);
+ }
+
+ /**
+ * Является ли узел c el_id дочерним для parent_id
+ * @param el_id
+ * @param parent_id
+ */
+
+ }, {
+ key: "isChild",
+ value: function isChild(elId, parent_id) {
+ function checkParent(el, parent) {
+ if (el.parent == parent) return true;
+ if (el.parent && el.parent != 'root') return checkParent(el.parent, parent);
+ return false;
+ }
+ return checkParent(this.getElementById(elId), this.getElementById(parent_id));
+ }
+ }, {
+ key: "hasChildren",
+ value: function hasChildren(elId) {
+ return this.getElementById(elId).children.length ? true : false;
+ }
+
+ /**
+ * @param start_parent_id(number) - начиная с
+ * @param attached(bool) - включая вложенные/дочерние
+ * @param exclude_id - исключая узел c exclude_id и всеми его вложенными узлами
+ * @returns [{name, id}, ...]
+ */
+
+ }, {
+ key: "dataToList",
+ value: function dataToList(start_parent_id, attached, exclude_id) {
+ var data_list = [];
+
+ function goInChildren(children) {
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].id == exclude_id) continue;
+ data_list.push({ name: children[i].name, id: children[i].id });
+ if (attached) goInChildren(children[i].children);
+ }
+ }
+ var start = start_parent_id ? this.getElementById(start_parent_id) : this._root;
+ goInChildren(start.children);
+ return data_list;
+ }
+
+ /**
+ *
+ * @param id
+ * @param incl(bool) - исключая сам элемент
+ * @returns {Array} всех узлов/элементов от элемента с id до корня
+ */
+
+ }, {
+ key: "getSpecChain",
+ value: function getSpecChain(id) {
+ var incl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+
+ var chain = [];
+ var el = this.getElementById(id);
+ function getParent(el) {
+ if (el.parent && el.parent != "root") {
+ chain.push(el.parent);
+ getParent(el.parent);
+ }
+ }
+ getParent(el);
+ if (incl) chain.unshift(el);
+ return chain;
+ }
+ }]);
+
+ return DataTree;
+ }();
+
+ exports.default = DataTree;
+
+/***/ },
+/* 8 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ var NoTreeData = function () {
+ function NoTreeData(data) {
+ _classCallCheck(this, NoTreeData);
+
+ this.data = data;
+ this.specChain = [];
+ }
+
+ _createClass(NoTreeData, [{
+ key: "getElementById",
+ value: function getElementById(id) {
+ for (var i = 0; i < this.data.length; i++) {
+ if (this.data[i].id == id) return this.data[i];
+ }
+ }
+ }, {
+ key: "getSpecChain",
+ value: function getSpecChain(id, incl) {
+ return this.specChain;
+ }
+ }, {
+ key: "isChild",
+ value: function isChild(el_id, parent_id) {
+ return false;
+ }
+ }, {
+ key: "hasChildren",
+ value: function hasChildren() {
+ return false;
+ }
+ }, {
+ key: "dataToList",
+ value: function dataToList() {
+ return this.data;
+ }
+ }]);
+
+ return NoTreeData;
+ }();
+
+ exports.default = NoTreeData;
+
+/***/ },
+/* 9 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = onBind;
+ function onBind(target, name, descriptor) {
+ var method = descriptor.value;
+
+ descriptor.value = function () {
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
+ var binds = [];
+ args = Array.from(args);
+ console.log("args -->", args.slice());
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = args.slice()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var arg = _step.value;
+
+ // console.log("onBind -->", typeof arg, "arg = ", arg);
+ // console.log("arg.func -->", typeof arg.originalEvent);
+ // typeof arg === 'object' && !(arg.originalEvent)
+ if (arg && arg.bindFunc) {
+ binds.push(arg);
+ args.splice(args.indexOf(arg), 1);
+ } else {
+ console.log("arg = ", arg);
+ }
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ method.apply(this, args);
+ var _iteratorNormalCompletion2 = true;
+ var _didIteratorError2 = false;
+ var _iteratorError2 = undefined;
+
+ try {
+ for (var _iterator2 = binds[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
+ var bind = _step2.value;
+
+ bind.func.bind(this)();
+ }
+ } catch (err) {
+ _didIteratorError2 = true;
+ _iteratorError2 = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
+ _iterator2.return();
+ }
+ } finally {
+ if (_didIteratorError2) {
+ throw _iteratorError2;
+ }
+ }
+ }
+
+ return this;
+ };
+ }
+
+ // export {onBind};
+
+/***/ },
+/* 10 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = undefined;
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
+
+ var _desc, _value, _class;
+
+ var _SelectedContainer2 = __webpack_require__(6);
+
+ var _SelectedContainer3 = _interopRequireDefault(_SelectedContainer2);
+
+ var _decorators = __webpack_require__(9);
+
+ var _decorators2 = _interopRequireDefault(_decorators);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
+ var desc = {};
+ Object['ke' + 'ys'](descriptor).forEach(function (key) {
+ desc[key] = descriptor[key];
+ });
+ desc.enumerable = !!desc.enumerable;
+ desc.configurable = !!desc.configurable;
+
+ if ('value' in desc || desc.initializer) {
+ desc.writable = true;
+ }
+
+ desc = decorators.slice().reverse().reduce(function (desc, decorator) {
+ return decorator(target, property, desc) || desc;
+ }, desc);
+
+ if (context && desc.initializer !== void 0) {
+ desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
+ desc.initializer = undefined;
+ }
+
+ if (desc.initializer === void 0) {
+ Object['define' + 'Property'](target, property, desc);
+ desc = null;
+ }
+
+ return desc;
+ }
+
+ /**
+ * Контэйнер - позволяющий принимать/отправлять новый объект для создания
+ */
+ //TODO: попробовать реализовать как Mixin
+ var SelectedContainerCreate = (_class = function (_SelectedContainer) {
+ _inherits(SelectedContainerCreate, _SelectedContainer);
+
+ function SelectedContainerCreate() {
+ _classCallCheck(this, SelectedContainerCreate);
+
+ return _possibleConstructorReturn(this, (SelectedContainerCreate.__proto__ || Object.getPrototypeOf(SelectedContainerCreate)).apply(this, arguments));
+ }
+
+ _createClass(SelectedContainerCreate, [{
+ key: 'add',
+ value: function add(_id, max_len) {
+ console.log("_id = ", _id);
+ var self = this;
+ if (_id.text) {
+ this._removeById(this.elements_id[0]);
+ this.elements_id = [0];
+ this.$input_id = this.$self.find('input[type="hidden"].-id');
+ this.$input_id.val();
+ this.$input_name = this.$self.find('input[type="hidden"].-name');
+ this.$input_name.val(_id.text);
+ this.$self.append(_SelectedContainer3.default.getTemplate("", _id.text, 0));
+ this.btn_remove = this.$self.find('.icon-remove');
+ this.btn_remove.on("click", this.remove.bind(self));
+ if (this.elements_id.length) this.$self.show();
+ return;
+ }
+ _get(SelectedContainerCreate.prototype.__proto__ || Object.getPrototypeOf(SelectedContainerCreate.prototype), 'add', this).call(this, _id, max_len);
+ }
+ }]);
+
+ return SelectedContainerCreate;
+ }(_SelectedContainer3.default), (_applyDecoratedDescriptor(_class.prototype, 'add', [_decorators2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'add'), _class.prototype)), _class);
+ exports.default = SelectedContainerCreate;
+
+/***/ },
+/* 11 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = undefined;
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
+
+ var _AbsBaseSelect2 = __webpack_require__(12);
+
+ var _NoTreeData = __webpack_require__(8);
+
+ var _NoTreeData2 = _interopRequireDefault(_NoTreeData);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var NoTreeSelect = function (_AbsBaseSelect) {
+ _inherits(NoTreeSelect, _AbsBaseSelect);
+
+ function NoTreeSelect($container, _ref) {
+ var url = _ref.url,
+ obj = _ref.obj,
+ _ref$visible = _ref.visible,
+ visible = _ref$visible === undefined ? true : _ref$visible,
+ _ref$required = _ref.required,
+ required = _ref$required === undefined ? false : _ref$required;
+
+ _classCallCheck(this, NoTreeSelect);
+
+ //TODO: сделать автоматическую передачу всех параметров родителю
+ return _possibleConstructorReturn(this, (NoTreeSelect.__proto__ || Object.getPrototypeOf(NoTreeSelect)).call(this, $container, { url: url, obj: obj, visible: visible, required: required }));
+ }
+
+ _createClass(NoTreeSelect, [{
+ key: '_buildComponents',
+ value: function _buildComponents(data) {
+ _get(NoTreeSelect.prototype.__proto__ || Object.getPrototypeOf(NoTreeSelect.prototype), '_buildComponents', this).call(this, data);
+ this.dataTree = this.dataTree || new _NoTreeData2.default(data.results);
+ this.$buttonAddOptions.hide();
+ this._fillOptionsData();
+ this._bindEvents();
+ }
+ }, {
+ key: '_onclickOptionsElement',
+ value: function _onclickOptionsElement(e) {
+ this.selectedEl.id = $(e.target).data("id");
+ this.selectedEl.value = $(e.target).html();
+ this.$searchInput.val($(e.target).html());
+
+ this.$buttonAddOptions.show();
+ this.$optionsBox.hide();
+
+ this.selectedContainer.add(this.selectedEl.id);
+ this.clear();
+ e.preventDefault();
+ return false;
+ }
+ }, {
+ key: '_onButtonAddOptions',
+ value: function _onButtonAddOptions(e) {
+ // pass
+ }
+ }]);
+
+ return NoTreeSelect;
+ }(_AbsBaseSelect2.AbsBaseSelect);
+
+ exports.default = NoTreeSelect;
+
+/***/ },
+/* 12 */
+/***/ function(module, exports) {
+
+ "use strict";
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ //TEMPLATES `
+ var tmpl_selectBoxEditCont = function tmpl_selectBoxEditCont() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$preloaderTemplat = _ref.preloaderTemplate,
+ preloaderTemplate = _ref$preloaderTemplat === undefined ? "" : _ref$preloaderTemplat;
+
+ return "\n \n
\n \n
\n " + preloaderTemplate + "\n \n \n
\n
\n
\n \n
\n
\n";
+ };
+
+ var tmpl_selectBox = function tmpl_selectBox() {
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref2$preloaderTempla = _ref2.preloaderTemplate,
+ preloaderTemplate = _ref2$preloaderTempla === undefined ? "" : _ref2$preloaderTempla;
+
+ return " \n " + preloaderTemplate + "\n \n \n";
+ };
+
+ var tmpl_elementResult = function tmpl_elementResult(el, id, header) {
+ return "";
+ };
+
+ var tmpl_elementOption = function tmpl_elementOption(el) {
+ return "" + el.name + "";
+ };
+
+ var tmpl_plug = function tmpl_plug(_ref3) {
+ var header = _ref3.header,
+ selectBox = _ref3.selectBox;
+ return htmlTemplate({ header: header, selectBox: selectBox });
+ };
+
+ var tmpl_selectBoxOptions = function tmpl_selectBoxOptions() {
+ return "\n \n";
+ };
+
+ var tmpl_selectBoxResults = function tmpl_selectBoxResults() {
+ return "\n \n
\n
\n \n
\n
\n";
+ };
+
+ var htmlTemplate = function htmlTemplate(_ref4) {
+ var header = _ref4.header,
+ selectBox = _ref4.selectBox,
+ _ref4$required = _ref4.required,
+ required = _ref4$required === undefined ? false : _ref4$required,
+ _ref4$id = _ref4.id,
+ id = _ref4$id === undefined ? "" : _ref4$id,
+ _ref4$classes = _ref4.classes,
+ classes = _ref4$classes === undefined ? "" : _ref4$classes,
+ _ref4$tmpl_selectBoxO = _ref4.tmpl_selectBoxOptions,
+ tmpl_selectBoxOptions = _ref4$tmpl_selectBoxO === undefined ? function () {
+ return "";
+ } : _ref4$tmpl_selectBoxO,
+ _ref4$tmpl_selectBoxR = _ref4.tmpl_selectBoxResults,
+ tmpl_selectBoxResults = _ref4$tmpl_selectBoxR === undefined ? function () {
+ return "";
+ } : _ref4$tmpl_selectBoxR;
+ return "\n\n \n
\n " + selectBox + "\n
\n \n " + tmpl_selectBoxOptions() + "\n " + tmpl_selectBoxResults() + "\n
\n
\n";
+ };
+ var tmpl_light = function tmpl_light(el) {
+ return "" + el + "";
+ };
+
+ var tmpl_preloader = function tmpl_preloader() {
+ return "
";
+ };
+
+ var AbsBaseSelect = function () {
+ function AbsBaseSelect($container, _ref5) {
+ var url = _ref5.url,
+ obj = _ref5.obj,
+ _ref5$hasEditableCont = _ref5.hasEditableContainer,
+ hasEditableContainer = _ref5$hasEditableCont === undefined ? false : _ref5$hasEditableCont,
+ _ref5$visible = _ref5.visible,
+ visible = _ref5$visible === undefined ? false : _ref5$visible,
+ _ref5$required = _ref5.required,
+ required = _ref5$required === undefined ? false : _ref5$required;
+
+ _classCallCheck(this, AbsBaseSelect);
+
+ if (new.target === AbsBaseSelect) {
+ throw new TypeError("Cannot construct Abstract instances directly");
+ }
+ if (obj && url) {
+ throw new URIError("Must be either the date or url");
+ }
+
+ var self = this;
+ //TODO: проверка наличия id контейнера
+ this.containerId = $container.attr("id");
+ this.$container = $container;
+ this.hasEditableContainer = hasEditableContainer;
+ this.visible = visible;
+ this.required = required;
+ // Быстрая заглушка, до отображения данных
+ if (visible) {
+ var preloaderTemplate = tmpl_preloader();
+ var selectBox = this.hasEditableContainer ? tmpl_selectBoxEditCont({ preloaderTemplate: preloaderTemplate }) : tmpl_selectBox({ preloaderTemplate: preloaderTemplate });
+ var plugTemplate = tmpl_plug({ header: "Loading...", selectBox: selectBox });
+ $container.html(plugTemplate);
+
+ this.$preloader = $container.find('#component-preloader');
+ this.$spinner = this.$preloader.find('.spinner');
+ }
+ if (url) {
+ this.dataPromise = this.getData(url);
+ //TODO: дописать более гибкую обработку url
+ this.type = url.split("/")[2];
+ }
+ var _dataPromise = void 0;
+ if (url) {
+ _dataPromise = this.dataPromise;
+ } else {
+ _dataPromise = obj.dataPromise;
+ }
+ // if (dataTree) this.dataTree = dataTree;
+ _dataPromise.then(self._buildComponents.bind(self)).catch(self._onLoadDataError.bind(self));
+
+ // INIT EMPTY PROP
+ this.selectedEl = { id: undefined, value: undefined };
+ this.parentId = undefined;
+ }
+
+ _createClass(AbsBaseSelect, [{
+ key: "getTemplate",
+ value: function getTemplate(classes) {
+ var selectBox = this.hasEditableContainer ? tmpl_selectBoxEditCont() : tmpl_selectBox();
+ classes = classes ? classes.join(" ") : "";
+ return htmlTemplate({
+ header: "TestHeader", selectBox: selectBox, required: this.required, id: this.containerId, classes: classes,
+ tmpl_selectBoxOptions: tmpl_selectBoxOptions, tmpl_selectBoxResults: tmpl_selectBoxResults
+ });
+ }
+ }, {
+ key: "getData",
+ value: function getData(url) {
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+ var self = this;
+ return Promise.resolve($.ajax({
+ url: url,
+ dataType: 'json',
+ data: data
+ }));
+ }
+ }, {
+ key: "hidePreloader",
+ value: function hidePreloader() {
+ // console.log("hide preloader ", this.$preloader);
+ this.$spinner.fadeOut();
+ return Promise.resolve(this.$preloader.delay(500).fadeOut(2000));
+ }
+ }, {
+ key: "clear",
+ value: function clear() {
+ this.$searchInput.val("");
+ this.$optionsBox.hide();
+ this.$resultsBox.hide();
+ this.$buttonAdd.hide();
+ this.$buttonAddOptions.hide();
+ this.selectedEl = { id: undefined, value: undefined };
+ if (this.hasEditableContainer) {
+ this.$editableContainer.html("");
+ this.$editableContainer.hide();
+ }
+ this.$searchInput.removeClass("active");
+ }
+ }, {
+ key: "hide",
+ value: function hide() {
+ this.$selectBox.hide();
+ }
+ }, {
+ key: "show",
+ value: function show() {
+ this.$selectBox.show();
+ }
+ }, {
+ key: "setHeader",
+ value: function setHeader(header) {
+
+ if (this.$header) {
+ this.$header.html(header);
+ } else {
+ this.header = header;
+ }
+ // default hide
+ // this.show();
+ }
+ }, {
+ key: "setParent",
+ value: function setParent(parentId) {
+ this.parentId = parentId;
+ this._fillOptionsData();
+ }
+ }, {
+ key: "connectSelectedContainer",
+ value: function connectSelectedContainer(selectedContainer) {
+ this.selectedContainer = selectedContainer;
+ }
+ }, {
+ key: "getIdsSelectedElements",
+ value: function getIdsSelectedElements() {
+ var allChecked = this.$resultsBox.find(":checked");
+ return allChecked.map(function () {
+ return $(this).data("id");
+ });
+ }
+ }, {
+ key: "updateEditableContainer",
+ value: function updateEditableContainer(elId) {
+ // Если нет контейнера для отображения ...
+ if (this.$editableContainer.length) {
+ var separator = ' / ';
+ var chainHeader = AbsBaseSelect.getHeader(this.dataTree.getSpecChain(elId, true), { separator: separator });
+ chainHeader = AbsBaseSelect.highlight(chainHeader, separator, true);
+ var elTemplate = "" + chainHeader + "";
+ this.$editableContainer.html(elTemplate);
+ this.$editableContainer.show();
+ return;
+ }
+ //..., передаем отображение предыдущему selectBox
+ if (this.prevSelectBox) this.prevSelectBox.updateEditableContainer(elId);
+ }
+ }, {
+ key: "_buildComponents",
+ value: function _buildComponents(data) {
+ // AFTER PRELOAD
+ // this.hidePreloader().then(() => console.log("END -)"));
+ var classes = this.$container.attr('class');
+ if (classes) classes = classes.split(/\s+/);
+ var template = this.getTemplate(classes);
+ this.$container.replaceWith(template);
+
+ this.$selectBox = $("#" + this.containerId);
+ this.$header = this.$selectBox.find('.select-box-header .header');
+ this.$header.html(this.header);
+ this.$resultsBox = this.$selectBox.find('.select-box-results');
+ this.$optionsBox = this.$selectBox.find('.select-box-options');
+ this.$searchInput = this.$selectBox.find('input.select-box-search');
+ this.$buttonAdd = this.$selectBox.find('.button-add.results');
+ this.$buttonAddOptions = this.$selectBox.find('.button-add.options');
+ this.$editableContainer = this.$selectBox.find('.editable-container');
+ this.$resultsBox.hide();
+ this.$optionsBox.hide();
+ this.$buttonAddOptions.hide();
+ // TODO: сделать проверку на наличие всех нужных элементов и их корректый jq select
+ }
+ }, {
+ key: "_fillOptionsData",
+ value: function _fillOptionsData() {
+ var self = this;
+ var dataList = this.dataTree.dataToList(this.parentId);
+ var $container = this.$optionsBox.find('ul');
+ $container.html("");
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = dataList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var el = _step.value;
+
+ $container.append($(tmpl_elementOption(el)));
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ this.$selectBox.find('li').on("click", this._onclickOptionsElement.bind(self));
+ }
+ }, {
+ key: "_search",
+ value: function _search(_ref6) {
+ var searchText = _ref6.searchText,
+ _ref6$parentCategoryI = _ref6.parentCategoryId,
+ parentCategoryId = _ref6$parentCategoryI === undefined ? null : _ref6$parentCategoryI,
+ _ref6$attached = _ref6.attached,
+ attached = _ref6$attached === undefined ? true : _ref6$attached,
+ _ref6$excludeCategory = _ref6.excludeCategoryId,
+ excludeCategoryId = _ref6$excludeCategory === undefined ? null : _ref6$excludeCategory;
+
+ // :FORMAT spec_list [{name, id}, ...]
+ var specList = this.dataTree.dataToList(parentCategoryId, attached, excludeCategoryId);
+ return specList.filter(function (el) {
+ return el.name.toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
+ });
+ }
+ }, {
+ key: "_fillContainer",
+ value: function _fillContainer($container, template, _ref7) {
+ var _ref7$searchText = _ref7.searchText,
+ searchText = _ref7$searchText === undefined ? "" : _ref7$searchText,
+ _ref7$parentCategoryI = _ref7.parentCategoryId,
+ parentCategoryId = _ref7$parentCategoryI === undefined ? null : _ref7$parentCategoryI,
+ _ref7$attached = _ref7.attached,
+ attached = _ref7$attached === undefined ? true : _ref7$attached,
+ _ref7$excludeCategory = _ref7.excludeCategoryId,
+ excludeCategoryId = _ref7$excludeCategory === undefined ? null : _ref7$excludeCategory;
+
+ $container.html("");
+ $('.other-part').show();
+ var searchRes = this._search({ searchText: searchText, parentCategoryId: parentCategoryId, attached: attached, excludeCategoryId: excludeCategoryId });
+ if (!searchRes.length) {
+ if ($container.closest('div').hasClass('main-part')) {
+ $container.append('Ничего не найдено');
+ this.$resultsBox.find('.button-add.results').hide();
+ } else {
+ $('.other-part').hide();
+ }
+ return;
+ }
+ this.$resultsBox.find('.button-add.results').show();
+ var _iteratorNormalCompletion2 = true;
+ var _didIteratorError2 = false;
+ var _iteratorError2 = undefined;
+
+ try {
+ for (var _iterator2 = searchRes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
+ var el = _step2.value;
+
+ var header = AbsBaseSelect.getHeader(this.dataTree.getSpecChain(el.id), {});
+ $container.append(template(AbsBaseSelect.highlight(el.name, searchText), el.id, header));
+ }
+ } catch (err) {
+ _didIteratorError2 = true;
+ _iteratorError2 = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
+ _iterator2.return();
+ }
+ } finally {
+ if (_didIteratorError2) {
+ throw _iteratorError2;
+ }
+ }
+ }
+ }
+ }, {
+ key: "_fillResultsData",
+ value: function _fillResultsData(searchText) {
+ var self = this;
+ // FILL RESULTS
+ // MAIN PART
+ var $container = this.$resultsBox.find('.main-part ul');
+ this._fillContainer($container, tmpl_elementResult, { searchText: searchText, parentCategoryId: self.parentId });
+
+ // OTHER PART
+ // Если нет parentId, не нужно искать в других категориях
+ if (!this.parentId) {
+ $('.other-part').hide();
+ } else {
+ $container = this.$resultsBox.find('.other-part ul');
+ this._fillContainer($container, tmpl_elementResult, { searchText: searchText, excludeCategoryId: self.parentId });
+ }
+ this.$resultsBox.find('div.header').hide();
+ this.$resultsBox.find('li').on("mouseover", function (e) {
+ $(e.target).children('.header').show(300);
+ e.preventDefault();
+ });
+
+ this.$resultsBox.find('li').on("mouseout", function (event) {
+ var e = event.toElement || event.relatedTarget;
+ if (e.parentNode == this || e == this) {
+ return;
+ }
+ $(this).find('.header').hide();
+ });
+ }
+ }, {
+ key: "_onclickOptionsElement",
+ value: function _onclickOptionsElement(e) {
+ this.selectedEl.id = $(e.target).data("id");
+ this.selectedEl.value = $(e.target).html();
+ this.$searchInput.val($(e.target).html());
+ this.updateEditableContainer($(e.target).data("id"));
+ this.$buttonAddOptions.show();
+ this.$optionsBox.hide();
+ }
+ }, {
+ key: "_onButtonAddOptions",
+ value: function _onButtonAddOptions(e) {
+ this._addToSelectedContainer(this.selectedEl.id);
+ this.clear();
+ e.preventDefault();
+ return false;
+ }
+ }, {
+ key: "_onButtonAdd",
+ value: function _onButtonAdd(e) {
+ var self = this;
+
+ this.getIdsSelectedElements().each(function () {
+ self._addToSelectedContainer(this);
+ });
+ this.clear();
+ e.preventDefault();
+ return false;
+ }
+ }, {
+ key: "_onLoadDataError",
+ value: function _onLoadDataError(error) {
+ console.log("Error loading data -->", error);
+ }
+ }, {
+ key: "_addToSelectedContainer",
+ value: function _addToSelectedContainer(id) {
+ this.selectedContainer.add(id);
+ }
+ }, {
+ key: "_onInput_searchInput",
+ value: function _onInput_searchInput(e) {
+ this._fillResultsData(this.$searchInput.val());
+ this.$resultsBox.show();
+ this.$optionsBox.hide();
+ }
+ }, {
+ key: "_onClick_searchInput",
+ value: function _onClick_searchInput(e) {
+ this.$optionsBox.show();
+ this.$resultsBox.hide();
+ this.$searchInput.val("");
+ }
+ }, {
+ key: "_bindEvents",
+ value: function _bindEvents() {
+ var self = this;
+ $(document).click(function (event) {
+ if ($(event.target).closest("#" + self.containerId).length) {
+ return;
+ }
+ self._looseFocus();
+ });
+ // RESULTS BOX
+ this.$searchInput.on("input", this._onInput_searchInput.bind(self));
+ // OPTIONS BOX
+ this.$searchInput.on("click", this._onClick_searchInput.bind(self));
+
+ this.$buttonAdd.on("click", this._onButtonAdd.bind(self));
+
+ this.$buttonAddOptions.on("click", this._onButtonAddOptions.bind(self));
+ }
+ }, {
+ key: "_looseFocus",
+ value: function _looseFocus() {
+ this.$resultsBox.hide();
+ this.$optionsBox.hide();
+ if (!this.selectedEl.id) {
+ this.$searchInput.val("");
+ } else {
+ this.$searchInput.val(this.selectedEl.value);
+ }
+ }
+ }], [{
+ key: "getHeader",
+ value: function getHeader(catChain, _ref8) {
+ var _ref8$separator = _ref8.separator,
+ separator = _ref8$separator === undefined ? " / " : _ref8$separator,
+ _ref8$maxLen = _ref8.maxLen,
+ maxLen = _ref8$maxLen === undefined ? 60 : _ref8$maxLen;
+
+ function toShortString(string, maxLen) {
+ return string.slice(0, maxLen) + (string.length > maxLen ? "..." : "");
+ }
+
+ var strChain = "";
+
+ catChain.forEach(function (el) {
+ strChain = (maxLen ? toShortString(el.name, maxLen) : el.name) + (strChain ? separator : "") + strChain;
+ });
+
+ return strChain;
+ }
+ }, {
+ key: "highlight",
+ value: function highlight(string, sub_string) {
+ var lastIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+
+ var index = lastIndex ? string.toLowerCase().lastIndexOf(sub_string.toLowerCase()) : string.toLowerCase().indexOf(sub_string.toLowerCase());
+ if (index === -1) return string;
+ var before = void 0,
+ select = void 0,
+ after = void 0;
+ if (lastIndex) {
+ var _ref9 = [string.slice(0, index), string.slice(index, string.length), ""];
+ before = _ref9[0];
+ select = _ref9[1];
+ after = _ref9[2];
+ } else {
+ var _ref10 = [string.slice(0, index), string.slice(index, index + sub_string.length), string.slice(index + sub_string.length)];
+ before = _ref10[0];
+ select = _ref10[1];
+ after = _ref10[2];
+ }
+
+ return "" + before + tmpl_light(select) + after;
+ }
+ }]);
+
+ return AbsBaseSelect;
+ }();
+
+ exports.default = AbsBaseSelect;
+ exports.htmlTemplate = htmlTemplate;
+ exports.tmpl_plug = tmpl_plug;
+ exports.tmpl_elementOption = tmpl_elementOption;
+ exports.tmpl_preloader = tmpl_preloader;
+ exports.tmpl_light = tmpl_light;
+ exports.tmpl_elementResult = tmpl_elementResult;
+ exports.tmpl_selectBox = tmpl_selectBox;
+ exports.tmpl_selectBoxEditCont = tmpl_selectBoxEditCont;
+ exports.tmpl_selectBoxResults = tmpl_selectBoxResults;
+ exports.tmpl_selectBoxOptions = tmpl_selectBoxOptions;
+ exports.AbsBaseSelect = AbsBaseSelect;
+
+/***/ },
+/* 13 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = undefined;
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
+
+ var _AbsBaseSelect2 = __webpack_require__(12);
+
+ var _DataTree = __webpack_require__(7);
+
+ var _DataTree2 = _interopRequireDefault(_DataTree);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var TreeSelect = function (_AbsBaseSelect) {
+ _inherits(TreeSelect, _AbsBaseSelect);
+
+ function TreeSelect() {
+ _classCallCheck(this, TreeSelect);
+
+ return _possibleConstructorReturn(this, (TreeSelect.__proto__ || Object.getPrototypeOf(TreeSelect)).apply(this, arguments));
+ }
+
+ _createClass(TreeSelect, [{
+ key: 'setNearbySelectBox',
+ value: function setNearbySelectBox(next, prev) {
+ this.nextSelectBox = next;
+ this.prevSelectBox = prev;
+ }
+ }, {
+ key: 'clearAllNext',
+ value: function clearAllNext() {
+ this.clear();
+ if (this.nextSelectBox) {
+ this.nextSelectBox.hide();
+ this.nextSelectBox.clearAllNext();
+ }
+ }
+ }, {
+ key: 'clearAllPrev',
+ value: function clearAllPrev() {
+ this.clear();
+ if (this.prevSelectBox) {
+ this.clear();
+ this.hide();
+ this.prevSelectBox.clearAllPrev();
+ }
+ }
+ }, {
+ key: '_buildComponents',
+ value: function _buildComponents(data) {
+ _get(TreeSelect.prototype.__proto__ || Object.getPrototypeOf(TreeSelect.prototype), '_buildComponents', this).call(this, data);
+ //TODO: Изменять свойство visible при show/hide
+ if (!this.visible) this.hide();
+ if (this.hasEditableContainer) this.$editableContainer.hide();
+ this.dataTree = this.dataTree || new _DataTree2.default(data.results);
+ this._fillOptionsData();
+ this._bindEvents();
+ }
+ }, {
+ key: '_onclickOptionsElement',
+ value: function _onclickOptionsElement(e) {
+ this.clearAllNext();
+ _get(TreeSelect.prototype.__proto__ || Object.getPrototypeOf(TreeSelect.prototype), '_onclickOptionsElement', this).call(this, e);
+ if (this.nextSelectBox && this.dataTree.hasChildren(this.selectedEl.id)) {
+ this.nextSelectBox.setParent(this.selectedEl.id);
+ this.nextSelectBox.setHeader(this.selectedEl.value);
+ this.nextSelectBox.show();
+ }
+ if (this.prevSelectBox) {
+ this.prevSelectBox.$buttonAddOptions.hide();
+ this.prevSelectBox.$searchInput.removeClass("active");
+ }
+ this.$searchInput.addClass('active');
+ }
+ }, {
+ key: '_onButtonAddOptions',
+ value: function _onButtonAddOptions(e) {
+ // this._addToSelectedContainer(this.selectedEl.id);
+ // this.clear();
+ // e.preventDefault();
+ // return false;
+ _get(TreeSelect.prototype.__proto__ || Object.getPrototypeOf(TreeSelect.prototype), '_onButtonAddOptions', this).call(this, e);
+ this.clearAllNext();
+ this.clearAllPrev();
+ }
+ }, {
+ key: '_onButtonAdd',
+ value: function _onButtonAdd(e) {
+ _get(TreeSelect.prototype.__proto__ || Object.getPrototypeOf(TreeSelect.prototype), '_onButtonAdd', this).call(this, e);
+ this.clearAllNext();
+ this.clearAllPrev();
+ }
+ }, {
+ key: '_addToSelectedContainer',
+ value: function _addToSelectedContainer(id) {
+ if (this.selectedContainer) {
+ this.selectedContainer.add(id);
+ return;
+ }
+
+ this.prevSelectBox._addToSelectedContainer(id);
+ }
+ }]);
+
+ return TreeSelect;
+ }(_AbsBaseSelect2.AbsBaseSelect);
+
+ exports.default = TreeSelect;
+
+/***/ },
+/* 14 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = undefined;
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ var _AbsBaseSelect = __webpack_require__(12);
+
+ var _TreeSelect2 = __webpack_require__(13);
+
+ var _TreeSelect3 = _interopRequireDefault(_TreeSelect2);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var tmpl_selectBoxResults = function tmpl_selectBoxResults() {
+ return '\n \n';
+ };
+
+ var tmpl_elementResult = function tmpl_elementResult(el, id, header) {
+ return '\n ' + el + '\n ';
+ };
+ /**
+ * Поиск только в своей категории, отсутствует множественный выбор
+ */
+
+ var SingleTreeSelect = function (_TreeSelect) {
+ _inherits(SingleTreeSelect, _TreeSelect);
+
+ function SingleTreeSelect() {
+ _classCallCheck(this, SingleTreeSelect);
+
+ return _possibleConstructorReturn(this, (SingleTreeSelect.__proto__ || Object.getPrototypeOf(SingleTreeSelect)).apply(this, arguments));
+ }
+
+ _createClass(SingleTreeSelect, [{
+ key: 'getTemplate',
+ value: function getTemplate(classes) {
+ var selectBox = this.hasEditableContainer ? (0, _AbsBaseSelect.tmpl_selectBoxEditCont)() : (0, _AbsBaseSelect.tmpl_selectBox)();
+ classes = classes ? classes.join(" ") : "";
+ return (0, _AbsBaseSelect.htmlTemplate)({
+ header: "TestHeader", selectBox: selectBox, id: this.containerId, classes: classes,
+ tmpl_selectBoxOptions: _AbsBaseSelect.tmpl_selectBoxOptions, tmpl_selectBoxResults: tmpl_selectBoxResults
+ });
+ }
+ }, {
+ key: '_fillResultsData',
+ value: function _fillResultsData(searchText) {
+ var self = this;
+ // FILL RESULTS
+ // MAIN PART
+ var $container = this.$resultsBox.find('.main-part ul');
+ this._fillContainer($container, tmpl_elementResult, { searchText: searchText, parentCategoryId: self.parentId, attached: false });
+
+ this.$resultsBox.find('li').on("click", function (e) {
+ var id = $(e.target).data("id");
+ self.selectedEl.id = id;
+ self.selectedEl.value = self.dataTree.getElementById(id).name;
+ self.$searchInput.val(self.selectedEl.value);
+ self.updateEditableContainer(id);
+ if (self.$buttonAddOptions) self.$buttonAddOptions.show();
+ self.$resultsBox.hide();
+
+ //TODO: duplicate code
+ if (self.nextSelectBox && self.dataTree.hasChildren(self.selectedEl.id)) {
+ self.nextSelectBox.setParent(self.selectedEl.id);
+ self.nextSelectBox.setHeader(self.selectedEl.value);
+ self.nextSelectBox.show();
+ }
+ if (self.prevSelectBox) {
+ self.prevSelectBox.$buttonAddOptions.hide();
+ self.prevSelectBox.$searchInput.removeClass("active");
+ }
+ self.$searchInput.addClass('active');
+ });
+ }
+ }]);
+
+ return SingleTreeSelect;
+ }(_TreeSelect3.default);
+
+ exports.default = SingleTreeSelect;
+
+/***/ },
+/* 15 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = undefined;
+
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
+
+ var _AbsBaseSelect2 = __webpack_require__(12);
+
+ var _NoTreeData = __webpack_require__(8);
+
+ var _NoTreeData2 = _interopRequireDefault(_NoTreeData);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var htmlTemplate = function htmlTemplate(_ref) {
+ var header = _ref.header,
+ selectBox = _ref.selectBox,
+ _ref$id = _ref.id,
+ id = _ref$id === undefined ? "" : _ref$id,
+ _ref$classes = _ref.classes,
+ classes = _ref$classes === undefined ? "" : _ref$classes,
+ _ref$tmpl_selectBoxOp = _ref.tmpl_selectBoxOptions,
+ tmpl_selectBoxOptions = _ref$tmpl_selectBoxOp === undefined ? function () {
+ return "";
+ } : _ref$tmpl_selectBoxOp,
+ _ref$tmpl_selectBoxRe = _ref.tmpl_selectBoxResults,
+ tmpl_selectBoxResults = _ref$tmpl_selectBoxRe === undefined ? function () {
+ return "";
+ } : _ref$tmpl_selectBoxRe;
+ return '\n\n
\n ' + selectBox + '\n
\n\n ' + tmpl_selectBoxOptions() + '\n ' + tmpl_selectBoxResults() + '\n
\n
\n';
+ };
+
+ var tmpl_selectBoxResults = function tmpl_selectBoxResults() {
+ return '\n \n \n
\n';
+ };
+
+ // const tmpl_elementResult = (el, id, header) =>
+ // `
+ // ${el}
+ // `;
+
+ var SelectOrCreate = function (_AbsBaseSelect) {
+ _inherits(SelectOrCreate, _AbsBaseSelect);
+
+ function SelectOrCreate() {
+ _classCallCheck(this, SelectOrCreate);
+
+ return _possibleConstructorReturn(this, (SelectOrCreate.__proto__ || Object.getPrototypeOf(SelectOrCreate)).apply(this, arguments));
+ }
+
+ _createClass(SelectOrCreate, [{
+ key: 'getTemplate',
+ value: function getTemplate(classes) {
+ var selectBox = this.hasEditableContainer ? (0, _AbsBaseSelect2.tmpl_selectBoxEditCont)() : (0, _AbsBaseSelect2.tmpl_selectBox)();
+ classes = classes ? classes.join(" ") : "";
+ return htmlTemplate({
+ header: "TestHeader", selectBox: selectBox, id: this.containerId, classes: classes,
+ tmpl_selectBoxOptions: _AbsBaseSelect2.tmpl_selectBoxOptions, tmpl_selectBoxResults: tmpl_selectBoxResults
+ });
+ }
+ }, {
+ key: 'setLinkBoxes',
+ value: function setLinkBoxes() {
+ var boxes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+
+ this.boxes = boxes;
+ }
+ }, {
+ key: '_buildComponents',
+ value: function _buildComponents(data) {
+ _get(SelectOrCreate.prototype.__proto__ || Object.getPrototypeOf(SelectOrCreate.prototype), '_buildComponents', this).call(this, data);
+ var self = this;
+ //TODO: Изменять свойство visible при show/hide
+ if (!this.visible) this.hide();
+ if (this.hasEditableContainer) this.$editableContainer.hide();
+ this.dataTree = this.dataTree || new _NoTreeData2.default(data);
+ this.$buttonCreate = this.$resultsBox.find('.create');
+ // console.log("$buttonCreate = ", $buttonCreate);
+ this.$buttonCreate.on("click", function () {
+ return console.log('Button Create');
+ });
+ this.$buttonCreate.on("click", this._onButtonCreate.bind(self));
+ this._fillOptionsData();
+ this._bindEvents();
+ }
+ }, {
+ key: 'getData',
+ value: function getData(url) {
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+ return Promise.resolve($.ajax({
+ url: url,
+ dataType: 'json',
+ data: data
+ }));
+ }
+ }, {
+ key: '_onLoadDataError',
+ value: function _onLoadDataError(error) {
+ console.log("Error loading data -->", error);
+ }
+ }, {
+ key: '_onButtonAddOptions',
+ value: function _onButtonAddOptions(e) {
+ var _this2 = this;
+
+ var self = this;
+ var id = this.selectedEl.id;
+ this.getData('/api/realties?id=' + id).then(function (_data) {
+ var data = _data.results[0] || _data[0];
+ // this._addToSelectedContainer(this.selectedEl.id);
+ console.log("res data = ", data);
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = _this2.boxes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var box = _step.value;
+
+ box.selectedContainer.removeAll();
+ //TODO: Костыль!
+ if (box.type == 'building_classifications' && data['building_classification']) {
+ // console.log("building_classification = ",data['building_classification']);
+ box._addToSelectedContainer(data['building_classification'].id);
+ } else if (box.type == 'locations_flat' && data['location']) {
+ // console.log("location = ",data['location']);
+ box._addToSelectedContainer(data['location'].id);
+ } else if (box.type == 'construction_type' && data['construction_type']) {
+ // console.log("construction_type = ",data['construction_type']);
+ box._addToSelectedContainer(data['construction_type'].id);
+ } else {
+ console.log("Нет совпадений для ", box.type);
+ }
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+ }).catch(this._onLoadDataError.bind(self));
+ _get(SelectOrCreate.prototype.__proto__ || Object.getPrototypeOf(SelectOrCreate.prototype), '_onButtonAddOptions', this).call(this, e);
+ }
+ }, {
+ key: '_onButtonCreate',
+ value: function _onButtonCreate(e) {
+ this.selectedContainer.add({ text: this.$searchInput.val() });
+ if (this.boxes) {
+ var _iteratorNormalCompletion2 = true;
+ var _didIteratorError2 = false;
+ var _iteratorError2 = undefined;
+
+ try {
+ for (var _iterator2 = this.boxes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
+ var box = _step2.value;
+
+ console.log('box clear');
+ box.selectedContainer.removeAll();
+ }
+ } catch (err) {
+ _didIteratorError2 = true;
+ _iteratorError2 = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
+ _iterator2.return();
+ }
+ } finally {
+ if (_didIteratorError2) {
+ throw _iteratorError2;
+ }
+ }
+ }
+ }
+ e.preventDefault();
+ this.$buttonCreate.hide();
+ this.$searchInput.val("");
+ }
+ }, {
+ key: '_onInput_searchInput',
+ value: function _onInput_searchInput(e) {
+ // this._fillResultsData(self .$searchInput.val());
+ this.$buttonAddOptions.hide();
+ this.$buttonCreate.show();
+ // console.log("on input");
+ this.$resultsBox.show();
+ this.$optionsBox.hide();
+ }
+ }, {
+ key: '_onClick_searchInput',
+ value: function _onClick_searchInput(e) {
+ this.$optionsBox.show();
+ this.$resultsBox.hide();
+ this.$searchInput.val("");
+ }
+ }]);
+
+ return SelectOrCreate;
+ }(_AbsBaseSelect2.AbsBaseSelect);
+
+ exports.default = SelectOrCreate;
+
+/***/ }
+/******/ ]);
\ No newline at end of file
diff --git a/assets/js/build/user.js b/assets/js/build/user.js
new file mode 100644
index 0000000..3b0288e
--- /dev/null
+++ b/assets/js/build/user.js
@@ -0,0 +1,223 @@
+/******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId])
+/******/ return installedModules[moduleId].exports;
+
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ exports: {},
+/******/ id: moduleId,
+/******/ loaded: false
+/******/ };
+
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+
+/******/ // Flag the module as loaded
+/******/ module.loaded = true;
+
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+
+
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "";
+
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(0);
+/******/ })
+/************************************************************************/
+/******/ ([
+/* 0 */
+/***/ function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+ var _createClass = function () {
+ function defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
+ }
+ }return function (Constructor, protoProps, staticProps) {
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
+ };
+ }();
+
+ var _desc, _value, _class;
+
+ var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
+ return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
+ } : function (obj) {
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
+ };
+
+ function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+ }
+
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
+ var desc = {};
+ Object['ke' + 'ys'](descriptor).forEach(function (key) {
+ desc[key] = descriptor[key];
+ });
+ desc.enumerable = !!desc.enumerable;
+ desc.configurable = !!desc.configurable;
+
+ if ('value' in desc || desc.initializer) {
+ desc.writable = true;
+ }
+
+ desc = decorators.slice().reverse().reduce(function (desc, decorator) {
+ return decorator(target, property, desc) || desc;
+ }, desc);
+
+ if (context && desc.initializer !== void 0) {
+ desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
+ desc.initializer = undefined;
+ }
+
+ if (desc.initializer === void 0) {
+ Object['define' + 'Property'](target, property, desc);
+ desc = null;
+ }
+
+ return desc;
+ }
+
+ function onBind(target, name, descriptor) {
+ var method = descriptor.value;
+
+ descriptor.value = function () {
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
+ var binds = [];
+ args = Array.from(args);
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = args.slice()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var arg = _step.value;
+
+ if ((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object') {
+ binds.push(arg);
+ args.splice(args.indexOf(arg), 1);
+ }
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ method.apply(this, args);
+ var _iteratorNormalCompletion2 = true;
+ var _didIteratorError2 = false;
+ var _iteratorError2 = undefined;
+
+ try {
+ for (var _iterator2 = binds[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
+ var bind = _step2.value;
+
+ bind.func.bind(this)();
+ }
+ } catch (err) {
+ _didIteratorError2 = true;
+ _iteratorError2 = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
+ _iterator2.return();
+ }
+ } finally {
+ if (_didIteratorError2) {
+ throw _iteratorError2;
+ }
+ }
+ }
+
+ return this;
+ };
+ }
+
+ var Base = (_class = function () {
+ function Base() {
+ _classCallCheck(this, Base);
+
+ this.attr1 = 'attr1';
+ console.log("Constructor");
+ }
+
+ _createClass(Base, [{
+ key: 'method1',
+ value: function method1() {
+ var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
+ var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
+
+ console.log("this.attr1 = ", this.attr1);
+ console.log("a = ", a, "b = ", b);
+ }
+ }, {
+ key: 'on',
+ value: function on(methodName, func) {
+ this[methodName] = this[methodName].bind(this, { func: func });
+ }
+ }]);
+
+ return Base;
+ }(), _applyDecoratedDescriptor(_class.prototype, 'method1', [onBind], Object.getOwnPropertyDescriptor(_class.prototype, 'method1'), _class.prototype), _class);
+
+ var b = new Base();
+
+ b.on("method1", function () {
+ return console.log("Another message...");
+ });
+ b.on("method1", function () {
+ console.log("bind this.attr1 =", this.attr1);
+ });
+
+ b.method1("one", 2);
+ b.method1("bbb");
+
+ if (true) {
+ console.log("Dev mode message");
+ }
+
+ function a(_ref) {
+ var _ref$a = _ref.a,
+ a = _ref$a === undefined ? 2 : _ref$a,
+ _ref$b = _ref.b,
+ b = _ref$b === undefined ? a + 4 : _ref$b;
+ }
+
+/***/ }
+/******/ ]);
\ No newline at end of file
diff --git a/assets/js/src/customer_project_create.js b/assets/js/src/customer_project_create.js
new file mode 100644
index 0000000..a66e453
--- /dev/null
+++ b/assets/js/src/customer_project_create.js
@@ -0,0 +1,25 @@
+import fileUploadInit from './seeds/file_upload'
+import {extendedFieldInit} from './seeds/extended_field'
+import {customCheckInit} from './seeds/custom_check'
+import {readMoreInit} from './seeds/read_more'
+import {print} from './seeds/test_seeds'
+
+function showHideRealry() {
+ let check = $('#checkbox-sb-realty');
+ check.on("click", function (e) {
+ let $realty = $('#sb-realty');
+ if ($(e.target).prop("checked")) {
+ $realty.show();
+ } else {
+ $realty.hide();
+ }
+ })
+}
+
+$(function () {
+ fileUploadInit();
+ extendedFieldInit();
+ customCheckInit();
+ showHideRealry();
+ readMoreInit();
+});
\ No newline at end of file
diff --git a/assets/js/src/init_customer_project_create.js b/assets/js/src/init_customer_project_create.js
new file mode 100644
index 0000000..aecf63a
--- /dev/null
+++ b/assets/js/src/init_customer_project_create.js
@@ -0,0 +1,122 @@
+import SelectedContainer from 'components/SelectedContainer';
+import SelectedContainerCreate from 'components/SelectedContainerCreate';
+import NoTreeSelect from 'components/NoTreeSelect';
+import TreeSelect from 'components/TreeSelect';
+import SingleTreeSelect from 'components/SingleTreeSelect'
+import SelectOrCreate from 'components/SelectOrCreate'
+
+$(function () {
+ function createSpecs(url) {
+ // SPECIALIZATIONS
+ let sb_main = new TreeSelect($('#select-box-1'), {url, visible: true, required: true});
+ sb_main.setHeader("Специальность");
+ let select_container = new SelectedContainer($('#selected-spec'),
+ {
+ obj: sb_main,
+ onlyOne: true
+ });
+ sb_main.connectSelectedContainer(select_container);
+ let sb_1 = new TreeSelect($('#select-box-2'), {obj: sb_main});
+ let sb_2 = new TreeSelect($('#select-box-3'), {obj: sb_main});
+ let sb_3 = new TreeSelect($('#select-box-4'), {obj: sb_main});
+ let sb_4 = new TreeSelect($('#select-box-5'), {obj: sb_main});
+
+ select_container.on("add", () => {
+ let $container = $('#spec-value');
+ $container.html($('#selected-spec').find(".selected-element").find(".name").html());
+ });
+
+ sb_main.setNearbySelectBox(sb_1);
+ sb_1.setNearbySelectBox(sb_2, sb_main);
+ sb_2.setNearbySelectBox(sb_3, sb_1);
+ sb_3.setNearbySelectBox(sb_4, sb_2);
+ sb_4.setNearbySelectBox("", sb_3);
+
+ }
+
+ function createBuildingClass(url) {
+ // BUILDING-CLASSIFICATION
+ sb_build_main = new TreeSelect($('#sb-building-classification'), {url, visible: true});
+ sb_build_main.setHeader("Классификация здания");
+
+ let sb_build_1 = new TreeSelect($('#sb-building-sub-classification'), {obj: sb_build_main});
+
+ let select_build_container = new SelectedContainer($('#selected-building-classification'),
+ {
+ obj: sb_build_main,
+ onlyOne: true
+ });
+ sb_build_main.connectSelectedContainer(select_build_container);
+
+ sb_build_main.setNearbySelectBox(sb_build_1);
+ sb_build_1.setNearbySelectBox("", sb_build_main);
+ }
+
+ function createConstructionType(url) {
+ sb_constr_main = new NoTreeSelect($('#sb-construction-type'), {url, visible: true});
+ sb_constr_main.setHeader("Вид строительства");
+ let select_constr_type = new SelectedContainer($('#selected-construction-type'), {
+ obj: sb_constr_main,
+ noTree: true,
+ onlyOne: true
+ });
+ sb_constr_main.connectSelectedContainer(select_constr_type);
+ }
+
+ function createLocations(url) {
+ sb_loc_main = new TreeSelect($('#sb-location-1'), {url, visible: true});
+ sb_loc_main.setHeader("Местоположение");
+ let select_loc = new SelectedContainer($('#selected-location'),
+ {
+ obj: sb_loc_main,
+ onlyOne: true
+ });
+ sb_loc_main.connectSelectedContainer(select_loc);
+ let sb_loc_1 = new TreeSelect($('#sb-location-2'), {obj: sb_loc_main});
+ let sb_loc_2 = new TreeSelect($('#sb-location-3'), {obj: sb_loc_main});
+
+ sb_loc_main.setNearbySelectBox(sb_loc_1);
+ sb_loc_1.setNearbySelectBox(sb_loc_2, sb_loc_main);
+ sb_loc_2.setNearbySelectBox("", sb_loc_1);
+ }
+
+ function createRealty(url) {
+ let sb_realty = new SelectOrCreate($('#sb-realty'), {url, visible: true});
+ sb_realty.setHeader(" ");
+ let select_realty = new SelectedContainerCreate($('#selected-realty'),
+ {
+ obj: sb_realty,
+ noTree: true,
+ onlyOne: true,
+ noHeader: true
+ });
+ sb_realty.connectSelectedContainer(select_realty);
+ sb_realty.setLinkBoxes([sb_loc_main, sb_constr_main, sb_build_main]);
+ select_realty.on("add", () => {
+ $('#checkbox-sb-realty').attr("disabled", true)
+ });
+ select_realty.on("remove", () => {
+ $('#checkbox-sb-realty').attr("disabled", false)
+ });
+ sb_realty.dataPromise.then(function () {
+ let $realty = $('#sb-realty');
+ let check = $('#checkbox-sb-realty');
+ if (!check.prop("checked")) {
+ $realty.hide();
+ console.log("hide");
+ }
+ }
+ )
+ }
+
+ let sb_loc_main, sb_constr_main, sb_build_main;
+
+ createSpecs('/api/specializations_flat');
+
+ createBuildingClass('/api/building_classifications');
+ createConstructionType('/api/construction_type');
+ createLocations('/api/locations_flat');
+
+ createRealty('/api/realties/current_user')
+
+});
\ No newline at end of file
diff --git a/assets/js/src/seeds/components_script.js b/assets/js/src/seeds/components_script.js
new file mode 100644
index 0000000..e69de29
diff --git a/assets/js/src/seeds/custom_check.js b/assets/js/src/seeds/custom_check.js
new file mode 100644
index 0000000..2f231bd
--- /dev/null
+++ b/assets/js/src/seeds/custom_check.js
@@ -0,0 +1,19 @@
+function customCheckInit() {
+ function tuneCheckBoxes($boxes) {
+ let currentState = $boxes.find("input").prop("checked") ? 'checked' : 'not-checked';
+ $boxes.find("div").hide();
+ $boxes.find("div." + currentState).show();
+ }
+
+ let $boxes = $('.custom-check');
+ tuneCheckBoxes($boxes);
+ $boxes.on("click", function (e) {
+ let inside_checkBox = $(e.target).parent().find("input");
+ inside_checkBox.prop("checked", !inside_checkBox.prop("checked"));
+ tuneCheckBoxes($boxes);
+ e.preventDefault();
+ return false;
+ });
+}
+
+export {customCheckInit}
\ No newline at end of file
diff --git a/assets/js/src/seeds/extended_field.js b/assets/js/src/seeds/extended_field.js
new file mode 100644
index 0000000..99599b6
--- /dev/null
+++ b/assets/js/src/seeds/extended_field.js
@@ -0,0 +1,20 @@
+function extendedFieldInit() {
+
+ let $buttonF1 = $('.resButton');
+ if ($('.slide').hasClass("active")) $buttonF1.css('transform', 'rotate(0deg)');
+
+ $buttonF1.on("click", function (e) {
+ e.preventDefault();
+ let $slide = $('.slide');
+ if ($slide.hasClass("active")) {
+ $buttonF1.css('transform', 'rotate(180deg)');
+ $slide.slideUp(300);
+ } else {
+ $buttonF1.css('transform', 'rotate(0deg)');
+ $slide.slideDown(300);
+ }
+ $slide.toggleClass("active");
+ });
+}
+
+export {extendedFieldInit}
\ No newline at end of file
diff --git a/assets/js/src/seeds/file_upload.js b/assets/js/src/seeds/file_upload.js
new file mode 100644
index 0000000..23aa00b
--- /dev/null
+++ b/assets/js/src/seeds/file_upload.js
@@ -0,0 +1,57 @@
+function humanFileSize(bytes, si) {
+ var thresh = si ? 1000 : 1024;
+
+ if (Math.abs(bytes) < thresh)
+ return bytes + ' B';
+
+ var units = si
+ ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
+ : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
+
+ var u = -1;
+
+ do {
+ bytes /= thresh;
+ ++u
+ } while (Math.abs(bytes) >= thresh && u < units.length - 1);
+
+ return bytes.toFixed(1) + ' ' + units[u]
+}
+
+export default function fileUploadInit() {
+ var $fileUploadContainer = $('#fileUploadContainer');
+
+ $('#fileUploadAddBtn').on('click', function ($evt) {
+ $fileUploadContainer.find('.file-upload-widget').last().find('.file-upload-input').click()
+ });
+
+ $fileUploadContainer.on('change', '.file-upload-input', function ($evt) {
+ var $fileInput = $(this);
+ var $fileUploadWidget = $fileInput.closest('.file-upload-widget');
+ var filePath = $fileInput.val().replace(/\\/g, '/');
+ var fileName = path.basename(filePath);
+ //var fileExt = path.extname(filePath)
+ var fileSize = $fileInput.get(0).files && humanFileSize($fileInput.get(0).files[0].size);
+
+ if (fileName) {
+ $fileUploadWidget.find('.file-upload-label').text(fileName + ' ' + fileSize);
+
+ var $newFileUploadWidget = $fileUploadWidget.clone();
+ $newFileUploadWidget.find('.file-upload-label').text('');
+
+ $fileUploadContainer.find('ul').first().append($newFileUploadWidget);
+
+ $fileUploadWidget.css('display', 'block')
+ }
+ });
+
+ $fileUploadContainer.on('click', '.file-upload-remove-btn', function ($evt) {
+ var $btn = $(this);
+ $btn.closest('.file-upload-widget').remove()
+ });
+
+ $fileUploadContainer.on('click', '.existing-file-remove-btn', function ($evt) {
+ var $btn = $(this);
+ $btn.closest('.existing-file-widget').remove()
+ });
+}
diff --git a/assets/js/src/seeds/read_more.js b/assets/js/src/seeds/read_more.js
new file mode 100644
index 0000000..a6b12e0
--- /dev/null
+++ b/assets/js/src/seeds/read_more.js
@@ -0,0 +1,16 @@
+function readMoreInit() {
+
+ $('.description .more').on("click", function (e) {
+ let $target = $(e.target);
+ $target.siblings(".complete").toggle();
+ $target.toggleClass("less");
+ });
+
+ // $(".more").toggle(function () {
+ // $(this).text("less..").siblings(".complete").show();
+ // }, function () {
+ // $(this).text("more..").siblings(".complete").hide();
+ // });
+}
+
+export {readMoreInit}
\ No newline at end of file
diff --git a/assets/js/src/seeds/test_seeds.js b/assets/js/src/seeds/test_seeds.js
new file mode 100644
index 0000000..f859e9c
--- /dev/null
+++ b/assets/js/src/seeds/test_seeds.js
@@ -0,0 +1,5 @@
+function print(text) {
+ console.log(text);
+}
+
+export {print}
\ No newline at end of file
diff --git a/assets/js/src/user.js b/assets/js/src/user.js
new file mode 100644
index 0000000..7e39f9b
--- /dev/null
+++ b/assets/js/src/user.js
@@ -0,0 +1,56 @@
+
+function onBind(target, name, descriptor) {
+ const method = descriptor.value;
+
+ descriptor.value = function (...args) {
+ let binds = [];
+ args = Array.from(args);
+ for (let arg of args.slice()) {
+ if (typeof arg === 'object') {
+ binds.push(arg);
+ args.splice(args.indexOf(arg), 1);
+ }
+ }
+ method.apply(this, args);
+ for (let bind of binds) {
+ bind.func.bind(this)();
+ }
+ return this;
+ }
+}
+
+class Base {
+ constructor() {
+ this.attr1 = 'attr1';
+ console.log("Constructor")
+ }
+
+ @onBind
+ method1(a = 1, b = 2) {
+ console.log("this.attr1 = ", this.attr1);
+ console.log("a = ", a, "b = ", b);
+ }
+
+ on(methodName, func) {
+ this[methodName] = this[methodName].bind(this, {func});
+ }
+}
+
+let b = new Base();
+
+b.on("method1", () => console.log("Another message..."));
+b.on("method1", function () {
+ console.log("bind this.attr1 =", this.attr1);
+});
+
+b.method1("one", 2);
+b.method1("bbb");
+
+if (NODE_ENV == 'dev') {
+ console.log("Dev mode message")
+}
+
+
+function a({a=2, b=a+4}) {
+
+}
\ No newline at end of file
diff --git a/assets/lib/proekton-components/bash/browserify.sh b/assets/lib/proekton-components/bash/browserify.sh
deleted file mode 100644
index 23b9365..0000000
--- a/assets/lib/proekton-components/bash/browserify.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-echo "run browserify"
-cd ..
-source ~/venv/proekton/bin/activate
-#browserify ./js/src/init.js -o ./js/build/init.js -t babelify
-#browserify ./js/src/init_user_profile.js -o ./js/build/init_user_profile.js -t babelify
-browserify ./js/src/init_customer_project_create.js -o ./js/build/init_customer_project_create.js -t babelify
-#watchify ./js/src/init.js -t babelify -o ./js/build/init.js
\ No newline at end of file
diff --git a/assets/lib/proekton-components/js/src/NoTreeSelect.js b/assets/lib/proekton-components/js/src/NoTreeSelect.js
index d536521..82ab5a2 100644
--- a/assets/lib/proekton-components/js/src/NoTreeSelect.js
+++ b/assets/lib/proekton-components/js/src/NoTreeSelect.js
@@ -2,9 +2,9 @@ import {AbsBaseSelect} from './base/AbsBaseSelect'
import NoTreeData from './data/NoTreeData'
export default class NoTreeSelect extends AbsBaseSelect{
- constructor($container, {url, obj, visible=true}){
+ constructor($container, {url, obj, visible=true, required = false}){
//TODO: сделать автоматическую передачу всех параметров родителю
- super($container, {url, obj, visible});
+ super($container, {url, obj, visible, required});
}
_buildComponents(data) {
diff --git a/assets/lib/proekton-components/js/src/SelectOrCreate.js b/assets/lib/proekton-components/js/src/SelectOrCreate.js
new file mode 100644
index 0000000..32ed5f0
--- /dev/null
+++ b/assets/lib/proekton-components/js/src/SelectOrCreate.js
@@ -0,0 +1,133 @@
+import {
+ tmpl_selectBoxOptions,
+ tmpl_selectBoxEditCont,
+ tmpl_selectBox,
+ AbsBaseSelect
+} from './base/AbsBaseSelect'
+import NoTreeData from './data/NoTreeData'
+
+const htmlTemplate = ({header, selectBox, id = "", classes = "", tmpl_selectBoxOptions = () => "", tmpl_selectBoxResults = () => ""}) =>
+ `
+
+
+ ${selectBox}
+
+
+ ${tmpl_selectBoxOptions()}
+ ${tmpl_selectBoxResults()}
+
+
+`;
+
+const tmpl_selectBoxResults = () =>
+ `
+
+
+
+`;
+
+// const tmpl_elementResult = (el, id, header) =>
+// `
+// ${el}
+// `;
+
+export default class SelectOrCreate extends AbsBaseSelect {
+ getTemplate(classes) {
+ let selectBox = this.hasEditableContainer ? tmpl_selectBoxEditCont() : tmpl_selectBox();
+ classes = classes ? classes.join(" ") : "";
+ return htmlTemplate({
+ header: "TestHeader", selectBox, id: this.containerId, classes,
+ tmpl_selectBoxOptions, tmpl_selectBoxResults
+ })
+ }
+
+ setLinkBoxes(boxes = []) {
+ this.boxes = boxes;
+ }
+
+ _buildComponents(data) {
+ super._buildComponents(data);
+ const self = this;
+ //TODO: Изменять свойство visible при show/hide
+ if (!this.visible) this.hide();
+ if (this.hasEditableContainer) this.$editableContainer.hide();
+ this.dataTree = this.dataTree || new NoTreeData(data);
+ this.$buttonCreate = this.$resultsBox.find('.create');
+ // console.log("$buttonCreate = ", $buttonCreate);
+ this.$buttonCreate.on("click", () => console.log('Button Create'));
+ this.$buttonCreate.on("click", this._onButtonCreate.bind(self));
+ this._fillOptionsData();
+ this._bindEvents();
+ }
+
+ getData(url, data = {}) {
+ return Promise.resolve($.ajax({
+ url: url,
+ dataType: 'json',
+ data: data,
+ }))
+ }
+
+ _onLoadDataError(error) {
+ console.log("Error loading data -->", error);
+ }
+
+ _onButtonAddOptions(e) {
+ const self = this;
+ let id = this.selectedEl.id;
+ this.getData(`/api/realties?id=${id}`)
+ .then((_data)=> {
+ let data = _data.results[0] || _data[0];
+ // this._addToSelectedContainer(this.selectedEl.id);
+ console.log("res data = ", data);
+ for (let box of this.boxes) {
+ box.selectedContainer.removeAll();
+ //TODO: Костыль!
+ if (box.type == 'building_classifications' && data['building_classification']) {
+ // console.log("building_classification = ",data['building_classification']);
+ box._addToSelectedContainer(data['building_classification'].id)
+ }else if (box.type == 'locations_flat' && data['location']){
+ // console.log("location = ",data['location']);
+ box._addToSelectedContainer(data['location'].id)
+ }else if (box.type == 'construction_type' && data['construction_type']){
+ // console.log("construction_type = ",data['construction_type']);
+ box._addToSelectedContainer(data['construction_type'].id)
+ }else{
+ console.log("Нет совпадений для ", box.type);
+ }
+ }
+ }
+ )
+ .catch(this._onLoadDataError.bind(self));
+ super._onButtonAddOptions(e);
+ }
+
+
+ _onButtonCreate(e) {
+ this.selectedContainer.add({text: this.$searchInput.val()});
+ if (this.boxes) {
+ for (let box of this.boxes) {
+ console.log('box clear');
+ box.selectedContainer.removeAll();
+ }
+ }
+ e.preventDefault();
+ this.$buttonCreate.hide();
+ this.$searchInput.val("");
+ }
+
+ _onInput_searchInput(e) {
+ // this._fillResultsData(self .$searchInput.val());
+ this.$buttonAddOptions.hide();
+ this.$buttonCreate.show();
+ // console.log("on input");
+ this.$resultsBox.show();
+ this.$optionsBox.hide();
+ }
+
+ _onClick_searchInput(e) {
+ this.$optionsBox.show();
+ this.$resultsBox.hide();
+ this.$searchInput.val("");
+ }
+}
\ No newline at end of file
diff --git a/assets/lib/proekton-components/js/src/SelectedContainer.js b/assets/lib/proekton-components/js/src/SelectedContainer.js
index 044cd12..681940e 100644
--- a/assets/lib/proekton-components/js/src/SelectedContainer.js
+++ b/assets/lib/proekton-components/js/src/SelectedContainer.js
@@ -5,8 +5,8 @@ import onBind from './decorators'
let tmpl_selectedElement = (header, name, id) =>
`
-
-