Merge pull request #1173 from ONLYOFFICE/featurre/fix-bug-reactjs
Featurre/fix bug reactjs
This commit is contained in:
commit
6429da5c5a
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect,useState } from 'react';
|
||||
import React, { useEffect,useRef,useState } from 'react';
|
||||
import FilterView from '../../src/view/FilterOptions';
|
||||
import { f7,Sheet,Popover } from 'framework7-react';
|
||||
import { Device } from '../../../../common/mobile/utils/device';
|
||||
|
@ -7,11 +7,11 @@ import { useTranslation } from 'react-i18next';
|
|||
const FilterOptionsController = () => {
|
||||
const { t } = useTranslation();
|
||||
const _t = t('View.Edit', {returnObjects: true});
|
||||
const configRef = useRef();
|
||||
|
||||
const [configFilter, setConfig] = useState(null);
|
||||
const [listVal, setListValue] = useState([]);
|
||||
const [isValid, setIsValid] = useState(null);
|
||||
const [checkSort, setCheckSort] = useState(null);
|
||||
const [checkSort, setCheckSort] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
function onDocumentReady() {
|
||||
|
@ -34,8 +34,7 @@ const FilterOptionsController = () => {
|
|||
|
||||
const onApiFilterOptions= (config) => {
|
||||
setDataFilterCells(config);
|
||||
setConfig(config);
|
||||
setClearDisable(config);
|
||||
configRef.current = config;
|
||||
|
||||
setCheckSort((config.asc_getSortState() === Asc.c_oAscSortOptions.Ascending ? 'down' : '') ||
|
||||
(config.asc_getSortState() === Asc.c_oAscSortOptions.Descending ? 'up' : ''));
|
||||
|
@ -55,7 +54,7 @@ const FilterOptionsController = () => {
|
|||
|
||||
const onSort = (type) => {
|
||||
const api = Common.EditorApi.get();
|
||||
api.asc_sortColFilter(type == 'sortdown' ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending, configFilter.asc_getCellId(), configFilter.asc_getDisplayName());
|
||||
api.asc_sortColFilter(type == 'sortdown' ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending, configRef.current.asc_getCellId(), configRef.current.asc_getDisplayName());
|
||||
f7.sheet.close('.picker__sheet');
|
||||
f7.popover.close('#picker-popover');
|
||||
};
|
||||
|
@ -112,15 +111,15 @@ const FilterOptionsController = () => {
|
|||
setListValue([...listVal]);
|
||||
|
||||
if ( listVal.some(item => item.check) ) {
|
||||
configFilter.asc_getValues().forEach(
|
||||
configRef.current.asc_getValues().forEach(
|
||||
(item, index) => item.asc_setVisible(listVal[index].check)
|
||||
);
|
||||
|
||||
configFilter.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters);
|
||||
api.asc_applyAutoFilter(configFilter);
|
||||
configRef.current.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters);
|
||||
api.asc_applyAutoFilter(configRef.current);
|
||||
}
|
||||
|
||||
setClearDisable(configFilter);
|
||||
setClearDisable(configRef.current);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -103,7 +103,6 @@ class MainPage extends Component {
|
|||
</Subnavbar>
|
||||
</Navbar>
|
||||
<CellEditor onClickToOpenAddOptions={(panels, button) => this.handleClickToOpenOptions('add', {panels: panels, button: button})}/>
|
||||
<FilterOptionsController/>
|
||||
{/* Page content */}
|
||||
<View id="editor_sdk" />
|
||||
{showPlaceholder ?
|
||||
|
@ -131,7 +130,9 @@ class MainPage extends Component {
|
|||
<CollaborationView onclosed={this.handleOptionsViewClosed.bind(this, 'coauth')} />
|
||||
}
|
||||
|
||||
<FilterOptionsController />
|
||||
{!appOptions.isDocReady ? null :
|
||||
<FilterOptionsController />
|
||||
}
|
||||
|
||||
<Statusbar />
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ const FilterOptions = (props) => {
|
|||
</List>
|
||||
|
||||
<List >
|
||||
<ListButton color="black" className={props.isValid ? 'disabled' : ''} onClick={HandleClearFilter}>{_t.textClearFilter}</ListButton>
|
||||
<ListButton color="black" className={props.isValid || is_all_checked ? 'disabled' : ''} onClick={HandleClearFilter}>{_t.textClearFilter}</ListButton>
|
||||
<ListButton color="red" onClick={() => props.onDeleteFilter()} id="btn-delete-filter">{_t.textDeleteFilter}</ListButton>
|
||||
</List>
|
||||
<List>
|
||||
|
|
Loading…
Reference in a new issue