Procházet zdrojové kódy

updated taskmanager

Piotr Labudda před 8 roky
rodič
revize
3a8426c404

+ 15 - 4
SE/se-lib/Route/UrlAction/TaskManager.php.task.css

@@ -2,7 +2,7 @@
 	margin:0 auto;
 	margin-top:25px;
 	margin-bottom:25px;
-	background-color: #fcf59b;
+	background-color: #fffcd7;
 	color: #212121;
 	font-size:1.5em;
 }
@@ -90,10 +90,9 @@
 }
 
 .editable{
-
+	padding-top: 7px;
 	margin-left:5px;
-	width:calc(100% - 200px);
-	display:inline-block;
+	width:100%;
 	background-color:transparent;
   min-height:15px;
 	border: none;
@@ -101,6 +100,18 @@
   outline: none;
 }
 
+.hours{
+	border-style: solid;
+    border-width: 1px;
+    border-color: grey;
+    border-radius: 0.1em;
+	height:15px;
+	font-size:13px;
+	border-radius:0px;
+	margin-top:4px;
+	
+}
+
 .cursorClick{
 	cursor:pointer;
 }

+ 93 - 92
SE/se-lib/Route/UrlAction/TaskManager.php.task.js

@@ -34,7 +34,9 @@ function setSort() {
   `;
     var i = 0;
     var idx = [];
-    $("#sortable").children(".singleTask").each(function() {
+    $("#sortable").find(".singleTask").each(function() {
+        if ($(this).data("parent") !== false) return true;
+
         i++;
         req += `
       <Insert xmlns="http://www.opengis.net/wfs">
@@ -157,7 +159,7 @@ function getCaretPosition(ctrl) {
     }
 }
 
-$(document).on('dblclick', '#sortable li', function(e) { //
+$(document).on('dblclick', '#sortable tr', function(e) { //
     var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
     var index = getIndexById($(this).data("id"));
     var req = `
@@ -280,7 +282,7 @@ $(document).on('keydown', '.hours', function(e) {
       </PROBLEMS>
       </Insert>`;
         req += '</Transaction>';
-		var ids = [];
+        var ids = [];
         var tab = getObjOfElement(this, ids);
         var period = $(this).val();
         var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
@@ -295,29 +297,30 @@ $(document).on('keydown', '.hours', function(e) {
 
                 $.notify("Zapisano!", "success");
                 tab["period"] = period;
-				console.log(ids)
-				$.each(ids, function(i, e){
-					var result = getObjOfElement($('.singleTask[data-id="'+e+'"]').children(".editable"));
-			
-					console.log(result)
-					var period = 0;
-					var count = 0;
-					$.each(result["childs"], function(i2,e2){
-						count++;
-					period += parseInt(e2["period"])
-				
-					})
-			
-					if(count != 0)
-						result["period"] = period
-			
-			
-				})		
+                $.each(ids, function(i, e) {
+                    var result = getObjOfElement($('.singleTask[data-id="' + e + '"]'));
+
+                    var period = 0;
+                    var count = 0;
+                    $.each(result["childs"], function(i2, e2) {
+                        count++;
+                        if (!isNaN(parseInt(e2["period"])))
+                            period += parseInt(e2["period"])
+                        else
+                            period += 0;
+
+                    })
+
+                    if (count != 0)
+                        result["period"] = period
+
+
+                })
                 render();
             }
         });
-		
-		
+
+
     }
 });
 
