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