| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // @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 p5Utils__convertToHtml(tagName, attributes, childrens) { // ( string tagName, object attributes, array childrens )
- return '<' + tagName + ( attributes ? ' ' + p5Utils__convertAttrsToHtml(attributes) : '' ) + '>' + ( childrens || [] ).join("") + '</' + tagName + '>';
- }
- function p5Utils__convertAttrsToHtml(attributes) {
- return Object.keys(attributes).map(function (attrName) {
- var name = attrName;
- if ('className' === name) name = 'class';
- return '' + name + '="' + attributes[attrName] + '"'
- }).join(" ")
- }
- function _viewProcesInitListItem(pInitId, label, selected) {
- 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 h = p5Utils__convertToHtml;
- return h('form', { className: "form-inline", method: "post", action: "", style: "padding: 3px 20px" }, [
- h('input', { type: "hidden", name: "_rootPostTask", value: "SetPermsByProces" }),
- h('input', { type: "hidden", name: "id_proces", value: pInitId }),
- h('i', {
- className: "glyphicon glyphicon-info-sign",
- style: "color:#aaa; cursor:help",
- onclick: jsInfo,
- title: "Przeglądaj proces {" + pInitId + "} " + label,
- onmouseover: "this.style.color = '#337AB7'", onmouseout: "this.style.color = '#aaa'"
- }),
- h('button', {
- className: "btn btn-link" + ( selected ? " disabled" : "" ),
- style: "padding:0 3px",
- title: "Uruchom filtr procesu {" + pInitId + "}"
- }, [
- " {" + pInitId + "} " + label,
- ]),
- ]);
- }
- function _viewProcesGotoAndRetListItem(gotoId, label, selected) {
- 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 h = p5Utils__convertToHtml;
- return h('form', { className: "form-inline", method: "post", action: "", style: "padding:3px 20px; margin-left:20px" }, [
- h('input', { type: "hidden", name: "_rootPostTask", value: "SetPermsByProces" }),
- h('input', { type: "hidden", name: "id_proces", value: gotoId }),
- h('i', {
- className: "glyphicon glyphicon-info-sign",
- style: "color:#aaa; cursor:help",
- title: "Przeglądaj proces {" + gotoId + "} " + label,
- onclick: jsInfo,
- onmouseover: "this.style.color = '#337AB7'", onmouseout: "this.style.color = '#aaa'"
- }),
- h('button', {
- className: "btn btn-link" + ( selected ? " disabled" : "" ),
- style: "padding:0 3px",
- title: "Uruchom filtr procesu {" + gotoId + "}"
- }, [
- " {" + gotoId + "} " + label,
- ]),
- ]);
- }
- function _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, label, selected) {
- 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 h = p5Utils__convertToHtml;
- return h('form', { className: "form-inline", method: "post", action: "", style: "padding:3px 20px; margin-left:40px" }, [
- h('input', { type: "hidden", name: "_rootPostTask", value: "SetPermsByProces" }),
- h('input', { type: "hidden", name: "id_proces", value: gotoLvl2Id }),
- h('i', { className: "glyphicon glyphicon-arrow-right", style: "color:#aaa" }),
- h('i', {
- className: "glyphicon glyphicon-info-sign",
- style: "color:#aaa; cursor:help",
- title: "Przeglądaj proces {" + gotoLvl2Id + "} " + label,
- onclick: jsInfo,
- onmouseover: "this.style.color = '#337AB7'", onmouseout: "this.style.color = '#aaa'"
- }),
- h('button', {
- className: "btn btn-link" + ( selected ? " disabled" : "" ),
- style: "padding:0 3px",
- title: "Uruchom filtr procesu {" + gotoLvl2Id + "}"
- }, [
- " {" + gotoLvl2Id + "} " + label,
- ]),
- ]);
- }
- function _viewDropdownListItem(id, label, selected, callback) {
- var h = p5Utils__convertToHtml;
- return h('li', {
- style: "white-space:nowrap; overflow:hidden; max-width:500px; /* text-overflow:ellipsis; */",
- onmouseover: "this.style.backgroundColor='#f5f5f5'", onmouseout: "this.style.backgroundColor='#fff'",
- }, [
- callback(id, label, selected),
- ]);
- }
- function toggleProcesInitFiltr(n) {
- var $n = jQuery(n);
- var $ul = $n.next();
- if ($n.data('fetched')) return false;
- function parseProcesInitData(pInitData) {
- return (!pInitData || !pInitData.mapTree)
- ? '<li><a href="#">' + "Brak danych" + '</a></li>'
- : Object.keys(pInitData.mapTree).map(function (vInitId) {
- var gotoIds = pInitData.mapTree[vInitId];
- var sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId);
- return [
- _viewDropdownListItem(vInitId, pInitData.pInitList[vInitId], sel, _viewProcesInitListItem)
- ].concat(
- (!gotoIds) ? null : Object.keys(gotoIds).map(function (gotoId) {
- var gotoLvl2Ids = gotoIds[gotoId];
- var sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId);
- return [
- _viewDropdownListItem(gotoId, pInitData.pInitList[gotoId], sel, _viewProcesGotoAndRetListItem)
- ].concat(
- (!gotoLvl2Ids) ? null : Object.keys(gotoLvl2Ids).map(function (gotoLvl2Id) {
- // var vBool = gotoLvl2Ids[gotoLvl2Id];
- return _viewDropdownListItem(gotoLvl2Id, pInitData.pInitList[gotoLvl2Id], sel, _viewProcesGotoAndRetLvl2ListItem);
- }).join("\n")
- ).join("\n");
- }).join("\n")
- ).join("\n");
- }).join("\n")
- ;
- }
- 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
|