diff --git a/js/components/ascribe_forms/form_piece_extradata.js b/js/components/ascribe_forms/form_piece_extradata.js index 282afcdf..41828120 100644 --- a/js/components/ascribe_forms/form_piece_extradata.js +++ b/js/components/ascribe_forms/form_piece_extradata.js @@ -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 ( -
+ +
{this.props.title}
@@ -345,7 +353,19 @@ let EditionFurtherDetails = React.createClass({ return ( - + + diff --git a/js/components/edition_container.js b/js/components/edition_container.js index b2d3bca0..8f8af927 100644 --- a/js/components/edition_container.js +++ b/js/components/edition_container.js @@ -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'; diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index fb807cb9..fd973ffb 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -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; diff --git a/js/utils/fetch.js b/js/utils/fetch.js index ec674935..96658587 100644 --- a/js/utils/fetch.js +++ b/js/utils/fetch.js @@ -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) {