// @require variables: if ('undefined' === typeof JS_FUNCTION_NAME) throw "Missing JS_FUNCTION_NAME"; if ('undefined' === typeof URL_GET_PROCES_INIT_FILTR) throw "Missing URL_GET_PROCES_INIT_FILTR"; if ('undefined' === typeof ID_ZASOB) throw "Missing ID_ZASOB"; function toggleProcesInitFiltr(n) { var $n = jQuery(n); var $ul = $n.next(); if ($n.data('fetched')) return false; function parseProcesInitData(pInitData) { var procesInitMapHtml = ''; if (!pInitData) { return '
  • ' + "Brak danych" + '
  • '; } else { function _viewProcesInitListItem(pInitId, gotoIds, pInitList) { var label = pInitList[pInitId]; var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + pInitId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;"; var out = '';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName} out += ' '; out += " {" + pInitId + "} " + label; out += ''; return out; } function _viewProcesGotoAndRetListItem(gotoId, pInitList) { var label = pInitList[gotoId]; var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;"; var out = ''; out += '';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName} out += ' '; out += ' '; out += ' '; out += " {" + gotoId + "} " + label; out += ''; return out; } function _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitList) { var label = pInitList[gotoLvl2Id]; var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoLvl2Id + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;"; var out = ''; out += '';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName} out += ' '; out += ' '; out += ' '; out += " {" + gotoLvl2Id + "} " + label; out += ''; return out; } var sel = '', liStyle = "white-space:nowrap; overflow:hidden; max-width:500px; /* text-overflow:ellipsis; */"; $.map(pInitData.mapTree, function(gotoIds, vInitId) { sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : ''; procesInitMapHtml += ''; procesInitMapHtml += _viewProcesInitListItem(vInitId, gotoIds, pInitData.pInitList); procesInitMapHtml += '' + "\n"; $.map(gotoIds, function(gotoLvl2Ids, gotoId) { sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : ''; procesInitMapHtml += ''; procesInitMapHtml += _viewProcesGotoAndRetListItem(gotoId, pInitData.pInitList); procesInitMapHtml += '' + "\n"; $.map(gotoLvl2Ids, function(vBool, gotoLvl2Id) { sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : ''; procesInitMapHtml += ''; procesInitMapHtml += _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitData.pInitList); procesInitMapHtml += '' + "\n"; }); }); }); } return procesInitMapHtml; } jQuery.ajax({ data: null, dataType: 'json', type: "GET", async: true, url: URL_GET_PROCES_INIT_FILTR }) .always(function(data, textStatus, jqXHR) { var type = data.type || null, msg = data.msg || "Error", pInitData = data.pInitData || null; if (type) { if ('success' == type) { $ul.html(parseProcesInitData(pInitData)); } else if ('error' == type) { $ul.html('
  • ' + msg + '
  • '); } else { $ul.html('
  • Wystapił błąd podczas pobierania listy procesów
  • '); } } else { $ul.html('
  • Wystapił błąd podczas pobierania listy procesów
  • '); } $n.data('fetched', true); }); return false; } global[JS_FUNCTION_NAME] = toggleProcesInitFiltr