Refactoring and fix typeSort

This commit is contained in:
ShimaginAndrey 2021-07-22 14:11:29 +03:00
parent 68ecdfa60e
commit 4e3144a159

View file

@ -63,6 +63,7 @@ const FilterOptionsController = () => {
const onClearFilter = () => { const onClearFilter = () => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if(api) api.asc_clearFilter(); if(api) api.asc_clearFilter();
setCheckSort('');
}; };
const onDeleteFilter = () => { const onDeleteFilter = () => {
@ -79,21 +80,17 @@ const FilterOptionsController = () => {
const setClearDisable = (config) => { const setClearDisable = (config) => {
let arr = config.asc_getValues(); let arr = config.asc_getValues();
let lenCheck = arr.filter((item) => item.visible == true).length; let lenCheck = arr.filter((item) => item.visible == true).length;
lenCheck == arr.length ? setIsValid(true) : setIsValid(false) lenCheck == arr.length ? setIsValid(true) : setIsValid(false);
}; };
const setDataFilterCells = (config) => { const setDataFilterCells = (config) => {
function isNumeric(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
let value = null, let value = null,
isnumber = null, isnumber = null,
arrCells = []; arrCells = [];
config.asc_getValues().forEach((item, index) => { config.asc_getValues().forEach((item, index) => {
value = item.asc_getText(); value = item.asc_getText();
isnumber = isNumeric(value); isnumber = !isNaN(parseFloat(value)) && isFinite(value);
arrCells.push({ arrCells.push({
id : index, id : index,
@ -111,12 +108,7 @@ const FilterOptionsController = () => {
const onUpdateCell = (id, state) => { const onUpdateCell = (id, state) => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if ( id == 'all' ) { id == 'all' ? listVal.forEach(item => item.check = state) : listVal[id].check = state;
listVal.forEach(item => item.check = state);
} else {
listVal[id].check = state;
}
setListValue([...listVal]); setListValue([...listVal]);
if ( listVal.some(item => item.check) ) { if ( listVal.some(item => item.check) ) {