ソースを参照

fixed BUG in processEditor - for empty process

Piotr Labudda 9 年 前
コミット
36539ab36c
2 ファイル変更53 行追加53 行削除
  1. 1 1
      SE/se-lib/Route/UrlAction/ProcesEditor.php
  2. 52 52
      SE/static/procesEditor.js

+ 1 - 1
SE/se-lib/Route/UrlAction/ProcesEditor.php

@@ -118,7 +118,7 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 		</div>
 		<script>var BASE_URL = '<?= Request::getPathUri(); ?>';var mainProces_id = <?= $id; ?>;</script>
 		<script src="static/sweetalert2.min.js"></script>
-		<script src="static/procesEditor.js?'.time().'"></script>
+		<script src="static/procesEditor.js?v=12"></script>
 <?php
 	}
 

+ 52 - 52
SE/static/procesEditor.js

@@ -111,65 +111,65 @@ $(document).ready(function() {
                 });
                 //console.log(res);
                 var sFiltr2 = [];
-
-                var link2 = BASE_URL+"index.php?_route=UrlAction_ProcesEditor&_task=getSingleResAjax";
                 $.each(res, function(index, value) {
                     var id = res[index]["ID_ZASOB"];
                     sFiltr2.push(id);
                 });
-                //sFiltr2 = JSON.stringify(sFiltr2);
-                //console.log(sFiltr2);
-                //console.log(link2);
-                var zasobInfo = new Array();
-                $.post(link2, {data: sFiltr2}, function(data2){
-                  //console.log("data");
-                  // console.log(data2);
-
-                  $.each(data2, function(i, e) {
-
-                      zasobInfo[e["ID"]] = new Array();
-                      zasobInfo[e["ID"]]["DESC"] = e["DESC"];
-                      zasobInfo[e["ID"]]["OPIS"] = e["OPIS"];
-                      zasobInfo[e["ID"]]["TYPE"] = e["TYPE"];
-                      zasobInfo[e["ID"]]["TREE"] = [];
-                      for(var i=3;i>0;i--){
-                        if(e["p"+i+"_ID"] != null){
-                          var temp = {};
-                          temp["ID"] = e["p"+i+"_ID"];
-                          temp["DESC"] = e["p"+i+"_DESC"];
-                          zasobInfo[e["ID"]]["TREE"].push(temp);
-                        }
-                    }
-                  });
-                  //console.log(res);
-                  $.each(res, function(index, value) {
-                      var type;
-                      if (zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "DZIAL" || zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "STANOWISKO" || zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "PODMIOT") {
-                          type = "prof";
-                      } else {
-                          type = "res";
+                if (sFiltr2.length > 0) {
+                  //sFiltr2 = JSON.stringify(sFiltr2);
+                  //console.log(sFiltr2);
+                  //console.log(link2);
+                  var zasobInfo = new Array();
+                  var link2 = BASE_URL+"index.php?_route=UrlAction_ProcesEditor&_task=getSingleResAjax";
+                  $.post(link2, {data: sFiltr2}, function(data2){
+                    //console.log("data");
+                    // console.log(data2);
+                    $.each(data2, function(i, e) {
+                        zasobInfo[e["ID"]] = new Array();
+                        zasobInfo[e["ID"]]["DESC"] = e["DESC"];
+                        zasobInfo[e["ID"]]["OPIS"] = e["OPIS"];
+                        zasobInfo[e["ID"]]["TYPE"] = e["TYPE"];
+                        zasobInfo[e["ID"]]["TREE"] = [];
+                        for(var i=3;i>0;i--){
+                          if(e["p"+i+"_ID"] != null){
+                            var temp = {};
+                            temp["ID"] = e["p"+i+"_ID"];
+                            temp["DESC"] = e["p"+i+"_DESC"];
+                            zasobInfo[e["ID"]]["TREE"].push(temp);
+                          }
                       }
-                      var id = res[index]["ID_PROCES"];
-
-                      var temp = {};
-                      temp["id_zasob"] = res[index]["ID_ZASOB"]
-                      temp["id"] = res[index]["ID"];
-                      temp["id_przypadek"] = res[index]["ID_PRZYPADEK"];
-                      temp["komentarz"] = res[index]["OPIS_ZASOB"];
-                      temp["desc"] = zasobInfo[res[index]["ID_ZASOB"]]["DESC"];
-                      temp["opis"] = zasobInfo[res[index]["ID_ZASOB"]]["OPIS"];
-                      temp["tree"] = zasobInfo[res[index]["ID_ZASOB"]]["TREE"];
-                      //console.log(temp);
-                      state[getIndexById(id)][type].push(temp);
-
+                    });
+                    //console.log(res);
+                  })
+                  .fail(function(xhr) {
+                    if (xhr.responseJSON && xhr.responseJSON.msg && xhr.responseJSON.type) jQuery.notify(xhr.responseJSON.msg, xhr.responseJSON.type);
+                    else jQuery.notify("Wystąpił nieznany błąd", 'error');
                   });
-                  $("#main").html("<center>Generowanie widoku.</center>");
-                  render(state, $("#main"));
-                })
-                .fail(function(res) {
-                  if (res.responseJSON && res.responseJSON.msg && res.responseJSON.type) jQuery.notify(res.responseJSON.msg, res.responseJSON.type);
-                  else jQuery.notify("Wystąpił nieznany błąd", 'error');
+                }
+
+                $.each(res, function(index, value) {
+                    var type;
+                    if (zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "DZIAL" || zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "STANOWISKO" || zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "PODMIOT") {
+                        type = "prof";
+                    } else {
+                        type = "res";
+                    }
+                    var id = res[index]["ID_PROCES"];
+
+                    var temp = {};
+                    temp["id_zasob"] = res[index]["ID_ZASOB"]
+                    temp["id"] = res[index]["ID"];
+                    temp["id_przypadek"] = res[index]["ID_PRZYPADEK"];
+                    temp["komentarz"] = res[index]["OPIS_ZASOB"];
+                    temp["desc"] = zasobInfo[res[index]["ID_ZASOB"]]["DESC"];
+                    temp["opis"] = zasobInfo[res[index]["ID_ZASOB"]]["OPIS"];
+                    temp["tree"] = zasobInfo[res[index]["ID_ZASOB"]]["TREE"];
+                    //console.log(temp);
+                    state[getIndexById(id)][type].push(temp);
+
                 });
+                $("#main").html("<center>Generowanie widoku.</center>");
+                render(state, $("#main"));
             }
         });
     }