|
@@ -32,56 +32,74 @@
|
|
|
})(document.getElementById(elementID).style);
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
+ // todo: do usuniecia
|
|
|
var testUrl = 'index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY&backRefNS=default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA&backRefPK=26&backRefField=default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY';
|
|
|
-getUrlParams(testUrl);
|
|
|
+ var responseUrl = getUrlParams(testUrl);
|
|
|
+console.log(responseUrl);
|
|
|
+
|
|
|
+// todo: przenieść do eventu który nasłuchuje zakonczenie wczytania tabeli
|
|
|
+setTimeout(searchColumnWithHref, 2000);
|
|
|
|
|
|
/**
|
|
|
- * Funkcja do aktualizacji kolumny w której podajemy namespace backRef i id PK backRef'u
|
|
|
+ * Funkcja przeszukuje td i pobiera dane na podstawie znalezionego adresu url
|
|
|
*/
|
|
|
-function updateColumnDataFieldByBackRefNsAndBackRefPK( paramUrl, arrayShowDataField, countShowDataField = 2 ) {
|
|
|
- var urlParams = getUrlParams(url_string);
|
|
|
- var urlGetData = '';
|
|
|
+function searchColumnWithHref() {
|
|
|
+ console.log('START searchColumnWithHref');
|
|
|
+
|
|
|
+ $("table tr").each(function () {
|
|
|
+ var tableRow = $(this);
|
|
|
|
|
|
- console.log(urlParams);
|
|
|
- //urlGetData =
|
|
|
- //todo: pobranie danych
|
|
|
- getDataByNamespaceAndPK(urlGetData);
|
|
|
- //todo: sprawdzenie wystapiepnia koluny i aktualizacja o dane
|
|
|
+ tableRow.find('td').each(function ( indexTd, valueTd ) {
|
|
|
+ var valueUrl = $(this).find('href');
|
|
|
+ // pobieramy url z linku a href
|
|
|
+ var hrefFromTd = tableRow.find('td:eq('+indexTd+') a').attr('href');
|
|
|
+
|
|
|
+ // pobieramy dane
|
|
|
+ if ( hrefFromTd !== undefined ) {
|
|
|
+ var responseData = getDataByUrl( hrefFromTd );
|
|
|
+ }
|
|
|
|
|
|
+ console.log('td tabeli', hrefFromTd, responseData);
|
|
|
+ console.log('####################' );
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ console.log('END searchColumnWithHref');
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * Funkcja do pobrania danych- należy podać url
|
|
|
+ * Funkcja do pobrania danych - należy podać url
|
|
|
*/
|
|
|
-functon getDataByNamespaceAndPK(url) {
|
|
|
+function getDataByUrl( paramUrl, urlNamespaceParams = [] ) {
|
|
|
|
|
|
- if (!url) {
|
|
|
+ if ( !paramUrl ) {
|
|
|
return;
|
|
|
}
|
|
|
- fetch(url, {
|
|
|
+
|
|
|
+ window.fetch(paramUrl, {
|
|
|
+
|
|
|
credentials: 'same-origin'
|
|
|
- })
|
|
|
- .then(function parseJSON(response) {
|
|
|
- return response.json()
|
|
|
- })
|
|
|
- .then(function(data) {
|
|
|
- //todo: odebrane dane
|
|
|
- //data.body.items
|
|
|
-
|
|
|
- if (data.body.item === null) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ })
|
|
|
+ .then(function parseJSON(response) {
|
|
|
+ return response.json()
|
|
|
+ })
|
|
|
+ .then(function(data) {
|
|
|
+ //todo: odebrane dane
|
|
|
+ //data.body.items
|
|
|
|
|
|
- return data.body.items;
|
|
|
+ if (data.body.item === null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ return data.body.items;
|
|
|
|
|
|
- console.log('request succeeded with JSON updateColumnDataFieldByBackRefNsAndBackRefPK', data.body.items);
|
|
|
- }).catch(function(error) {
|
|
|
- console.log('request failed', error)
|
|
|
- });
|
|
|
-}
|
|
|
+ console.log('request succeeded with JSON getDataByNamespaceAndPK', data.body.items);
|
|
|
+ }).catch(function(error) {
|
|
|
+ console.log('request failed', error)
|
|
|
+ });
|
|
|
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* Funkcja do parsowania url (pobieramy dane na temat parametr=wartosc)
|
|
@@ -100,4 +118,5 @@ function getUrlParams(url) {
|
|
|
return params;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
</script>
|