Piotr Labudda преди 7 години
родител
ревизия
6318ed366b
променени са 1 файла, в които са добавени 33 реда и са изтрити 3 реда
  1. 33 3
      tools/Bocian.php.addItemToRaport.js

+ 33 - 3
tools/Bocian.php.addItemToRaport.js

@@ -117,10 +117,10 @@ var P5UI_AddItemToReport = createReactClass({
         };
     },
     _handleSelectBaza: function (baza) {
-        this.setState({ baza: baza, newItemBaza: null });
+        this.setState({ baza: baza, newItemBaza: null, selected: null, isSearching: false });
     },
     _handleSelectNewItem: function (baza) {
-        this.setState({ baza: null, newItemBaza: baza });
+        this.setState({ baza: null, newItemBaza: baza, selected: null, isSearching: false });
     },
     _handleSelected: function (selected) {
         this.setState({ selected: (selected.length > 0) ? selected[0] : null });
@@ -241,7 +241,37 @@ var P5UI_AddItemToReport = createReactClass({
                     })
                 )
             ),
-            selectedBaza && h(AsyncTypeahead, {
+            ('default_db/BI_audit_KRS/BI_audit_KRS' === selectedBaza) && h(AsyncTypeahead, {
+                isLoading: this.state.isSearching,
+                allowNew: false,
+                multiple: false,
+                options: this.state.options,
+                labelKey: "label",
+                emptyLabel: "Brak danych pasujących do kryteriów wyszukiwania",
+                searchText: "Wyszukiwanie...",
+                // labelKey: function (option) {
+                //   return [
+                //     option.nazwa.replace('"', ''),
+                //     option.nip,
+                //     option.krs,
+                //     option.regon,
+                //     option.S_miejscowosc,
+                //   ].join(' ')
+                // },
+                minLength: 3,
+                onSearch: handleSearch,
+                placeholder: "Wyszukaj...",
+                onChange: handleSelected,
+                autoFocus: true,
+                // filterBy: function (option, text) {
+                //   console.log('TODO: filterBy...', {option, text});
+                //   return true;
+                // },
+                renderMenuItemChildren: function (option, props) {
+                    return h(P5UI_AddItemToReport_BazaMenuItem, { key: option.ID, baza: selectedBaza, data: option });
+                }
+            }),
+            ('default_db/BI_audit_KRS_person/BI_audit_KRS_person' === selectedBaza) && h(AsyncTypeahead, {
                 isLoading: this.state.isSearching,
                 allowNew: false,
                 multiple: false,