mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Force consignee to be submissions@lumenus.co
Special white label form settings only defined for consign form for now, but could be added to others as needed.
This commit is contained in:
parent
e226477424
commit
3dedc93d2e
@ -34,15 +34,19 @@ let AclButton = React.createClass({
|
|||||||
className: React.PropTypes.string
|
className: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
isPiece(){
|
isPiece() {
|
||||||
return this.props.pieceOrEditions.constructor !== Array;
|
return this.props.pieceOrEditions.constructor !== Array;
|
||||||
},
|
},
|
||||||
|
|
||||||
actionProperties(){
|
actionProperties() {
|
||||||
|
let message = getAclFormMessage({
|
||||||
|
aclName: this.props.action,
|
||||||
|
entities: this.props.pieceOrEditions,
|
||||||
|
isPiece: this.isPiece(),
|
||||||
|
senderName: this.props.currentUser.username
|
||||||
|
});
|
||||||
|
|
||||||
let message = getAclFormMessage(this.props.action, this.getTitlesString(), this.props.currentUser.username);
|
if (this.props.action === 'acl_consign') {
|
||||||
|
|
||||||
if (this.props.action === 'acl_consign'){
|
|
||||||
return {
|
return {
|
||||||
title: getLangText('Consign artwork'),
|
title: getLangText('Consign artwork'),
|
||||||
tooltip: getLangText('Have someone else sell the artwork'),
|
tooltip: getLangText('Have someone else sell the artwork'),
|
||||||
@ -51,11 +55,10 @@ let AclButton = React.createClass({
|
|||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={ApiUrls.ownership_consigns}/>
|
url={ApiUrls.ownership_consigns}/>
|
||||||
),
|
),
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
} else if (this.props.action === 'acl_unconsign') {
|
||||||
if (this.props.action === 'acl_unconsign'){
|
|
||||||
return {
|
return {
|
||||||
title: getLangText('Unconsign artwork'),
|
title: getLangText('Unconsign artwork'),
|
||||||
tooltip: getLangText('Have the owner manage his sales again'),
|
tooltip: getLangText('Have the owner manage his sales again'),
|
||||||
@ -64,10 +67,10 @@ let AclButton = React.createClass({
|
|||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={ApiUrls.ownership_unconsigns}/>
|
url={ApiUrls.ownership_unconsigns}/>
|
||||||
),
|
),
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}else if (this.props.action === 'acl_transfer') {
|
} else if (this.props.action === 'acl_transfer') {
|
||||||
return {
|
return {
|
||||||
title: getLangText('Transfer artwork'),
|
title: getLangText('Transfer artwork'),
|
||||||
tooltip: getLangText('Transfer the ownership of the artwork'),
|
tooltip: getLangText('Transfer the ownership of the artwork'),
|
||||||
@ -79,32 +82,32 @@ let AclButton = React.createClass({
|
|||||||
),
|
),
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
} else if (this.props.action === 'acl_loan') {
|
||||||
else if (this.props.action === 'acl_loan'){
|
|
||||||
return {
|
return {
|
||||||
title: getLangText('Loan artwork'),
|
title: getLangText('Loan artwork'),
|
||||||
tooltip: getLangText('Loan your artwork for a limited period of time'),
|
tooltip: getLangText('Loan your artwork for a limited period of time'),
|
||||||
form: (<LoanForm
|
form: (
|
||||||
|
<LoanForm
|
||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={this.isPiece() ? ApiUrls.ownership_loans_pieces : ApiUrls.ownership_loans_editions}/>
|
url={this.isPiece() ? ApiUrls.ownership_loans_pieces
|
||||||
|
: ApiUrls.ownership_loans_editions}/>
|
||||||
),
|
),
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
} else if (this.props.action === 'acl_loan_request') {
|
||||||
else if (this.props.action === 'acl_loan_request'){
|
|
||||||
return {
|
return {
|
||||||
title: getLangText('Loan artwork'),
|
title: getLangText('Loan artwork'),
|
||||||
tooltip: getLangText('Someone requested you to loan your artwork for a limited period of time'),
|
tooltip: getLangText('Someone requested you to loan your artwork for a limited period of time'),
|
||||||
form: (<LoanRequestAnswerForm
|
form: (
|
||||||
|
<LoanRequestAnswerForm
|
||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={ApiUrls.ownership_loans_pieces_request_confirm}/>
|
url={ApiUrls.ownership_loans_pieces_request_confirm}/>
|
||||||
),
|
),
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
}
|
} else if (this.props.action === 'acl_share') {
|
||||||
else if (this.props.action === 'acl_share'){
|
|
||||||
return {
|
return {
|
||||||
title: getLangText('Share artwork'),
|
title: getLangText('Share artwork'),
|
||||||
tooltip: getLangText('Share the artwork'),
|
tooltip: getLangText('Share the artwork'),
|
||||||
@ -112,8 +115,9 @@ let AclButton = React.createClass({
|
|||||||
<ShareForm
|
<ShareForm
|
||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={this.isPiece() ? ApiUrls.ownership_shares_pieces : ApiUrls.ownership_shares_editions }/>
|
url={this.isPiece() ? ApiUrls.ownership_shares_pieces
|
||||||
),
|
: ApiUrls.ownership_shares_editions}/>
|
||||||
|
),
|
||||||
handleSuccess: this.showNotification
|
handleSuccess: this.showNotification
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@ -121,32 +125,18 @@ let AclButton = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification(response){
|
showNotification(response) {
|
||||||
this.props.handleSuccess();
|
this.props.handleSuccess();
|
||||||
if(response.notification) {
|
if (response.notification) {
|
||||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
let notification = new GlobalNotificationModel(response.notification, 'success');
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// plz move to share form
|
|
||||||
getTitlesString(){
|
|
||||||
if (this.isPiece()){
|
|
||||||
return '\"' + this.props.pieceOrEditions.title + '\"';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this.props.pieceOrEditions.map(function(edition) {
|
|
||||||
return '- \"' + edition.title + ', ' + getLangText('edition') + ' ' + edition.edition_number + '\"\n';
|
|
||||||
}).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
getFormDataId(){
|
getFormDataId(){
|
||||||
if (this.isPiece()) {
|
if (this.isPiece()) {
|
||||||
return {piece_id: this.props.pieceOrEditions.id};
|
return {piece_id: this.props.pieceOrEditions.id};
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return {bitcoin_id: this.props.pieceOrEditions.map(function(edition){
|
return {bitcoin_id: this.props.pieceOrEditions.map(function(edition){
|
||||||
return edition.bitcoin_id;
|
return edition.bitcoin_id;
|
||||||
}).join()};
|
}).join()};
|
||||||
@ -162,7 +152,7 @@ let AclButton = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.availableAcls){
|
if (this.props.availableAcls) {
|
||||||
let shouldDisplay = this.props.availableAcls[this.props.action];
|
let shouldDisplay = this.props.availableAcls[this.props.action];
|
||||||
let aclProps = this.actionProperties();
|
let aclProps = this.actionProperties();
|
||||||
let buttonClassName = this.props.buttonAcceptClassName ? this.props.buttonAcceptClassName : '';
|
let buttonClassName = this.props.buttonAcceptClassName ? this.props.buttonAcceptClassName : '';
|
||||||
|
@ -11,6 +11,7 @@ import InputTextAreaToggable from './input_textarea_toggable';
|
|||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
import { getLangText } from '../../utils/lang_utils.js';
|
import { getLangText } from '../../utils/lang_utils.js';
|
||||||
|
|
||||||
|
import { getSubdomainFormSettings } from '../../utils/form_utils';
|
||||||
|
|
||||||
let ConsignForm = React.createClass({
|
let ConsignForm = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -25,6 +26,8 @@ let ConsignForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let envSettings = getSubdomainFormSettings('consign');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
ref='form'
|
ref='form'
|
||||||
@ -49,10 +52,13 @@ let ConsignForm = React.createClass({
|
|||||||
</div>}>
|
</div>}>
|
||||||
<Property
|
<Property
|
||||||
name='consignee'
|
name='consignee'
|
||||||
label={getLangText('Email')}>
|
label={getLangText('Email')}
|
||||||
|
editable={!envSettings.consigneeDisabled}
|
||||||
|
overrideForm={true}>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
placeholder={getLangText('Email of the consignee')}
|
placeholder={getLangText('Email of the consignee')}
|
||||||
|
defaultValue={envSettings.consignee}
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property
|
<Property
|
||||||
|
@ -220,7 +220,12 @@ let CylandRegisterPiece = React.createClass({
|
|||||||
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
||||||
<LoanForm
|
<LoanForm
|
||||||
loanHeading={getLangText('Loan to Cyland archive')}
|
loanHeading={getLangText('Loan to Cyland archive')}
|
||||||
message={getAclFormMessage('acl_loan', '\"' + this.state.piece.title + '\"', this.state.currentUser.username)}
|
message={getAclFormMessage({
|
||||||
|
aclName: 'acl_loan',
|
||||||
|
entities: this.state.piece,
|
||||||
|
isPiece: true,
|
||||||
|
senderName: this.state.currentUser.username
|
||||||
|
})}
|
||||||
id={{piece_id: this.state.piece.id}}
|
id={{piece_id: this.state.piece.id}}
|
||||||
url={ApiUrls.ownership_loans_pieces}
|
url={ApiUrls.ownership_loans_pieces}
|
||||||
email={this.state.whitelabel.user}
|
email={this.state.whitelabel.user}
|
||||||
|
@ -52,7 +52,13 @@ let constants = {
|
|||||||
'name': 'Lumenus',
|
'name': 'Lumenus',
|
||||||
'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/lumenus/lumenus-logo.png',
|
'logo': 'https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/lumenus/lumenus-logo.png',
|
||||||
'permissions': ['register', 'edit', 'share', 'del_from_collection'],
|
'permissions': ['register', 'edit', 'share', 'del_from_collection'],
|
||||||
'type': 'wallet'
|
'type': 'wallet',
|
||||||
|
'formSettings': {
|
||||||
|
'consign': {
|
||||||
|
'consignee': 'submissions@lumenus.co',
|
||||||
|
'consigneeDisabled': true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'defaultDomain': {
|
'defaultDomain': {
|
||||||
|
@ -2,14 +2,37 @@
|
|||||||
|
|
||||||
import { getLangText } from './lang_utils';
|
import { getLangText } from './lang_utils';
|
||||||
|
|
||||||
|
import AppConstants from '../constants/application_constants';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a dictionary of settings for a form based on the environment
|
||||||
|
* (ie. if on a whitelabel)
|
||||||
|
* @param {string} formName Name of the form
|
||||||
|
* @return {object} Settings key-val dictionary
|
||||||
|
*/
|
||||||
|
export function getSubdomainFormSettings(formName) {
|
||||||
|
let subdomainFormSettings = AppConstants.whitelabel.formSettings || {};
|
||||||
|
|
||||||
|
return subdomainFormSettings[formName] || {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a message for submitting a form
|
* Generates a message for submitting a form
|
||||||
* @param {string} aclName Enum name of a acl
|
* @param {object} options Options object for creating the message:
|
||||||
* @param {string} entities Already computed name of entities
|
* @param {string} options.aclName Enum name of an acl
|
||||||
* @param {string} senderName Name of the sender
|
* @param {(object|object[])} options.entities Piece or array of Editions
|
||||||
* @return {string} Completed message
|
* @param {string} [options.senderName] Name of the sender
|
||||||
|
* @return {string} Completed message
|
||||||
*/
|
*/
|
||||||
export function getAclFormMessage(aclName, entities, senderName) {
|
export function getAclFormMessage(options) {
|
||||||
|
if (!options || options.aclName === undefined || options.isPiece === undefined ||
|
||||||
|
!(typeof options.entities === 'object' || options.entities.constructor === Array)) {
|
||||||
|
throw new Error('You must specify an acl class, entities in the correct format, and entity type');
|
||||||
|
}
|
||||||
|
|
||||||
|
let aclName = options.aclName;
|
||||||
|
let entityTitles = options.isPiece ? getTitlesStringOfPiece(options.entities)
|
||||||
|
: getTitlesStringOfEditions(options.entities);
|
||||||
let message = '';
|
let message = '';
|
||||||
|
|
||||||
message += getLangText('Hi');
|
message += getLangText('Hi');
|
||||||
@ -32,7 +55,7 @@ export function getAclFormMessage(aclName, entities, senderName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message += ':\n';
|
message += ':\n';
|
||||||
message += entities;
|
message += entityTitles;
|
||||||
|
|
||||||
if(aclName === 'acl_transfer' || aclName === 'acl_loan' || aclName === 'acl_consign') {
|
if(aclName === 'acl_transfer' || aclName === 'acl_loan' || aclName === 'acl_consign') {
|
||||||
message += getLangText('to you');
|
message += getLangText('to you');
|
||||||
@ -44,10 +67,22 @@ export function getAclFormMessage(aclName, entities, senderName) {
|
|||||||
throw new Error('Your specified aclName did not match a an acl class.');
|
throw new Error('Your specified aclName did not match a an acl class.');
|
||||||
}
|
}
|
||||||
|
|
||||||
message += '\n\n';
|
if (options.senderName) {
|
||||||
message += getLangText('Truly yours,');
|
message += '\n\n';
|
||||||
message += '\n';
|
message += getLangText('Truly yours,');
|
||||||
message += senderName;
|
message += '\n';
|
||||||
|
message += options.senderName;
|
||||||
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTitlesStringOfPiece(piece){
|
||||||
|
return '\"' + piece.title + '\"';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTitlesStringOfEditions(editions) {
|
||||||
|
return editions.map(function(edition) {
|
||||||
|
return '- \"' + edition.title + ', ' + getLangText('edition') + ' ' + edition.edition_number + '\"\n';
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user