Fix ctm editview backheader

This commit is contained in:
cyril lopez 2017-12-16 12:26:47 +01:00
parent fff73de9c7
commit 0ff0b2e2aa
2 changed files with 8 additions and 5 deletions

View File

@ -131,9 +131,11 @@ export class Edit extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.editSuccess !== nextProps.editSuccess) {
if (!isEmpty(this.props.location.search) && includes(this.props.location.search, '?redirectUrl')) {
const redirectUrl = this.props.location.search.split('?redirectUrl=')[1];
router.push({
pathname: replace(this.props.location.search, '?redirectUrl=', ''),
search: `?source=${this.source}`,
pathname: redirectUrl.split('?')[0],
search: redirectUrl.split('?')[1],
});
} else {
router.push({

View File

@ -89,6 +89,7 @@ export class List extends React.Component {
init(props) {
const source = getQueryParameters(props.location.search, 'source');
const slug = props.match.params.slug;
// Set current model name
this.props.setCurrentModelName(slug.toLowerCase());
@ -97,8 +98,8 @@ export class List extends React.Component {
getQueryParameters('sort')) || 'id';
if (!isEmpty(props.location.search)) {
this.props.changePage(toInteger(getQueryParameters('page')), source);
this.props.changeLimit(toInteger(getQueryParameters('limit')), source);
this.props.changePage(toInteger(getQueryParameters(props.location.search, 'page')), source);
this.props.changeLimit(toInteger(getQueryParameters(props.location.search, 'limit')), source);
}
this.props.changeSort(sort, source);
@ -191,7 +192,7 @@ export class List extends React.Component {
history={this.props.history}
primaryKey={currentModel.primaryKey || 'id'}
handleDelete={this.toggleModalWarning}
redirectUrl={`?redirectUrl=/plugins/content-manager/${this.props.currentModelName.toLowerCase()}/?page=${this.props.currentPage}&limit=${this.props.limit}&sort=${this.props.sort}&source=${source}`}
redirectUrl={`?redirectUrl=/plugins/content-manager/${this.props.currentModelName.toLowerCase()}?page=${this.props.currentPage}&limit=${this.props.limit}&sort=${this.props.sort}&source=${source}`}
/>
);