1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-14 21:10:27 +01:00

Merge branch 'AD-499-whitelabel-prize-with-sluice-as-k' of bitbucket.org:ascribe/onion into AD-499-whitelabel-prize-with-sluice-as-k

This commit is contained in:
vrde 2015-07-15 14:52:23 +02:00
commit 48aa6caacf
18 changed files with 345 additions and 64 deletions

View File

@ -0,0 +1,48 @@
'use strict';
import alt from '../alt';
import OwnershipFetcher from '../fetchers/ownership_fetcher';
class LoanContractActions {
constructor() {
this.generateActions(
'updateLoanContract'
);
}
fetchLoanContract(email) {
if(email.match(/.+\@.+\..+/)) {
OwnershipFetcher.fetchLoanContract(email)
.then((contracts) => {
if (contracts && contracts.length > 0) {
this.actions.updateLoanContract({
contractKey: contracts[0].s3Key,
contractUrl: contracts[0].s3Url,
contractEmail: email
});
}
else {
this.actions.updateLoanContract({
contractKey: null,
contractUrl: null,
contractEmail: null
});
}
})
.catch((err) => {
console.error(err);
this.actions.updateLoanContract({
contractKey: null,
contractUrl: null,
contractEmail: null
});
});
} else {
/* No email was entered - Ignore and keep going*/
}
}
}
export default alt.createActions(LoanContractActions);

View File

