|
@@ -2,21 +2,14 @@
|
|
|
|
|
|
function getAllData(){
|
|
function getAllData(){
|
|
$( "#data" ).empty();
|
|
$( "#data" ).empty();
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
var url_string = window.location.href
|
|
var url_string = window.location.href
|
|
var url = new URL(url_string);
|
|
var url = new URL(url_string);
|
|
if(!url.searchParams.has("display")){
|
|
if(!url.searchParams.has("display")){
|
|
- var urlarray = ["aktivieren","aktivierenPrio","stornieren","moveTop","moveX","move","edit"]
|
|
|
|
|
|
+ var urlarray = ["aktivieren","aktivierenPrio","stornieren","moveTop","moveX","move","move2","edit"]
|
|
}else{
|
|
}else{
|
|
-
|
|
|
|
var urlparams = url.searchParams.get("display").replace("/","");
|
|
var urlparams = url.searchParams.get("display").replace("/","");
|
|
var urlarray = urlparams.split(",");
|
|
var urlarray = urlparams.split(",");
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
if(url.searchParams.has("menu")){
|
|
if(url.searchParams.has("menu")){
|
|
console.log("MENU");
|
|
console.log("MENU");
|
|
menuentries = url.searchParams.get("menu").split(",")
|
|
menuentries = url.searchParams.get("menu").split(",")
|
|
@@ -60,7 +53,7 @@ function getAllData(){
|
|
container = document.getElementById("tablecontent");
|
|
container = document.getElementById("tablecontent");
|
|
entry = document.createElement("tr");
|
|
entry = document.createElement("tr");
|
|
$(entry).attr("id","AddEntry");
|
|
$(entry).attr("id","AddEntry");
|
|
- $(entry).attr("class","tableentry");
|
|
|
|
|
|
+ $(entry).attr("class","tableentryAdd");
|
|
|
|
|
|
|
|
|
|
tableedit = "<td class='addEntry'><a onclick='addEntry()' href='#'>Add</a></td>"
|
|
tableedit = "<td class='addEntry'><a onclick='addEntry()' href='#'>Add</a></td>"
|
|
@@ -95,25 +88,121 @@ function getAllData(){
|
|
$('[name="' + searchkey +'"]').keyup();
|
|
$('[name="' + searchkey +'"]').keyup();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if(url.searchParams.has("sendListBack")){
|
|
if(url.searchParams.has("sendListBack")){
|
|
|
|
+ $('body').append('<a onclick="collectdata2sendBack()" href="#">Sende Liste</a>');
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ //Single move
|
|
|
|
+ if(urlarray.includes("move")){
|
|
|
|
+ $( "#data" ).prepend('<a id="storesortedtablebutton" onclick="storesortedtable()" hidden href="#">Store Table</a>');
|
|
|
|
+ $( "#tablecontent" ).sortable({
|
|
|
|
+ handle: '.handle',
|
|
|
|
+ change: function (event, ui) {
|
|
|
|
+ $( "#storesortedtablebutton" ).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ if(urlarray.includes("move") || urlarray.includes("move")){
|
|
|
|
+ $( "#data" ).prepend('<a id="storesortedtablebutton" onclick="storesortedtable()" hidden href="#">Store Table</a>');
|
|
|
|
+ }
|
|
|
|
+ //move single or multiple items (buttonpress)
|
|
|
|
+ if(urlarray.includes("move")){
|
|
|
|
+ new Sortable(tablecontent, {
|
|
|
|
+ handle: '.handle',
|
|
|
|
+ multiDrag: true, // Enable multi-drag
|
|
|
|
+ selectedClass: 'sortable-selected', // The class applied to the selected items
|
|
|
|
+ fallbackTolerance: 3, // So that we can select items on mobile
|
|
|
|
+ animation: 150,
|
|
|
|
+ avoidImplicitDeselect: false,
|
|
|
|
+
|
|
|
|
+ onSelect: function(/**Event*/evt) {
|
|
|
|
+ $( 'tr[ grouping="' + $(evt.item).attr("grouping") + '"]' ).each(function( index ) {
|
|
|
|
+ console.log( index + ":select " + $( this ).text() );
|
|
|
|
+ Sortable.utils.select($(this)[0]);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ onDeselect: function(/**Event*/evt) {
|
|
|
|
+ $( 'tr[ grouping="' + $(evt.item).attr("grouping") + '"]' ).each(function( index ) {
|
|
|
|
+ console.log( index + ":deselect " + $( this ).text() );
|
|
|
|
+ Sortable.utils.deselect($(this)[0]);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ onEnd: function (/**Event*/evt) { //deselect all on end
|
|
|
|
+ $( 'tr' ).each(function( index ) {
|
|
|
|
+ console.log( index + ": " + $( this ).text() );
|
|
|
|
+ Sortable.utils.deselect($(this)[0]);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ onSort: function (/**Event*/evt) { //on any change show store table button
|
|
|
|
+ $( "#storesortedtablebutton" ).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(urlarray.includes("move2")){
|
|
|
|
+ new Sortable(tablecontent, {
|
|
|
|
+ handle: '.handle2',
|
|
|
|
+ multiDrag: true, // Enable multi-drag
|
|
|
|
+ selectedClass: 'sortable-selected', // The class applied to the selected items
|
|
|
|
+ fallbackTolerance: 3, // So that we can select items on mobile
|
|
|
|
+ animation: 150,
|
|
|
|
+ avoidImplicitDeselect: false,
|
|
|
|
+
|
|
|
|
+ onSelect: function(/**Event*/evt) {
|
|
|
|
+ $( 'tr[ grouping2="' + $(evt.item).attr("grouping2") + '"]' ).each(function( index ) {
|
|
|
|
+ console.log( index + ": " + $( this ).text() );
|
|
|
|
+ Sortable.utils.select($(this)[0]);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ onDeselect: function(/**Event*/evt) {
|
|
|
|
+ $( 'tr[ grouping2="' + $(evt.item).attr("grouping2") + '"]' ).each(function( index ) {
|
|
|
|
+ console.log( index + ": " + $( this ).text() );
|
|
|
|
+ Sortable.utils.deselect($(this)[0]);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ onEnd: function (/**Event*/evt) { //deselect all on end
|
|
|
|
+ $( 'tr' ).each(function( index ) {
|
|
|
|
+ console.log( index + ": " + $( this ).text() );
|
|
|
|
+ Sortable.utils.deselect($(this)[0]);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ onSort: function (/**Event*/evt) { //on any change show store table button
|
|
|
|
+ $( "#storesortedtablebutton" ).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ $( "#tablecontent" ).sortable({
|
|
|
|
+ multiDrag: true, // Enable the plugin
|
|
|
|
+ selectedClass: "sortable-selected", // Class name for selected item
|
|
|
|
+ multiDragKey: null, // Key that must be down for items to be selected
|
|
|
|
+ avoidImplicitDeselect: true, // true - if you don't want to deselect items on outside click
|
|
|
|
+
|
|
|
|
+ // Called when an item is selected
|
|
|
|
+ onSelect: function(/**Event*/ /*evt) {
|
|
|
|
+ evt.item // The selected item
|
|
|
|
+ console.log(evt.item);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // Called when an item is deselected
|
|
|
|
+ onDeselect: function(/**Event*/ /*evt) {
|
|
|
|
+ evt.item // The deselected item
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
|
|
- $('body').append('<a onclick="collectdata2sendBack()" href="#">Sende Liste</a>');
|
|
|
|
|
|
+ //$( "#tablecontent" ).on( "sortstart", function( event, ui ) {console.log("start" + ui.item.html())} );
|
|
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
- /*
|
|
|
|
- new Sortable(document.getElementById('data'),{
|
|
|
|
- handle: '.handle',
|
|
|
|
- animation: 150
|
|
|
|
- });
|
|
|
|
- */
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
-function collectdata2sendBack(){
|
|
|
|
|
|
+function collectdata2sendBack(){
|
|
console.log("sending");
|
|
console.log("sending");
|
|
var sendback = [];
|
|
var sendback = [];
|
|
$('[name="pkvalues"]:visible').each(function(){
|
|
$('[name="pkvalues"]:visible').each(function(){
|
|
@@ -123,26 +212,7 @@ function collectdata2sendBack(){
|
|
sendDataElementBack(sendback)
|
|
sendDataElementBack(sendback)
|
|
}
|
|
}
|
|
|
|
|
|
-//https://www.therogerlab.com/sandbox/pages/how-to-reorder-table-rows-in-javascript?s=0ea4985d74a189e8b7b547976e7192ae.4122809346f6a15e41c9a43f6fcb5fd5
|
|
|
|
-var row;
|
|
|
|
-
|
|
|
|
-function start(){
|
|
|
|
- row = event.target;
|
|
|
|
-}
|
|
|
|
-function dragover(){
|
|
|
|
- var e = event;
|
|
|
|
- e.preventDefault();
|
|
|
|
-
|
|
|
|
- let children= Array.from(e.target.parentNode.parentNode.children);
|
|
|
|
-
|
|
|
|
- if(children.indexOf(e.target.parentNode)>children.indexOf(row))
|
|
|
|
- e.target.parentNode.after(row);
|
|
|
|
- else
|
|
|
|
- e.target.parentNode.before(row);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
function searchtable(key) {
|
|
function searchtable(key) {
|
|
- console.log("AAA");
|
|
|
|
// Declare variables
|
|
// Declare variables
|
|
var input, filter, table, tr, td, i, txtValue;
|
|
var input, filter, table, tr, td, i, txtValue;
|
|
input = document.getElementById("searchtable" +key);
|
|
input = document.getElementById("searchtable" +key);
|
|
@@ -241,6 +311,35 @@ function sendDataElementBack(dataelement, type){
|
|
//deleteDataElement(dataelement.__orderID__)
|
|
//deleteDataElement(dataelement.__orderID__)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//retrieves ID´s in current order and sends back 2 server
|
|
|
|
+//security, in case an id got removed it is not retrieved, in case an id got added it will still be added
|
|
|
|
+//server does the following: looks for ID and sets the order to the current order we sent,
|
|
|
|
+//in case the id is not found nothing happens (entry was removed during sorting by someone else)
|
|
|
|
+//in case another ID is in the db that was added while we sort, the id will remain (maybe at different position)
|
|
|
|
+function storesortedtable(){
|
|
|
|
+
|
|
|
|
+ var alldata = [];
|
|
|
|
+ alldata.entry = entry;
|
|
|
|
+ $( ".tableentry" ).each(function( index ) {
|
|
|
|
+ alldata.push($( this ).attr("id"));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $.LoadingOverlay("show");
|
|
|
|
+
|
|
|
|
+ $.ajax({
|
|
|
|
+ type: "PUT",
|
|
|
|
+ url: location.protocol + '//' + location.host + location.pathname,
|
|
|
|
+ headers: {"content-id": "storesortedtable"},
|
|
|
|
+ contentType: "application/json",
|
|
|
|
+ data: JSON.stringify(alldata),
|
|
|
|
+ success: function(ret) {
|
|
|
|
+ $.LoadingOverlay("hide");
|
|
|
|
+ getAllData();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
function move(from, to){
|
|
function move(from, to){
|
|
@@ -265,13 +364,24 @@ function setSingleData(singleData, urlarray, i = -1, url = ""){
|
|
$(entry).attr("id",singleData.__orderID__);
|
|
$(entry).attr("id",singleData.__orderID__);
|
|
$(entry).attr("class","tableentry");
|
|
$(entry).attr("class","tableentry");
|
|
|
|
|
|
|
|
+ if(urlarray.includes("move")){
|
|
|
|
+ if(url.searchParams.has("group1column")){
|
|
|
|
+ $(entry).attr("grouping","Grp1" + JSON.parse(singleData.alldata)[url.searchParams.get("group1column").replace("/","")]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(urlarray.includes("move2")){
|
|
|
|
+ if(url.searchParams.has("group2column1") & url.searchParams.has("group2column2")){
|
|
|
|
+ $(entry).attr("grouping2","Grp2" + JSON.parse(singleData.alldata)[url.searchParams.get("group2column1").replace("/","")]+ "_" + JSON.parse(singleData.alldata)[url.searchParams.get("group2column2").replace("/","")]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /*
|
|
if(urlarray.includes("move")){
|
|
if(urlarray.includes("move")){
|
|
$(entry).attr("draggable","true");
|
|
$(entry).attr("draggable","true");
|
|
$(entry).attr("ondragstart","start()");
|
|
$(entry).attr("ondragstart","start()");
|
|
$(entry).attr("ondragover","dragover()");
|
|
$(entry).attr("ondragover","dragover()");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -314,9 +424,23 @@ function setSingleData(singleData, urlarray, i = -1, url = ""){
|
|
if(urlarray.includes("moveX")){
|
|
if(urlarray.includes("moveX")){
|
|
tableentry += "<td><a onclick='move(" + singleData.__orderID__ +",7)' href='#'>MovetoX</a></td>"
|
|
tableentry += "<td><a onclick='move(" + singleData.__orderID__ +",7)' href='#'>MovetoX</a></td>"
|
|
}
|
|
}
|
|
|
|
+
|
|
if(urlarray.includes("move")){
|
|
if(urlarray.includes("move")){
|
|
- tableentry += '<td class="handle"><a href="#">⇅</a></td>'
|
|
|
|
|
|
+ var name = "⇅";
|
|
|
|
+ if(url.searchParams.has("group1name")){
|
|
|
|
+ name = url.searchParams.get("group1name").replace("/","")
|
|
|
|
+ }
|
|
|
|
+ tableentry += '<td class="handle"><a href="#">' + name +'</a></td>'
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(urlarray.includes("move2")){
|
|
|
|
+ var name = "⇅";
|
|
|
|
+ if(url.searchParams.has("group2name")){
|
|
|
|
+ name = url.searchParams.get("group2name").replace("/","")
|
|
|
|
+ }
|
|
|
|
+ tableentry += '<td class="handle2"><a href="#">' + name + '</a></td>'
|
|
}
|
|
}
|
|
|
|
+ url.searchParams.get("menu")
|
|
if(urlarray.includes("edit")){
|
|
if(urlarray.includes("edit")){
|
|
tableentry += "<td class='edit'><a onclick='edit(" + singleData.__orderID__ +")' href='#'>Edit</a></td>"
|
|
tableentry += "<td class='edit'><a onclick='edit(" + singleData.__orderID__ +")' href='#'>Edit</a></td>"
|
|
}
|
|
}
|
|
@@ -328,7 +452,7 @@ function setSingleData(singleData, urlarray, i = -1, url = ""){
|
|
tableentry += "<td class='editable'>" + Object.values(JSON.parse(singleData.alldata)).join("</td><td class='editable'>") + "</td>"
|
|
tableentry += "<td class='editable'>" + Object.values(JSON.parse(singleData.alldata)).join("</td><td class='editable'>") + "</td>"
|
|
$(entry).html(tableentry);
|
|
$(entry).html(tableentry);
|
|
|
|
|
|
- $(entry).hide().fadeIn(2000);
|
|
|
|
|
|
+ //$(entry).hide().fadeIn(2000);
|
|
$("#tablecontent tr:last").before(entry);
|
|
$("#tablecontent tr:last").before(entry);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -529,6 +653,7 @@ function init() {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
es.onerror = function() {
|
|
es.onerror = function() {
|
|
|
|
+ es.close();
|
|
reason = 'Server down.';
|
|
reason = 'Server down.';
|
|
clearDocument();
|
|
clearDocument();
|
|
setTimeout(init, 10000);
|
|
setTimeout(init, 10000);
|