| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- // @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 '<li><a href="#">' + "Brak danych" + '</a></li>';
- } 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 = '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + pInitId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + pInitId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
- out += ' <i class="glyphicon glyphicon-info-sign"';
- out += ' onclick="' + jsInfo + '"';
- out += ' style="color:#aaa;"';
- out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
- out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
- out += " {" + pInitId + "} " + label;
- out += '</a>';
- 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 += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + gotoId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
- out += ' <span style="padding:10px;"></span>';
- out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
- out += ' <i class="glyphicon glyphicon-info-sign"';
- out += ' onclick="' + jsInfo + '"';
- out += ' style="color:#aaa;"';
- out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
- out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
- out += " {" + gotoId + "} " + label;
- out += '</a>';
- 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 += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoLvl2Id + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + gotoLvl2Id + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
- out += ' <span style="padding:20px;"></span>';
- out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
- out += ' <i class="glyphicon glyphicon-info-sign"';
- out += ' onclick="' + jsInfo + '"';
- out += ' style="color:#aaa;"';
- out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
- out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
- out += " {" + gotoLvl2Id + "} " + label;
- out += '</a>';
- 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 += '<li' + sel + ' style="' + liStyle + '">';
- procesInitMapHtml += _viewProcesInitListItem(vInitId, gotoIds, pInitData.pInitList);
- procesInitMapHtml += '</li>' + "\n";
- $.map(gotoIds, function(gotoLvl2Ids, gotoId) {
- sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
- procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
- procesInitMapHtml += _viewProcesGotoAndRetListItem(gotoId, pInitData.pInitList);
- procesInitMapHtml += '</li>' + "\n";
- $.map(gotoLvl2Ids, function(vBool, gotoLvl2Id) {
- sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
- procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
- procesInitMapHtml += _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitData.pInitList);
- procesInitMapHtml += '</li>' + "\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('<li><a href="#">' + msg + '</a></li>');
- } else {
- $ul.html('<li><a href="#">Wystapił błąd podczas pobierania listy procesów</a></li>');
- }
- } else {
- $ul.html('<li><a href="#">Wystapił błąd podczas pobierania listy procesów</a></li>');
- }
- $n.data('fetched', true);
- });
- return false;
- }
- global[JS_FUNCTION_NAME] = toggleProcesInitFiltr
|