1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

further details functional / unstyled

This commit is contained in:
ddejongh 2015-06-09 17:24:06 +02:00
parent 509aa111ab
commit 9241d3e38f
5 changed files with 42 additions and 19 deletions

View File

@ -2,34 +2,39 @@
import React from 'react';
import fetch from '../../utils/fetch';
import apiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin';
import InputTextAreaToggable from './input_textarea_toggable';
let PersonalNoteForm = React.createClass({
let PieceExtraDataForm = React.createClass({
mixins: [FormMixin],
url() {
return apiUrls.note_notes;
return fetch.prepareUrl(apiUrls.piece_extradata, {piece_id: this.props.editions[0].bitcoin_id});
},
getFormData() {
let extradata = {};
extradata[this.props.name] = this.refs[this.props.name].state.value;
return {
bitcoin_id: this.getBitcoinIds().join(),
note: this.refs.personalNote.state.value
extradata: extradata
};
},
renderForm() {
return (
<form id="personal_note_content" role="form" key="personal_note_content">
<form role="form" key={this.props.name}>
<h5>{this.props.title}</h5>
<InputTextAreaToggable
ref="personalNote"
ref={this.props.name}
className="form-control"
defaultValue={this.props.editions[0].note_from_user}
defaultValue={this.props.editions[0].extra_data[this.props.name]}
rows={3}
editable={true}
required=""
@ -40,4 +45,4 @@ let PersonalNoteForm = React.createClass({
}
});
export default PersonalNoteForm;
export default PieceExtraDataForm;

View File

@ -10,10 +10,14 @@ import Button from 'react-bootstrap/lib/Button';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import PersonalNoteForm from './ascribe_forms/form_note_personal';
import PieceExtraDataForm from './ascribe_forms/form_piece_extradata';
import EditionActions from '../actions/edition_actions';
import AclButtonList from './ascribe_buttons/acl_button_list';
import GlobalNotificationModel from '../models/global_notification_model';
import GlobalNotificationActions from '../actions/global_notification_actions';
import classNames from 'classnames';
/**
@ -319,13 +323,17 @@ let EditionPersonalNote = React.createClass({
edition: React.PropTypes.object,
handleSuccess: React.PropTypes.func
},
showNotification(){
this.props.handleSuccess();
let notification = new GlobalNotificationModel('Note saved', 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
},
render() {
return (
<Row>
<Col md={12} className="ascribe-edition-personal-note">
<PersonalNoteForm
handleSuccess={this.props.handleSuccess}
handleSuccess={this.showNotification}
editions={[this.props.edition]} />
</Col>
</Row>
@ -345,7 +353,19 @@ let EditionFurtherDetails = React.createClass({
return (
<Row>
<Col md={12} className="ascribe-edition-personal-note">
<PersonalNoteForm
<PieceExtraDataForm
name='artist_contact_info'
title='Artist Contact Info'
handleSuccess={this.props.handleSuccess}
editions={[this.props.edition]} />
<PieceExtraDataForm
name='display_instructions'
title='Display Instructions'
handleSuccess={this.props.handleSuccess}
editions={[this.props.edition]} />
<PieceExtraDataForm
name='technology_details'
title='Technology Details'
handleSuccess={this.props.handleSuccess}
editions={[this.props.edition]} />
</Col>

View File

@ -4,9 +4,6 @@ import React from 'react';
import { mergeOptions } from '../utils/general_utils';
import apiUrls from '../constants/api_urls';
import fetch from '../utils/fetch';
import EditionActions from '../actions/edition_actions';
import EditionStore from '../stores/edition_store';
import UserActions from '../actions/user_actions';

View File

@ -14,7 +14,8 @@ let apiUrls = {
'ownership_consigns': AppConstants.baseUrl + 'ownership/consigns/',
'ownership_unconsigns': AppConstants.baseUrl + 'ownership/unconsigns/',
'ownership_unconsigns_request': AppConstants.baseUrl + 'ownership/unconsigns/request/',
'note_notes': AppConstants.baseUrl + 'note/notes/'
'note_notes': AppConstants.baseUrl + 'note/notes/',
'piece_extradata': AppConstants.baseUrl + 'pieces/${piece_id}/extradata/'
};
export default apiUrls;

View File

@ -88,19 +88,19 @@ class Fetch {
get(url, params) {
let paramsCopy = this._merge(params);
let newUrl = this.prepareUrl(url, params, true);
let newUrl = this.prepareUrl(url, paramsCopy, true);
return this.request('get', newUrl);
}
post(url, params) {
let paramsCopy = this._merge(params);
let newUrl = this.prepareUrl(url, params);
let newUrl = this.prepareUrl(url, paramsCopy);
let body = null;
if (params.body) {
body = JSON.stringify(params.body);
if (paramsCopy && paramsCopy.body) {
body = JSON.stringify(paramsCopy.body);
}
return this.request('post', url, { body });
return this.request('post', newUrl, { body });
}
defaults(options) {