[DE PE] Refactoring TableStyles
This commit is contained in:
parent
ba2a62786d
commit
81f331fd2a
|
@ -9,9 +9,6 @@ class AddTableController extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.onStyleClick = this.onStyleClick.bind(this);
|
this.onStyleClick = this.onStyleClick.bind(this);
|
||||||
|
|
||||||
const api = Common.EditorApi.get();
|
|
||||||
api.asc_GetDefaultTableStyles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal () {
|
closeModal () {
|
||||||
|
|
|
@ -11,6 +11,7 @@ class DocumentSettingsController extends Component {
|
||||||
this.getMargins = this.getMargins.bind(this);
|
this.getMargins = this.getMargins.bind(this);
|
||||||
this.applyMargins = this.applyMargins.bind(this);
|
this.applyMargins = this.applyMargins.bind(this);
|
||||||
this.onFormatChange = this.onFormatChange.bind(this);
|
this.onFormatChange = this.onFormatChange.bind(this);
|
||||||
|
this.onColorSchemeChange = this.onColorSchemeChange.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPageOrientation (value){
|
onPageOrientation (value){
|
||||||
|
@ -107,6 +108,7 @@ class DocumentSettingsController extends Component {
|
||||||
onColorSchemeChange(newScheme) {
|
onColorSchemeChange(newScheme) {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
api.asc_ChangeColorSchemeByIdx(+newScheme);
|
api.asc_ChangeColorSchemeByIdx(+newScheme);
|
||||||
|
this.props.storeTableSettings.setStyles([], 'default');
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -122,4 +124,4 @@ class DocumentSettingsController extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default inject("storeDocumentSettings")(observer(withTranslation()(DocumentSettingsController)));
|
export default inject("storeDocumentSettings", 'storeTableSettings')(observer(withTranslation()(DocumentSettingsController)));
|
|
@ -14,10 +14,12 @@ export class storeTableSettings {
|
||||||
updateCellBorderColor: action,
|
updateCellBorderColor: action,
|
||||||
setAutoColor: action,
|
setAutoColor: action,
|
||||||
colorAuto: observable,
|
colorAuto: observable,
|
||||||
|
arrayStylesDefault: observable,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayStyles = [];
|
arrayStyles = [];
|
||||||
|
arrayStylesDefault = [];
|
||||||
colorAuto = 'auto';
|
colorAuto = 'auto';
|
||||||
|
|
||||||
setAutoColor(value) {
|
setAutoColor(value) {
|
||||||
|
@ -28,7 +30,7 @@ export class storeTableSettings {
|
||||||
this.arrayStyles = [];
|
this.arrayStyles = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
setStyles (arrStyles) {
|
setStyles (arrStyles, typeStyles) {
|
||||||
let styles = [];
|
let styles = [];
|
||||||
for (let template of arrStyles) {
|
for (let template of arrStyles) {
|
||||||
styles.push({
|
styles.push({
|
||||||
|
@ -36,6 +38,10 @@ export class storeTableSettings {
|
||||||
templateId : template.asc_getId()
|
templateId : template.asc_getId()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeStyles === 'default') {
|
||||||
|
return this.arrayStylesDefault = styles;
|
||||||
|
}
|
||||||
return this.arrayStyles = styles;
|
return this.arrayStyles = styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,9 +179,12 @@ const AddTabs = inject("storeFocusObjects", "storeTableSettings")(observer(({sto
|
||||||
component: <AddLinkController noNavbar={true}/>
|
component: <AddLinkController noNavbar={true}/>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const onGetTableStylesPreviews = () => {
|
const onGetTableStylesPreviews = () => {
|
||||||
const api = Common.EditorApi.get();
|
if(storeTableSettings.arrayStylesDefault.length == 0) {
|
||||||
setTimeout(() => storeTableSettings.setStyles(api.asc_getTableStylesPreviews(true)), 1);
|
const api = Common.EditorApi.get();
|
||||||
|
setTimeout(() => storeTableSettings.setStyles(api.asc_getTableStylesPreviews(true), 'default'), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {Device} from '../../../../../common/mobile/utils/device';
|
||||||
|
|
||||||
const AddTable = props => {
|
const AddTable = props => {
|
||||||
const storeTableSettings = props.storeTableSettings;
|
const storeTableSettings = props.storeTableSettings;
|
||||||
const styles = storeTableSettings.arrayStyles;
|
const styles = storeTableSettings.arrayStylesDefault;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'table-styles dataview'}>
|
<div className={'table-styles dataview'}>
|
||||||
|
|
|
@ -226,11 +226,9 @@ const PageStyleOptions = props => {
|
||||||
isBandVer = tableLook.get_BandVer();
|
isBandVer = tableLook.get_BandVer();
|
||||||
}
|
}
|
||||||
|
|
||||||
const openIndicator = () => props.onGetTableStylesPreviews();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Navbar title={_t.textOptions} backLink={_t.textBack} onBackClick={openIndicator}>
|
<Navbar title={_t.textOptions} backLink={_t.textBack} onBackClick={props.onGetTableStylesPreviews}>
|
||||||
{Device.phone &&
|
{Device.phone &&
|
||||||
<NavRight>
|
<NavRight>
|
||||||
<Link sheetClose='#edit-sheet'>
|
<Link sheetClose='#edit-sheet'>
|
||||||
|
|
|
@ -10,10 +10,7 @@ class AddOtherController extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.onStyleClick = this.onStyleClick.bind(this);
|
this.onStyleClick = this.onStyleClick.bind(this);
|
||||||
this.initStyleTable = this.initStyleTable.bind(this);
|
|
||||||
this.onGetTableStylesPreviews = this.onGetTableStylesPreviews.bind(this);
|
this.onGetTableStylesPreviews = this.onGetTableStylesPreviews.bind(this);
|
||||||
|
|
||||||
this.initTable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal () {
|
closeModal () {
|
||||||
|
@ -24,14 +21,6 @@ class AddOtherController extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initStyleTable () {
|
|
||||||
if (!this.initTable) {
|
|
||||||
const api = Common.EditorApi.get();
|
|
||||||
api.asc_GetDefaultTableStyles();
|
|
||||||
this.initTable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onStyleClick (type) {
|
onStyleClick (type) {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
|
|
||||||
|
@ -93,8 +82,10 @@ class AddOtherController extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onGetTableStylesPreviews = () => {
|
onGetTableStylesPreviews = () => {
|
||||||
const api = Common.EditorApi.get();
|
if(this.props.storeTableSettings.arrayStylesDefault.length == 0) {
|
||||||
setTimeout(() => this.props.storeTableSettings.setStyles(api.asc_getTableStylesPreviews(true)), 1);
|
const api = Common.EditorApi.get();
|
||||||
|
setTimeout(() => this.props.storeTableSettings.setStyles(api.asc_getTableStylesPreviews(true), 'default'), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideAddComment () {
|
hideAddComment () {
|
||||||
|
@ -127,7 +118,6 @@ class AddOtherController extends Component {
|
||||||
return (
|
return (
|
||||||
<AddOther closeModal={this.closeModal}
|
<AddOther closeModal={this.closeModal}
|
||||||
onStyleClick={this.onStyleClick}
|
onStyleClick={this.onStyleClick}
|
||||||
initStyleTable={this.initStyleTable}
|
|
||||||
hideAddComment={this.hideAddComment}
|
hideAddComment={this.hideAddComment}
|
||||||
onGetTableStylesPreviews = {this.onGetTableStylesPreviews}
|
onGetTableStylesPreviews = {this.onGetTableStylesPreviews}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -7,6 +7,7 @@ class PresentationSettingsController extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.initSlideSize = this.initSlideSize.bind(this);
|
this.initSlideSize = this.initSlideSize.bind(this);
|
||||||
this.onSlideSize = this.onSlideSize.bind(this);
|
this.onSlideSize = this.onSlideSize.bind(this);
|
||||||
|
this.onColorSchemeChange = this.onColorSchemeChange.bind(this);
|
||||||
this.initSlideSize();
|
this.initSlideSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ class PresentationSettingsController extends Component {
|
||||||
onColorSchemeChange(newScheme) {
|
onColorSchemeChange(newScheme) {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
api.asc_ChangeColorSchemeByIdx(newScheme);
|
api.asc_ChangeColorSchemeByIdx(newScheme);
|
||||||
|
this.props.storeTableSettings.setStyles([], 'default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,4 +64,4 @@ class PresentationSettingsController extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default inject("storePresentationSettings")(observer(PresentationSettingsController));
|
export default inject("storePresentationSettings", "storeTableSettings")(observer(PresentationSettingsController));
|
|
@ -14,10 +14,12 @@ export class storeTableSettings {
|
||||||
updateCellBorderColor: action,
|
updateCellBorderColor: action,
|
||||||
setAutoColor: action,
|
setAutoColor: action,
|
||||||
colorAuto: observable,
|
colorAuto: observable,
|
||||||
|
arrayStylesDefault: observable,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayStyles = [];
|
arrayStyles = [];
|
||||||
|
arrayStylesDefault = [];
|
||||||
colorAuto = 'auto';
|
colorAuto = 'auto';
|
||||||
|
|
||||||
setAutoColor(value) {
|
setAutoColor(value) {
|
||||||
|
@ -28,7 +30,7 @@ export class storeTableSettings {
|
||||||
this.arrayStyles = [];
|
this.arrayStyles = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
setStyles (arrStyles) {
|
setStyles (arrStyles, typeStyles) {
|
||||||
let styles = [];
|
let styles = [];
|
||||||
for (let template of arrStyles) {
|
for (let template of arrStyles) {
|
||||||
styles.push({
|
styles.push({
|
||||||
|
@ -36,6 +38,10 @@ export class storeTableSettings {
|
||||||
templateId : template.asc_getId()
|
templateId : template.asc_getId()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeStyles === 'default') {
|
||||||
|
return this.arrayStylesDefault = styles;
|
||||||
|
}
|
||||||
return this.arrayStyles = styles;
|
return this.arrayStyles = styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,10 @@ import { useTranslation } from 'react-i18next';
|
||||||
import {Device} from "../../../../../common/mobile/utils/device";
|
import {Device} from "../../../../../common/mobile/utils/device";
|
||||||
|
|
||||||
const PageTable = props => {
|
const PageTable = props => {
|
||||||
props.initStyleTable();
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const _t = t('View.Add', {returnObjects: true});
|
const _t = t('View.Add', {returnObjects: true});
|
||||||
const storeTableSettings = props.storeTableSettings;
|
const storeTableSettings = props.storeTableSettings;
|
||||||
const styles = storeTableSettings.arrayStyles;
|
const styles = storeTableSettings.arrayStylesDefault;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page id={'add-table'}>
|
<Page id={'add-table'}>
|
||||||
|
@ -50,7 +49,6 @@ const AddOther = props => {
|
||||||
<List>
|
<List>
|
||||||
<ListItem title={_t.textTable} link={'/add-table/'} onClick = {() => props.onGetTableStylesPreviews()} routeProps={{
|
<ListItem title={_t.textTable} link={'/add-table/'} onClick = {() => props.onGetTableStylesPreviews()} routeProps={{
|
||||||
onStyleClick: props.onStyleClick,
|
onStyleClick: props.onStyleClick,
|
||||||
initStyleTable: props.initStyleTable
|
|
||||||
}}>
|
}}>
|
||||||
<Icon slot="media" icon="icon-add-table"></Icon>
|
<Icon slot="media" icon="icon-add-table"></Icon>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
|
@ -66,11 +66,9 @@ const PageStyleOptions = props => {
|
||||||
isBandVer = tableLook.get_BandVer();
|
isBandVer = tableLook.get_BandVer();
|
||||||
}
|
}
|
||||||
|
|
||||||
const openIndicator = () => props.onGetTableStylesPreviews();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Navbar title={_t.textOptions} backLink={_t.textBack} onBackClick={openIndicator}>
|
<Navbar title={_t.textOptions} backLink={_t.textBack} onBackClick={props.onGetTableStylesPreviews}>
|
||||||
{Device.phone &&
|
{Device.phone &&
|
||||||
<NavRight>
|
<NavRight>
|
||||||
<Link sheetClose='#edit-sheet'>
|
<Link sheetClose='#edit-sheet'>
|
||||||
|
|
Loading…
Reference in a new issue