Przeglądaj źródła

Added KeineAngabe to product cote for assignments

Manuel Gall 3 lat temu
rodzic
commit
3390f2acf9
4 zmienionych plików z 76 dodań i 33 usunięć
  1. 4 0
      server/json/ProductCode.json
  2. 26 1
      ui/TransformProductCode.php
  3. 44 30
      ui/js/assignment.js
  4. 2 2
      ui/js/design.js

+ 4 - 0
server/json/ProductCode.json

@@ -63,6 +63,7 @@
       "types": [
         "",
         "*",
+        "KeineAngabeZi",
         "31",
         "36",
         "41",
@@ -99,6 +100,7 @@
       "types": [
         "",
         "*",
+        "KeineAngabeKf",
         "X1K",
         "ATA",
         "Blind",
@@ -111,6 +113,7 @@
       "types": [
         "",
         "*",
+        "KeineAngabePf",
         "FZG",
         "FAP",
         "FLU",
@@ -123,6 +126,7 @@
       "types": [
         "",
         "*",
+        "KeineAngabeVa",
         "AV05",
         "AV10",
         "AV15"

+ 26 - 1
ui/TransformProductCode.php

@@ -33,7 +33,7 @@
       foreach($json->pattern as $node){
         foreach($node->types as $type){
           if($productarray[$i] == $type && $type != "*"){
-              $asocarray[$node->abk] = $productarray[$i];
+            $asocarray[$node->abk] = $productarray[$i];
           }
         }
       }
@@ -50,6 +50,31 @@
     
   }
   
+  if(!array_key_exists("Pf", $asocarray)){
+    $asocarray["Pf"] = "KeineAngabePf";
+  }
+  if(!array_key_exists("Va", $asocarray)){
+    $asocarray["Va"] = "KeineAngabeVa";
+  }
+  if(!array_key_exists("Kf", $asocarray)){
+    $asocarray["Kf"] = "KeineAngabeKf";
+  }
+  if(!array_key_exists("Zi", $asocarray)){
+    $asocarray["Zi"] = "KeineAngabeZi";
+  }
+  
+  if($asocarray["Pf"] == ""){
+    $asocarray["Pf"] = "KeineAngabePf";
+  }
+  if($asocarray["Va"] == ""){
+    $asocarray["Va"] = "KeineAngabeVa";
+  }
+  if($asocarray["Kf"] == ""){
+    $asocarray["Kf"] = "KeineAngabeKf";
+  }
+  if($asocarray["Zi"] == ""){
+    $asocarray["Zi"] = "KeineAngabeZi";
+  }
   
   echo json_encode($asocarray);
 ?>

+ 44 - 30
ui/js/assignment.js

@@ -1,4 +1,4 @@
-
+var productcodestructure = {};
 
 function createAssignmentForm(assID, url){
   
@@ -33,48 +33,39 @@ function createAssignmentForm(assID, url){
     
     
     //Show Assignments
-    
     $.getJSON( "../server/assignments/" + assID, function( data ) {
-      
-      
-      console.log(data);
-    
-      $.each( data, function(i, alldata){
-      
+      $.each( data, function(curstation, alldata){
       
         var clonePattern = $("#copyAssignmentTable").clone();
         $('td',clonePattern).text("");
-        $('[data-class=station]',clonePattern).text(i);
-        $('#assignmentdetaillist').append(clonePattern);
-        
-        
+        $('[data-class=station]',clonePattern).text(curstation);
         $('#assignmentdetaillist').append(clonePattern);
       
         $.each( alldata, function(i, pattern){
           var clonePattern = $("#copyAssignmentTable").clone();
           $('td',clonePattern).text("");
           
-          
+          var searchpattern = productcodestructure;
           $.each( pattern, function(i, item){
-            console.log(i);
             $('[data-class=part' + i + ']',clonePattern).text(item);
+            if(i != "TEXT"){
+              searchpattern[i] = item;
+            }
           });
           $('[data-class=delete]',clonePattern).html('<a href="javascript:deleteSingleAssignment(' + assID +', ' + i + ');">[⨯]</a>');
           
+          arr = jQuery.map( searchpattern, function( n, i ) {
+            return ( n + "." );
+          });
+          
+          $('[data-class=search]',clonePattern).html('<a href="javascript:newSearchAssignment(\'' + curstation + '\', \'' + arr.join( "" ) +'\', \'' + pattern.TEXT + '\' );">[?]</a>');
+          
+          
           $('#assignmentdetaillist').append(clonePattern);
         });
-        
-        
-        
-        
-        
       });
     });
-    
   }
-  
-  
-  
   $('#assignment_details').css("display", "block");
 }
 
@@ -91,7 +82,9 @@ function getImgText(imgtext){
 function submitAssignment(newassignment){
   
   var obj = new Object();
+  var skipasscreationform = false;
   if(typeof newassignment !== "undefined"){
+    skipasscreationform = true;
     obj = newassignment;
   }
   else{
@@ -101,7 +94,7 @@ function submitAssignment(newassignment){
     abk.forEach(function(item){
       if(typeof $("#FormPatternAssignment_Form_" + item).val() !== 'undefined' && typeof $("#FormPatternAssignment_Form_" + item).val() !== 'undefined'){
         //if($("#FormPatternAssignment_Form_" + item).find(":selected").text() != ""){
-          obj.parts[item] = $("#FormPatternAssignment_Form_" + item).find(":selected").text();
+        obj.parts[item] = $("#FormPatternAssignment_Form_" + item).find(":selected").text();
         //}
       }
     });
@@ -114,7 +107,10 @@ function submitAssignment(newassignment){
 		headers: {"content-id": "list"},
     contentType: "application/json",
     url: "../server/assignments/",
-    success: function(res) {
+    success: function(res) {     
+      if(!skipasscreationform){
+        createAssignmentForm(res.id, $('#addExternalImageAssignment').val())
+      }
     },
     error: function (request, status, error) {
       alert(request.responseText + status + error);
@@ -128,7 +124,7 @@ function deleteAssignment(assignmentID) { //Delete From DB
       type: "DELETE",
       url: "../server/assignments/" + assignmentID,
       success: function(res) { 
-        location.reload();
+        initAssignment();
       }
     });
   }
@@ -139,24 +135,37 @@ function deleteSingleAssignment(assignmentID, patternID) { //Delete From DB
     $.ajax({
       type: "DELETE",
       url: "../server/assignments/" + assignmentID + "/" + patternID,
-      success: function(res) { 
-        location.reload();
+      success: function(res) {
+        initAssignment();
+        createAssignmentForm(assignmentID, $('#addExternalImageAssignment').val())
       }
     });
   }
 }
 
+function newSearchAssignment(station, pattern, searchtext){
+  console.log(station + pattern + searchtext);
+  $('#searchAssingmentStation').val(station);
+  $('#searchAssingmentPattern').val(pattern);
+  $('#searchAssingmentText').val(searchtext);
+  searchAssignmentForm();
+}
+
+
 function searchAssignmentForm(){
   
   $('#assignmentslist tr').css('background-color', 'white');
   $.getJSON( "../server/assignments/search/?pattern=" + $('#searchAssingmentPattern').val() + "&station=" + $('#searchAssingmentStation option:selected').text() + "&text=" + $('#searchAssingmentText').val(), function( data ) {  
-    console.log(data);
-    $('tr[name="' + data +'"]').css('background-color', '#73d216')   // Matches exactly 'tcol1'
+    $.each( data, function(i, item){
+      $('tr[name="' + item +'"]').css('background-color', '#73d216')   // Matches exactly 'tcol1'
+    });
+    
 
   });
 }
 
 function initAssignment(){
+  $('#assignmentslist').text("");
   
   $.getJSON( "../server/assignments/", function( data ) {
     $.each( data, function(i, item){
@@ -170,6 +179,9 @@ function initAssignment(){
           $('#assignmentslist').append(clonePattern);
       });
   });
+  
+  $('#searchAssingmentStation').find('option').remove()
+  
   $.ajax({
     type: "GET",
     url: "../server/",
@@ -191,9 +203,11 @@ function initAssignmentTable(){
   $.getJSON( "../server/json/ProductCode.json", function( data ) {
     $.each( data["pattern"], function(i, item){
       $('#assignmentdetaillist tr').append("<td data-class='part"+ item["abk"] +"'>"+ item["abk"] +"</td>");
+      productcodestructure[item["abk"]] = "";
     });
     $('#assignmentdetaillist tr').append("<td data-class='partTEXT'>Text</td>");
     $('#assignmentdetaillist tr').append("<td data-class='delete'>Delete</td>");
+    $('#assignmentdetaillist tr').append("<td data-class='search'>Search</td>");
   });
   
 }

+ 2 - 2
ui/js/design.js

@@ -206,6 +206,8 @@ function getPattern(stationID, patternID){ //Get DB 2 HTML
       url: "../server/"+stationID+ "/" + patternID,
       dataType: "xml",
       success: function(xml) {
+      
+        $('#pattern_description').val($(xml).find('pattern').attr('description'));
         $(xml).find('parts').children().each(function(index){
           /*
           
@@ -259,7 +261,6 @@ function getPattern(stationID, patternID){ //Get DB 2 HTML
           
           $('#pattern').val($(this).attr('value'));
           */
-          $('#pattern_description').val($(this).attr('description'));
         });
       }
     });
@@ -267,7 +268,6 @@ function getPattern(stationID, patternID){ //Get DB 2 HTML
   
   $('#pattern_details').css("display", "block");
   $('#pattern_station').text(stationID);
-  $('#pattern_description').text("");
 	
   //Reset Pattern
   $('#patternInput').text("");