From d293a327002a6d9f55c46a46bb29e8c7ffb20590 Mon Sep 17 00:00:00 2001 From: booblegum Date: Wed, 28 Dec 2016 17:03:33 +0300 Subject: [PATCH] =?UTF-8?q?PR-61=20=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8E=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D1=87=D0=B8=D0=BA=D0=B0,=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D0=BC=20=D0=B7=D0=B0=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D1=81=D1=81?= =?UTF-8?q?=D1=8B=D0=BB=D0=BA=D0=B5=20=D0=B2=20=D1=88=D0=B0=D0=BF=D0=BA?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Мелкие визуальные и функциональные правки --- assets/js/build/create_project.js | 7 ++ .../js/build/init_customer_project_create.js | 2 + assets/js/build/init_portfolio_create_edit.js | 84 ------------------ assets/js/src/customer_project_create.js | 7 ++ assets/js/src/init_customer_project_create.js | 2 + assets/js/src/init_portfolio_create_edit.js | 87 ------------------- .../customer_project_create_or_edit.html | 12 +-- projects/views.py | 12 ++- users/static/sass/customer-profile.sass | 2 +- users/templates/partials/inc-objects.html | 8 +- users/views.py | 4 +- 11 files changed, 41 insertions(+), 186 deletions(-) diff --git a/assets/js/build/create_project.js b/assets/js/build/create_project.js index d3122f3..4cc450a 100644 --- a/assets/js/build/create_project.js +++ b/assets/js/build/create_project.js @@ -76,6 +76,12 @@ }); } + function changeButtonText() { + //Если перешли со страницы профиля по кнопке "Добавить заказ" + var id = window.location.hash.replace("#", ""); + if (id) $('.js-change-text').val("ДОБАВИТЬ ЗАКАЗ"); + } + $(function () { (0, _file_upload.fileUploadInit)(); (0, _extended_field.extendedFieldInit)(); @@ -86,6 +92,7 @@ (0, _scroll_on_required.scrollOnRequiredInit)(); (0, _popups.showPopupsInit)(); (0, _ajax_registration.ajaxRegistrationInit)('customer'); + changeButtonText(); window.addMessage = _popups.addMessage; }); diff --git a/assets/js/build/init_customer_project_create.js b/assets/js/build/init_customer_project_create.js index fba34b2..2e69091 100644 --- a/assets/js/build/init_customer_project_create.js +++ b/assets/js/build/init_customer_project_create.js @@ -174,8 +174,10 @@ if (!sb_realty_top.dataTree.data.length) { sb_realty_top.hide(); } else { + //Если перешли со страницы профиля по кнопке "Добавить заказ" var id = window.location.hash.replace("#", ""); if (id) sb_realty_top.setElementById(id); + select_realty.add(id); } }); select_realty.on("add", function (args) { diff --git a/assets/js/build/init_portfolio_create_edit.js b/assets/js/build/init_portfolio_create_edit.js index e3e7deb..921689e 100644 --- a/assets/js/build/init_portfolio_create_edit.js +++ b/assets/js/build/init_portfolio_create_edit.js @@ -111,86 +111,6 @@ 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(); - } - }); - var sb_realty_top = new _NoTreeSelect2.default($('#sb-realty-top'), { url: url, visible: true }); - sb_realty_top.setHeader("Объект"); - sb_realty_top.connectSelectedContainer(select_realty); - sb_realty_top.dataPromise.then(function () { - if (!sb_realty_top.dataTree.data.length) { - sb_realty_top.hide(); - } else { - var id = window.location.hash.replace("#", ""); - if (id) sb_realty_top.setElementById(id); - } - }); - select_realty.on("add", function (args) { - //TODO: Костыли!!! - $('#checkbox-sb-realty').prop("checked", true); - sb_realty.show(); - var id = args[0]; - if (id.text) return; - var el = sb_realty.dataTree.getElementById(id); - sb_realty_top.dataPromise.then(function () { - sb_realty_top.$searchInput.val(el.name); - sb_realty_top.selectedEl.id = id; - sb_realty_top.selectedEl.value = el.name; - }); - - sb_realty.selectedEl.id = id; - sb_realty._fillBoxes(); - }); - } - var sb_loc_main = void 0, sb_constr_main = void 0, sb_build_main = void 0; @@ -198,10 +118,6 @@ createSpecs('/api/specializations_flat'); // Классификация здания createBuildingClass('/api/building_classifications'); - // createConstructionType('/api/construction_type'); - // createLocations('/api/locations_flat'); - - // createRealty('/api/realties/current_user') }); // import SingleTreeSelect from 'components/SingleTreeSelect' diff --git a/assets/js/src/customer_project_create.js b/assets/js/src/customer_project_create.js index 0ac65d6..dd7296c 100644 --- a/assets/js/src/customer_project_create.js +++ b/assets/js/src/customer_project_create.js @@ -20,6 +20,12 @@ function showHideRealry() { }) } +function changeButtonText() { + //Если перешли со страницы профиля по кнопке "Добавить заказ" + let id = window.location.hash.replace("#", ""); + if (id) $('.js-change-text').val("ДОБАВИТЬ ЗАКАЗ"); +} + $(function () { fileUploadInit(); extendedFieldInit(); @@ -30,5 +36,6 @@ $(function () { scrollOnRequiredInit(); showPopupsInit(); ajaxRegistrationInit('customer'); + changeButtonText(); window.addMessage = addMessage; }); \ 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 index bad2d50..aff853c 100644 --- a/assets/js/src/init_customer_project_create.js +++ b/assets/js/src/init_customer_project_create.js @@ -113,8 +113,10 @@ $(function () { if (!sb_realty_top.dataTree.data.length) { sb_realty_top.hide() }else{ + //Если перешли со страницы профиля по кнопке "Добавить заказ" let id = window.location.hash.replace("#", ""); if (id) sb_realty_top.setElementById(id); + select_realty.add(id); } }); select_realty.on("add", (args)=> { diff --git a/assets/js/src/init_portfolio_create_edit.js b/assets/js/src/init_portfolio_create_edit.js index c21c3f8..71c633d 100644 --- a/assets/js/src/init_portfolio_create_edit.js +++ b/assets/js/src/init_portfolio_create_edit.js @@ -52,97 +52,10 @@ $(function () { 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(); - } - } - ); - let sb_realty_top = new NoTreeSelect($('#sb-realty-top'), {url, visible: true}); - sb_realty_top.setHeader("Объект"); - sb_realty_top.connectSelectedContainer(select_realty); - sb_realty_top.dataPromise.then(function () { - if (!sb_realty_top.dataTree.data.length) { - sb_realty_top.hide() - }else{ - let id = window.location.hash.replace("#", ""); - if (id) sb_realty_top.setElementById(id); - } - }); - select_realty.on("add", (args)=> { - //TODO: Костыли!!! - $('#checkbox-sb-realty').prop("checked", true); - sb_realty.show(); - let id = args[0]; - if (id.text) return; - let el = sb_realty.dataTree.getElementById(id); - sb_realty_top.dataPromise.then(function () { - sb_realty_top.$searchInput.val(el.name); - sb_realty_top.selectedEl.id = id; - sb_realty_top.selectedEl.value = el.name; - }); - - sb_realty.selectedEl.id = id; - sb_realty._fillBoxes(); - }) - } - 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/projects/templates/customer_project_create_or_edit.html b/projects/templates/customer_project_create_or_edit.html index 63e1b9d..88cc117 100644 --- a/projects/templates/customer_project_create_or_edit.html +++ b/projects/templates/customer_project_create_or_edit.html @@ -254,6 +254,7 @@ autocomplete="off">
+
 
+
 
-
@@ -426,10 +428,10 @@ {% endblock %} {% block old_js %} - - - - +{# #} +{# #} +{# #} +{# #} {% endblock %} {% block js_block %} diff --git a/projects/views.py b/projects/views.py index b58d15c..cb2c52d 100644 --- a/projects/views.py +++ b/projects/views.py @@ -395,18 +395,22 @@ class ProjectFilterView(BaseMixin, View): class SortRealtyBy(View): - def get_context(self): - # print("request.POST = ", self.request.POST) + def get_context_data(self, **kwargs): + context = {} user_id = self.request.POST.get('user_id') sort_by = self.request.POST.get('sortBy') state = self.request.POST.get('state') objects = Realty.objects.filter(user__id=user_id, state=state, is_virtual=False) if sort_by == 'num_orders': objects = objects.annotate(num_orders=Count('projects')) - return {"objects": objects.order_by('{}'.format(sort_by))} + context.update({ + "objects": objects.order_by('{}'.format(sort_by)), + "customer": User.objects.get(id=user_id), + }) + return context def post(self, *args, **kwargs): - return render(self.request, 'partials/inc-objects.html', self.get_context()) + return render(self.request, 'partials/inc-objects.html', self.get_context_data()) class CustomerProjectCreateView(BaseMixin, View): diff --git a/users/static/sass/customer-profile.sass b/users/static/sass/customer-profile.sass index 9b9efd7..78258bb 100644 --- a/users/static/sass/customer-profile.sass +++ b/users/static/sass/customer-profile.sass @@ -77,7 +77,7 @@ table.projects .cut display: inline-block text-overflow: ellipsis - max-width: 550px + max-width: 500px overflow: hidden word-wrap: break-word white-space: nowrap diff --git a/users/templates/partials/inc-objects.html b/users/templates/partials/inc-objects.html index 4cac95a..ff15f33 100644 --- a/users/templates/partials/inc-objects.html +++ b/users/templates/partials/inc-objects.html @@ -70,16 +70,18 @@