Merge pull request #964 from ONLYOFFICE/feature/Bug_43270

Feature/bug 43270
This commit is contained in:
SergeyEzhin 2021-07-05 12:52:07 +03:00 committed by GitHub
commit fe1b82ee8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 62 deletions

View file

@ -318,6 +318,7 @@
"textThin": "Thin", "textThin": "Thin",
"textMedium": "Medium", "textMedium": "Medium",
"textThick": "Thick", "textThick": "Thick",
"textFraction": "Fraction",
"textGeneral": "General", "textGeneral": "General",
"textNumber": "Number", "textNumber": "Number",
"textInteger": "Integer", "textInteger": "Integer",

View file

@ -1,12 +1,29 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import { f7 } from 'framework7-react';
import {Device} from '../../../../../common/mobile/utils/device';
import { EditCell } from '../../view/edit/EditCell'; import { EditCell } from '../../view/edit/EditCell';
class EditCellController extends Component { class EditCellController extends Component {
constructor (props) { constructor (props) {
super(props); super(props);
this.dateFormats = this.initFormats(Asc.c_oAscNumFormatType.Date, 38822);
this.timeFormats = this.initFormats(Asc.c_oAscNumFormatType.Time, 1.534);
}
initFormats(type, exampleVal) {
const api = Common.EditorApi.get();
let info = new Asc.asc_CFormatCellsInfo();
info.asc_setType(type);
info.asc_setDecimalPlaces(0);
info.asc_setSeparator(false);
let formatsArr = api.asc_getFormatCells(info),
data = [];
formatsArr.forEach(function(item) {
data.push({value: item, displayValue: api.asc_getLocaleExample(item, exampleVal)});
});
return data;
} }
toggleBold(value) { toggleBold(value) {
@ -116,10 +133,23 @@ class EditCellController extends Component {
api.asc_setCellAngle(angle); api.asc_setCellAngle(angle);
} }
onCellFormat(value) { onCellFormat(format) {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
let type = decodeURIComponent(atob(value)); api.asc_setCellFormat(format);
api.asc_setCellFormat(type); }
onAccountingCellFormat(value) {
const api = Common.EditorApi.get();
let info = new Asc.asc_CFormatCellsInfo();
info.asc_setType(Asc.c_oAscNumFormatType.Accounting);
info.asc_setSeparator(false);
info.asc_setSymbol(value);
let format = api.asc_getFormatCells(info);
if (format && format.length > 0)
api.asc_setCellFormat(format[0]);
} }
onBorderStyle(type, borderInfo) { onBorderStyle(type, borderInfo) {
@ -168,6 +198,9 @@ class EditCellController extends Component {
onCellFormat={this.onCellFormat} onCellFormat={this.onCellFormat}
onTextOrientationChange={this.onTextOrientationChange} onTextOrientationChange={this.onTextOrientationChange}
onBorderStyle={this.onBorderStyle} onBorderStyle={this.onBorderStyle}
onAccountingCellFormat={this.onAccountingCellFormat}
dateFormats={this.dateFormats}
timeFormats={this.timeFormats}
/> />
) )
} }

View file

@ -88,7 +88,11 @@ const EditCell = props => {
</List> </List>
<List> <List>
<ListItem title={_t.textFormat} link="/edit-format-cell/" routeProps={{ <ListItem title={_t.textFormat} link="/edit-format-cell/" routeProps={{
onCellFormat: props.onCellFormat onCellFormat: props.onCellFormat,
onCurrencyCellFormat: props.onCurrencyCellFormat,
onAccountingCellFormat: props.onAccountingCellFormat,
dateFormats: props.dateFormats,
timeFormats: props.timeFormats
}}> }}>
{!isAndroid ? {!isAndroid ?
<Icon slot="media" icon="icon-format-general"></Icon> : null <Icon slot="media" icon="icon-format-general"></Icon> : null
@ -757,20 +761,20 @@ const PageFormatCell = props => {
} }
</Navbar> </Navbar>
<List> <List>
<ListItem link='#' className='no-indicator' title={_t.textGeneral} onClick={() => props.onCellFormat('R2VuZXJhbA==')}> <ListItem link='#' className='no-indicator' title={_t.textGeneral} onClick={() => props.onCellFormat('General')}>
<Icon slot="media" icon="icon-format-general"></Icon> <Icon slot="media" icon="icon-format-general"></Icon>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textNumber} onClick={() => props.onCellFormat('MC4wMA==')}> <ListItem link='#' className='no-indicator' title={_t.textNumber} onClick={() => props.onCellFormat('0.00')}>
<Icon slot="media" icon="icon-format-number"></Icon> <Icon slot="media" icon="icon-format-number"></Icon>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textInteger} onClick={() => props.onCellFormat('JTIzMA==')}> <ListItem link='#' className='no-indicator' title={_t.textFraction} onClick={() => props.onCellFormat('# ?/?')}>
<Icon slot="media" icon="icon-format-integer"></Icon> <Icon slot="media" icon="icon-format-integer"></Icon>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textScientific} onClick={() => props.onCellFormat('MC4wMEUlMkIwMA==')}> <ListItem link='#' className='no-indicator' title={_t.textScientific} onClick={() => props.onCellFormat('0.00E+00')}>
<Icon slot="media" icon="icon-format-scientific"></Icon> <Icon slot="media" icon="icon-format-scientific"></Icon>
</ListItem> </ListItem>
<ListItem title={_t.textAccounting} link="/edit-accounting-format-cell/" routeProps={{ <ListItem title={_t.textAccounting} link="/edit-accounting-format-cell/" routeProps={{
onCellFormat: props.onCellFormat onAccountingCellFormat: props.onAccountingCellFormat
}}> }}>
<Icon slot="media" icon="icon-format-accounting"></Icon> <Icon slot="media" icon="icon-format-accounting"></Icon>
</ListItem> </ListItem>
@ -780,19 +784,21 @@ const PageFormatCell = props => {
<Icon slot="media" icon="icon-format-currency"></Icon> <Icon slot="media" icon="icon-format-currency"></Icon>
</ListItem> </ListItem>
<ListItem title={_t.textDate} link='/edit-date-format-cell/' routeProps={{ <ListItem title={_t.textDate} link='/edit-date-format-cell/' routeProps={{
onCellFormat: props.onCellFormat onCellFormat: props.onCellFormat,
dateFormats: props.dateFormats
}}> }}>
<Icon slot="media" icon="icon-format-date"></Icon> <Icon slot="media" icon="icon-format-date"></Icon>
</ListItem> </ListItem>
<ListItem title={_t.textTime} link='/edit-time-format-cell/' routeProps={{ <ListItem title={_t.textTime} link='/edit-time-format-cell/' routeProps={{
onCellFormat: props.onCellFormat onCellFormat: props.onCellFormat,
timeFormats: props.timeFormats
}}> }}>
<Icon slot="media" icon="icon-format-time"></Icon> <Icon slot="media" icon="icon-format-time"></Icon>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textPercentage} onClick={() => props.onCellFormat('MC4wMCUyNQ==')}> <ListItem link='#' className='no-indicator' title={_t.textPercentage} onClick={() => props.onCellFormat('0.00%')}>
<Icon slot="media" icon="icon-format-percentage"></Icon> <Icon slot="media" icon="icon-format-percentage"></Icon>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textText} onClick={() => props.onCellFormat('JTQw')}> <ListItem link='#' className='no-indicator' title={_t.textText} onClick={() => props.onCellFormat('@')}>
<Icon slot="media" icon="icon-format-text"></Icon> <Icon slot="media" icon="icon-format-text"></Icon>
</ListItem> </ListItem>
</List> </List>
@ -815,19 +821,19 @@ const PageAccountingFormatCell = props => {
</Navbar> </Navbar>
<List> <List>
<ListItem link='#' className='no-indicator' title={_t.textDollar} after='$' <ListItem link='#' className='no-indicator' title={_t.textDollar} after='$'
onClick={() => props.onCellFormat('XyglMjQqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglMjQqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglMjQqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> onClick={() => props.onAccountingCellFormat(1033)}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textEuro} after='€' <ListItem link='#' className='no-indicator' title={_t.textEuro} after='€'
onClick={() => props.onCellFormat('XyglRTIlODIlQUMqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglRTIlODIlQUMqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglRTIlODIlQUMqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> onClick={() => props.onAccountingCellFormat(1031)}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textPound} after='£' <ListItem link='#' className='no-indicator' title={_t.textPound} after='£'
onClick={() => props.onCellFormat('XyglQzIlQTMqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglQzIlQTMqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglQzIlQTMqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> onClick={() => props.onAccountingCellFormat(2057)}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textRouble} after='₽' <ListItem link='#' className='no-indicator' title={_t.textRouble} after='₽'
onClick={() => props.onCellFormat('Xy0qJTIwJTIzJTJDJTIzJTIzMC4wMCU1QiUyNCVEMSU4MC4tNDE5JTVEXy0lM0ItKiUyMCUyMyUyQyUyMyUyMzAuMDAlNUIlMjQlRDElODAuLTQxOSU1RF8tJTNCXy0qJTIwJTIyLSUyMiUzRiUzRiU1QiUyNCVEMSU4MC4tNDE5JTVEXy0lM0JfLSU0MF8t')}> onClick={() => props.onAccountingCellFormat(1049)}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textYen} after='¥' <ListItem link='#' className='no-indicator' title={_t.textYen} after='¥'
onClick={() => props.onCellFormat('XyglQzIlQTUqJTIwJTIzJTJDJTIzJTIzMC4wMF8pJTNCXyglQzIlQTUqJTIwKCUyMyUyQyUyMyUyMzAuMDApJTNCXyglQzIlQTUqJTIwJTIyLSUyMiUzRiUzRl8pJTNCXyglNDBfKQ==')}> onClick={() => props.onAccountingCellFormat(1041)}>
</ListItem> </ListItem>
</List> </List>
</Page> </Page>
@ -840,7 +846,7 @@ const PageCurrencyFormatCell = props => {
return ( return (
<Page> <Page>
<Navbar title={_t.textAccounting} backLink={_t.textBack}> <Navbar title={_t.textCurrency} backLink={_t.textBack}>
{Device.phone && {Device.phone &&
<NavRight> <NavRight>
<Link icon='icon-expand-down' sheetClose></Link> <Link icon='icon-expand-down' sheetClose></Link>
@ -849,19 +855,19 @@ const PageCurrencyFormatCell = props => {
</Navbar> </Navbar>
<List> <List>
<ListItem link='#' className='no-indicator' title={_t.textDollar} after='$' <ListItem link='#' className='no-indicator' title={_t.textDollar} after='$'
onClick={() => props.onCellFormat('JTI0JTIzJTJDJTIzJTIzMC4wMA==')}> onClick={() => props.onCellFormat('[$$-409]#,##0.00')}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textEuro} after='€' <ListItem link='#' className='no-indicator' title={_t.textEuro} after='€'
onClick={() => props.onCellFormat('JUUyJTgyJUFDJTIzJTJDJTIzJTIzMC4wMA==')}> onClick={() => props.onCellFormat('#,##0.00\ [$€-407]')}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textPound} after='£' <ListItem link='#' className='no-indicator' title={_t.textPound} after='£'
onClick={() => props.onCellFormat('JUMyJUEzJTIzJTJDJTIzJTIzMC4wMA==')}> onClick={() => props.onCellFormat('[$£-809]#,##0.00')}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textRouble} after='₽' <ListItem link='#' className='no-indicator' title={_t.textRouble} after='₽'
onClick={() => props.onCellFormat('JTIzJTJDJTIzJTIzMC4wMCUyMiVEMSU4MC4lMjI=')}> onClick={() => props.onCellFormat('#,##0.00\ [$₽-419]')}>
</ListItem> </ListItem>
<ListItem link='#' className='no-indicator' title={_t.textYen} after='¥' <ListItem link='#' className='no-indicator' title={_t.textYen} after='¥'
onClick={() => props.onCellFormat('JUMyJUE1JTIzJTJDJTIzJTIzMC4wMA==')}> onClick={() => props.onCellFormat('[$¥-411]#,##0.00')}>
</ListItem> </ListItem>
</List> </List>
</Page> </Page>
@ -871,6 +877,7 @@ const PageCurrencyFormatCell = props => {
const PageDateFormatCell = props => { const PageDateFormatCell = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t('View.Edit', {returnObjects: true}); const _t = t('View.Edit', {returnObjects: true});
const dateFormats = props.dateFormats;
return ( return (
<Page> <Page>
@ -882,26 +889,12 @@ const PageDateFormatCell = props => {
} }
</Navbar> </Navbar>
<List> <List>
<ListItem link='#' className='no-indicator' title='07-24-88' after='MM-dd-yy' {dateFormats.map((format, index) => {
onClick={() => props.onCellFormat('TU0tZGQteXk=')}></ListItem> return (
<ListItem link='#' className='no-indicator' title='07-24-1988' after='MM-dd-yyyy' <ListItem link='#' key={index} className='no-indicator' title={format.displayValue}
onClick={() => props.onCellFormat('TU0tZGQteXl5eQ==')}> onClick={() => props.onCellFormat(format.value)}></ListItem>
</ListItem> )
<ListItem link='#' className='no-indicator' title='24-07-88' after='dd-MM-yy' })}
onClick={() => props.onCellFormat('ZGQtTU0teXk=')}>
</ListItem>
<ListItem link='#' className='no-indicator' title='24-07-1988' after='dd-MM-yyyy'
onClick={() => props.onCellFormat('ZGQtTU0teXl5eQ==')}>
</ListItem>
<ListItem link='#' className='no-indicator' title='24-Jul-1988' after='dd-MMM-yyyy'
onClick={() => props.onCellFormat('ZGQtTU1NLXl5eXk=')}>
</ListItem>
<ListItem link='#' className='no-indicator' title='24-Jul' after='dd-MMM'
onClick={() => props.onCellFormat('ZGQtTU1N')}>
</ListItem>
<ListItem link='#' className='no-indicator' title='Jul-88' after='MMM-yy'
onClick={() => props.onCellFormat('TU1NLXl5')}>
</ListItem>
</List> </List>
</Page> </Page>
) )
@ -910,6 +903,7 @@ const PageDateFormatCell = props => {
const PageTimeFormatCell = props => { const PageTimeFormatCell = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t('View.Edit', {returnObjects: true}); const _t = t('View.Edit', {returnObjects: true});
const timeFormats = props.timeFormats;
return ( return (
<Page> <Page>
@ -921,21 +915,12 @@ const PageTimeFormatCell = props => {
} }
</Navbar> </Navbar>
<List> <List>
<ListItem link='#' className='no-indicator' title='10:56' after='HH:mm' {timeFormats.map((format, index) => {
onClick={() => props.onCellFormat('aCUzQW1tJTNCJTQw')}> return (
</ListItem> <ListItem link='#' key={index} className='no-indicator' title={format.displayValue}
<ListItem link='#' className='no-indicator' title='21:56:00' after='HH:MM:ss' onClick={() => props.onCellFormat(format.value)}></ListItem>
onClick={() => props.onCellFormat('aCUzQW1tJTNBc3MlM0IlNDA=')}> )
</ListItem> })}
<ListItem link='#' className='no-indicator' title='05:56 AM' after='hh:mm tt'
onClick={() => props.onCellFormat('aCUzQW1tJTIwQU0lMkZQTSUzQiU0MA==')}>
</ListItem>
<ListItem link='#' className='no-indicator' title='05:56:00 AM' after='hh:mm:ss tt'
onClick={() => props.onCellFormat('aCUzQW1tJTNBc3MlMjBBTSUyRlBNJTNCJTQw')}>
</ListItem>
<ListItem link='#' className='no-indicator' title='38:56:00' after='[h]:mm:ss'
onClick={() => props.onCellFormat('JTVCaCU1RCUzQW1tJTNBc3MlM0IlNDA=')}>
</ListItem>
</List> </List>
</Page> </Page>
) )