@@ -94,16 +94,16 @@ function getFieldValue({ field, entry, isTranslatable, locale }) {
9494 return entry . getIn ( [ 'data' , field . get ( 'name' ) ] ) ;
9595}
9696
97- function calculateCondition ( { field, fields, entry, locale, isTranslatable} ) {
98- const condition = field . get ( 'condition' )
97+ function calculateCondition ( { field, fields, entry, locale, isTranslatable } ) {
98+ const condition = field . get ( 'condition' ) ;
9999 if ( ! condition ) return true ;
100100
101101 const condFieldName = condition . get ( 'field' ) ;
102102 const operator = condition . get ( 'operator' ) || '==' ;
103103 const condValue = condition . get ( 'value' ) ;
104104
105105 const condField = fields . find ( f => f . get ( 'name' ) === condFieldName ) ;
106- let condFieldValue = getFieldValue ( { field : condField , entry, locale, isTranslatable, } ) ;
106+ let condFieldValue = getFieldValue ( { field : condField , entry, locale, isTranslatable } ) ;
107107 condFieldValue = condFieldValue ?. toJS ? condFieldValue . toJS ( ) : condFieldValue ;
108108
109109 switch ( operator ) {
@@ -146,38 +146,40 @@ export default class ControlPane extends React.Component {
146146 this . props . onLocaleChange ( val ) ;
147147 } ;
148148
149- copyFromOtherLocale = ( { targetLocale, t } ) => sourceLocale => {
150- if (
151- ! window . confirm (
152- t ( 'editor.editorControlPane.i18n.copyFromLocaleConfirm' , {
153- locale : sourceLocale . toUpperCase ( ) ,
154- } ) ,
155- )
156- ) {
157- return ;
158- }
159- const { entry, collection } = this . props ;
160- const { locales, defaultLocale } = getI18nInfo ( collection ) ;
161-
162- const locale = this . state . selectedLocale ;
163- const i18n = locales && {
164- currentLocale : locale ,
165- locales,
166- defaultLocale,
167- } ;
168-
169- this . props . fields . forEach ( field => {
170- if ( isFieldTranslatable ( field , targetLocale , sourceLocale ) ) {
171- const copyValue = getFieldValue ( {
172- field,
173- entry,
174- locale : sourceLocale ,
175- isTranslatable : sourceLocale !== defaultLocale ,
176- } ) ;
177- if ( copyValue ) this . props . onChange ( field , copyValue , undefined , i18n ) ;
149+ copyFromOtherLocale =
150+ ( { targetLocale, t } ) =>
151+ sourceLocale => {
152+ if (
153+ ! window . confirm (
154+ t ( 'editor.editorControlPane.i18n.copyFromLocaleConfirm' , {
155+ locale : sourceLocale . toUpperCase ( ) ,
156+ } ) ,
157+ )
158+ ) {
159+ return ;
178160 }
179- } ) ;
180- } ;
161+ const { entry, collection } = this . props ;
162+ const { locales, defaultLocale } = getI18nInfo ( collection ) ;
163+
164+ const locale = this . state . selectedLocale ;
165+ const i18n = locales && {
166+ currentLocale : locale ,
167+ locales,
168+ defaultLocale,
169+ } ;
170+
171+ this . props . fields . forEach ( field => {
172+ if ( isFieldTranslatable ( field , targetLocale , sourceLocale ) ) {
173+ const copyValue = getFieldValue ( {
174+ field,
175+ entry,
176+ locale : sourceLocale ,
177+ isTranslatable : sourceLocale !== defaultLocale ,
178+ } ) ;
179+ if ( copyValue ) this . props . onChange ( field , copyValue , undefined , i18n ) ;
180+ }
181+ } ) ;
182+ } ;
181183
182184 validate = async ( ) => {
183185 const { fields, entry, collection } = this . props ;
@@ -268,7 +270,7 @@ export default class ControlPane extends React.Component {
268270 locale,
269271 isTranslatable,
270272 } ) ;
271- if ( ! isConditionMet ) return
273+ if ( ! isConditionMet ) return ;
272274
273275 return (
274276 < EditorControl
0 commit comments