Skip to content

Commit

Permalink
Merge pull request #61 from dew326/cleanup-cotf
Browse files Browse the repository at this point in the history
EZP-29010: Move Content on the Fly common configuration to root namespace od AdminUI config
  • Loading branch information
Nattfarinn authored Mar 26, 2018
2 parents dda3bb0 + 5259a4d commit 2c0fa70
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Resources/public/js/MultiFileUpload.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Resources/public/js/MultiFileUpload.module.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Resources/public/js/SubItems.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Resources/public/js/SubItems.module.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Resources/public/js/UniversalDiscovery.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Resources/public/js/UniversalDiscovery.module.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class TableViewItemComponent extends Component {
href: generateLink(location.id)
};
const translations = content.CurrentVersion.Version.VersionInfo.VersionTranslationInfo.Language.map(langauge => {
return languages.map[langauge.languageCode].name;
return languages.mappings[langauge.languageCode].name;
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ export default class ContentMetaPreviewComponent extends Component {
return;
}

const version = response.View.Result.searchHits.searchHit[0].value.Content.CurrentVersion.Version
const version = response.View.Result.searchHits.searchHit[0].value.Content.CurrentVersion.Version;
const imageField = version.Fields.field.find(field => field.fieldTypeIdentifier === 'ezimage');
const translations = version.VersionInfo.VersionTranslationInfo.Language.map(langauge => {
// @TODO: pass it in props when COTF is cleaned
return window.eZ.adminUiConfig.languages.map[langauge.languageCode].name;
});
const versionLanguages = version.VersionInfo.VersionTranslationInfo.Language;
const translations = versionLanguages.map(langauge => this.props.languages.mappings[langauge.languageCode].name);
const imageUri = imageField && imageField.fieldValue ? imageField.fieldValue.uri : null;

this.setState(state => Object.assign({}, state, { imageUri, translations }));
Expand Down Expand Up @@ -202,5 +200,6 @@ ContentMetaPreviewComponent.propTypes = {
translations: PropTypes.string.isRequired
}).isRequired,
maxHeight: PropTypes.number.isRequired,
activeTab: PropTypes.string.isRequired
activeTab: PropTypes.string.isRequired,
languages: PropTypes.object.isRequired
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,32 @@ export default class ChooseLanguageComponent extends Component {
this.renderOption = this.renderOption.bind(this);

this.state = {
selectedLanguage: props.languages[0]
selectedLanguage: props.languages.mappings[props.languages.priority[0]]
};
}

updateSelection(event) {
const languageCode = event.target.value;
const selectedLanguage = this.props.languages.find(language => language.languageCode === languageCode);
const selectedLanguage = this.props.languages.mappings[languageCode];

this.props.onLanguageSelected(selectedLanguage);

this.setState(state => Object.assign({}, state, { selectedLanguage }));
}

renderOption(item, index) {
renderOption(languageCode, index) {
const language = this.props.languages.mappings[languageCode];
const attrs = {
key: index,
value: item.languageCode
value: language.languageCode
};

if (item.languageCode === this.props.forcedLanguage) {
if (languageCode === this.props.forcedLanguage) {
attrs.selected = true;
}

return (
<option {...attrs}>{item.name}</option>
<option {...attrs}>{language.name}</option>
);
}

Expand All @@ -54,7 +55,7 @@ export default class ChooseLanguageComponent extends Component {
<p className="c-choose-language__title">{this.props.labels.contentOnTheFly.selectLanguage}</p>
<div className="c-choose-lagauge__select-wrapper">
<select {...selectAttrs}>
{this.props.languages.map(this.renderOption)}
{this.props.languages.priority.map(this.renderOption)}
</select>
</div>
</div>
Expand All @@ -65,7 +66,7 @@ export default class ChooseLanguageComponent extends Component {
ChooseLanguageComponent.propTypes = {
maxHeight: PropTypes.number.isRequired,
labels: PropTypes.object.isRequired,
languages: PropTypes.array.isRequired,
languages: PropTypes.object.isRequired,
onLanguageSelected: PropTypes.func.isRequired,
forcedLanguage: PropTypes.string.isRequired
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const CreateComponent = (props) => {
CreateComponent.propTypes = {
maxHeight: PropTypes.number.isRequired,
labels: PropTypes.object.isRequired,
languages: PropTypes.array.isRequired,
languages: PropTypes.object.isRequired,
contentTypes: PropTypes.object.isRequired,
onLanguageSelected: PropTypes.func.isRequired,
onContentTypeSelected: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CreatePanelComponent.propTypes = {
siteaccess: PropTypes.string.isRequired
}).isRequired,
labels: PropTypes.object.isRequired,
languages: PropTypes.array.isRequired,
languages: PropTypes.object.isRequired,
contentTypes: PropTypes.object.isRequired,
onLanguageSelected: PropTypes.func.isRequired,
onContentTypeSelected: PropTypes.func.isRequired,
Expand Down
11 changes: 6 additions & 5 deletions src/modules/universal-discovery/universal.discovery.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export default class UniversalDiscoveryModule extends Component {
constructor(props) {
super(props);

let selectedLanguage = props.languages[0];
let selectedLanguage = props.languages.mappings[props.languages.priority[0]];

this.onLanguageSelected = this.onLanguageSelected.bind(this);
this.onContentTypeSelected = this.onContentTypeSelected.bind(this);
this.handlePublish = this.handlePublish.bind(this);

if (props.cotfForcedLanguage) {
selectedLanguage = props.languages.find(language => language.languageCode === props.cotfForcedLanguage);
selectedLanguage = props.languages.mappings[props.cotfForcedLanguage];
}

this.state = {
Expand Down Expand Up @@ -156,6 +156,7 @@ export default class UniversalDiscoveryModule extends Component {
loadContentInfo={this.props.loadContentInfo}
restInfo={this.props.restInfo}
contentTypesMap={this.state.contentTypesMap}
languages={this.props.languages}
labels={this.props.labels.contentMetaPreview}
maxHeight={this.state.maxHeight}
activeTab={this.state.activeTab}/>
Expand Down Expand Up @@ -453,7 +454,7 @@ UniversalDiscoveryModule.propTypes = {
}),
maxHeight: PropTypes.number,
searchResultsPerPage: PropTypes.number,
languages: PropTypes.array,
languages: PropTypes.object,
contentTypes: PropTypes.object,
allowContainersOnly: PropTypes.bool.isRequired,
onlyContentOnTheFly: PropTypes.bool,
Expand All @@ -474,8 +475,8 @@ UniversalDiscoveryModule.defaultProps = {
startingLocationId: 1,
maxHeight: 500,
searchResultsPerPage: 10,
languages: window.eZ.adminUiConfig.universalDiscoveryWidget.contentOnTheFly.languages,
contentTypes: window.eZ.adminUiConfig.universalDiscoveryWidget.contentOnTheFly.contentTypes,
languages: window.eZ.adminUiConfig.languages,
contentTypes: window.eZ.adminUiConfig.contentTypes,
allowContainersOnly: false,
onlyContentOnTheFly: false,
cotfForcedLanguage: '',
Expand Down

0 comments on commit 2c0fa70

Please sign in to comment.