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) { componentWillReceiveProps(nextProps) {
if (this.props.editSuccess !== nextProps.editSuccess) { if (this.props.editSuccess !== nextProps.editSuccess) {
if (!isEmpty(this.props.location.search) && includes(this.props.location.search, '?redirectUrl')) { if (!isEmpty(this.props.location.search) && includes(this.props.location.search, '?redirectUrl')) {
const redirectUrl = this.props.location.search.split('?redirectUrl=')[1];
router.push({ router.push({
pathname: replace(this.props.location.search, '?redirectUrl=', ''), pathname: redirectUrl.split('?')[0],
search: `?source=${this.source}`, search: redirectUrl.split('?')[1],
}); });
} else { } else {
router.push({ router.push({

View File

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