|
@@ -110,14 +110,15 @@ function initLocalStorage() {
|
|
|
/**
|
|
|
* Funkcja pozwala na wyświetlenie okienka importu
|
|
|
*/
|
|
|
-function showViewUploadFile( event, headerTitle, enumType, csvFileExample ) {
|
|
|
+function showViewUploadFile( event, headerTitle, enumType, showCheckbox, csvFileExample ) {
|
|
|
event.preventDefault();
|
|
|
|
|
|
var enumType = enumType;
|
|
|
- var csvFileExample = csvFileExample;
|
|
|
- if( csvFileExample !== undefined) {
|
|
|
+
|
|
|
+ if( csvFileExample !== undefined) { // przykład + instrukcja do pobrania
|
|
|
csvFileExample = '<div><a href="'+csvFileExample+'" title="Pobierz przykład" download target="_balnk">Pobierz przykład</a></div>';
|
|
|
}
|
|
|
+
|
|
|
swal({
|
|
|
title: 'Importuj plik csv',
|
|
|
input: 'file',
|
|
@@ -133,17 +134,17 @@ function showViewUploadFile( event, headerTitle, enumType, csvFileExample ) {
|
|
|
reject("Proszę wybrać plik csv");
|
|
|
return
|
|
|
}
|
|
|
- var formData = new FormData();
|
|
|
- formData.append('file', file);
|
|
|
- console.log('uploadowany plik: ',formData);
|
|
|
- var responseParseFile = parseCsvFile( formData, enumType );
|
|
|
+ var input = document.querySelector('input[type="file"]');
|
|
|
+
|
|
|
+ var data = new FormData()
|
|
|
+ data.append('file', input.files[0])
|
|
|
+ data.append('showCheckbox', showCheckbox);
|
|
|
|
|
|
- console.log('TODO: upload file', file)
|
|
|
+ var responseParseFile = parseCsvFile( data, enumType );
|
|
|
resolve('file imported')
|
|
|
})
|
|
|
},
|
|
|
}).then(function (result) {
|
|
|
-
|
|
|
console.log('result', result)
|
|
|
}).catch(function (e) {
|
|
|
console.log('catch: ', e)
|
|
@@ -158,6 +159,8 @@ function showViewUploadFile( event, headerTitle, enumType, csvFileExample ) {
|
|
|
function parseCsvFile( fileData, enumType ) {
|
|
|
event.preventDefault();
|
|
|
|
|
|
+console.log( 'parseCsvFile fileData', fileData);
|
|
|
+
|
|
|
fetch(URL_FORM_DATA_CSV_FILE_AJAX, {
|
|
|
method: 'POST',
|
|
|
credentials: 'same-origin',
|
|
@@ -166,7 +169,6 @@ function parseCsvFile( fileData, enumType ) {
|
|
|
.then(function(response) {
|
|
|
return response.json()
|
|
|
}).then(function(json) {
|
|
|
- console.log('parsed json', json)
|
|
|
|
|
|
swal({
|
|
|
title: 'Dane załadowane z pliku CSV',
|
|
@@ -184,8 +186,6 @@ function parseCsvFile( fileData, enumType ) {
|
|
|
|
|
|
// zapisanie danych
|
|
|
var responseSaveData = saveFormCsvFileAjaxAction(enumType);
|
|
|
-
|
|
|
- console.log('TODO: data save from form', dataForm)
|
|
|
resolve('data save from form')
|
|
|
})
|
|
|
},
|
|
@@ -571,32 +571,7 @@ function createGroupPracownicy(event) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// fetch(URL_FETCH_TEST_KRS, {
|
|
|
-// credentials: 'same-origin'
|
|
|
-// })
|
|
|
-// .then(function parseJSON(response) {
|
|
|
-// return response.json()
|
|
|
-// })
|
|
|
-// .then(function(data) {
|
|
|
-// console.log('request succeeded with JSON response', data)
|
|
|
-// }).catch(function(error) {
|
|
|
-// console.log('request failed', error)
|
|
|
-// })
|
|
|
-//
|
|
|
-// fetch(URL_FETCH_TEST_CEIDG, {
|
|
|
-// credentials: 'same-origin'
|
|
|
-// })
|
|
|
-// .then(function parseJSON(response) {
|
|
|
-// return response.json()
|
|
|
-// })
|
|
|
-// .then(function(data) {
|
|
|
-// console.log('request succeeded with JSON response', data)
|
|
|
-// }).catch(function(error) {
|
|
|
-// console.log('request failed', error)
|
|
|
-// })
|
|
|
-
|
|
|
function rootChangeForm() {
|
|
|
-
|
|
|
//todo: do przeniesienia
|
|
|
urlFetchKontrahenciPowiazania();
|
|
|
var valueUrl = global.location.hash;
|