application/managers/content-manager/index.js
import Immutable from 'immutable';
import {browserHistory} from 'react-router';
import {
contentFetch,
contentFetchOne,
contentCheckIn,
contentCheckOut
} from '../../redux/actions/content-actions';
import request from './../../util/request';
export default {
get: function(uuid) {
},
fetch: function(props = {}) {
const myProps = Object.assign({}, {
'per_page': 40,
'page': 1
}, props);
return window.Store.dispatch(contentFetch(props));
},
fetchFromView: function() {
const props = this.translateProps(window.Store.getState().contentView);
browserHistory.push(request.getPath() + '?' + request.setQuery(props));
return window.Store.dispatch(contentFetch(props));
},
translateProps: function(props) {
return {
page: props.page ? props.page : 1,
type: props.type ? props.type : null,
keywords: props.keywords ? props.keywords : null,
workflow: props.workflow ? props.workflow : null,
status: props.status ? props.status : null,
order: props.sorter ? props.sorter : 'modified_at',
mediatype: props.mediatype ? props.mediatype : null,
grid: props.grid ? props.grid : false,
dir: props.flip ? 'asc' : 'desc'
};
},
propsFromUrl() {
const query = request.getQuery(false);
return {
page: query.page ? query.page : 1,
type: query.type ? query.type : null,
keywords: query.keywords ? query.keywords : null,
workflow: query.workflow ? query.workflow : null,
status: query.status ? query.status : null,
sorter: query.order ? query.order : 'modified_at',
mediatype: query.mediatype ? query.mediatype : null,
grid: query.grid ? query.grid : false,
flip: query.dir == 'asc' ? true : false
};
}
};