|
|
|
|
@ -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() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}()) |
|
|
|
|
|
|
|
|
|
|