Quellcode durchsuchen

fixed procesEditor width, response json error msg

Piotr Labudda vor 9 Jahren
Ursprung
Commit
dec19c3dcc
3 geänderte Dateien mit 48 neuen und 59 gelöschten Zeilen
  1. 2 2
      SE/se-lib/Response.php
  2. 36 49
      SE/se-lib/Route/UrlAction/ProcesEditor.php
  3. 10 8
      SE/static/procesEditor.js

+ 2 - 2
SE/se-lib/Response.php

@@ -38,7 +38,7 @@ class Response {
 			$response = call_user_func_array($callback, $args);
 		} catch (AlertDangerException $e) {
 			Http::sendHeaderByCode(200);
-			$response['type'] = 'danger';
+			$response['type'] = 'error';
 			$response['msg'] = $e->getMessage();
 			$response['code'] = "#" . $e->getCode() . "L" . $e->getLine();
 			Response::sendJsonExit($response);
@@ -62,7 +62,7 @@ class Response {
 			Response::sendJsonExit($response);
 		} catch (Exception $e) {
 			Http::sendHeaderByCode(500);
-			$response['type'] = 'danger';
+			$response['type'] = 'error';
 			$response['msg'] = $e->getMessage();
 			$response['code'] = "#" . $e->getCode() . "L" . $e->getLine();
 			Response::sendJsonExit($response);

+ 36 - 49
SE/se-lib/Route/UrlAction/ProcesEditor.php

@@ -56,32 +56,25 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 			}
 	}
 
