|
@@ -33,6 +33,7 @@ var P5UI_AddItemToReport = createReactClass({
|
|
},
|
|
},
|
|
_handleSearch: function (query) {
|
|
_handleSearch: function (query) {
|
|
this.setState({ isSearching: true });
|
|
this.setState({ isSearching: true });
|
|
|
|
+ var _setState = this.setState.bind(this);
|
|
var baza = this.state.baza;
|
|
var baza = this.state.baza;
|
|
var options= [];
|
|
var options= [];
|
|
window.fetch(URL_FETCH_FROM_BAZA, {
|
|
window.fetch(URL_FETCH_FROM_BAZA, {
|
|
@@ -46,6 +47,9 @@ var P5UI_AddItemToReport = createReactClass({
|
|
query: query,
|
|
query: query,
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
+ .then(function(response) {
|
|
|
|
+ return response.text();
|
|
|
|
+ })
|
|
.then(function(responseText) {
|
|
.then(function(responseText) {
|
|
try {
|
|
try {
|
|
return JSON.parse(responseText);
|
|
return JSON.parse(responseText);
|
|
@@ -56,47 +60,28 @@ var P5UI_AddItemToReport = createReactClass({
|
|
.then(function(result) {
|
|
.then(function(result) {
|
|
if (result.type == 'success') {
|
|
if (result.type == 'success') {
|
|
p5UI__notifyAjaxCallback(result);
|
|
p5UI__notifyAjaxCallback(result);
|
|
- resolve(result.body);
|
|
|
|
|
|
+ if (result.body && result.body.items && result.body.items.length > 0) {
|
|
|
|
+ return result.body.items;
|
|
|
|
+ } else {
|
|
|
|
+ p5UI__notifyAjaxCallback({ type: 'warning', msg: "Brak danych pasujących do kryteriów wyszukiwania" });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.then(function(items) {
|
|
.then(function(items) {
|
|
- options = items;
|
|
|
|
- this.setState({ isSearching: false, options: options });
|
|
|
|
|
|
+ DBG && console.log('items fetched:', items);
|
|
|
|
+ _setState({ isSearching: false, options: items });
|
|
})
|
|
})
|
|
.catch(function(error) {
|
|
.catch(function(error) {
|
|
- if(DBG) console.log('request failed', error);
|
|
|
|
|
|
+ DBG && console.log('request failed', error);
|
|
})
|
|
})
|
|
- // setTimeout(function () {
|
|
|
|
- // var options = [];
|
|
|
|
- // options.push({
|
|
|
|
- // ID: 601900,
|
|
|
|
- // nazwa: "ADEGROUP SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ SPÓŁKA KOMANDYTOWA",
|
|
|
|
- // krs: "0000721712", nip: "5862328735", regon: "369609850",
|
|
|
|
- // S_kraj: "POLSKA", S_miejscowosc: "GDYNIA", A_kod: "81-310", A_ulica: "ŚLĄSKA", A_nrDomu: "35/37",
|
|
|
|
- // searchLabel: "ADEGROUP SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ SPÓŁKA KOMANDYTOWA, ŚLĄSKA 35/37, 81-310 GDYNIA, krs: 0000721712, nip: 5862328735, regon: 369609850",
|
|
|
|
- // label: "ADEGROUP SPÓŁKA ..., ŚLĄSKA 35/37, 81-310 GDYNIA"
|
|
|
|
- // })
|
|
|
|
- // options.push({
|
|
|
|
- // ID: 601900,
|
|
|
|
- // nazwa: "BIZNESLIMIT.PL SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ",
|
|
|
|
- // krs: "0000721708", nip: "9452218050", regon: "369608402",
|
|
|
|
- // S_kraj: "POLSKA", S_miejscowosc: "KRAKÓW", A_kod: "31-315", A_ulica: "ELIASZA RADZIKOWSKIEGO", A_nrLokalu: "16", A_nrDomu: "74",
|
|
|
|
- // searchLabel: "BIZNESLIMIT.PL SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ ELIASZA RADZIKOWSKIEGO 74/16, 31-315 KRAKÓW 0000721708 9452218050 369608402",
|
|
|
|
- // label: "BIZNESLIMIT.PL ..., ELIASZA RADZIKOWSKIEGO 74/16, 31-315 KRAKÓW"
|
|
|
|
- // })
|
|
|
|
- // this.setState({ isSearching: false, options: options });
|
|
|
|
- // }.bind(this), 1000);
|
|
|
|
- // makeAndHandleRequest(query)
|
|
|
|
- // .then(({ options }) => {
|
|
|
|
- // this.setState({
|
|
|
|
- // isLoading: false,
|
|
|
|
- // options,
|
|
|
|
- // });
|
|
|
|
- // });
|
|
|
|
},
|
|
},
|
|
componentWillUnmount: function () {
|
|
componentWillUnmount: function () {
|
|
DBG && console.log("DBG: conponentDidUnmount...");
|
|
DBG && console.log("DBG: conponentDidUnmount...");
|
|
},
|
|
},
|
|
|
|
+ shouldComponentUpdate: function (nextProps, nextState) {
|
|
|
|
+ DBG && console.log("DBG: shouldComponentUpdate...", { nextProps, nextState });
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
render: function () {
|
|
render: function () {
|
|
// '<div>' +
|
|
// '<div>' +
|
|
// '<p style="text-align:center">' + 'Wybierz bazę' + '</p>' +
|
|
// '<p style="text-align:center">' + 'Wybierz bazę' + '</p>' +
|
|
@@ -153,7 +138,7 @@ var P5UI_AddItemToReport = createReactClass({
|
|
}
|
|
}
|
|
var handleSearch = this._handleSearch.bind(this);
|
|
var handleSearch = this._handleSearch.bind(this);
|
|
var handleSelected = this._handleSelected.bind(this);
|
|
var handleSelected = this._handleSelected.bind(this);
|
|
-
|
|
|
|
|
|
+ DBG && console.log('DBG: render this.state.options', this.state.options);
|
|
return h('div', {}, [
|
|
return h('div', {}, [
|
|
h('p', { style: { textAlign: "center" } }, "Wybierz bazę"),
|
|
h('p', { style: { textAlign: "center" } }, "Wybierz bazę"),
|
|
h('div', { style: { marginBottom: '22px' } },
|
|
h('div', { style: { marginBottom: '22px' } },
|
|
@@ -176,50 +161,56 @@ var P5UI_AddItemToReport = createReactClass({
|
|
allowNew: false,
|
|
allowNew: false,
|
|
multiple: false,
|
|
multiple: false,
|
|
options: this.state.options,
|
|
options: this.state.options,
|
|
- labelKey: "searchLabel",
|
|
|
|
- minLength: 2,
|
|
|
|
|
|
+ // labelKey: "searchLabel",
|
|
|
|
+ labelKey: function (option) {
|
|
|
|
+ return [
|
|
|
|
+ option.nazwa.replace('"', ''),
|
|
|
|
+ option.nip,
|
|
|
|
+ option.krs,
|
|
|
|
+ option.regon,
|
|
|
|
+ option.S_miejscowosc,
|
|
|
|
+ ].join(' ')
|
|
|
|
+ },
|
|
|
|
+ minLength: 3,
|
|
onSearch: handleSearch,
|
|
onSearch: handleSearch,
|
|
placeholder: "Wyszukaj...",
|
|
placeholder: "Wyszukaj...",
|
|
onChange: handleSelected,
|
|
onChange: handleSelected,
|
|
autoFocus: true,
|
|
autoFocus: true,
|
|
- // filterBy: function (option, text) {
|
|
|
|
- // console.log('TODO: filterBy...', {option, text});
|
|
|
|
- // return true;
|
|
|
|
- // },
|
|
|
|
|
|
+ filterBy: function (option, text) {
|
|
|
|
+ console.log('TODO: filterBy...', {option, text});
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
renderMenuItemChildren: function (option, props) {
|
|
renderMenuItemChildren: function (option, props) {
|
|
return h(P5UI_AddItemToReport_BazaMenuItem, { key: option.ID, baza: selectedBaza, data: option });
|
|
return h(P5UI_AddItemToReport_BazaMenuItem, { key: option.ID, baza: selectedBaza, data: option });
|
|
}
|
|
}
|
|
}),
|
|
}),
|
|
- selectedNewItem && h('p', {}, "Dodaj nowy ... " + selectedNewItem),
|
|
|
|
- //TODO dlaczego to nie działa
|
|
|
|
- // selectedNewItem && h('div', {className='form-group'},[
|
|
|
|
- // h('input',{
|
|
|
|
- // className:'form-control required',
|
|
|
|
- // id:'personName',
|
|
|
|
- // placeholder:'Imię'
|
|
|
|
- // }),
|
|
|
|
- // h('input',{
|
|
|
|
- // className:'form-control required',
|
|
|
|
- // id:'personSurname',
|
|
|
|
- // placeholder:'Nazwisko'
|
|
|
|
- // },[]),
|
|
|
|
- // h('input',{
|
|
|
|
- // className:'form-control required',
|
|
|
|
- // id:'personNip',
|
|
|
|
- // placeholder:'NIP'
|
|
|
|
- // },[]),
|
|
|
|
- // h('input',{
|
|
|
|
- // className:'form-control required',
|
|
|
|
- // id:'personPesel',
|
|
|
|
- // placeholder:'personPesel'
|
|
|
|
- // },[]),
|
|
|
|
- // h('input',{
|
|
|
|
- // className:'form-control required',
|
|
|
|
- // id:'personRegon',
|
|
|
|
- // placeholder:'REGON'
|
|
|
|
- // },[])
|
|
|
|
- // ]
|
|
|
|
- // ),
|
|
|
|
|
|
+ selectedNewItem && h('div', { className: 'form-group' }, [
|
|
|
|
+ h('input',{
|
|
|
|
+ className:'form-control required',
|
|
|
|
+ id:'personName',
|
|
|
|
+ placeholder:'Imię'
|
|
|
|
+ }),
|
|
|
|
+ h('input',{
|
|
|
|
+ className:'form-control required',
|
|
|
|
+ id:'personSurname',
|
|
|
|
+ placeholder:'Nazwisko'
|
|
|
|
+ }),
|
|
|
|
+ h('input',{
|
|
|
|
+ className:'form-control required',
|
|
|
|
+ id:'personNip',
|
|
|
|
+ placeholder:'NIP'
|
|
|
|
+ }),
|
|
|
|
+ h('input',{
|
|
|
|
+ className:'form-control required',
|
|
|
|
+ id:'personPesel',
|
|
|
|
+ placeholder:'personPesel'
|
|
|
|
+ }),
|
|
|
|
+ h('input',{
|
|
|
|
+ className:'form-control required',
|
|
|
|
+ id:'personRegon',
|
|
|
|
+ placeholder:'REGON'
|
|
|
|
+ })
|
|
|
|
+ ]),
|
|
// '' === selectedNewItem && h
|
|
// '' === selectedNewItem && h
|
|
(selectedBaza && this.state.selected) && h('div', { style: { marginTop: '22px' } }, [
|
|
(selectedBaza && this.state.selected) && h('div', { style: { marginTop: '22px' } }, [
|
|
h('button', {
|
|
h('button', {
|
|
@@ -256,7 +247,7 @@ function createPracownikAjax(event) {
|
|
swal({
|
|
swal({
|
|
title: "Dodaj osobę lub podmiot",
|
|
title: "Dodaj osobę lub podmiot",
|
|
width: (getWindowWidth() * 0.8),
|
|
width: (getWindowWidth() * 0.8),
|
|
- html: '<div id="createPracownikAjax__searchBaza" style="padding:0 24px 24px 24px"></div>',
|
|
|
|
|
|
+ html: '<div id="createPracownikAjax__searchBaza" style="padding:0 24px 24px 24px; min-height:400px"></div>',
|
|
animation: false,
|
|
animation: false,
|
|
showConfirmButton: false,
|
|
showConfirmButton: false,
|
|
showCancelButton: false,
|
|
showCancelButton: false,
|