mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Merge with AD-1255
This commit is contained in:
parent
3a8f91e29e
commit
f7259a8ab3
@ -1,174 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
import ConsignForm from '../ascribe_forms/form_consign';
|
|
||||||
import UnConsignForm from '../ascribe_forms/form_unconsign';
|
|
||||||
import TransferForm from '../ascribe_forms/form_transfer';
|
|
||||||
import LoanForm from '../ascribe_forms/form_loan';
|
|
||||||
import LoanRequestAnswerForm from '../ascribe_forms/form_loan_request_answer';
|
|
||||||
import ShareForm from '../ascribe_forms/form_share_email';
|
|
||||||
import ModalWrapper from '../ascribe_modal/modal_wrapper';
|
|
||||||
import AppConstants from '../../constants/application_constants';
|
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
|
||||||
|
|
||||||
import { getAclFormMessage, getAclFormDataId } from '../../utils/form_utils';
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
|
||||||
|
|
||||||
let AclButton = React.createClass({
|
|
||||||
propTypes: {
|
|
||||||
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
|
|
||||||
availableAcls: React.PropTypes.object.isRequired,
|
|
||||||
pieceOrEditions: React.PropTypes.oneOfType([
|
|
||||||
React.PropTypes.object,
|
|
||||||
React.PropTypes.array
|
|
||||||
]).isRequired,
|
|
||||||
currentUser: React.PropTypes.object,
|
|
||||||
buttonAcceptName: React.PropTypes.string,
|
|
||||||
buttonAcceptClassName: React.PropTypes.string,
|
|
||||||
email: React.PropTypes.string,
|
|
||||||
handleSuccess: React.PropTypes.func.isRequired,
|
|
||||||
className: React.PropTypes.string
|
|
||||||
},
|
|
||||||
|
|
||||||
isPiece() {
|
|
||||||
return this.props.pieceOrEditions.constructor !== Array;
|
|
||||||
},
|
|
||||||
|
|
||||||
actionProperties() {
|
|
||||||
let message = getAclFormMessage({
|
|
||||||
aclName: this.props.action,
|
|
||||||
entities: this.props.pieceOrEditions,
|
|
||||||
isPiece: this.isPiece(),
|
|
||||||
senderName: this.props.currentUser.username
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.props.action === 'acl_consign') {
|
|
||||||
return {
|
|
||||||
title: getLangText('Consign artwork'),
|
|
||||||
tooltip: getLangText('Have someone else sell the artwork'),
|
|
||||||
form: (
|
|
||||||
<ConsignForm
|
|
||||||
email={this.props.email}
|
|
||||||
message={message}
|
|
||||||
id={this.getFormDataId()}
|
|
||||||
url={ApiUrls.ownership_consigns}/>
|
|
||||||
),
|
|
||||||
handleSuccess: this.showNotification
|
|
||||||
};
|
|
||||||
} else if (this.props.action === 'acl_unconsign') {
|
|
||||||
return {
|
|
||||||
title: getLangText('Unconsign artwork'),
|
|
||||||
tooltip: getLangText('Have the owner manage his sales again'),
|
|
||||||
form: (
|
|
||||||
<UnConsignForm
|
|
||||||
message={message}
|
|
||||||
id={this.getFormDataId()}
|
|
||||||
url={ApiUrls.ownership_unconsigns}/>
|
|
||||||
),
|
|
||||||
handleSuccess: this.showNotification
|
|
||||||
};
|
|
||||||
} else if (this.props.action === 'acl_transfer') {
|
|
||||||
return {
|
|
||||||
title: getLangText('Transfer artwork'),
|
|
||||||
tooltip: getLangText('Transfer the ownership of the artwork'),
|
|
||||||
form: (
|
|
||||||
<TransferForm
|
|
||||||
message={message}
|
|
||||||
id={this.getFormDataId()}
|
|
||||||
url={ApiUrls.ownership_transfers}/>
|
|
||||||
),
|
|
||||||
handleSuccess: this.showNotification
|
|
||||||
};
|
|
||||||
} else if (this.props.action === 'acl_loan') {
|
|
||||||
return {
|
|
||||||
title: getLangText('Loan artwork'),
|
|
||||||
tooltip: getLangText('Loan your artwork for a limited period of time'),
|
|
||||||
form: (
|
|
||||||
<LoanForm
|
|
||||||
email={this.props.email}
|
|
||||||
message={message}
|
|
||||||
id={this.getFormDataId()}
|
|
||||||
url={this.isPiece() ? ApiUrls.ownership_loans_pieces
|
|
||||||
: ApiUrls.ownership_loans_editions}/>
|
|
||||||
),
|
|
||||||
handleSuccess: this.showNotification
|
|
||||||
};
|
|
||||||
} else if (this.props.action === 'acl_loan_request') {
|
|
||||||
return {
|
|
||||||
title: getLangText('Loan artwork'),
|
|
||||||
tooltip: getLangText('Someone requested you to loan your artwork for a limited period of time'),
|
|
||||||
form: (
|
|
||||||
<LoanRequestAnswerForm
|
|
||||||
message={message}
|
|
||||||
id={this.getFormDataId()}
|
|
||||||
url={ApiUrls.ownership_loans_pieces_request_confirm}/>
|
|
||||||
),
|
|
||||||
handleSuccess: this.showNotification
|
|
||||||
};
|
|
||||||
} else if (this.props.action === 'acl_share') {
|
|
||||||
return {
|
|
||||||
title: getLangText('Share artwork'),
|
|
||||||
tooltip: getLangText('Share the artwork'),
|
|
||||||
form: (
|
|
||||||
<ShareForm
|
|
||||||
message={message}
|
|
||||||
id={this.getFormDataId()}
|
|
||||||
url={this.isPiece() ? ApiUrls.ownership_shares_pieces
|
|
||||||
: ApiUrls.ownership_shares_editions}/>
|
|
||||||
),
|
|
||||||
handleSuccess: this.showNotification
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
throw new Error('Your specified action did not match a form.');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
showNotification(response) {
|
|
||||||
this.props.handleSuccess();
|
|
||||||
if (response.notification) {
|
|
||||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getFormDataId(){
|
|
||||||
return getAclFormDataId(this.isPiece(), this.props.pieceOrEditions);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Removes the acl_ prefix and converts to upper case
|
|
||||||
sanitizeAction() {
|
|
||||||
if (this.props.buttonAcceptName) {
|
|
||||||
return this.props.buttonAcceptName;
|
|
||||||
}
|
|
||||||
return this.props.action.split('acl_')[1].toUpperCase();
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.props.availableAcls) {
|
|
||||||
let shouldDisplay = this.props.availableAcls[this.props.action];
|
|
||||||
let aclProps = this.actionProperties();
|
|
||||||
let buttonClassName = this.props.buttonAcceptClassName ? this.props.buttonAcceptClassName : '';
|
|
||||||
return (
|
|
||||||
<ModalWrapper
|
|
||||||
trigger={
|
|
||||||
<button
|
|
||||||
className={shouldDisplay ? 'btn btn-default btn-sm ' + buttonClassName : 'hidden'}>
|
|
||||||
{this.sanitizeAction()}
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
handleSuccess={aclProps.handleSuccess}
|
|
||||||
title={aclProps.title}>
|
|
||||||
{aclProps.form}
|
|
||||||
</ModalWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default AclButton;
|
|
@ -5,21 +5,25 @@ import React from 'react/addons';
|
|||||||
import UserActions from '../../actions/user_actions';
|
import UserActions from '../../actions/user_actions';
|
||||||
import UserStore from '../../stores/user_store';
|
import UserStore from '../../stores/user_store';
|
||||||
|
|
||||||
import AclButton from '../ascribe_buttons/acl_button';
|
import ConsignButton from './acls/consign_button';
|
||||||
|
import LoanButton from './acls/loan_button';
|
||||||
|
import LoanRequestButton from './acls/loan_request_button';
|
||||||
|
import ShareButton from './acls/share_button';
|
||||||
|
import TransferButton from './acls/transfer_button';
|
||||||
|
import UnconsignButton from './acls/unconsign_button';
|
||||||
|
|
||||||
import { mergeOptions } from '../../utils/general_utils';
|
import { mergeOptions } from '../../utils/general_utils';
|
||||||
|
|
||||||
|
|
||||||
let AclButtonList = React.createClass({
|
let AclButtonList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
editions: React.PropTypes.oneOfType([
|
pieceOrEditions: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.object,
|
React.PropTypes.object,
|
||||||
React.PropTypes.array
|
React.PropTypes.array
|
||||||
]),
|
]).isRequired,
|
||||||
availableAcls: React.PropTypes.object,
|
availableAcls: React.PropTypes.object.isRequired,
|
||||||
buttonsStyle: React.PropTypes.object,
|
buttonsStyle: React.PropTypes.object,
|
||||||
handleSuccess: React.PropTypes.func,
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
children: React.PropTypes.oneOfType([
|
children: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||||
React.PropTypes.element
|
React.PropTypes.element
|
||||||
@ -78,7 +82,7 @@ let AclButtonList = React.createClass({
|
|||||||
const { className,
|
const { className,
|
||||||
buttonsStyle,
|
buttonsStyle,
|
||||||
availableAcls,
|
availableAcls,
|
||||||
editions,
|
pieceOrEditions,
|
||||||
handleSuccess } = this.props;
|
handleSuccess } = this.props;
|
||||||
|
|
||||||
const { currentUser } = this.state;
|
const { currentUser } = this.state;
|
||||||
@ -86,34 +90,29 @@ let AclButtonList = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<span ref="buttonList" style={buttonsStyle}>
|
<span ref="buttonList" style={buttonsStyle}>
|
||||||
<AclButton
|
<ShareButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="acl_share"
|
pieceOrEditions={pieceOrEditions}
|
||||||
pieceOrEditions={editions}
|
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
handleSuccess={handleSuccess} />
|
handleSuccess={handleSuccess} />
|
||||||
<AclButton
|
<TransferButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="acl_transfer"
|
pieceOrEditions={pieceOrEditions}
|
||||||
pieceOrEditions={editions}
|
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
handleSuccess={handleSuccess}/>
|
handleSuccess={handleSuccess}/>
|
||||||
<AclButton
|
<ConsignButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="acl_consign"
|
pieceOrEditions={pieceOrEditions}
|
||||||
pieceOrEditions={editions}
|
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
handleSuccess={handleSuccess} />
|
handleSuccess={handleSuccess} />
|
||||||
<AclButton
|
<UnconsignButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="acl_unconsign"
|
pieceOrEditions={pieceOrEditions}
|
||||||
pieceOrEditions={editions}
|
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
handleSuccess={handleSuccess} />
|
handleSuccess={handleSuccess} />
|
||||||
<AclButton
|
<LoanButton
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
action="acl_loan"
|
pieceOrEditions={pieceOrEditions}
|
||||||
pieceOrEditions={editions}
|
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
handleSuccess={handleSuccess} />
|
handleSuccess={handleSuccess} />
|
||||||
{this.renderChildren()}
|
{this.renderChildren()}
|
||||||
|
83
js/components/ascribe_buttons/acls/acl_button.js
Normal file
83
js/components/ascribe_buttons/acls/acl_button.js
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import AclProxy from '../../acl_proxy';
|
||||||
|
|
||||||
|
import AclFormFactory from '../../ascribe_forms/acl_form_factory';
|
||||||
|
|
||||||
|
import ModalWrapper from '../../ascribe_modal/modal_wrapper';
|
||||||
|
|
||||||
|
import AppConstants from '../../../constants/application_constants';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import ApiUrls from '../../../constants/api_urls';
|
||||||
|
|
||||||
|
import { getAclFormMessage, getAclFormDataId } from '../../../utils/form_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let AclButton = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
|
||||||
|
availableAcls: React.PropTypes.object.isRequired,
|
||||||
|
buttonAcceptName: React.PropTypes.string,
|
||||||
|
buttonAcceptClassName: React.PropTypes.string,
|
||||||
|
currentUser: React.PropTypes.object.isRequired,
|
||||||
|
email: React.PropTypes.string,
|
||||||
|
pieceOrEditions: React.PropTypes.oneOfType([
|
||||||
|
React.PropTypes.object,
|
||||||
|
React.PropTypes.array
|
||||||
|
]).isRequired,
|
||||||
|
title: React.PropTypes.string,
|
||||||
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
|
className: React.PropTypes.string
|
||||||
|
},
|
||||||
|
|
||||||
|
// Removes the acl_ prefix and converts to upper case
|
||||||
|
sanitizeAction() {
|
||||||
|
if (this.props.buttonAcceptName) {
|
||||||
|
return this.props.buttonAcceptName;
|
||||||
|
}
|
||||||
|
return this.props.action.split('acl_')[1].toUpperCase();
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
action,
|
||||||
|
availableAcls,
|
||||||
|
buttonAcceptClassName,
|
||||||
|
currentUser,
|
||||||
|
email,
|
||||||
|
pieceOrEditions,
|
||||||
|
handleSuccess,
|
||||||
|
title } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AclProxy
|
||||||
|
aclName={action}
|
||||||
|
aclObject={availableAcls}>
|
||||||
|
<ModalWrapper
|
||||||
|
trigger={
|
||||||
|
<button
|
||||||
|
className={classNames('btn', 'btn-default', 'btn-sm', buttonAcceptClassName)}>
|
||||||
|
{this.sanitizeAction()}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
handleSuccess={handleSuccess}
|
||||||
|
title={title}>
|
||||||
|
<AclFormFactory
|
||||||
|
action={action}
|
||||||
|
currentUser={currentUser}
|
||||||
|
email={email}
|
||||||
|
pieceOrEditions={pieceOrEditions}
|
||||||
|
showNotification />
|
||||||
|
</ModalWrapper>
|
||||||
|
</AclProxy>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default AclButton;
|
27
js/components/ascribe_buttons/acls/consign_button.js
Normal file
27
js/components/ascribe_buttons/acls/consign_button.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AclButton from './acl_button';
|
||||||
|
|
||||||
|
import { omitFromObject } from '../../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let ConsignButton = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
...omitFromObject(AclButton.propTypes, ['action']),
|
||||||
|
email: React.PropTypes.string
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AclButton
|
||||||
|
{...this.props}
|
||||||
|
action='acl_consign'
|
||||||
|
title={getLangText('Consign artwork')}
|
||||||
|
tooltip={getLangText('Have someone else sell the artwork')} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ConsignButton;
|
27
js/components/ascribe_buttons/acls/loan_button.js
Normal file
27
js/components/ascribe_buttons/acls/loan_button.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AclButton from './acl_button';
|
||||||
|
|
||||||
|
import { omitFromObject } from '../../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let LoanButton = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
...omitFromObject(AclButton.propTypes, ['action']),
|
||||||
|
email: React.PropTypes.string
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AclButton
|
||||||
|
{...this.props}
|
||||||
|
action='acl_loan'
|
||||||
|
title={getLangText('Loan artwork')}
|
||||||
|
tooltip={getLangText('Loan your artwork for a limited period of time')} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default LoanButton;
|
24
js/components/ascribe_buttons/acls/loan_request_button.js
Normal file
24
js/components/ascribe_buttons/acls/loan_request_button.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AclButton from './acl_button';
|
||||||
|
|
||||||
|
import { omitFromObject } from '../../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let LoanButton = React.createClass({
|
||||||
|
propTypes: omitFromObject(AclButton.propTypes, ['action']),
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AclButton
|
||||||
|
{...this.props}
|
||||||
|
action='acl_loan_request'
|
||||||
|
title={getLangText('Loan artwork')}
|
||||||
|
tooltip={getLangText('Someone requested you to loan your artwork for a limited period of time')} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default LoanButton;
|
24
js/components/ascribe_buttons/acls/share_button.js
Normal file
24
js/components/ascribe_buttons/acls/share_button.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AclButton from './acl_button';
|
||||||
|
|
||||||
|
import { omitFromObject } from '../../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let ShareButton = React.createClass({
|
||||||
|
propTypes: omitFromObject(AclButton.propTypes, ['action']),
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AclButton
|
||||||
|
{...this.props}
|
||||||
|
action='acl_share'
|
||||||
|
title={getLangText('Share artwork')}
|
||||||
|
tooltip={getLangText('Share the artwork')} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ShareButton;
|
24
js/components/ascribe_buttons/acls/transfer_button.js
Normal file
24
js/components/ascribe_buttons/acls/transfer_button.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AclButton from './acl_button';
|
||||||
|
|
||||||
|
import { omitFromObject } from '../../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let TransferButton = React.createClass({
|
||||||
|
propTypes: omitFromObject(AclButton.propTypes, ['action']),
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AclButton
|
||||||
|
{...this.props}
|
||||||
|
action='acl_transfer'
|
||||||
|
title={getLangText('Transfer artwork')}
|
||||||
|
tooltip={getLangText('Transfer the ownership of the artwork')} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default TransferButton;
|
24
js/components/ascribe_buttons/acls/unconsign_button.js
Normal file
24
js/components/ascribe_buttons/acls/unconsign_button.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AclButton from './acl_button';
|
||||||
|
|
||||||
|
import { omitFromObject } from '../../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../../utils/lang_utils';
|
||||||
|
|
||||||
|
let UnconsignButton = React.createClass({
|
||||||
|
propTypes: omitFromObject(AclButton.propTypes, ['action']),
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AclButton
|
||||||
|
{...this.props}
|
||||||
|
action='acl_unconsign'
|
||||||
|
title={getLangText('Unconsign artwork')}
|
||||||
|
tooltip={getLangText('Have the owner manage his sales again')} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default UnconsignButton;
|
@ -115,7 +115,7 @@ let EditionActionPanel = React.createClass({
|
|||||||
<ActionPanelButtonListType
|
<ActionPanelButtonListType
|
||||||
className="ascribe-button-list"
|
className="ascribe-button-list"
|
||||||
availableAcls={edition.acl}
|
availableAcls={edition.acl}
|
||||||
editions={[edition]}
|
pieceOrEditions={[edition]}
|
||||||
handleSuccess={this.handleSuccess}>
|
handleSuccess={this.handleSuccess}>
|
||||||
<AclProxy
|
<AclProxy
|
||||||
aclObject={edition.acl}
|
aclObject={edition.acl}
|
||||||
|
@ -207,7 +207,7 @@ let PieceContainer = React.createClass({
|
|||||||
<AclButtonList
|
<AclButtonList
|
||||||
className="ascribe-button-list"
|
className="ascribe-button-list"
|
||||||
availableAcls={piece.acl}
|
availableAcls={piece.acl}
|
||||||
editions={piece}
|
pieceOrEditions={piece}
|
||||||
handleSuccess={this.loadPiece}>
|
handleSuccess={this.loadPiece}>
|
||||||
<CreateEditionsButton
|
<CreateEditionsButton
|
||||||
label={getLangText('CREATE EDITIONS')}
|
label={getLangText('CREATE EDITIONS')}
|
||||||
|
128
js/components/ascribe_forms/acl_form_factory.js
Normal file
128
js/components/ascribe_forms/acl_form_factory.js
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import ConsignForm from '../ascribe_forms/form_consign';
|
||||||
|
import UnConsignForm from '../ascribe_forms/form_unconsign';
|
||||||
|
import TransferForm from '../ascribe_forms/form_transfer';
|
||||||
|
import LoanForm from '../ascribe_forms/form_loan';
|
||||||
|
import LoanRequestAnswerForm from '../ascribe_forms/form_loan_request_answer';
|
||||||
|
import ShareForm from '../ascribe_forms/form_share_email';
|
||||||
|
|
||||||
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import { getAclFormMessage, getAclFormDataId } from '../../utils/form_utils';
|
||||||
|
|
||||||
|
let AclFormFactory = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
|
||||||
|
currentUser: React.PropTypes.object.isRequired,
|
||||||
|
email: React.PropTypes.string,
|
||||||
|
message: React.PropTypes.string,
|
||||||
|
pieceOrEditions: React.PropTypes.oneOfType([
|
||||||
|
React.PropTypes.object,
|
||||||
|
React.PropTypes.array
|
||||||
|
]).isRequired,
|
||||||
|
handleSuccess: React.PropTypes.func,
|
||||||
|
showNotification: React.PropTypes.bool
|
||||||
|
},
|
||||||
|
|
||||||
|
isPiece() {
|
||||||
|
return this.props.pieceOrEditions.constructor !== Array;
|
||||||
|
},
|
||||||
|
|
||||||
|
getFormDataId() {
|
||||||
|
return getAclFormDataId(this.isPiece(), this.props.pieceOrEditions);
|
||||||
|
},
|
||||||
|
|
||||||
|
showSuccessNotification(response) {
|
||||||
|
if (typeof this.props.handleSuccess === 'function') {
|
||||||
|
this.props.handleSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.notification) {
|
||||||
|
const notification = new GlobalNotificationModel(response.notification, 'success');
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
action,
|
||||||
|
pieceOrEditions,
|
||||||
|
currentUser,
|
||||||
|
email,
|
||||||
|
message,
|
||||||
|
handleSuccess,
|
||||||
|
showNotification } = this.props;
|
||||||
|
|
||||||
|
const formMessage = message || getAclFormMessage({
|
||||||
|
aclName: action,
|
||||||
|
entities: pieceOrEditions,
|
||||||
|
isPiece: this.isPiece(),
|
||||||
|
senderName: currentUser.username
|
||||||
|
});
|
||||||
|
|
||||||
|
if (action === 'acl_consign') {
|
||||||
|
return (
|
||||||
|
<ConsignForm
|
||||||
|
email={email}
|
||||||
|
message={formMessage}
|
||||||
|
id={this.getFormDataId()}
|
||||||
|
url={ApiUrls.ownership_consigns}
|
||||||
|
handleSuccess={showNotification ? this.showSuccessNotification : handleSuccess} />
|
||||||
|
);
|
||||||
|
} else if (action === 'acl_unconsign') {
|
||||||
|
return (
|
||||||
|
<UnConsignForm
|
||||||
|
message={formMessage}
|
||||||
|
id={this.getFormDataId()}
|
||||||
|
url={ApiUrls.ownership_unconsigns}
|
||||||
|
handleSuccess={showNotification ? this.showSuccessNotification : handleSuccess} />
|
||||||
|
);
|
||||||
|
} else if (action === 'acl_transfer') {
|
||||||
|
return (
|
||||||
|
<TransferForm
|
||||||
|
message={formMessage}
|
||||||
|
id={this.getFormDataId()}
|
||||||
|
url={ApiUrls.ownership_transfers}
|
||||||
|
handleSuccess={showNotification ? this.showSuccessNotification : handleSuccess} />
|
||||||
|
);
|
||||||
|
} else if (action === 'acl_loan') {
|
||||||
|
return (
|
||||||
|
<LoanForm
|
||||||
|
email={email}
|
||||||
|
message={formMessage}
|
||||||
|
id={this.getFormDataId()}
|
||||||
|
url={this.isPiece() ? ApiUrls.ownership_loans_pieces
|
||||||
|
: ApiUrls.ownership_loans_editions}
|
||||||
|
handleSuccess={showNotification ? this.showSuccessNotification : handleSuccess} />
|
||||||
|
);
|
||||||
|
} else if (action === 'acl_loan_request') {
|
||||||
|
return (
|
||||||
|
<LoanRequestAnswerForm
|
||||||
|
message={formMessage}
|
||||||
|
id={this.getFormDataId()}
|
||||||
|
url={ApiUrls.ownership_loans_pieces_request_confirm}
|
||||||
|
handleSuccess={showNotification ? this.showSuccessNotification : handleSuccess} />
|
||||||
|
);
|
||||||
|
} else if (action === 'acl_share') {
|
||||||
|
return (
|
||||||
|
<ShareForm
|
||||||
|
message={formMessage}
|
||||||
|
id={this.getFormDataId()}
|
||||||
|
url={this.isPiece() ? ApiUrls.ownership_shares_pieces
|
||||||
|
: ApiUrls.ownership_shares_editions}
|
||||||
|
handleSuccess={showNotification ? this.showSuccessNotification : handleSuccess} />
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new Error('Your specified action did not match a form.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default AclFormFactory;
|
@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import AclButton from './../ascribe_buttons/acl_button';
|
|
||||||
import ActionPanel from '../ascribe_panel/action_panel';
|
|
||||||
import Form from './form';
|
import Form from './form';
|
||||||
|
|
||||||
|
import LoanRequestButton from '../ascribe_buttons/acls/loan_request_button';
|
||||||
|
import UnconsignButton from '../ascribe_buttons/acls/unconsign_button';
|
||||||
|
|
||||||
|
import ActionPanel from '../ascribe_panel/action_panel';
|
||||||
|
|
||||||
import NotificationActions from '../../actions/notification_actions';
|
import NotificationActions from '../../actions/notification_actions';
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
@ -13,9 +16,9 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
|
|||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
import { getAclFormDataId } from '../../utils/form_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils.js';
|
import { getLangText } from '../../utils/lang_utils.js';
|
||||||
|
|
||||||
|
|
||||||
let RequestActionForm = React.createClass({
|
let RequestActionForm = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
pieceOrEditions: React.PropTypes.oneOfType([
|
pieceOrEditions: React.PropTypes.oneOfType([
|
||||||
@ -27,26 +30,26 @@ let RequestActionForm = React.createClass({
|
|||||||
handleSuccess: React.PropTypes.func
|
handleSuccess: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
|
||||||
isPiece(){
|
isPiece() {
|
||||||
return this.props.pieceOrEditions.constructor !== Array;
|
return this.props.pieceOrEditions.constructor !== Array;
|
||||||
},
|
},
|
||||||
|
|
||||||
getUrls() {
|
getUrls() {
|
||||||
let urls = {};
|
let urls = {};
|
||||||
|
|
||||||
if (this.props.notifications.action === 'consign'){
|
if (this.props.notifications.action === 'consign') {
|
||||||
urls.accept = ApiUrls.ownership_consigns_confirm;
|
urls.accept = ApiUrls.ownership_consigns_confirm;
|
||||||
urls.deny = ApiUrls.ownership_consigns_deny;
|
urls.deny = ApiUrls.ownership_consigns_deny;
|
||||||
} else if (this.props.notifications.action === 'unconsign'){
|
} else if (this.props.notifications.action === 'unconsign') {
|
||||||
urls.accept = ApiUrls.ownership_unconsigns;
|
urls.accept = ApiUrls.ownership_unconsigns;
|
||||||
urls.deny = ApiUrls.ownership_unconsigns_deny;
|
urls.deny = ApiUrls.ownership_unconsigns_deny;
|
||||||
} else if (this.props.notifications.action === 'loan' && !this.isPiece()){
|
} else if (this.props.notifications.action === 'loan' && !this.isPiece()) {
|
||||||
urls.accept = ApiUrls.ownership_loans_confirm;
|
urls.accept = ApiUrls.ownership_loans_confirm;
|
||||||
urls.deny = ApiUrls.ownership_loans_deny;
|
urls.deny = ApiUrls.ownership_loans_deny;
|
||||||
} else if (this.props.notifications.action === 'loan' && this.isPiece()){
|
} else if (this.props.notifications.action === 'loan' && this.isPiece()) {
|
||||||
urls.accept = ApiUrls.ownership_loans_pieces_confirm;
|
urls.accept = ApiUrls.ownership_loans_pieces_confirm;
|
||||||
urls.deny = ApiUrls.ownership_loans_pieces_deny;
|
urls.deny = ApiUrls.ownership_loans_pieces_deny;
|
||||||
} else if (this.props.notifications.action === 'loan_request' && this.isPiece()){
|
} else if (this.props.notifications.action === 'loan_request' && this.isPiece()) {
|
||||||
urls.accept = ApiUrls.ownership_loans_pieces_request_confirm;
|
urls.accept = ApiUrls.ownership_loans_pieces_request_confirm;
|
||||||
urls.deny = ApiUrls.ownership_loans_pieces_request_deny;
|
urls.deny = ApiUrls.ownership_loans_pieces_request_deny;
|
||||||
}
|
}
|
||||||
@ -54,37 +57,28 @@ let RequestActionForm = React.createClass({
|
|||||||
return urls;
|
return urls;
|
||||||
},
|
},
|
||||||
|
|
||||||
getFormData(){
|
getFormData() {
|
||||||
if (this.isPiece()) {
|
return getAclFormDataId(this.isPiece(), this.props.pieceOrEditions);
|
||||||
return {piece_id: this.props.pieceOrEditions.id};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return {bitcoin_id: this.props.pieceOrEditions.map(function(edition){
|
|
||||||
return edition.bitcoin_id;
|
|
||||||
}).join()};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification(option, action, owner) {
|
showNotification(option, action, owner) {
|
||||||
return () => {
|
return () => {
|
||||||
let message = getLangText('You have successfully') + ' ' + option + ' the ' + action + ' request ' + getLangText('from') + ' ' + owner;
|
const message = getLangText('You have successfully %s the %s request from %s', getLangText(option), getLangText(action), owner);
|
||||||
|
const notifications = new GlobalNotificationModel(message, 'success');
|
||||||
let notifications = new GlobalNotificationModel(message, 'success');
|
|
||||||
GlobalNotificationActions.appendGlobalNotification(notifications);
|
GlobalNotificationActions.appendGlobalNotification(notifications);
|
||||||
|
|
||||||
this.handleSuccess();
|
this.handleSuccess();
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess() {
|
handleSuccess() {
|
||||||
if (this.isPiece()){
|
if (this.isPiece()) {
|
||||||
NotificationActions.fetchPieceListNotifications();
|
NotificationActions.fetchPieceListNotifications();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
NotificationActions.fetchEditionListNotifications();
|
NotificationActions.fetchEditionListNotifications();
|
||||||
}
|
}
|
||||||
if(this.props.handleSuccess) {
|
|
||||||
|
if (typeof this.props.handleSuccess === 'function') {
|
||||||
this.props.handleSuccess();
|
this.props.handleSuccess();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -98,21 +92,19 @@ let RequestActionForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getAcceptButtonForm(urls) {
|
getAcceptButtonForm(urls) {
|
||||||
if(this.props.notifications.action === 'unconsign') {
|
if (this.props.notifications.action === 'unconsign') {
|
||||||
return (
|
return (
|
||||||
<AclButton
|
<UnconsignButton
|
||||||
availableAcls={{'acl_unconsign': true}}
|
availableAcls={{'acl_unconsign': true}}
|
||||||
action="acl_unconsign"
|
|
||||||
buttonAcceptClassName='inline pull-right btn-sm ascribe-margin-1px'
|
buttonAcceptClassName='inline pull-right btn-sm ascribe-margin-1px'
|
||||||
pieceOrEditions={this.props.pieceOrEditions}
|
pieceOrEditions={this.props.pieceOrEditions}
|
||||||
currentUser={this.props.currentUser}
|
currentUser={this.props.currentUser}
|
||||||
handleSuccess={this.handleSuccess} />
|
handleSuccess={this.handleSuccess} />
|
||||||
);
|
);
|
||||||
} else if(this.props.notifications.action === 'loan_request') {
|
} else if (this.props.notifications.action === 'loan_request') {
|
||||||
return (
|
return (
|
||||||
<AclButton
|
<LoanRequestButton
|
||||||
availableAcls={{'acl_loan_request': true}}
|
availableAcls={{'acl_loan_request': true}}
|
||||||
action="acl_loan_request"
|
|
||||||
buttonAcceptName="LOAN"
|
buttonAcceptName="LOAN"
|
||||||
buttonAcceptClassName='inline pull-right btn-sm ascribe-margin-1px'
|
buttonAcceptClassName='inline pull-right btn-sm ascribe-margin-1px'
|
||||||
pieceOrEditions={this.props.pieceOrEditions}
|
pieceOrEditions={this.props.pieceOrEditions}
|
||||||
@ -125,7 +117,7 @@ let RequestActionForm = React.createClass({
|
|||||||
url={urls.accept}
|
url={urls.accept}
|
||||||
getFormData={this.getFormData}
|
getFormData={this.getFormData}
|
||||||
handleSuccess={
|
handleSuccess={
|
||||||
this.showNotification(getLangText('accepted'), this.props.notifications.action, this.props.notifications.by)
|
this.showNotification('accepted', this.props.notifications.action, this.props.notifications.by)
|
||||||
}
|
}
|
||||||
isInline={true}
|
isInline={true}
|
||||||
className='inline pull-right'>
|
className='inline pull-right'>
|
||||||
@ -140,8 +132,8 @@ let RequestActionForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getButtonForm() {
|
getButtonForm() {
|
||||||
let urls = this.getUrls();
|
const urls = this.getUrls();
|
||||||
let acceptButtonForm = this.getAcceptButtonForm(urls);
|
const acceptButtonForm = this.getAcceptButtonForm(urls);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -150,7 +142,7 @@ let RequestActionForm = React.createClass({
|
|||||||
isInline={true}
|
isInline={true}
|
||||||
getFormData={this.getFormData}
|
getFormData={this.getFormData}
|
||||||
handleSuccess={
|
handleSuccess={
|
||||||
this.showNotification(getLangText('denied'), this.props.notifications.action, this.props.notifications.by)
|
this.showNotification('denied', this.props.notifications.action, this.props.notifications.by)
|
||||||
}
|
}
|
||||||
className='inline pull-right'>
|
className='inline pull-right'>
|
||||||
<button
|
<button
|
||||||
@ -168,7 +160,7 @@ let RequestActionForm = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<ActionPanel
|
<ActionPanel
|
||||||
content={this.getContent()}
|
content={this.getContent()}
|
||||||
buttons={this.getButtonForm()}/>
|
buttons={this.getButtonForm()} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -47,7 +47,7 @@ let WalletActionPanel = React.createClass({
|
|||||||
<AclButtonList
|
<AclButtonList
|
||||||
className="text-center ascribe-button-list"
|
className="text-center ascribe-button-list"
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
editions={this.props.piece}
|
pieceOrEditions={this.props.piece}
|
||||||
handleSuccess={this.props.loadPiece}>
|
handleSuccess={this.props.loadPiece}>
|
||||||
<AclProxy
|
<AclProxy
|
||||||
aclObject={this.props.currentUser.acl}
|
aclObject={this.props.currentUser.acl}
|
||||||
|
@ -20,6 +20,22 @@ export function getAclFormDataId(isPiece, pieceOrEditions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data ids of the given piece or editions.
|
||||||
|
* @param {boolean} isPiece Is the given entities parameter a piece? (False: array of editions)
|
||||||
|
* @param {(object|object[])} pieceOrEditions Piece or array of editions
|
||||||
|
* @return {(object|object[])} Data IDs of the pieceOrEditions for the form
|
||||||
|
*/
|
||||||
|
export function getAclFormDataId(isPiece, pieceOrEditions) {
|
||||||
|
if (isPiece) {
|
||||||
|
return {piece_id: pieceOrEditions.id};
|
||||||
|
} else {
|
||||||
|
return {bitcoin_id: pieceOrEditions.map(function(edition){
|
||||||
|
return edition.bitcoin_id;
|
||||||
|
}).join()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a message for submitting a form
|
* Generates a message for submitting a form
|
||||||
* @param {object} options Options object for creating the message:
|
* @param {object} options Options object for creating the message:
|
||||||
|
@ -195,14 +195,41 @@ export function escapeHTML(s) {
|
|||||||
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function excludePropFromObject(obj, propList){
|
/**
|
||||||
let clonedObj = mergeOptions({}, obj);
|
* Returns a copy of the given object's own and inherited enumerable
|
||||||
for (let item in propList){
|
* properties, omitting any keys that pass the given filter function.
|
||||||
if (clonedObj[propList[item]]){
|
*/
|
||||||
delete clonedObj[propList[item]];
|
function filterObjOnFn(obj, filterFn) {
|
||||||
|
const filteredObj = {};
|
||||||
|
|
||||||
|
for (let key in obj) {
|
||||||
|
const val = obj[key];
|
||||||
|
if (filterFn == null || !filterFn(val, key)) {
|
||||||
|
filteredObj[key] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return clonedObj;
|
|
||||||
|
return filteredObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to lodash's _.omit(), this returns a copy of the given object's
|
||||||
|
* own and inherited enumerable properties, omitting any keys that are
|
||||||
|
* in the given array or whose value pass the given filter function.
|
||||||
|
* @param {object} obj Source object
|
||||||
|
* @param {array|function} filter Array of key names to omit or function to invoke per iteration
|
||||||
|
* @return {object} The new object
|
||||||
|
*/
|
||||||
|
export function omitFromObject(obj, filter) {
|
||||||
|
if (filter && filter.constructor === Array) {
|
||||||
|
return filterObjOnFn(obj, (_, key) => {
|
||||||
|
return filter.indexOf(key) >= 0;
|
||||||
|
});
|
||||||
|
} else if (filter && typeof filter === 'function') {
|
||||||
|
return filterObjOnFn(obj, filter);
|
||||||
|
} else {
|
||||||
|
throw new Error('The given filter is not an array or function. Exclude aborted');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,15 +22,15 @@ export function getLangText(s, ...args) {
|
|||||||
let lang = getLang();
|
let lang = getLang();
|
||||||
try {
|
try {
|
||||||
if(lang in languages) {
|
if(lang in languages) {
|
||||||
return formatText(languages[lang][s], args);
|
return formatText(languages[lang][s], ...args);
|
||||||
} else {
|
} else {
|
||||||
// just use the english language
|
// just use the english language
|
||||||
return formatText(languages['en-US'][s], args);
|
return formatText(languages['en-US'][s], ...args);
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
//if(!(s in languages[lang])) {
|
//if(!(s in languages[lang])) {
|
||||||
//console.warn('Language-string is not in constants file. Add: "' + s + '" to the "' + lang + '" language file. Defaulting to keyname');
|
//console.warn('Language-string is not in constants file. Add: "' + s + '" to the "' + lang + '" language file. Defaulting to keyname');
|
||||||
return formatText(s, args);
|
return formatText(s, ...args);
|
||||||
//} else {
|
//} else {
|
||||||
// console.error(err);
|
// console.error(err);
|
||||||
//}
|
//}
|
||||||
|
@ -6,7 +6,7 @@ import { argsToQueryParams, getCookie } from '../utils/fetch_api_utils';
|
|||||||
|
|
||||||
import AppConstants from '../constants/application_constants';
|
import AppConstants from '../constants/application_constants';
|
||||||
|
|
||||||
import {excludePropFromObject} from '../utils/general_utils';
|
import { omitFromObject } from '../utils/general_utils';
|
||||||
|
|
||||||
class Requests {
|
class Requests {
|
||||||
_merge(defaults, options) {
|
_merge(defaults, options) {
|
||||||
@ -138,9 +138,9 @@ class Requests {
|
|||||||
return this.request('delete', newUrl);
|
return this.request('delete', newUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
_putOrPost(url, paramsAndBody, method){
|
_putOrPost(url, paramsAndBody, method) {
|
||||||
let paramsCopy = this._merge(paramsAndBody);
|
let paramsCopy = Object.assign({}, paramsAndBody);
|
||||||
let params = excludePropFromObject(paramsAndBody, ['body']);
|
let params = omitFromObject(paramsAndBody, ['body']);
|
||||||
let newUrl = this.prepareUrl(url, params);
|
let newUrl = this.prepareUrl(url, params);
|
||||||
let body = null;
|
let body = null;
|
||||||
if (paramsCopy && paramsCopy.body) {
|
if (paramsCopy && paramsCopy.body) {
|
||||||
|
Loading…
Reference in New Issue
Block a user