|
@@ -33,8 +33,8 @@ var P5UI_AddItemToReport = createReactClass({
|
|
|
},
|
|
|
_handleSearch: function (query) {
|
|
|
this.setState({ isSearching: true });
|
|
|
+ var baza = this.state.baza;
|
|
|
var options= [];
|
|
|
- //Baza= this.state.baza;
|
|
|
window.fetch(URL_FETCH_FROM_BAZA, {
|
|
|
method: 'POST',
|
|
|
header: {
|
|
@@ -42,31 +42,30 @@ var P5UI_AddItemToReport = createReactClass({
|
|
|
},
|
|
|
credentials: 'same-origin',
|
|
|
body: JSON.stringify({
|
|
|
- 'baza': this.state.baza,
|
|
|
-
|
|
|
+ baza: baza,
|
|
|
+ query: query,
|
|
|
})
|
|
|
- .then(function(responseText) {
|
|
|
-
|
|
|
- try {
|
|
|
- return JSON.parse(responseText);
|
|
|
- } catch (e) {
|
|
|
- throw responseText;
|
|
|
- }
|
|
|
- })
|
|
|
- .then(function(result) {
|
|
|
-
|
|
|
- if (result.type == 'success') {
|
|
|
-
|
|
|
- p5UI__notifyAjaxCallback(result);
|
|
|
- resolve(result.body);
|
|
|
- options=result.body.items;
|
|
|
- this.setState({ isSearching: false, options: options });
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(function(error) {
|
|
|
- if(DBG) console.log('request failed', error);
|
|
|
- })
|
|
|
})
|
|
|
+ .then(function(responseText) {
|
|
|
+ try {
|
|
|
+ return JSON.parse(responseText);
|
|
|
+ } catch (e) {
|
|
|
+ throw responseText;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(function(result) {
|
|
|
+ if (result.type == 'success') {
|
|
|
+ p5UI__notifyAjaxCallback(result);
|
|
|
+ resolve(result.body);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(function(items) {
|
|
|
+ options = items;
|
|
|
+ this.setState({ isSearching: false, options: options });
|
|
|
+ })
|
|
|
+ .catch(function(error) {
|
|
|
+ if(DBG) console.log('request failed', error);
|
|
|
+ })
|
|
|
// setTimeout(function () {
|
|
|
// var options = [];
|
|
|
// options.push({
|
|
@@ -87,13 +86,13 @@ var P5UI_AddItemToReport = createReactClass({
|
|
|
// })
|
|
|
// this.setState({ isSearching: false, options: options });
|
|
|
// }.bind(this), 1000);
|
|
|
- makeAndHandleRequest(query)
|
|
|
- .then(({ options }) => {
|
|
|
- this.setState({
|
|
|
- isLoading: false,
|
|
|
- options,
|
|
|
- });
|
|
|
- });
|
|
|
+ // makeAndHandleRequest(query)
|
|
|
+ // .then(({ options }) => {
|
|
|
+ // this.setState({
|
|
|
+ // isLoading: false,
|
|
|
+ // options,
|
|
|
+ // });
|
|
|
+ // });
|
|
|
},
|
|
|
componentWillUnmount: function () {
|
|
|
DBG && console.log("DBG: conponentDidUnmount...");
|