@ -5,7 +5,7 @@ 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 LoanForm from '../ascribe_forms/form_loan_new';
import ShareForm from '../ascribe_forms/form_share_email';
import ModalWrapper from '../ascribe_modal/modal_wrapper';
import AppConstants from '../../constants/application_constants';
@ -30,7 +30,7 @@ let AclButton = React.createClass({
},
isPiece(){
return !(this.props.pieceOrEditions.constructor === Array);
return this.props.pieceOrEditions.constructor !== Array;
},
actionProperties(){
@ -68,7 +68,7 @@ let AclButton = React.createClass({
message={this.getTransferMessage()}
id={this.getFormDataId()}
url={apiUrls.ownership_transfers}/>
),
),
handleSuccess: this.showNotification
};
}
@ -76,7 +76,11 @@ let AclButton = React.createClass({
return {
title: getLangText('Loan artwork'),
tooltip: getLangText('Loan your artwork for a limited period of time'),
form: <LoanForm currentUser={ this.props.currentUser } editions={ this.props.pieceOrEditions }/>,
form: (<LoanForm
message={this.getLoanMessage()}
id={this.getFormDataId()}
url={this.isPiece() ? apiUrls.ownership_loans_pieces : apiUrls.ownership_loans_editions}/>
),
handleSuccess: this.showNotification
};
}
@ -135,6 +139,20 @@ let AclButton = React.createClass({
${getLangText('I transfer ownership of')}:
${this.getTitlesString()} ${getLangText('to you')}.
${getLangText('Truly yours')},
${this.props.currentUser.username}
`
);
},
// plz move to transfer form
getLoanMessage(){
return (
`${getLangText('Hi')},
${getLangText('I loan')}:
${this.getTitlesString()} ${getLangText('to you')}.
${getLangText('Truly yours')},
${this.props.currentUser.username}
`
@ -191,6 +209,7 @@ ${this.props.currentUser.username}
render() {
let shouldDisplay = this.props.availableAcls[this.props.action];
let aclProps = this.actionProperties();
return (
<ModalWrapper
button={
@ -198,10 +217,10 @@ ${this.props.currentUser.username}
{this.sanitizeAction()}
</button>
}
handleSuccess={ aclProps.handleSuccess }
title={ aclProps.title }
tooltip={ aclProps.tooltip }>
{ aclProps.form }
handleSuccess={aclProps.handleSuccess}
title={aclProps.title}
tooltip={aclProps.tooltip}>
{aclProps.form}
</ModalWrapper>
);
}

View File

@ -38,8 +38,8 @@ let DetailProperty = React.createClass({
return (
<div className="row ascribe-detail-property">
<div className="row-same-height">
<div className={this.props.labelClassName + ' col-xs-height col-bottom'}>
<div>{ this.props.label + this.props.separator}</div>
<div className={this.props.labelClassName + ' col-xs-height col-bottom ascribe-detail-property-label'}>
{ this.props.label + this.props.separator}
</div>
<div className={this.props.valueClassName + ' col-xs-height col-bottom'}>
{value}

View File

@ -135,7 +135,7 @@ let Piece = React.createClass({
<EditionDetailProperty label="TITLE" value={<div className="ascribe-detail-title">{this.props.piece.title}</div>} />
<EditionDetailProperty label="BY" value={this.props.piece.artist_name} />
<EditionDetailProperty label="DATE" value={ this.props.piece.date_created.slice(0, 4) } />
{this.props.piece.num_editions > 0 ? <EditionDetailProperty label="NUMBER OF EDITIONS" value={ this.props.piece.num_editions } /> : null}
{this.props.piece.num_editions > 0 ? <EditionDetailProperty label="EDITIONS" value={ this.props.piece.num_editions } /> : null}
<hr/>
</div>
<div className="ascribe-detail-header">

View File

@ -52,7 +52,7 @@ let CreateEditionsForm = React.createClass({
<input
type="number"
placeholder="(e.g. 32)"
min={0}/>
min={1}/>
</Property>
</Form>
);

View File

@ -13,7 +13,7 @@ import InputTextArea from './input_textarea';
import OwnershipFetcher from '../../fetchers/ownership_fetcher';
import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
import { getLangText } from '../../utils/lang_utils.js'
import { getLangText } from '../../utils/lang_utils.js';
let LoanForm = React.createClass({

View File

@ -0,0 +1,168 @@
'use strict';
import React from 'react';
import Button from 'react-bootstrap/lib/Button';
import Form from './form';
import Property from './property';
import InputTextAreaToggable from './input_textarea_toggable';
import InputDate from './input_date';
import InputCheckbox from './input_checkbox';
import LoanContractStore from '../../stores/loan_contract_store';
import LoanContractActions from '../../actions/loan_contract_actions';
import AppConstants from '../../constants/application_constants';
import { mergeOptions } from '../../utils/general_utils';
import { getLangText } from '../../utils/lang_utils';
let LoanForm = React.createClass({
propTypes: {
url: React.PropTypes.string,
id: React.PropTypes.object,
message: React.PropTypes.string,
onRequestHide: React.PropTypes.func,
handleSuccess: React.PropTypes.func
},
getInitialState() {
return LoanContractStore.getState();
},
componentDidMount() {
LoanContractStore.listen(this.onChange);
},
componentWillUnmount() {
LoanContractStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
getFormData(){
return this.props.id;
},
handleOnBlur(event) {
LoanContractActions.fetchLoanContract(event.target.value);
},
getContractCheckbox() {
if(this.state.contractKey && this.state.contractUrl) {
return (
<Property
name="terms"
className="ascribe-settings-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox>
<span>
{getLangText('I agree to the')}&nbsp;
<a href={this.state.contractUrl} target="_blank">
{getLangText('terms of')} {this.state.contractEmail}
</a>
</span>
</InputCheckbox>
</Property>
);
}
},
onRequestHide() {
// Since the modal can be opened without sending it to the server
// and therefore clearing the store,
// we'll need to make sure to flush the store once the
// modal unmounts
LoanContractActions.updateLoanContract({
contractUrl: null,
contractEmail: null,
contractKey: null
});
this.props.onRequestHide();
},
render() {
return (
<Form
ref='form'
url={this.props.url}
getFormData={this.getFormData}
handleSuccess={this.props.handleSuccess}
buttons={
<div className="modal-footer">
<p className="pull-right">
<Button
className="btn btn-default btn-sm ascribe-margin-1px"
type="submit">{getLangText('LOAN')}</Button>
<Button
className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
style={{marginLeft: '0'}}
onClick={this.onRequestHide}>{getLangText('CLOSE')}</Button>
</p>
</div>}
spinner={
<div className="modal-footer">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_small.gif'} />
</div>}>
<Property
name='loanee'
label={getLangText('Loanee Email')}
onBlur={this.handleOnBlur}>
<input
type="email"
placeholder={getLangText('Email of the loanee')}
required/>
</Property>
<Property
name='gallery_name'
label={getLangText('Gallery/exhibition (optional)')}
onBlur={this.handleOnBlur}>
<input
type="text"
placeholder={getLangText('Gallery/exhibition (optional)')}/>
</Property>
<Property
name='startdate'
label={getLangText('Start date')}>
<InputDate
placeholderText={getLangText('Loan start date')} />
</Property>
<Property
name='enddate'
label={getLangText('End date')}>
<InputDate
placeholderText={getLangText('Loan end date')} />
</Property>
<Property
name='loan_message'
label={getLangText('Personal Message')}
editable={true}>
<InputTextAreaToggable
rows={1}
editable={true}
defaultValue={this.props.message}
placeholder={getLangText('Enter a message...')}
required="required"/>
</Property>
<Property
name='password'
label={getLangText('Password')}>
<input
type="password"
placeholder={getLangText('Enter your password')}
required/>
</Property>
{this.getContractCheckbox()}
</Form>
);
}
});
export default LoanForm;

View File

@ -2,7 +2,6 @@
import React from 'react';
import AlertMixin from '../../mixins/alert_mixin';
import DatePicker from 'react-datepicker/dist/react-datepicker';
let InputDate = React.createClass({
@ -11,31 +10,33 @@ let InputDate = React.createClass({
placeholderText: React.PropTypes.string
},
mixins: [AlertMixin],
getInitialState() {
return {
value: null,
value_formatted: null,
alerts: null // needed in AlertMixin
value: null
};
},
handleChange(date) {
let formattedDate = date.format('YYYY-MM-DD');
this.setState({
value: date,
value_formatted: date.format('YYYY-MM-DD')});
value: formattedDate,
value_moment: date
});
this.props.onChange({
target: {
value: formattedDate
}
});
},
render: function () {
let alerts = (this.props.submitted) ? null : this.state.alerts;
console.log(this.state.value);
return (
<div className="form-group">
{alerts}
<DatePicker
key="example2"
dateFormat="YYYY-MM-DD"
selected={this.state.value}
selected={this.state.value_moment}
onChange={this.handleChange}
placeholderText={this.props.placeholderText}/>
</div>

View File

@ -82,7 +82,7 @@ let Property = React.createClass({
this.props.onChange(event);
}
this.setState({value: true});
this.setState({value: event.target.value});
},
handleFocus() {
@ -104,10 +104,14 @@ let Property = React.createClass({
});
},
handleBlur() {
handleBlur(event) {
this.setState({
isFocused: false
});
if(this.props.onBlur) {
this.props.onBlur(event);
}
},
handleSuccess(){

View File

@ -5,7 +5,7 @@ import Router from 'react-router';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
import FormPropertyHeader from './ascribe_forms/form_property_header';
import apiUrls from '../constants/api_urls';
import GlobalNotificationModel from '../models/global_notification_model';
@ -25,9 +25,6 @@ let PasswordResetContainer = React.createClass({
if (this.props.query.email && this.props.query.token) {
return (
<div>
<div className="ascribe-login-text ascribe-login-header">
{getLangText('Reset the password for')} {this.props.query.email}
</div>
<PasswordResetForm
email={this.props.query.email}
token={this.props.query.token}/>
@ -38,9 +35,6 @@ let PasswordResetContainer = React.createClass({
if (this.state.isRequested === false) {
return (
<div>
<div className="ascribe-login-text ascribe-login-header">
{getLangText('Reset your password')}
</div>
<PasswordRequestResetForm
handleRequestSuccess={this.handleRequestSuccess}/>
</div>
@ -86,6 +80,9 @@ let PasswordRequestResetForm = React.createClass({
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
</span>
}>
<FormPropertyHeader>
<h3>{getLangText('Reset your password')}</h3>
</FormPropertyHeader>
<Property
name='email'
label={getLangText('Email')}>
@ -133,6 +130,9 @@ let PasswordResetForm = React.createClass({
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
</span>
}>
<FormPropertyHeader>
<h3>{getLangText('Reset the password for')} {this.props.email}</h3>
</FormPropertyHeader>
<Property
name='password'
label={getLangText('Password')}>

View File

@ -32,7 +32,7 @@ let SettingsContainer = React.createClass({
render() {
return (
<div>
<div className="settings-container">
<AccountSettings />
<APISettings />
<BitcoinWalletSettings />
@ -297,10 +297,10 @@ let APISettings = React.createClass({
name={app.name}
label={app.name}>
<div className="row-same-height">
<div className="no-padding col-xs-6 col-xs-height col-middle">
<div className="no-padding col-xs-6 col-sm-10 col-xs-height col-middle">
{'Bearer ' + app.bearer_token.token}
</div>
<div className="col-xs-6 col-xs-height">
<div className="col-xs-6 col-sm-2 col-xs-height">
<button
className="pull-right btn btn-default btn-sm"
onClick={this.handleTokenRefresh}

View File

@ -52,7 +52,28 @@ let PieceContainer = React.createClass({
<Piece
piece={this.state.piece}
loadPiece={this.loadPiece}>
<CollapsibleParagraph
<PrizePieceDetails piece={this.state.piece}/>
</Piece>
);
} else {
return (
<div className="fullpage-spinner">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />
</div>
);
}
}
});
let PrizePieceDetails = React.createClass({
propTypes: {
piece: React.PropTypes.object
},
render() {
if (this.props.piece.prize && this.props.piece.prize.name){
return (
<CollapsibleParagraph
title="Prize Details"
show={true}
defaultExpanded={true}>
@ -69,16 +90,10 @@ let PieceContainer = React.createClass({
</Property>
<hr />
</Form>
</CollapsibleParagraph>
</Piece>
);
} else {
return (
<div className="fullpage-spinner">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />
</div>
</CollapsibleParagraph>
);
}
return null;
}
});

View File

@ -24,10 +24,11 @@ let apiUrls = {
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/',
'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/',
'ownership_loans_pieces': AppConstants.apiEndpoint + 'ownership/loans/pieces/',
'ownership_loans_editions': AppConstants.apiEndpoint + 'ownership/loans/editions/',
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/',
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/',
'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/contract/',
'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/editions/contract/',
'ownership_shares_editions': AppConstants.apiEndpoint + 'ownership/shares/editions/',
'ownership_shares_pieces': AppConstants.apiEndpoint + 'ownership/shares/pieces/',
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',

View File

@ -1,8 +1,8 @@
'use strict';
import requests from '../utils/requests';
import AppConstants from '../constants/application_constants';
import ApiUrls from '../constants/api_urls';
let OwnershipFetcher = {
/**
@ -10,7 +10,7 @@ let OwnershipFetcher = {
* If no arg is supplied, load the current user
*/
fetchLoanContract(email) {
return requests.get(AppConstants.apiEndpoint + 'ownership/loans/contract/?loanee=' + email);
return requests.get(ApiUrls.ownership_loans_contract + '?loanee=' + email);
}
};

View File

@ -0,0 +1,22 @@
'use strict';
import alt from '../alt';
import LoanContractActions from '../actions/loan_contract_actions';
class LoanContractStore {
constructor() {
this.contractKey = null;
this.contractUrl = null;
this.contractEmail = null;
this.bindActions(LoanContractActions);
}
onUpdateLoanContract({contractKey, contractUrl, contractEmail}) {
this.contractKey = contractKey;
this.contractUrl = contractUrl;
this.contractEmail = contractEmail;
}
}
export default alt.createStore(LoanContractStore, 'LoanContractStore');

View File

@ -1,3 +1,7 @@
.settings-container{
max-width: 600px;
margin: auto;
}
.ascribe-settings-wrapper {
width: 100%;
@ -96,7 +100,7 @@
margin-top: 0 !important;
}
> input, > pre, > textarea, > select {
> input, > pre, > textarea, > select, .datepicker__input {
font-weight: 400;
font-size: 1.1em;
width:100%;
@ -105,6 +109,7 @@
background-color: rgba(0,0,0,0);
color: rgba(0,0,0,.8);
padding-left: 0;
box-shadow: none;
&:focus {
border:0;

View File

@ -44,6 +44,11 @@ hr {
margin-bottom: 15px;
}
form{
max-width: 600px;
margin: auto;
}
#main {
height: 100%;
}
@ -217,6 +222,10 @@ hr {
padding-bottom: 0.4em;
}
.ascribe-detail-property-label{
font-size: 0.8em;
}
::-webkit-input-placeholder { /* WebKit browsers */
font-size: 0.9em;
font-style: italic;
@ -234,18 +243,6 @@ hr {
font-style: italic;
}
.input-text-ascribe,
.datepicker__input {
border-bottom: 1px solid black;
border-top: 0;
border-left: 0;
border-right: 0;
background: transparent;
border-radius: 0 !important;
box-shadow: none;
width: 100%;
}
.textarea-ascribe-message {
height: 13em !important;
}

View File

@ -1,6 +1,7 @@
.wp {
height: 100%;
max-width: 90%;
margin: auto;
/* We need this, otherwise piece list will have a scrollbar */
overflow-x: hidden;
}