[SSE mobile] Added sort and filter into Add Other

This commit is contained in:
JuliaSvinareva 2021-02-07 23:40:26 +03:00
parent 683a9722e5
commit 2317bb594f
5 changed files with 115 additions and 1 deletions

View file

@ -44,7 +44,9 @@
"textDisplay": "Display",
"textScreenTip": "Screen Tip",
"textInsert": "Insert",
"textInvalidRange": "ERROR! Invalid cells range"
"textInvalidRange": "ERROR! Invalid cells range",
"textSortAndFilter": "Sort and Filter",
"textFilter": "Filter"
},
"Edit" : {
"textSelectObjectToEdit": "Select object to edit",

View file

@ -0,0 +1,67 @@
import React, {Component} from 'react';
import AddSortAndFilter from '../../view/add/AddFilter';
class AddFilterController extends Component {
constructor (props) {
super(props);
this.onInsertFilter = this.onInsertFilter.bind(this);
this.uncheckedFilter = this.uncheckedFilter.bind(this);
const api = Common.EditorApi.get();
const filterInfo = api.asc_getCellInfo().asc_getAutoFilterInfo();
const isFilter = (filterInfo ? filterInfo.asc_getIsAutoFilter() : false);
this.state = {
isFilter: isFilter
};
}
componentDidMount () {
const api = Common.EditorApi.get();
api.asc_registerCallback('asc_onError', this.uncheckedFilter);
}
componentWillUnmount () {
const api = Common.EditorApi.get();
api.asc_unregisterCallback('asc_onError', this.uncheckedFilter);
}
uncheckedFilter (id, level, errData) {
setTimeout(() => {
if (id === Asc.c_oAscError.ID.AutoFilterDataRangeError) {
this.setState({isFilter: false});
}
}, 0);
}
onInsertSort (type) {
const api = Common.EditorApi.get();
api.asc_sortColFilter(type == 'down' ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending, '', undefined, undefined, true);
}
onInsertFilter (checked) {
this.setState({isFilter: checked});
const api = Common.EditorApi.get();
const formatTableInfo = api.asc_getCellInfo().asc_getFormatTableInfo();
const tablename = (formatTableInfo) ? formatTableInfo.asc_getTableName() : undefined;
if (checked) {
api.asc_addAutoFilter();
} else {
api.asc_changeAutoFilter(tablename, Asc.c_oAscChangeFilterOptions.filter, checked);
}
}
render () {
return (
<AddSortAndFilter getIsAutoFilter={this.getIsAutoFilter}
onInsertSort={this.onInsertSort}
onInsertFilter={this.onInsertFilter}
isFilter={this.state.isFilter}
/>
)
}
}
export default AddFilterController;

View file

@ -14,6 +14,7 @@ import {AddImageController} from "../../controller/add/AddImage";
import {PageImageLinkSettings} from "./AddImage";
import {AddLinkController} from "../../controller/add/AddLink";
import {PageTypeLink, PageSheet} from "./AddLink";
import AddFilterController from "../../controller/add/AddFilter";
const routes = [
// Functions
@ -46,6 +47,11 @@ const routes = [
{
path: '/add-link-sheet/',
component: PageSheet
},
// Other
{
path: '/add-sort-and-filter/',
component: AddFilterController
}
];

View file

@ -0,0 +1,36 @@
import React, {useState} from 'react';
import {Page, Navbar, List, ListItem, Icon, Row, Toggle} from 'framework7-react';
import { useTranslation } from 'react-i18next';
const AddSortAndFilter = props => {
const { t } = useTranslation();
const _t = t('View.Add', {returnObjects: true});
const isFilter = props.isFilter;
return (
<Page>
<Navbar title={_t.textSortAndFilter} backLink={_t.textBack}/>
<List>
<ListItem className='buttons'>
<Row>
<a className='button' onClick={() => {props.onInsertSort('down')}}>
<Icon slot="media" icon="sortdown"></Icon>
</a>
<a className='button' onClick={() => {props.onInsertSort('up')}}>
<Icon slot="media" icon="sortup"></Icon>
</a>
</Row>
</ListItem>
</List>
<List>
<ListItem title={_t.textFilter}>
<Toggle checked={isFilter}
onToggleChange={(prev) => {
props.onInsertFilter(!prev);
}}/>
</ListItem>
</List>
</Page>
)
};
export default AddSortAndFilter;

View file

@ -13,6 +13,9 @@ const AddOther = props => {
<ListItem title={_t.textLink} link={'/add-link/'}>
<Icon slot="media" icon="icon-link"></Icon>
</ListItem>
<ListItem title={_t.textSortAndFilter} link={'/add-sort-and-filter/'}>
<Icon slot="media" icon="icon-sort"></Icon>
</ListItem>
</List>
)
};