@@ -338,7 +341,7 @@ $(document).on('keydown', '.editable', function(e) {
         req += `
       <Insert xmlns="http://www.opengis.net/wfs">
       <PROBLEMS xmlns="` + BASE_WFS_URL + `/default_db/">
-      <ID xmlns="` + BASE_WFS_URL + `/default_db/">` + $(this).parents("li").data('id') + `</ID>`;
+      <ID xmlns="` + BASE_WFS_URL + `/default_db/">` + $(this).closest(".singleTask").data('id') + `</ID>`;
         if (details.worker != false)
             req += '<L_APPOITMENT_USER xmlns="' + BASE_WFS_URL + '/default_db/">' + details.worker + '</L_APPOITMENT_USER>';
         else
@@ -458,11 +461,13 @@ $(document).on('keydown', '.eInput', function(e) {
 });
 
 function getObjOfElement(el, ids = []) {
-    var acc = $(el).parent().closest(".singleTask")
+    var acc = $(el).closest(".singleTask")
 
-    while ($(acc).length > 0) {
+    while (true) {
         ids.unshift($(acc).data("id"));
-        acc = $(acc).parent().closest(".singleTask")
+        var parent_id = $(acc).data("parent")
+        if (!parent_id) break;
+        acc = $(".singleTask[data-id='" + parent_id + "']");
 
 
     }
@@ -477,7 +482,7 @@ function getObjOfElement(el, ids = []) {
             tab = tab["childs"][index];
         }
     });
-	ids.reverse();
+    ids.reverse();
     return tab;
 
 }
@@ -618,7 +623,7 @@ function getIndexById(id, arr = state) {
 $(document).on('click', '.check', function() {
     var node = this;
     var id = $(node).closest("li").data("id");
-	var ids = [];
+    var ids = [];
     var tab = getObjOfElement(this, ids);
     if (tab['status'] == "OFF_HARD") {
         $.notify("Nie możesz zmieniać stanu zatwierdzonych zadań", "danger");
@@ -664,25 +669,23 @@ $(document).on('click', '.check', function() {
             setSort();
         }
     });
-	console.log(ids)
-	$.each(ids, function(i, e){
-		var result = getObjOfElement($('.singleTask[data-id="'+e+'"]').children(".editable"));
-		
-		console.log(result)
-		var percent = 0;
-		var count = 0;
-		$.each(result["childs"], function(i2,e2){
-			count++;
-			percent += parseInt(e2["percent"])
-			
-		})
-		
-		if(count != 0)
-			result["percent"] = (percent/count)+"%"
-		
-		
-	})
-	
+    $.each(ids, function(i, e) {
+        var result = getObjOfElement($('.singleTask[data-id="' + e + '"]'));
+
+        var percent = 0;
+        var count = 0;
+        $.each(result["childs"], function(i2, e2) {
+            count++;
+            if (!isNaN(parseInt(e2["percent"])))
+                percent += parseInt(e2["percent"])
+            else
+                percent += 0;
+        })
+
+        if (count != 0)
+            result["percent"] = (percent / count) + "%"
+    })
+
     updateProgress();
     render();
 });
@@ -815,16 +818,13 @@ function getData(type, parent_id, target) {
     });
 }
 
-
-function renderTasks(arr, ret = false) {
+function renderTasks(arr, ret = false, depth = 0) {
     var resultActive = "";
     var resultDone = "";
-
-
     $.each(arr, function(i, e) {
         var result = "";
         var css = "";
-        var css3 = "";
+
         if (e["percent"] != "100%") {
 
             if (e['status'] == "NORMAL") {
@@ -832,19 +832,25 @@ function renderTasks(arr, ret = false) {
             } else if (e['status'] == "WAITING") {
                 css = "background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.1) " + e["percent"] + ", transparent " + e["percent"] + ", transparent 100%);";
             }
-            if (ret)
+            if (ret !== false)
                 css = "background-color:#fffabe;";
         } else {
-            if (ret)
+            if (ret !== false)
                 css = "background-color:#e6e6e6;";
         }
-        var css2 = "border-left-style:solid;border-left-width:6px;border-left-color:" + (e['percent'] == "100%" ? "#202020" : "#00FF00") + ";";
 
 
-        css2 += "border-right-style:solid;border-right-width:6px;border-right-color:" + (e['percent'] == "100%" ? "#202020" : "#00FF00") + ";";
-        result += "<li class=singleTask data-id=" + e["id"] + "  style='" + css + css2 + "'>";
 
+        result += "<tr class=singleTask data-parent=" + ret + " data-id=" + e["id"] + "  style='" + css + "'>";
+        result += "<td style='padding-left:10px;padding-right:10px;'>"
+        if (e["childs"] !== false)
+            result += "<span class='glyphicon " + (!e["expand"] ? "glyphicon-menu-down" : "glyphicon-menu-up") + " cursorClick expand' data-state=" + e["expand"] + "	style=padding-left:" + depth * 16 + "px></span>";
+        else
+            result += "<span class='glyphicon glyphicon-menu-right'	style=color:silver;padding-left:" + depth * 16 + "px></span>";
+        result += "</td>"
+        result += "<td>"
         if (e["percent"] == "100%") {
+            result += "</td><td></td><td style=padding-right:5px;min-width:45px;>"
             result += "<span class=check style='background-color:#333333' data-toggle='popover' data-trigger='hover' title='' data-content='Kliknij teraz, aby zmienić status na niewykonane.' data-original-title='Zadanie wykonane'></span>";
             if (e['status'] != "OFF_HARD") {
                 result += "<span class=aCheck data-toggle='popover' data-trigger='hover' title='' data-content='Wykonawca oznaczył zadanie jako wykonane, ale zleceniodawca jeszcze go nie zatwierdził.' data-original-title='Wykonanie zadania niezatwierdzone.'></span>";
@@ -852,43 +858,46 @@ function renderTasks(arr, ret = false) {
                 result += "<span class=aCheck style=background-color:#2ecc71; data-toggle='popover' data-trigger='hover' title='' data-content='Zleceniodawca zatwierdził wykonanie zadania. Kliknij, aby cofnąć zatwierdzenie.' data-original-title='Zadanie zatwierdzone'></span>";
             }
         } else {
-            if (!ret)
-                result += "<span class='glyphicon glyphicon-option-vertical ico cursorClick' style=float:left;cursor:grab; data-toggle='popover' data-trigger='hover' title='' data-content='Złap tutaj, aby zmienić pozycje tego zadania.' data-original-title='Sortowanie'></span>";
-
+            result += "</td><td >"
+            //if (ret === false)
+            //    result += "<span class='glyphicon glyphicon-option-vertical ico cursorClick' style=float:left;cursor:grab; data-toggle='popover' data-trigger='hover' title='' data-content='Złap tutaj, aby zmienić pozycje tego zadania.' data-original-title='Sortowanie'></span>";
+            result += "</td><td style=padding-right:5px;>"
             result += "<span class=check data-toggle='popover' data-trigger='hover' title='' data-content='Oznacz zadanie jako wykonane. Podwójne kliknięcie gdziekolwiek na zadanie spowoduje oznaczenie go jako aktualnie wykonywane.' data-original-title='Zadanie niewykonane'></span>";
-        }
-        if (e["childs"] !== false)
-            result += "<span class='glyphicon " + (!e["expand"] ? "glyphicon-chevron-down" : "glyphicon-chevron-up") + " cursorClick expand' data-state=" + e["expand"] + "	style=float:left;padding-right:5px;></span>";
-        result += "<input type=text " + (e["childs"] ? "DISABLED" : "") + " placeholder='czas' class='form-control hours' value='" + e["period"] + "' style=width:40px;float:left;padding:0px;height:25px; data-toggle='popover' data-trigger='hover' title='' data-content='Wpisz tutaj czas, który zostanie/został przeznaczony na to zadanie i zatwierdź ENTER. ' data-original-title='Czas przeznaczony na zadanie'>"
 
-        result += "<textarea " + (USER != e["owner"] || e['status'] == "OFF_HARD" ? "DISABLED" : "") + ' class="editable" style="font-size:small" >' + e['desc'] + "</textarea>";
+        }
+        result += "</td>"
+
+        result += "<td>"
+        result += "<input type=text " + (e["childs"] ? "DISABLED" : "") + " placeholder='czas' class='form-control hours' value='" + e["period"] + "' style=width:40px;float:left;padding:0px; data-toggle='popover' data-trigger='hover' title='' data-content='Wpisz tutaj czas, który zostanie/został przeznaczony na to zadanie i zatwierdź ENTER. ' data-original-title='Czas przeznaczony na zadanie'>"
+        result += "</td>"
+        result += "<td style=width:95%;>"
+        result += "&nbsp;<textarea " + (USER != e["owner"] || e['status'] == "OFF_HARD" ? "DISABLED" : "") + ' class="editable" style="font-size:small" >' + e['desc'] + "</textarea>";
+        result += "</td>"
+        result += "<td>"
         result += `<div class="dropdown" style=display:inline;float:right;>
-		  <span class="glyphicon glyphicon glyphicon-menu-hamburger cursorClick" style="vertical-align: top;float:right;" data-toggle="dropdown"></span>
+		  <span class="glyphicon glyphicon glyphicon-menu-hamburger cursorClick" style="vertical-align: top;padding-right:5px;" data-toggle="dropdown"></span>
 		  <ul class="dropdown-menu dropdown-menu-right">
 		  <li><a href=` + BASE_URL + `index.php?_route=UrlAction_TaskManager&ID_PROBLEM=` + e['id'] + `>Szczegóły</a></li>`;
-        if (!ret)
-            result += '<li><p style="cursor:pointer;padding:3px 20px;" class=delTask>Usuń</p></li>';
+        //if (ret === false)
+        //result += '<li><p style="cursor:pointer;padding:3px 20px;" class=delTask>Usuń</p></li>';
         result += "</ul></div>";
+        result += "</td>"
+        result += "</tr>"
         if (e["childs"] !== false && e["childs"] !== true && e["expand"]) {
-            result += "<ul class=notSortable >";
-            result += renderTasks(e["childs"], true)
-            result += "</ul>";
+            result += renderTasks(e["childs"], e["id"], depth + 1)
         }
-        result += "</li>"
+
         //result += ((e['owner'] != USER) ? " <span class='glyphicon glyphicon-user user' title='Zlecone przez inną osobę'></span>" : "") + "</li>";
         if (e['percent'] == "100%") {
             resultDone += result;
         } else {
             resultActive += result;
         }
-		updateProgress()
+        updateProgress()
     });
-
-
+    if (ret !== false) return resultActive + resultDone;
     resultActive += "<div class=clearfix></div>";
     resultDone += "<div class=clearfix></div>";
-    if (ret) return resultActive + resultDone;
-
     $("#sortable").html(resultActive);
     $("#doneList").html(resultDone);
 }
@@ -914,7 +923,6 @@ function loadStats() {
 }
 
 function renderTaskManager() {
-
     $("#right").append("<div class=taskList ></div>");
     if (false) { // TODO
         $("#right").append("<h2>Statystyki</h2><div class=stats></div>");
@@ -936,22 +944,15 @@ function renderTaskManager() {
             vertical: 'bottom'
         }
     })
-    $('.taskList').append(picker);    
-	$(".taskList").append('<div id="add" style="font-size:small;">' +
+    $('.taskList').append(picker);
+    $(".taskList").append('<div id="add" style="font-size:small;">' +
         '<span class="glyphicon glyphicon-plus addIco" style="padding-top:3px;margin-left:65px;"></span> ' +
         '<textarea class="eInput" style="font-size:small" data-toggle="popover" data-trigger="hover" title="" data-content="Wpisz treść i zatwierdź <b>ENTER</b>.<br> Użyj tagów:<br> @nazwauzytkownika -> wykonawca <br> @RRRR-MM-DD -> Termin wykonania <br> np. <br>`@janKowalski @2017-03-12 Nadać przesyłkę`" data-html="true" data-original-title="Dodaj zadanie" data-placement="top" id="datepicker" placeholder="Dodaj zadanie"></textarea>' +
         '<div class="clearfix"></div>' + '</div>');
-		
-	$(".taskList").append("<ul id='sortable'></ul>");
 
-    // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Zaprojektować podstawowy layout skryptu</div></li>");
-    // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Stworzyć tasklistę, dodać przesuwaunie i flagowanie</div></li>");
-    // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Dodać po lewej stronie formularz</div></li>");
-    // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Połączyć z API</div></li>");
-
-
-    $(".taskList").append("<div id=showMore >Pokaż wykonane zadania <span class='glyphicon glyphicon-chevron-down'></span></div>");
-    $(".taskList").append("<ul id='doneList'></ul>");
+    $(".taskList").append("<table style='width:100%' id='sortable'></table>");
+    $(".taskList").append("<div id=showMore style=border-top-style:solid;border-bottom-style:solid;border-width:2px;>Pokaż wykonane zadania <span class='glyphicon glyphicon-chevron-down'></span></div>");
+    $(".taskList").append("<table style='width:100%' id='doneList'></table>");
     var link;
 
     $("#doneList").hide();
@@ -975,4 +976,4 @@ function renderTaskManager() {
         $('.eInput').autosize();
     });
     render();
-}
+}