[SSE mobile] Added sort and filter into Add Other
This commit is contained in:
parent
683a9722e5
commit
2317bb594f
|
@ -44,7 +44,9 @@
|
||||||
"textDisplay": "Display",
|
"textDisplay": "Display",
|
||||||
"textScreenTip": "Screen Tip",
|
"textScreenTip": "Screen Tip",
|
||||||
"textInsert": "Insert",
|
"textInsert": "Insert",
|
||||||
"textInvalidRange": "ERROR! Invalid cells range"
|
"textInvalidRange": "ERROR! Invalid cells range",
|
||||||
|
"textSortAndFilter": "Sort and Filter",
|
||||||
|
"textFilter": "Filter"
|
||||||
},
|
},
|
||||||
"Edit" : {
|
"Edit" : {
|
||||||
"textSelectObjectToEdit": "Select object to edit",
|
"textSelectObjectToEdit": "Select object to edit",
|
||||||
|
|
|
@ -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;
|
|
@ -14,6 +14,7 @@ import {AddImageController} from "../../controller/add/AddImage";
|
||||||
import {PageImageLinkSettings} from "./AddImage";
|
import {PageImageLinkSettings} from "./AddImage";
|
||||||
import {AddLinkController} from "../../controller/add/AddLink";
|
import {AddLinkController} from "../../controller/add/AddLink";
|
||||||
import {PageTypeLink, PageSheet} from "./AddLink";
|
import {PageTypeLink, PageSheet} from "./AddLink";
|
||||||
|
import AddFilterController from "../../controller/add/AddFilter";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
// Functions
|
// Functions
|
||||||
|
@ -46,6 +47,11 @@ const routes = [
|
||||||
{
|
{
|
||||||
path: '/add-link-sheet/',
|
path: '/add-link-sheet/',
|
||||||
component: PageSheet
|
component: PageSheet
|
||||||
|
},
|
||||||
|
// Other
|
||||||
|
{
|
||||||
|
path: '/add-sort-and-filter/',
|
||||||
|
component: AddFilterController
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
36
apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx
Normal file
36
apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx
Normal 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;
|
|
@ -13,6 +13,9 @@ const AddOther = props => {
|
||||||
<ListItem title={_t.textLink} link={'/add-link/'}>
|
<ListItem title={_t.textLink} link={'/add-link/'}>
|
||||||
<Icon slot="media" icon="icon-link"></Icon>
|
<Icon slot="media" icon="icon-link"></Icon>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
<ListItem title={_t.textSortAndFilter} link={'/add-sort-and-filter/'}>
|
||||||
|
<Icon slot="media" icon="icon-sort"></Icon>
|
||||||
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue