From cd61dba85807ef8c8ebc38a6af03a7e5cce95c45 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Wed, 21 Sep 2016 15:21:30 +0300 Subject: [PATCH] Fixes --- assets/css/extra.css | 3 ++ assets/index.js | 57 +++++++++++++++++--------- projects/templates/project_detail.html | 14 +++---- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/assets/css/extra.css b/assets/css/extra.css index 1e5a2b2..d94427c 100644 --- a/assets/css/extra.css +++ b/assets/css/extra.css @@ -240,3 +240,6 @@ li a:active .count-tab, li a:hover .count-tab{ color: white; } +.select2-drop { + width: 400px !important; +} diff --git a/assets/index.js b/assets/index.js index 864dd3a..1176f78 100644 --- a/assets/index.js +++ b/assets/index.js @@ -51,7 +51,6 @@ $('[data-tooltip]').tooltip({ results: _.map(function(item) { return { id: item.id, - //text: item.name, text: _.repeat(item.level-1, '---') + item.name, origItem: item, } @@ -146,6 +145,34 @@ $('[data-tooltip]').tooltip({ placeholder: 'Выберите специализацию', // Required by `allowClear` allowClear: true, + ajax: { + url: '/api/specializations/', + dataType: 'json', + quietMillis: 250, + cache: true, + + data: function(term, page) { + return { + name__icontains: term, + page: page, + } + }, + + results: function(data, page) { + return { + results: _.map(function(item) { + return { + id: item.id, + text: _.repeat(item.level-1, '---') + item.name, + origItem: item, + } + }, data.results), + + more: (page * API_PAGE_SIZE) < data.count, + } + }, + }, + //initSelection: function(element, callback) { // var id = $(element).val() // @@ -185,30 +212,20 @@ $('[data-tooltip]').tooltip({ function initSimpleSpecSelect2($select, specId) { - return $.ajax({url: '/api/specializations/', method: 'GET', dataType: 'json'}) - .then(function(res) { - var specs = res.results - - $select.select2(_.merge(simpleSpecSelectsOptions, { - data: _.map(function(spec) { - return { - id: spec.id, - text: _.repeat(spec.level-1, '---') + spec.name, - origItem: spec, - } - }, specs), - })) - - if (specId) { - var spec = _.find({id: specId}, specs) - + $select.select2(simpleSpecSelectsOptions) + + if (specId) { + return $.get(format('/api/specializations/%s/', specId)) + .then(function(spec) { $select.select2('data', { id: spec.id, text: _.repeat(spec.level-1, '---') + spec.name, origItem: spec, }) - } - }) + }) + } else { + return $.when() + } } }()) diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 6eaa682..13e19ce 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -345,14 +345,14 @@
{% if message.is_sender_customer %}

- {% firstof project.customer.get_full_name.strip project.customer.username %} | seen?: {{ message.seen_by_contractor }} + {% firstof project.customer.get_full_name.strip project.customer.username %}

{% else %}

{% if answer.author|class_name == 'User' %} - {% firstof answer.author.get_full_name.strip answer.author.username %} | seen?: {{ message.seen_by_contractor }} + {% firstof answer.author.get_full_name.strip answer.author.username %} {% elif answer.author|class_name == 'Team' %} - {% firstof answer.author.name.strip answer.author.owner.username %} | seen?: {{ message.seen_by_contractor }} + {% firstof answer.author.name.strip answer.author.owner.username %} {% endif %}

{% endif %} @@ -651,7 +651,7 @@

{% if answer.term_type == 'project' %} Срок: За проект - {% else %} + {% elif answer.term and answer.term_type %} Срок: {% morph answer.term TERM_TYPE_MORPHS|get:answer.term_type %} {% endif %}

@@ -718,14 +718,14 @@
{% if message.is_sender_customer %}

- {% firstof project.customer.get_full_name.strip project.customer.username %} | seen?: {{ message.seen_by_customer }} + {% firstof project.customer.get_full_name.strip project.customer.username %}

{% else %}

{% if answer.author|class_name == 'User' %} - {% firstof answer.author.get_full_name.strip answer.author.username %} | seen?: {{ message.seen_by_customer }} + {% firstof answer.author.get_full_name.strip answer.author.username %} {% elif answer.author|class_name == 'Team' %} - {% firstof answer.author.name.strip answer.author.owner.username %} | seen?: {{ message.seen_by_customer }} + {% firstof answer.author.name.strip answer.author.owner.username %} {% endif %}

{% endif %}