+	public function getSingleResAjaxReponseCallback(){
+		if (!isset($_POST['data'])) throw new Exception("data is not set.");
+		$data = $_POST['data'];
+		$sqlWhereIdIn = array();
+		foreach ($data as $value) {
+			$sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT);
+											}
+			$sqlWhereIdIn = (!empty($sqlWhereIdIn)) ? "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")" : "1=1";
+		$rows = DB::getPDO()->fetchAll("
+		select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
+		from CRM_LISTA_ZASOBOW g
+			left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
+			left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
+			left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
+		where {$sqlWhereIdIn}");
+		return $rows;
+	}
 	public function getSingleResAjaxAction(){
-
-		try {
-			if (!isset($_POST['data'])) throw new Exception("data is not set.");
-			$data = $_POST['data'];
-			$sqlWhereIdIn = array();
-			foreach ($data as $value) {
-        $sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT);
-                        }
-        $sqlWhereIdIn = (!empty($sqlWhereIdIn)) ? "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")" : "1=1";
-			$rows = DB::getPDO()->fetchAll("
-			select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
-			from CRM_LISTA_ZASOBOW g
-			  left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
-			  left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
-				left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
-			where {$sqlWhereIdIn}");
-				Response::sendJsonExit($rows);
-
-			} catch (Exception $e) {
-				UI::alert('danger', "Error: " . $e->getMessage());
-			}
-
-
-
-
+		Response::sendTryCatchJson(array($this, 'getSingleResAjaxReponseCallback'));
 	}
 
 	public function handleAuth() {
@@ -110,25 +103,23 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 	public function showEditor($id) {
 		echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
 		$this->showEditorCss();
-
-		echo "<div id=wrapper class=toggled>";
-		echo "<div id='sidebar-wrapper'><div id=side>";
-
-		echo "";
-		echo "</div></div>";
-		echo "<div id='page-content-wrapper'><div class=col-xs-1 id=left style='width:40px;'>";
-		echo "<button class='lButton btn btn-default' id=btnZasoby style=top:150px; ><p>Zasoby</p></button><button class='lButton btn btn-default' style=top:315px; id=btnProcesy><p>Procesy</p></button>";
-		echo "</div><div class=col-xs-11 id=main>";
-
-		echo '<center>Uruchamianie aplikacji.</center>';
-
-		echo "</div></div>";
-
-		echo "<div class=clearfix></div>";
-		echo "</div>";
-		echo "<script>var BASE_URL = '".Request::getPathUri()."';var mainProces_id = ".$id.";</script>";
-		echo '<script src="static/sweetalert2.min.js"></script>';
-		echo '<script src="static/procesEditor.js?'.time().'"></script>';
+?>
+		<div id="wrapper" class="toggled" style="overflow:hidden">
+			<div id='sidebar-wrapper'><div id="side"></div></div>
+			<div id='page-content-wrapper'>
+				<div id="left" style='width:40px;'>
+					<button class='lButton btn btn-default' id="btnZasoby" style="top:150px"><p>Zasoby</p></button>
+					<button class='lButton btn btn-default' style="top:315px" id="btnProcesy"><p>Procesy</p></button>
+				</div>
+				<div id="main" style="margin-left:40px">
+					<center>Uruchamianie aplikacji.</center>
+				</div>
+			</div>
+		</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>
+<?php
 	}
 
 	public function showEditorCss() {
@@ -190,11 +181,6 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
     margin-left: 5px;
     cursor: pointer;
 }
-.options {
-    min-width: 120px;
-    width: auto !important;
-    width: 120px;
-}
 #wrapper {
     padding-left: 0;
     -webkit-transition: all 0.5s ease;
@@ -471,6 +457,7 @@ width:290px;
         color: grey;
         cursor: pointer;
 				display:block;
+				font-size:10px;
     }
 
 		.sDescAdd:hover{

+ 10 - 8
SE/static/procesEditor.js

@@ -123,7 +123,7 @@ $(document).ready(function() {
                 var zasobInfo = new Array();
                 $.post(link2, {data: sFiltr2}, function(data2){
                   //console.log("data");
-                  console.log(data2);
+                  // console.log(data2);
 
                   $.each(data2, function(i, e) {
 
@@ -165,8 +165,10 @@ $(document).ready(function() {
                   });
                   $("#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');
                 });
             }
         });
@@ -970,7 +972,7 @@ $(document).ready(function() {
         var id = lastSearch;
         var link;
         link = BASE_URL+"index.php?_route=UrlAction_ProcesEditor&_task=getResAjax&word="+id+"&filter="+filtr;
-        console.log(link);
+        // console.log(link);
 
 
         $.get(link, function(data) {
@@ -991,7 +993,7 @@ $(document).ready(function() {
                     tree += e["p"+i+"_DESC"] + (i>1 ? " <span class='glyphicon glyphicon-triangle-right'></span>" : "");
                   }
                 }
-                console.log(e["TYPE"]);
+                // console.log(e["TYPE"]);
                 var type = 0;
                 if (e["TYPE"] == "DZIAL" || e["TYPE"] == "PODMIOT" || e["TYPE"] == "STANOWISKO")
                     type = 1;
@@ -1290,7 +1292,7 @@ $(document).ready(function() {
                 });
             }
         }).then(function(result) {
-            console.log(zasobTree);
+            // console.log(zasobTree);
             //console.log("Dodaj zasob " + ui.draggable.data("id") + " do " + $(target).data("id") + " i uprawnienia id " + result[0] + " komentarz: " + result[1]); //
             newRes--;
             var temp = {};
@@ -1517,7 +1519,7 @@ $(document).ready(function() {
     function render(arr, target) {
         stepsGenerator();
         var result = "";
-        console.log(arr);
+        // console.log(arr);
         $.each(arr, function(i, e) {
             result += "<div class='drop container-fluid' data-id=" + e["id"] + " id='proc" + e["id"] + "'>";
             result += "<div class='col-xs-1 options' style=text-align:right;padding-top:2px; id=opt" + e["id"] + ">";
@@ -1546,7 +1548,7 @@ $(document).ready(function() {
             else
                 result += "<span class=sDescAdd>Edytuj opis</span>";
             result += "</div>";
-            result += "<div class='col-xs-10 desc' id='desc" + e["id"] + "' ><h4 class='changable " + (e["C-desc"] ? "changed" : "") + "'><span class='stepDesc'>" + e["stepDesc"] + "</span><span class=hdesc>" + e["desc"] + "</span> <span class=ids>{" + (e["id"] >= 0 ? e["id"] : "?") + "}</span></h4><span  class='sdesc changable " + (e["C-opis"] ? "changed" : "") + "'>" + e["opis"] + "</span>";
+            result += "<div class='col-xs-11 desc' id='desc" + e["id"] + "' ><h4 class='changable " + (e["C-desc"] ? "changed" : "") + "'><span class='stepDesc'>" + e["stepDesc"] + "</span><span class=hdesc>" + e["desc"] + "</span> <span class=ids>{" + (e["id"] >= 0 ? e["id"] : "?") + "}</span></h4><span  class='sdesc changable " + (e["C-opis"] ? "changed" : "") + "'>" + e["opis"] + "</span>";
 
             // }
             // if ($(this).find("OPIS").text() == "") {