|
@@ -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>");
|
|
|
});
|
|
|
|
|
|
}
|