fix: Не работал поиск в компонентах по дочерним категориям
Исправлен шрифт на кнопках
remotes/origin/PR-41
booblegum 9 years ago
parent 116873648c
commit 3293ca41f7
  1. 8
      assets/lib/proekton-components/js/build/init.js
  2. 18
      assets/lib/proekton-components/js/build/init_user_profile.js
  3. 55
      assets/lib/proekton-components/js/src/SingleTreeSelect.js
  4. 8
      assets/lib/proekton-components/js/src/base/AbsBaseSelect.js
  5. 20
      users/static/css/user_profile_edit.css

@ -710,11 +710,13 @@ var AbsBaseSelect = function () {
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, false, excludeCategoryId);
var specList = this.dataTree.dataToList(parentCategoryId, attached, excludeCategoryId);
return specList.filter(function (el) {
return el.name.toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
});
@ -726,12 +728,14 @@ var AbsBaseSelect = function () {
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, excludeCategoryId: excludeCategoryId });
var searchRes = this._search({ searchText: searchText, parentCategoryId: parentCategoryId, attached: attached, excludeCategoryId: excludeCategoryId });
if (!searchRes.length) {
if ($container.closest('div').hasClass('main-part')) {
$container.append('<li>Ничего не найдено</li>');

@ -372,7 +372,7 @@ var SingleTreeSelect = function (_TreeSelect) {
// FILL RESULTS
// MAIN PART
var $container = this.$resultsBox.find('.main-part ul');
this._fillContainer($container, tmpl_elementResult, { searchText: searchText, parentCategoryId: self.parentId });
this._fillContainer($container, tmpl_elementResult, { searchText: searchText, parentCategoryId: self.parentId, attached: false });
// OTHER PART
// // Если нет parentId, не нужно искать в других категориях
@ -844,11 +844,13 @@ var AbsBaseSelect = function () {
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, false, excludeCategoryId);
var specList = this.dataTree.dataToList(parentCategoryId, attached, excludeCategoryId);
return specList.filter(function (el) {
return el.name.toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
});
@ -860,12 +862,14 @@ var AbsBaseSelect = function () {
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, excludeCategoryId: excludeCategoryId });
var searchRes = this._search({ searchText: searchText, parentCategoryId: parentCategoryId, attached: attached, excludeCategoryId: excludeCategoryId });
if (!searchRes.length) {
if ($container.closest('div').hasClass('main-part')) {
$container.append('<li>Ничего не найдено</li>');
@ -1429,16 +1433,10 @@ $(function () {
var sb_loc_1 = new _SingleTreeSelect2.default($('#sb-location-2'), { obj: sb_loc_main });
var sb_loc_2 = new _SingleTreeSelect2.default($('#sb-location-3'), { obj: sb_loc_main });
// Убираем кнопки add-options, блокирем поиск, меняем подсказки
// Убираем кнопки add-options
sb_loc_main.dataPromise.then(function () {
sb_loc_1.$buttonAddOptions.remove();
sb_loc_main.$buttonAddOptions.remove();
// sb_loc_main.$searchInput.prop("readonly", true);
// sb_loc_1.$searchInput.prop("readonly", true);
// sb_loc_2.$searchInput.prop("readonly", true);
// sb_loc_main.$searchInput.prop("placeholder", "Выберите");
// sb_loc_1.$searchInput.prop("placeholder", "Выберите");
// sb_loc_2.$searchInput.prop("placeholder", "Выберите");
});
sb_loc_main.setNearbySelectBox(sb_loc_1);

@ -9,22 +9,13 @@ const tmpl_selectBoxResults = () =>
<ul>
</ul>
</div>
<!--<div class="other-part">-->
<!--<span class="other-header">Из других категорий</span>-->
<!--<ul>-->
<!--</ul>-->
<!--</div>-->
</div>
<!--<div style="padding-top: 5px">-->
<!--<button class="button-add results">ПРИМЕНИТЬ</button>-->
<!--</div>-->
</div>
`;
const tmpl_elementResult = (el, id, header) =>
`<li data-id="${id}">
${el}
<!--<div class="header">${header}</div>-->
</li>`;
export default class SingleTreeSelect extends TreeSelect {
@ -37,56 +28,12 @@ export default class SingleTreeSelect extends TreeSelect {
})
}
// _buildComponents(data) {
// // AFTER PRELOAD
// let classes = this.$container.attr('class');
// if (classes) classes = classes.split(/\s+/);
// let 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
//
// // REDEFINE IN CHILD
// // this.dataTree = data;
// // this._bindEvents();
// }
_fillResultsData(searchText) {
let self = this;
// FILL RESULTS
// MAIN PART
let $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._fillContainer($container, tmpl_elementResult, {searchText: searchText, parentCategoryId: self.parentId, attached: false});
this.$resultsBox.find('li').on("click", function (e) {
const id = $(e.target).data("id");

@ -298,18 +298,18 @@ export default class AbsBaseSelect {
}
_search({searchText, parentCategoryId = null, excludeCategoryId = null}) {
_search({searchText, parentCategoryId = null, attached = true, excludeCategoryId = null}) {
// :FORMAT spec_list [{name, id}, ...]
let specList = this.dataTree.dataToList(parentCategoryId, false, excludeCategoryId);
let specList = this.dataTree.dataToList(parentCategoryId, attached, excludeCategoryId);
return specList.filter(function (el) {
return el.name.toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
});
}
_fillContainer($container, template, {searchText = "", parentCategoryId = null, excludeCategoryId = null}) {
_fillContainer($container, template, {searchText = "", parentCategoryId = null, attached = true, excludeCategoryId = null}) {
$container.html("");
$('.other-part').show();
let searchRes = this._search({searchText, parentCategoryId, excludeCategoryId});
let searchRes = this._search({searchText, parentCategoryId, attached, excludeCategoryId});
if (!searchRes.length) {
if ($container.closest('div').hasClass('main-part')) {
$container.append('<li>Ничего не найдено</li>');

@ -60,7 +60,7 @@
/* СУПЕР-костыльная кнопка. Не прикасаться!*/
.upload-new {
width: 60%;
width: 50%;
height: 30px;
overflow: hidden;
cursor: pointer;
@ -93,9 +93,9 @@
text-transform: uppercase;
margin: -30px 0 0 0;
/*padding: 0 5px 0 5px;*/
font-size: 10px;
font-size: 12px;
text-align: center;
font-family: Miriad;
font-family: Myriad;
}
/** Конец супер-костыля**/
@ -117,18 +117,14 @@
border-radius: 40px;
padding: 10px 15px;
border: 1px solid #FF0029;
color: black;
/*color: black;*/
background: none;
font-family: Miriad;
font-family: Myriad;
font-weight: normal;
font-style: normal;
font-size: 14pt;
}
/*.btn-simple:hover {*/
/*box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);*/
/*-webkit-transform: scale(1.04);*/
/*-moz-transform: scale(1.04);*/
/*transform: scale(1.04);*/
/*}*/
.no-margin .selected-element {
margin: 0;
}

Loading…
Cancel
Save