renamed existing request

This commit is contained in:
bill bittner 2018-02-12 19:01:29 -08:00
parent 0912cd45d9
commit b1fb65b1ec
8 changed files with 64 additions and 57 deletions

View file

@ -8,8 +8,8 @@ const mapStateToProps = ({ show }) => {
status: show.displayAsset.status,
};
// select asset info
const existingRequest = show.assetRequests[show.request.id];
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`;
const previousRequest = show.assetRequests[show.request.id];
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`;
const asset = show.assetList[assetKey];
if (asset) {
props['asset'] = asset;

View file

@ -4,8 +4,8 @@ import View from './view';
const mapStateToProps = ({ show }) => {
let props = {};
// select title
const existingRequest = show.assetRequests[show.request.id];
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`;
const previousRequest = show.assetRequests[show.request.id];
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`;
const asset = show.assetList[assetKey];
if (asset) {
props['title'] = asset.claimData.title;

View file

@ -4,8 +4,8 @@ import View from './view';
const mapStateToProps = ({ show }) => {
let props = {};
// select name and claim id
const existingRequest = show.assetRequests[show.request.id];
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`;
const previousRequest = show.assetRequests[show.request.id];
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`;
const asset = show.assetList[assetKey];
if (asset) {
props['name'] = asset.name;

View file

@ -3,17 +3,16 @@ import { updateChannelClaimsAsync } from 'actions/show';
import View from './view';
const mapStateToProps = ({ show }) => {
let props = {};
// select channel key
const request = show.channelRequests[show.request.id];
const channelKey = `c#${request.name}#${request.longId}`;
props['channelKey'] = channelKey;
// select channel claims
const channel = show.channelList[channelKey];
if (channel) {
props['channel'] = channel;
const channel = show.channelList[channelKey] || null;
// return props
return {
channelKey,
channel,
};
return props;
};
const mapDispatchToProps = dispatch => {

View file

@ -3,25 +3,30 @@ import View from './view';
import { newAssetRequest, showNewAsset } from 'actions/show';
const mapStateToProps = ({ show }) => {
let props = {};
props['requestType'] = show.request.type;
props['requestId'] = show.request.id;
props['requestName'] = show.request.data.name;
props['requestModifier'] = show.request.data.modifier;
props['requestExtension'] = show.request.data.extension;
// select request info
const requestType = show.request.type;
const requestId = show.request.id;
const requestName = show.request.data.name;
const requestModifier = show.request.data.modifier;
const requestExtension = show.request.data.extension;
// select request
const existingRequest = show.assetRequests[show.request.id];
if (existingRequest) {
props['existingRequest'] = existingRequest;
// select asset info
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; // note: just store this in the request
const asset = show.assetList[assetKey];
if (asset) {
console.log('existing asset found', asset);
props['asset'] = asset;
const previousRequest = show.assetRequests[show.request.id] || null;
// select asset infogit
let asset;
if (previousRequest) {
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; // note: just store this in the request
asset = show.assetList[assetKey] || null;
};
// return props
return {
requestType,
requestId,
requestName,
requestModifier,
requestExtension,
previousRequest,
asset,
};
return props;
};
const mapDispatchToProps = dispatch => {

View file

@ -11,23 +11,23 @@ function requestIsAnAssetRequest ({ requestType }) {
class ShowAsset extends React.Component {
componentDidMount () {
const { asset, existingRequest, requestId, requestName, requestModifier } = this.props;
if (!existingRequest) { // case: the asset request does not exist
const { asset, previousRequest, requestId, requestName, requestModifier } = this.props;
if (!previousRequest) { // case: the asset request does not exist
return this.props.onNewRequest(requestId, requestName, requestModifier);
};
if (!asset) { // case: the asset request does not exist
const { name, claimId } = existingRequest;
const { name, claimId } = previousRequest;
return this.props.onShowNewAsset(name, claimId);
};
}
componentWillReceiveProps (nextProps) {
if (requestIsAnAssetRequest(nextProps)) {
const { asset, existingRequest, requestId, requestName, requestModifier } = nextProps;
if (!existingRequest) {
const { asset, previousRequest, requestId, requestName, requestModifier } = nextProps;
if (!previousRequest) {
return this.props.onNewRequest(requestId, requestName, requestModifier);
};
if (!asset) {
const { name, claimId } = existingRequest;
const { name, claimId } = previousRequest;
return this.props.onShowNewAsset(name, claimId);
};
}

View file

@ -4,24 +4,27 @@ import { newChannelRequest, showNewChannel } from 'actions/show';
import View from './view';
const mapStateToProps = ({ show }) => {
let props = {};
props['requestId'] = show.request.id;
props['requestType'] = show.request.type;
props['requestChannelName'] = show.request.data.name;
props['requestChannelId'] = show.request.data.id;
// select request info
const requestId = show.request.id;
const requestType = show.request.type;
const requestChannelName = show.request.data.name;
const requestChannelId = show.request.data.id;
// select request
const existingRequest = show.channelRequests[show.request.id];
if (existingRequest) {
props['existingRequest'] = existingRequest;
console.log('existing channel request found', existingRequest);
const previousRequest = show.channelRequests[show.request.id] || null;
// select channel info
const channelKey = `c#${existingRequest.name}#${existingRequest.longId}`;
const channel = show.channelList[channelKey];
if (channel) {
props['channel'] = channel;
};
let channel;
if (previousRequest) {
const channelKey = `c#${previousRequest.name}#${previousRequest.longId}`;
channel = show.channelList[channelKey] || null;
}
return props;
return {
requestId,
requestType,
requestChannelName,
requestChannelId,
previousRequest,
channel,
};
};
const mapDispatchToProps = dispatch => {

View file

@ -11,23 +11,23 @@ function requestIsAChannelRequest ({ requestType }) {
class ShowChannel extends React.Component {
componentDidMount () {
const { existingRequest, channel, requestId, requestChannelName, requestChannelId } = this.props;
if (!existingRequest) {
const { previousRequest, channel, requestId, requestChannelName, requestChannelId } = this.props;
if (!previousRequest) {
return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
}
if (!channel) {
const { name, shortId, longId } = existingRequest;
const { name, shortId, longId } = previousRequest;
return this.props.onShowNewChannel(name, shortId, longId);
}
}
componentWillReceiveProps (nextProps) {
if (requestIsAChannelRequest(nextProps)) {
const { existingRequest, channel, requestId, requestChannelName, requestChannelId } = nextProps;
if (!existingRequest) {
const { previousRequest, channel, requestId, requestChannelName, requestChannelId } = nextProps;
if (!previousRequest) {
return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
}
if (!channel) {
const { name, shortId, longId } = existingRequest;
const { name, shortId, longId } = previousRequest;
return this.props.onShowNewChannel(name, shortId, longId);
}
}