[DE] Refactoring styles loading

This commit is contained in:
Julia Radzhabova 2019-08-21 10:50:32 +03:00
parent 61ed3059e2
commit 6e93a76a0a
2 changed files with 8 additions and 10 deletions

View file

@ -414,10 +414,11 @@ define([
}
}
me.fieldPicker.store.reset([]); // remove all
var indexRec = store.indexOf(record);
if (indexRec < 0)
return;
var indexRec = store.indexOf(record),
countRec = store.length,
var countRec = store.length,
maxViewCount = Math.floor(Math.max(fieldPickerEl.width(), me.minWidth) / (me.itemWidth + (me.itemMarginLeft || 0) + (me.itemMarginRight || 0) + (me.itemPaddingLeft || 0) + (me.itemPaddingRight || 0) +
(me.itemBorderLeft || 0) + (me.itemBorderRight || 0))),
newStyles = [];
@ -425,9 +426,6 @@ define([
if (fieldPickerEl.height() / me.itemHeight > 2)
maxViewCount *= Math.floor(fieldPickerEl.height() / me.itemHeight);
if (indexRec < 0)
return;
indexRec = Math.floor(indexRec / maxViewCount) * maxViewCount;
if (countRec - indexRec < maxViewCount)
indexRec = Math.max(countRec - maxViewCount, 0);
@ -435,7 +433,7 @@ define([
newStyles.push(store.at(index));
}
me.fieldPicker.store.add(newStyles);
me.fieldPicker.store.reset(newStyles);
}
if (forceSelect) {

View file

@ -2681,17 +2681,17 @@ define([
return;
}
listStyles.menuPicker.store.reset([]); // remove all
var arr = [];
var mainController = this.getApplication().getController('Main');
_.each(styles.get_MergedStyles(), function(style){
listStyles.menuPicker.store.add({
arr.push({
imageUrl: style.asc_getImage(),
title : style.get_Name(),
tip : mainController.translationTable[style.get_Name()] || style.get_Name(),
id : Common.UI.getId()
});
});
listStyles.menuPicker.store.reset(arr); // remove all
if (listStyles.menuPicker.store.length > 0 && listStyles.rendered){
var styleRec;