From bb0c9c0c1d871f3f274017db753d3d8c980f8719 Mon Sep 17 00:00:00 2001 From: stephtzhang Date: Sun, 22 Nov 2015 15:13:19 -0500 Subject: [PATCH] Make record form components --- frickfeed/static/js/src/.DS_Store | Bin 0 -> 6148 bytes frickfeed/static/js/src/recordForm.js | 255 ++++++++++++++++++++++++++ frickfeed/templates/base.html | 5 + frickfeed/templates/index.html | 2 +- 4 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 frickfeed/static/js/src/.DS_Store create mode 100644 frickfeed/static/js/src/recordForm.js diff --git a/frickfeed/static/js/src/.DS_Store b/frickfeed/static/js/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 +

Record Details

+ + + + + + + + + + + + ); + } +}); + +///////// SpecimenInputFields ///////// +// TODO: add ability to append multiple specimen input fields +var SpecimenInputFields = React.createClass({ + getInitialState: function() { + var resetState = { + client_identifier: (Math.random() * 1000000).toString(), + amnh_catalog_a: '', + amnh_catalog_b: '', + field_no: '', + description: '', + location: '', + }; + return resetState; + }, + handleAmnhCatalogAChange: function(e) { + debugger; + this.setState({amnh_catalog_a: e.target.value}); + this.props.onChange(this.state); + }, + handleAmnhCatalogBChange: function(e) { + this.setState({amnh_catalog_b: e.target.value}); + this.props.onChange(this.state); + }, + handleFieldNoChange: function(e) { + this.setState({field_no: e.target.value}); + this.props.onChange(this.state); + }, + handleDescriptionChange: function(e) { + this.setState({description: e.target.value}); + this.props.onChange(this.state); + }, + handleLocationChange: function(e) { + this.setState({location: e.target.value}); + this.props.onChange(this.state); + }, + render: function() { + return ( +
+

Specimen Details

+ + + + + +
+ ); + } +}); + +///////// RecordBox ///////// +var RecordBox = React.createClass({ + handleRecordSubmit: function(record) { + // TODO: optimistically append record here + $.ajax({ + url: this.props.url, + dataType: 'json', + type: 'POST', + data: record, + success: function(data) { + // TODO: handle successful record post req appropriately + }.bind(this), + error: function(xhr, status, err) { + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + render: function() { + return ( +
+ +
+ ); + } +}); + +///////// render RecordBox ///////// +ReactDOM.render( + , + document.getElementById('content') +); \ No newline at end of file diff --git a/frickfeed/templates/base.html b/frickfeed/templates/base.html index 2771cc1..b1f11ee 100644 --- a/frickfeed/templates/base.html +++ b/frickfeed/templates/base.html @@ -41,5 +41,10 @@ + + + + + diff --git a/frickfeed/templates/index.html b/frickfeed/templates/index.html index 732cfae..9bc0e61 100644 --- a/frickfeed/templates/index.html +++ b/frickfeed/templates/index.html @@ -1,5 +1,5 @@ {% extends 'base.html' %} {% block content %} -

Home

+
{% endblock %}