diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 393c30b5c..ef8c92889 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -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", diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx new file mode 100644 index 000000000..ef9a13408 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx @@ -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 ( + + ) + } +} + +export default AddFilterController; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx index 83ae07067..3fd709181 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx @@ -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 } ]; diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx new file mode 100644 index 000000000..6f97ff992 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx @@ -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 ( + + + + + + {props.onInsertSort('down')}}> + + + {props.onInsertSort('up')}}> + + + + + + + + { + props.onInsertFilter(!prev); + }}/> + + + + ) +}; + +export default AddSortAndFilter; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx index f24a12367..06727ee2a 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx @@ -13,6 +13,9 @@ const AddOther = props => { + + + ) };