diff --git a/assets/css/main.css b/assets/css/main.css index 595b0ac..62037d6 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -1329,10 +1329,10 @@ footer:after { } .titleResF1, div p.titleResF1 { - font-size: 15px; + font-size: 14pt; font-family: 'Arial-MT-Regular', sans-serif; - font-weight: bold; - color: #2c2c2c; + /*font-weight: bold;*/ + color: #000000; float: left; } diff --git a/assets/lib/proekton-components/css/other.css b/assets/lib/proekton-components/css/other.css index 375262d..21206b3 100644 --- a/assets/lib/proekton-components/css/other.css +++ b/assets/lib/proekton-components/css/other.css @@ -10,8 +10,8 @@ label { } .selected-container .selected-element { - display: inline-block; - padding: 5px 25px 5px 10px; + /*display: inline-block;*/ + padding: 5px 35px 5px 10px; margin-top: 8px; min-height: 45px; background-color: #e3e3e3; @@ -21,35 +21,45 @@ label { -webkit-border-radius: 10px; /* Safari 4 */ border-radius: 10px; /* IE 9, Safari 5, Chrome */ } +.horizontal .selected-element{ + display: inline-block; +} -.selected-element .header{ - font-size: 9pt; - color: #979494; +.selected-element .header,.name{ white-space: nowrap; text-overflow: ellipsis; overflow: hidden; - word-wrap: break-word; + width: 100%; +} + +.selected-element .header{ + font-size: 7pt; + color: #676363; + /*white-space: nowrap;*/ + /*text-overflow: ellipsis;*/ + /*overflow: hidden;*/ + /*word-wrap: break-word;*/ + /*width: 100%;*/ } .selected-element .name { - font-size: 14pt; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - vertical-align: middle; - width: 100%; + font-size: 11pt; + /*white-space: nowrap;*/ + /*text-overflow: ellipsis;*/ + /*overflow: hidden;*/ + /*width: 100%;*/ } .selected-element .icon-remove{ background-image: url('../img/cross01.png'); - background-size: 24px 24px; + background-size: 20px 20px; /*display: inline-block;*/ position: absolute; right: 5px; top: 15px; - width: 16px; - height: 16px; + width: 20px; + height: 20px; cursor: pointer; margin-left: -20px; } @@ -66,7 +76,8 @@ label { } .separator { - margin: 20px 0; + margin-top: 35px; + margin-bottom: 5px; } .max-width { @@ -83,26 +94,26 @@ label { } .custom-check { background: url("../img/rect01.png") no-repeat center; - background-size: 200px 40px; - width: 200px; - height: 40px; + background-size: 210px 51px; + width: 210px; + height: 51px; cursor: pointer; } .custom-check.checked { background: url("../img/rect02.png") no-repeat center; - background-size: 200px 40px; - width: 200px; - height: 40px; + background-size: 210px 51px; + width: 210px; + height: 51px; } #page-preloader { - position: fixed; + position: absolute; left: 0; top: 0; right: 0; bottom: 0; - background: #000; + background: #090909; z-index: 100500; } diff --git a/assets/lib/proekton-components/css/select-box.css b/assets/lib/proekton-components/css/select-box.css index 15d067e..54eeb1a 100644 --- a/assets/lib/proekton-components/css/select-box.css +++ b/assets/lib/proekton-components/css/select-box.css @@ -1,10 +1,38 @@ +body { + font-size: 11pt; + font-family: Arial-MT-Regular, Arial, Sans-Serif; +} + +input[type="checkbox"] + span, input[type="checkbox"]:checked + span { + all: initial; + font-size: 9pt; + color: #494546; + cursor: pointer; +} + +.noselect { + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Chrome/Safari/Opera */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; + /* Non-prefixed version, currently + not supported by any browser */ +} + +/*input[type="checkbox"]:checked + span {*/ +/*all: initial;*/ +/*font-size: 9pt;*/ +/*color: #494546;*/ +/*}*/ + .select-box-container { display: block; /*margin-top: 40px;*/ /*min-width: 200px;*/ } -.select-box-header{ +.select-box-header { font-size: 14pt; white-space: nowrap; word-wrap: break-word; @@ -12,7 +40,7 @@ /*top:10px;*/ } -.select-box-header .header{ +.select-box-header .header { display: inline-block; color: black; text-overflow: ellipsis; @@ -23,11 +51,15 @@ } /*.select-box-header i {*/ - /*position: relative;*/ - /*top: -5px;*/ +/*position: relative;*/ +/*top: -5px;*/ /*}*/ -.select-box-header .fa:hover{ +.select-box-header .fa { + color: #565656; +} + +.select-box-header .fa:hover { cursor: pointer; } @@ -70,17 +102,21 @@ padding: 2px 10px; border-bottom: 1px solid #afb2b6; list-style: none; + font-size: 9pt; + color: #494546; } .select-box-results label, .select-box-options label, .select-box-results li, .select-box-options li { cursor: pointer; + display: inline-block; width: 100%; } .select-box-results li:hover, .select-box-options li:hover { background-color: #dcdcdc; border-left: 2px solid red; + color: #0b0b0b; } .select-box-search { @@ -88,7 +124,7 @@ } input.select-box-search { - height: 40px; + height: 51px; width: 100%; border: 1px solid #cccccc; outline: none; @@ -157,15 +193,16 @@ input.select-box-search { .editable-container { display: block; float: left; - /*max-width: 400px;*/ background-color: #e5e5e5; - min-height: 40px; + color: #585858; + font-size: 9pt; padding: 5px 10px; - /*min-width: 40px;*/ + height: 51px; + margin-left: 8px; position: relative; left: -30px; } -.vertical-child{ +.vertical-child { margin-top: 30px; } \ No newline at end of file diff --git a/assets/lib/proekton-components/img/rect01.png b/assets/lib/proekton-components/img/rect01.png index 841209e..aa314ce 100644 Binary files a/assets/lib/proekton-components/img/rect01.png and b/assets/lib/proekton-components/img/rect01.png differ diff --git a/assets/lib/proekton-components/img/rect02.png b/assets/lib/proekton-components/img/rect02.png index a46d1d4..a3f5826 100644 Binary files a/assets/lib/proekton-components/img/rect02.png and b/assets/lib/proekton-components/img/rect02.png differ diff --git a/assets/lib/proekton-components/js/SelectBox.js b/assets/lib/proekton-components/js/SelectBox.js index 59f6ece..5edb2a8 100644 --- a/assets/lib/proekton-components/js/SelectBox.js +++ b/assets/lib/proekton-components/js/SelectBox.js @@ -245,7 +245,8 @@ class SelectBox { } // FILL RESULTS - let result_template = (el, id) => `
  • `; + let result_template = (el, id) => + `
  • `; // MAIN PART let $container = this.$results_box.find('.main-part ul'); fillContainer($container, result_template, search_text, self.parent_id); diff --git a/assets/lib/proekton-components/js/SelectedContainer.js b/assets/lib/proekton-components/js/SelectedContainer.js index fccc924..43e0b30 100644 --- a/assets/lib/proekton-components/js/SelectedContainer.js +++ b/assets/lib/proekton-components/js/SelectedContainer.js @@ -22,9 +22,9 @@ class SelectedContainer { let htmlTemplate = `
    - +
    ${header} - +
    ${name}
    diff --git a/assets/lib/proekton-components/js/SimpleSelect.js b/assets/lib/proekton-components/js/SimpleSelect.js index a1ad262..7f3a48c 100644 --- a/assets/lib/proekton-components/js/SimpleSelect.js +++ b/assets/lib/proekton-components/js/SimpleSelect.js @@ -108,7 +108,8 @@ class SimpleSelect { } // FILL RESULTS - let result_template = (el, id) => `
  • `; + let result_template = (el, id) => + `
  • `; // MAIN PART let $container = this.$results_box.find('.main-part ul'); fillContainer($container, result_template, search_text, self.parent_id); diff --git a/assets/projects-filter.js b/assets/projects-filter.js new file mode 100644 index 0000000..294e7d7 --- /dev/null +++ b/assets/projects-filter.js @@ -0,0 +1,45 @@ +function getFormData($form, pageNum) { + var unindexed_array = $form.serializeArray(); + var indexed_array = {}; + + $.map(unindexed_array, function (n, i) { + indexed_array[n['name']] = n['value']; + }); + indexed_array["page"] = pageNum || ""; + return indexed_array; +} + +function modUrl($form, postfix) { + let curLoc = '?' + $form.serialize() + (postfix || ""); + try { + history.replaceState($form.serialize(), null, curLoc); + } catch (e) { + console.log("Error!"); + } +} + +function sendData(url, $form, pageNum) { + function updateResults(html) { + $container.html(html); + } + + const $container = $('#projectsBlock'); + $.ajax({ + url: url, + type: "POST", + dataType: 'html', + data: getFormData($form, pageNum), + beforeSend: function (xhr) { + xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken')); + }, + success: updateResults, + error: (data) => console.log("Error", data) + }); +} + +function sendFilterData(url) { + const $form = $('#filter-form'); + sendData('/projects/', $form); + modUrl($form); + return false; +} \ No newline at end of file diff --git a/projects/templates/partials/inc-projects-filter.html b/projects/templates/partials/inc-projects-filter.html new file mode 100644 index 0000000..11a9035 --- /dev/null +++ b/projects/templates/partials/inc-projects-filter.html @@ -0,0 +1,119 @@ +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +

    Поиск по ключевым словам и фразам

    +
    +
    +
    +
    +
    + + + + +
    +
    +

    Расширенные поля

    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + Требуется допуск (СРО) + +
    +
    + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/projects/templates/partials/inc-projects-results.html b/projects/templates/partials/inc-projects-results.html new file mode 100644 index 0000000..d262f8d --- /dev/null +++ b/projects/templates/partials/inc-projects-results.html @@ -0,0 +1,72 @@ +

    + {% if num_results > 0 %} + Найдено {{ num_results }} проектов + {% else %} + Ничего не найдено + {% endif %} +

    +{# SORT_BY #} +{% include 'partials/inc-projects-sort_by.html' %} +
    + {% for project in projects %} +
    +
    +

    + {{ project.name }} +

    + + {% if project.realty and project.realty.name %} +
      + + {% endif %} + +

      {{ project.text|linebreaksbr|truncatechars:300 }}

      + + {% if TEMPLATE_DEBUG %} +
      Specialization: {{ project.specialization }}

      Realty location: {{ project.realty.location }}

      Constr. type: {{ project.realty.construction_type }}

      Build. classif.: {{ project.realty.building_classification }}
      + {% endif %} + +
        +
      • {{ project.created }}
      • +
      • {{ project.hit_count.hits }}
      • +
      • {{ project.answers.count }}
      • + + {% if request.user.is_authenticated %} +
      • {{ project.customer.username }}
      • + {% endif %} +
      +
    +
    +

    + {{ project.budget }} +

    + +
      + {% if project.secure_deal %} +
    • Безопасная сделка
    • + {% endif %} + +
    • + {{ project.specialization.name }} +
    • +
    +
    +
    + {% endfor %} +
    +
    + {% include 'partials/ajax_pagination.html' %} +
    \ No newline at end of file diff --git a/projects/templates/partials/inc-projects-sort_by.html b/projects/templates/partials/inc-projects-sort_by.html new file mode 100644 index 0000000..2084d3d --- /dev/null +++ b/projects/templates/partials/inc-projects-sort_by.html @@ -0,0 +1,13 @@ +
    +

    Сортировать по:

    + + {% for val, text in choices %} + + {% endfor %} + +{# #} +{# #} +
    \ No newline at end of file diff --git a/projects/templates/project_filter.html b/projects/templates/project_filter.html index ca7b083..f81d7a9 100644 --- a/projects/templates/project_filter.html +++ b/projects/templates/project_filter.html @@ -7,216 +7,22 @@ {% endblock %} {% block content %} {% include 'partials/header.html' %} -
    -
    -
    -
    + +
    +
    +

    Поиск заказов

    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -
    -

    Поиск по ключевым словам и фразам

    -
    -
    -
    -
    -
    - - - - -
    -
    -

    Расширенные поля

    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - Требуется допуск (СРО) - -
    -
    - -
    -
    -
    -
    - - -
    - {# FILTERS #} -
    -

    {{ display_msg }}

    -
    -

    Сортировать по:

    - - {% for val, text in form.order_by.field.choices %} - - {% endfor %} - - - -
    -
    - {# PROJECTS LIST #} -
    - {% for project in projects %} -
    -
    -

    - {{ project.name }} -

    - - {% if project.realty and project.realty.name %} - - {% endif %} + {# FILTER#} + {% include 'partials/inc-projects-filter.html' %} -

    {{ project.text|linebreaksbr|truncatechars:300 }}

    - - {% if TEMPLATE_DEBUG %} -
    Specialization: {{ project.specialization }}

    Realty location: {{ project.realty.location }}

    Constr. type: {{ project.realty.construction_type }}

    Build. classif.: {{ project.realty.building_classification }}
    - {% endif %} - -
      -
    • {{ project.created }}
    • -
    • {{ project.hit_count.hits }}
    • -
    • {{ project.answers.count }}
    • - - {% if request.user.is_authenticated %} -
    • {{ project.customer.username }}
    • - {% endif %} -
    -
    -
    -

    - {{ project.budget }} -

    - -
      - {% if project.secure_deal %} -
    • Безопасная сделка
    • - {% endif %} - -
    • - {{ project.specialization.name }} -
    • -
    -
    -
    - {% endfor %} -
    - - -
    - {% include 'partials/pagination.html' %} -
    - - - {% include 'partials/footer.html' %} +
    +
    + {% include 'partials/inc-projects-results.html' %}
    - + {% include 'partials/footer.html' %} +
    {% endblock %} @@ -229,6 +35,7 @@ + diff --git a/projects/views.py b/projects/views.py index 9f7d88e..4ab7b5c 100644 --- a/projects/views.py +++ b/projects/views.py @@ -286,26 +286,26 @@ def build_query(id_str, _class, *args): class ProjectFilterView(BaseMixin, View): template_name = 'project_filter.html' - form_class = ProjectFilterForm - - def get(self, request, *args, **kwargs): - context = self.get_context_data(**_.merge({}, request.GET, kwargs)) - form = self.form_class(request.GET, request=request) + # form_class = ProjectFilterForm + # renderer_classes = (TemplateHTMLRenderer,) + PROJECT_ORDER_CHOICES = ( # "Упорядочить по"... + ('name', 'названию'), + ('budget', 'цене'), + ('created', 'дате размещения'), + ('views', 'просмотрам'), + ) - projects = Project.objects.filter(state='active') - specialization = request.GET.get('specialization') - keywords = request.GET.get('keywords') - building_classification = request.GET.get('building_classification') - construction_type = request.GET.get('construction_type') - location = request.GET.get('location') - cro = request.GET.get('cro') - order_by = request.GET.get('order_by') - last_order_by = request.GET.get('last_order_by') - reverse_order = request.GET.get('reverse_order') - ord = None - manual_sort = None + def filter(self, projects, data): + # print("filter data = ", data) + specialization = data.get('specialization') + keywords = data.get('keywords') + building_classification = data.get('building_classification') + construction_type = data.get('construction_type') + location = data.get('location') + cro = data.get('cro') if keywords: + # print("keywords = ", keywords) keywords = tuple(filter(None, re.split(r'\s|,|;', keywords))) for k in keywords: @@ -334,31 +334,33 @@ class ProjectFilterView(BaseMixin, View): if cro: projects = projects.filter(cro=True) - # ORDERS - if order_by: - reverse_order = not reverse_order if order_by == last_order_by else False - ord = order_by - last_order_by = ord - elif last_order_by: - ord = last_order_by - - if ord and ord == 'views': - projects = natsort.natsorted(projects.all(), key=lambda p: p.hit_count.hits, reverse=reverse_order) - manual_sort = True - elif ord: - projects = projects.order_by('-%s' % ord if reverse_order else ord) - - context.update({ - 'last_order_by': last_order_by, - 'reverse_order': reverse_order, - }) - - project_count = len(projects) - display_msg = 'Найдено %s проектов' % project_count if project_count > 0 else 'Ничего не найдено' - - paginator = Paginator(projects if manual_sort else projects.all(), settings.PAGE_SIZE) - page = request.GET.get('page') - + return projects + + def sort_by(self, projects): + # order_by = request.GET.get('order_by') + # last_order_by = request.GET.get('last_order_by') + # reverse_order = request.GET.get('reverse_order') + # ord = None + # manual_sort = None + # + # # ORDERS + # if order_by: + # reverse_order = not reverse_order if order_by == last_order_by else False + # ord = order_by + # last_order_by = ord + # elif last_order_by: + # ord = last_order_by + # + # if ord and ord == 'views': + # projects = natsort.natsorted(projects.all(), key=lambda p: p.hit_count.hits, reverse=reverse_order) + # manual_sort = True + # elif ord: + # projects = projects.order_by('-%s' % ord if reverse_order else ord) + return projects + + def pagination(self, projects, page): + paginator = Paginator(projects, settings.PAGE_SIZE) + # print("pag page = ", page) try: projects = paginator.page(page) except PageNotAnInteger: @@ -366,16 +368,31 @@ class ProjectFilterView(BaseMixin, View): except EmptyPage: projects = paginator.page(paginator.num_pages) + return projects + + def get_context(self, request): + context = request.dict() + + projects = Project.objects.filter(state='active') + projects = self.filter(projects, request) + num_results = projects.count() + projects = self.sort_by(projects) + projects = self.pagination(projects, request.get("page")) + context.update({ - 'form': form, - # 'realty_form': realty_form, + 'choices': self.PROJECT_ORDER_CHOICES, 'projects': projects, 'is_paginated': True, - # 'page_obj': projects, - 'display_msg': display_msg, + 'page_obj': projects, + 'num_results': num_results, }) + return context - return render(request, self.template_name, context) + def get(self, request): + return render(request, self.template_name, self.get_context(request.GET)) + + def post(self, request): + return render(request, 'partials/inc-projects-results.html', self.get_context(request.POST)) class CustomerProjectCreateView(BaseMixin, View): diff --git a/templates/partials/ajax_pagination.html b/templates/partials/ajax_pagination.html new file mode 100644 index 0000000..67b2b34 --- /dev/null +++ b/templates/partials/ajax_pagination.html @@ -0,0 +1,65 @@ +{% if is_paginated %} + + + +{% endif %} \ No newline at end of file