2021-12-29 21:26:40 +00:00
|
|
|
import React, { Fragment, useEffect, useState } from 'react';
|
2022-03-05 10:05:49 +00:00
|
|
|
import {f7, View, Link, Icon, Popover, Navbar, NavRight, List, ListGroup, ListItem, ListButton, Actions, ActionsGroup, ActionsButton, Sheet, Page } from 'framework7-react';
|
2021-03-23 13:43:10 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2021-03-24 17:50:09 +00:00
|
|
|
import { Device } from '../../../../common/mobile/utils/device';
|
2021-07-28 15:19:46 +00:00
|
|
|
import { inject, observer } from 'mobx-react';
|
2021-12-29 21:26:40 +00:00
|
|
|
import { ThemeColorPalette, CustomColorPicker } from '../../../../common/mobile/lib/component/ThemeColorPalette.jsx';
|
2020-12-15 21:17:26 +00:00
|
|
|
|
|
|
|
const viewStyle = {
|
|
|
|
height: 30
|
|
|
|
};
|
2020-12-10 13:14:52 +00:00
|
|
|
|
2021-12-19 12:38:19 +00:00
|
|
|
const PageListMove = props => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { sheets, onMenuMoveClick } = props;
|
|
|
|
const allSheets = sheets.sheets;
|
|
|
|
|
|
|
|
return (
|
2022-02-24 14:10:26 +00:00
|
|
|
<View style={!Device.phone ? {height: '420px'} : null}>
|
|
|
|
<Page>
|
|
|
|
<Navbar title={t('Statusbar.textMoveBefore')}/>
|
|
|
|
<List>
|
|
|
|
<ListGroup>
|
|
|
|
{ allSheets.map((model, index) =>
|
|
|
|
model.hidden ? null :
|
|
|
|
<ListItem
|
|
|
|
key={model.name}
|
|
|
|
title={model.name}
|
|
|
|
onClick={() => onMenuMoveClick(index)} />)
|
|
|
|
}
|
2022-02-11 13:44:55 +00:00
|
|
|
<ListItem
|
2022-02-24 14:10:26 +00:00
|
|
|
title={t('Statusbar.textMoveToEnd')}
|
|
|
|
onClick={() => onMenuMoveClick(-255)}/>
|
|
|
|
</ListGroup>
|
|
|
|
</List>
|
|
|
|
</Page>
|
|
|
|
</View>
|
2021-12-19 12:38:19 +00:00
|
|
|
)
|
|
|
|
};
|
|
|
|
|
2022-02-01 09:29:01 +00:00
|
|
|
const PageAllList = (props) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { sheets, onTabListClick } = props;
|
2021-12-19 12:38:19 +00:00
|
|
|
const allSheets = sheets.sheets;
|
|
|
|
|
2022-04-28 05:43:22 +00:00
|
|
|
useEffect(() => {
|
|
|
|
const tabs = $$('.sheet-tabs .tab');
|
|
|
|
let tab = tabs.eq(sheets.activeWorksheet);
|
|
|
|
|
|
|
|
if(sheets.activeWorksheet !== -1) {
|
|
|
|
if(tab.length === 0) {
|
|
|
|
tab = tabs.eq(tabs.length - 1);
|
|
|
|
$$('.sheet-tabs').scrollLeft( tab.offset().left + tab.width(), 500);
|
|
|
|
} else if(tab.offset().left < 0) {
|
|
|
|
$$('.sheet-tabs').scrollLeft( $$('.sheet-tabs').scrollLeft() + tab.offset().left - 96, 500);
|
|
|
|
} else {
|
|
|
|
$$('.sheet-tabs').scrollLeft( $$('.sheet-tabs').scrollLeft() + (tab.offset().left + tab.width() - $$('.sheet-tabs').width()), 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [sheets.activeWorksheet]);
|
|
|
|
|
2021-12-19 12:38:19 +00:00
|
|
|
return (
|
2022-02-24 14:10:26 +00:00
|
|
|
<View style={{height: '240px'}}>
|
|
|
|
<Page>
|
|
|
|
<List>
|
|
|
|
{ allSheets.map( (model,sheetIndex) =>
|
|
|
|
<ListItem className='item-list' key={model.name} title={model.name} checkbox checked={model.active} onClick={() => onTabListClick(sheetIndex)}>
|
|
|
|
{model.hidden ?
|
|
|
|
<div slot='after'>
|
|
|
|
{t('Statusbar.textHidden')}
|
|
|
|
</div>
|
|
|
|
: null}
|
|
|
|
</ListItem>)
|
|
|
|
}
|
|
|
|
</List>
|
|
|
|
</Page>
|
|
|
|
</View>
|
2021-12-19 12:38:19 +00:00
|
|
|
)
|
|
|
|
};
|
|
|
|
|
2021-12-29 21:26:40 +00:00
|
|
|
const PageCustomTabColor = inject("storePalette")(observer (props => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const _t = t('View.Edit', {returnObjects: true});
|
|
|
|
|
|
|
|
const onAddNewColor = (colors, color) => {
|
|
|
|
props.storePalette.changeCustomColors(colors);
|
|
|
|
props.onSetWorkSheetColor(color);
|
|
|
|
props.sheets.changeTabColor(color);
|
|
|
|
props.f7router.back();
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Page>
|
|
|
|
<Navbar title={_t.textCustomColor} backLink={_t.textBack}>
|
|
|
|
{Device.phone &&
|
|
|
|
<NavRight>
|
|
|
|
<Link icon='icon-expand-down' sheetClose ></Link>
|
|
|
|
</NavRight>
|
|
|
|
}
|
|
|
|
</Navbar>
|
|
|
|
<CustomColorPicker currentColor={props.sheets.colorTab} onAddNewColor={onAddNewColor}/>
|
|
|
|
</Page>
|
|
|
|
)
|
|
|
|
}));
|
|
|
|
|
|
|
|
const PageTabColor = inject("storePalette")(observer(props => {
|
|
|
|
const { t } = useTranslation();
|
2022-01-28 11:20:41 +00:00
|
|
|
const {sheets, allSheets = sheets.sheets} = props;
|
2021-12-29 21:26:40 +00:00
|
|
|
const storePalette = props.storePalette;
|
|
|
|
const customColors = storePalette.customColors;
|
|
|
|
const activeIndex = sheets.activeWorksheet;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (allSheets.length !== 0) {
|
|
|
|
let color = sheets.at(activeIndex).color;
|
2022-01-24 14:18:12 +00:00
|
|
|
if(color !== null) {
|
2021-12-29 21:26:40 +00:00
|
|
|
sheets.changeTabColor('' + Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()));
|
|
|
|
} else {
|
|
|
|
sheets.changeTabColor('transparent');
|
|
|
|
}
|
|
|
|
}
|
2022-01-28 11:20:41 +00:00
|
|
|
}, [activeIndex]);
|
2021-12-29 21:26:40 +00:00
|
|
|
|
|
|
|
const changeColor = (color, effectId, effectValue) => {
|
|
|
|
if (color !== 'empty') {
|
|
|
|
if (effectId !== undefined ) {
|
|
|
|
const newColor = {color: color, effectId: effectId, effectValue: effectValue};
|
|
|
|
sheets.changeTabColor(newColor);
|
|
|
|
props.onSetWorkSheetColor(color);
|
|
|
|
} else {
|
|
|
|
sheets.changeTabColor(color);
|
|
|
|
props.onSetWorkSheetColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
Device.isPhone ? f7.sheet.close('.tab-color-sheet') : f7.popover.close('#idx-tab-color-popover');
|
|
|
|
|
|
|
|
} else {
|
2022-01-24 14:18:12 +00:00
|
|
|
f7.views.tabColorView.router.navigate('/sheet-tab-custom-color/', {props:{onSetWorkSheetColor: props.onSetWorkSheetColor, sheets}});
|
2021-12-29 21:26:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Page>
|
|
|
|
<Navbar title={t('Statusbar.textTabColor')}>
|
|
|
|
{Device.phone &&
|
|
|
|
<NavRight>
|
|
|
|
<Link sheetClose>
|
|
|
|
<Icon icon='icon-expand-down'/>
|
|
|
|
</Link>
|
|
|
|
</NavRight>
|
|
|
|
}
|
|
|
|
</Navbar>
|
|
|
|
|
|
|
|
{ allSheets.length !== 0 &&
|
|
|
|
<ThemeColorPalette changeColor={changeColor} curColor={sheets.colorTab} customColors={customColors} transparent={true}/> }
|
|
|
|
<List>
|
|
|
|
<ListItem title={t('View.Edit.textAddCustomColor')} link="/sheet-tab-custom-color/" routeProps={{
|
|
|
|
onSetWorkSheetColor: props.onSetWorkSheetColor,
|
|
|
|
sheets,
|
|
|
|
}}></ListItem>
|
|
|
|
</List>
|
|
|
|
</Page>
|
|
|
|
)
|
|
|
|
}));
|
|
|
|
|
2022-03-23 10:43:21 +00:00
|
|
|
const PopoverAllList = (props) => {
|
|
|
|
const {sheets, onTabListClick} = props;
|
|
|
|
|
|
|
|
const onScrollList = () => {
|
|
|
|
const listHeight = $$('.list .item-list').height();
|
|
|
|
$$('.all-list .page-content').scrollTop(listHeight*sheets.activeWorksheet);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Popover id="idx-all-list" className="all-list" onPopoverOpen={onScrollList}>
|
|
|
|
<PageAllList sheets={sheets} onTabListClick={onTabListClick}/>
|
|
|
|
</Popover>
|
|
|
|
)
|
|
|
|
};
|
2021-12-29 21:26:40 +00:00
|
|
|
|
2021-08-31 13:01:44 +00:00
|
|
|
const StatusbarView = inject('storeAppOptions', 'sheets', 'users')(observer(props => {
|
2021-03-23 13:43:10 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
const _t = t('Statusbar', {returnObjects: true});
|
2021-03-24 17:50:09 +00:00
|
|
|
const isAndroid = Device.android;
|
|
|
|
const isPhone = Device.isPhone;
|
2021-08-31 13:01:44 +00:00
|
|
|
const {sheets, storeAppOptions, users} = props;
|
2021-07-28 15:19:46 +00:00
|
|
|
const allSheets = sheets.sheets;
|
|
|
|
const hiddenSheets = sheets.hiddenWorksheets();
|
2021-10-06 09:03:06 +00:00
|
|
|
const isWorkbookLocked = sheets.isWorkbookLocked;
|
|
|
|
const isProtectedWorkbook = sheets.isProtectedWorkbook;
|
2021-07-28 15:19:46 +00:00
|
|
|
const isEdit = storeAppOptions.isEdit;
|
2021-08-31 13:01:44 +00:00
|
|
|
const isDisconnected = users.isDisconnected;
|
2021-10-22 15:52:59 +00:00
|
|
|
const isDisabledEditSheet = sheets.isDisabledEditSheet;
|
2021-03-30 12:17:24 +00:00
|
|
|
|
2021-07-28 15:19:46 +00:00
|
|
|
return (
|
2021-03-23 13:43:10 +00:00
|
|
|
<Fragment>
|
|
|
|
<View id="idx-statusbar" className="statusbar" style={viewStyle}>
|
2021-11-11 08:37:06 +00:00
|
|
|
{isEdit &&
|
2022-02-01 09:29:01 +00:00
|
|
|
<div id="idx-box-add-tab" className={`${isDisconnected || isWorkbookLocked || isProtectedWorkbook ? 'disabled box-tab' : 'box-tab'}`}>
|
2021-11-11 08:37:06 +00:00
|
|
|
<Link href={false} id="idx-btn-addtab" className={`tab${isDisabledEditSheet || isDisconnected || isWorkbookLocked || isProtectedWorkbook ? ' disabled' : ''}`} onClick={props.onAddTabClicked}>
|
2022-01-25 18:08:58 +00:00
|
|
|
<Icon className={`icon icon-plus ${isAndroid ? 'bold' : ''}`}/>
|
2021-11-11 08:37:06 +00:00
|
|
|
</Link>
|
2022-02-01 09:29:01 +00:00
|
|
|
<Link href={false} id="idx-btn-all-list-tab" className={`tab${isDisabledEditSheet || isDisconnected || isWorkbookLocked || isProtectedWorkbook ? ' disabled' : ''}`} onClick={(e) => f7.popover.open('#idx-all-list', e.target)}>
|
|
|
|
<Icon className={`icon icon-list ${isAndroid ? 'bold' : ''}`}/>
|
2021-11-11 08:37:06 +00:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
}
|
2020-12-28 20:52:32 +00:00
|
|
|
<div className="statusbar--box-tabs">
|
|
|
|
<ul className="sheet-tabs bottom">
|
2021-03-30 12:17:24 +00:00
|
|
|
{allSheets.map((model,i) =>
|
|
|
|
model.hidden ? null :
|
2021-07-28 15:19:46 +00:00
|
|
|
<li className={`tab${model.active ? ' active' : ''} ${model.locked ? 'locked' : ''}`} key={i} onClick={(e) => props.onTabClick(i, e.target)}>
|
2021-12-29 21:26:40 +00:00
|
|
|
<a className={`tab-color-${model.index}`}>{model.name}</a>
|
2020-12-28 20:52:32 +00:00
|
|
|
</li>
|
2021-03-30 12:17:24 +00:00
|
|
|
|
2020-12-28 20:52:32 +00:00
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2021-03-23 13:43:10 +00:00
|
|
|
</View>
|
2021-06-10 22:08:23 +00:00
|
|
|
{isEdit ?
|
|
|
|
<Popover id="idx-tab-context-menu-popover"
|
|
|
|
className="document-menu"
|
|
|
|
backdrop={false}
|
|
|
|
closeByBackdropClick={false}
|
|
|
|
closeByOutsideClick={false}
|
|
|
|
>
|
|
|
|
{isPhone || isAndroid ? (
|
|
|
|
<List className="list-block">
|
|
|
|
<ListButton title={_t.textDuplicate} onClick={() => props.onTabMenu('copy')} />
|
|
|
|
<ListButton title={_t.textDelete} onClick={() => props.onTabMenu('del')} />
|
|
|
|
<ListButton title={_t.textMore} onClick={() => props.onTabMenu('showMore')} />
|
|
|
|
</List>
|
|
|
|
) : (
|
|
|
|
<List className="list-block">
|
|
|
|
<ListButton title={_t.textDuplicate} onClick={() => props.onTabMenu('copy')} />
|
|
|
|
<ListButton title={_t.textDelete} onClick={() => props.onTabMenu('del')} />
|
|
|
|
<ListButton title={_t.textRename} onClick={() => props.onTabMenu('ren')} />
|
|
|
|
<ListButton title={_t.textHide} onClick={() => props.onTabMenu('hide')} />
|
2021-12-19 12:38:19 +00:00
|
|
|
<ListButton title={_t.textMove} onClick={() => props.onTabMenu('move')} />
|
2021-12-29 21:26:40 +00:00
|
|
|
<ListButton title={_t.textTabColor} onClick={() => props.onTabMenu('tab-color')} />
|
2021-06-10 22:08:23 +00:00
|
|
|
{hiddenSheets.length ? (
|
|
|
|
<ListButton title={_t.textUnhide} onClick={() => props.onTabMenu('unhide')} />
|
|
|
|
) : null}
|
|
|
|
</List>
|
|
|
|
)}
|
|
|
|
</Popover>
|
|
|
|
: null}
|
2021-03-24 17:50:09 +00:00
|
|
|
{isPhone || isAndroid ? (
|
|
|
|
<Actions id="idx-tab-menu-actions" backdrop={true} closeByBackdropClick={true}>
|
|
|
|
<ActionsGroup>
|
|
|
|
<ActionsButton onClick={() => props.onTabMenu('ren')}>{_t.textRename}</ActionsButton>
|
|
|
|
<ActionsButton onClick={() => props.onTabMenu('hide')}>{_t.textHide}</ActionsButton>
|
2021-12-19 12:38:19 +00:00
|
|
|
<ActionsButton onClick={() => props.onTabMenu('move')}>{_t.textMove}</ActionsButton>
|
2021-12-29 21:26:40 +00:00
|
|
|
<ActionsButton onClick={() => props.onTabMenu('tab-color')}>{_t.textTabColor}</ActionsButton>
|
2021-03-25 20:34:22 +00:00
|
|
|
{hiddenSheets.length ? (
|
|
|
|
<ActionsButton onClick={() => props.onTabMenu('unhide')}>{_t.textUnhide}</ActionsButton>
|
|
|
|
) : null}
|
2021-03-24 17:50:09 +00:00
|
|
|
</ActionsGroup>
|
|
|
|
<ActionsGroup>
|
2021-03-25 20:34:22 +00:00
|
|
|
<ActionsButton bold={true}>{_t.textCancel}</ActionsButton>
|
|
|
|
</ActionsGroup>
|
2021-03-24 17:50:09 +00:00
|
|
|
</Actions>
|
|
|
|
) : null}
|
2022-02-01 09:29:01 +00:00
|
|
|
{
|
2022-03-23 10:43:21 +00:00
|
|
|
<PopoverAllList sheets={sheets} onTabListClick={props.onTabListClick}/>
|
2022-02-01 09:29:01 +00:00
|
|
|
}
|
2021-12-19 12:38:19 +00:00
|
|
|
{isPhone ?
|
2022-02-11 13:44:55 +00:00
|
|
|
<Sheet style={{height: '48%'}} className='move-sheet' swipeToClose={true}>
|
2021-12-19 12:38:19 +00:00
|
|
|
<div className='swipe-container'>
|
|
|
|
<Icon icon='icon-swipe'/>
|
|
|
|
</div>
|
|
|
|
<PageListMove sheets={sheets} onMenuMoveClick={props.onMenuMoveClick}/>
|
|
|
|
</Sheet>
|
|
|
|
:
|
2022-02-24 14:10:26 +00:00
|
|
|
<Popover id="idx-move-sheet-popover" closeByOutsideClick={false}>
|
2021-12-19 12:38:19 +00:00
|
|
|
<PageListMove sheets={sheets} onMenuMoveClick={props.onMenuMoveClick}/>
|
|
|
|
</Popover>
|
|
|
|
}
|
2021-12-29 21:26:40 +00:00
|
|
|
{ isPhone ?
|
|
|
|
<Sheet style={{height: '50%'}} className='tab-color-sheet' backdrop={false}
|
|
|
|
onSheetClose={() =>
|
|
|
|
{
|
|
|
|
f7.navbar.show('.main-navbar');
|
|
|
|
$$('.statusbar').css('top', '0%');
|
|
|
|
}}>
|
2022-01-24 14:18:12 +00:00
|
|
|
<View routes={routes} name='tabColorView'>
|
2021-12-29 21:26:40 +00:00
|
|
|
<PageTabColor sheets={sheets} onSetWorkSheetColor={props.onSetWorkSheetColor}/>
|
|
|
|
</View>
|
|
|
|
</Sheet>
|
|
|
|
:
|
|
|
|
<Popover id="idx-tab-color-popover" backdrop={false}>
|
2022-01-24 14:18:12 +00:00
|
|
|
<View style={{height: '450px'}} routes={routes} name='tabColorView'>
|
2021-12-29 21:26:40 +00:00
|
|
|
<PageTabColor sheets={sheets} onSetWorkSheetColor={props.onSetWorkSheetColor}/>
|
|
|
|
</View>
|
|
|
|
</Popover>
|
|
|
|
}
|
2021-03-23 13:43:10 +00:00
|
|
|
{hiddenSheets.length ? (
|
|
|
|
<Popover id="idx-hidden-sheets-popover"
|
|
|
|
className="document-menu"
|
|
|
|
backdrop={false}
|
|
|
|
closeByBackdropClick={false}
|
|
|
|
closeByOutsideClick={false}
|
|
|
|
>
|
|
|
|
<List className="list-block">
|
|
|
|
{hiddenSheets.map(sheet => {
|
|
|
|
return (
|
2021-03-23 22:46:37 +00:00
|
|
|
<ListButton key={sheet.index} data-event={`reveal:${sheet.index}`} title={sheet.name}
|
|
|
|
onClick={() => props.onTabMenu(`reveal:${sheet.index}`)} />
|
2021-03-23 13:43:10 +00:00
|
|
|
)
|
|
|
|
})}
|
|
|
|
</List>
|
|
|
|
</Popover>
|
|
|
|
) : null}
|
|
|
|
</Fragment>
|
2021-03-19 22:38:40 +00:00
|
|
|
)
|
2021-07-28 15:19:46 +00:00
|
|
|
}));
|
2021-03-19 22:38:40 +00:00
|
|
|
|
2021-12-29 21:26:40 +00:00
|
|
|
const routes = [
|
|
|
|
{
|
|
|
|
path: '/sheet-tab-custom-color/',
|
|
|
|
component: PageCustomTabColor
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-03-23 13:43:10 +00:00
|
|
|
export {StatusbarView};
|