Commit b35583f5 authored by Julien Sailly's avatar Julien Sailly
Browse files

feat: improving save and adding user interaction toast

parent 847b2006
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ function drop(event) {
  let draggedItem = document.getElementById(data);
  if(event.target === zoneStart){
    zoneList[draggedItem.parentElement.id.split('zone')[1]].updateCounterNeg(setDropZoneSize(draggedItem));
    console.log("Count" + zoneList[draggedItem.parentElement.id.split('zone')[1]].getCounter());
    //console.log("Count" + zoneList[draggedItem.parentElement.id.split('zone')[1]].getCounter());
    zoneStart.appendChild(draggedItem);
  }else
    if(zoneList[index].getCounter() <= 3 && zoneList[index].getCounter() + setDropZoneSize(draggedItem) <= 3){
@@ -68,7 +68,7 @@ function drop(event) {
        && draggedItem.parentElement !== zoneList[index])
        zoneList[draggedItem.parentElement.id.split('zone')[1]].updateCounterNeg(setDropZoneSize(draggedItem));
      zoneList[index].updateCounterPos(setDropZoneSize(draggedItem));
      console.log("Count" + zoneList[index].getCounter());
      //console.log("Count" + zoneList[index].getCounter());
      event.target.appendChild(draggedItem);
    }
    // else{
@@ -81,7 +81,7 @@ function drop(event) {
function setZoneSize(zone){
  zone.forEach(element => {
    element.childNodes.forEach(elements => {
      console.log(elements);
      //console.log(elements);
      if(elements.id.split(',')[1] === 'PB')
        zoneList[element.id.split('zone')[1] ].updateCounterPos(2);
      else
@@ -116,6 +116,7 @@ addPalanque.addEventListener("click", function(){
  zoneList.push(new DropZoneClass(countZone));
  DropZone.appendChild(palanque);
  countZone++;
  //console.log(zoneList);
});

removePalanque.addEventListener("click", function(){
@@ -149,11 +150,11 @@ async function getDiver(ds_code){
}

function proccessDiverData(data){
  console.log(data);
  //console.log(data);
  for(let i = 0; i < data.length; i++){
    countDiver++;
    let diver = document.createElement("div");
    diver.setAttribute("class", "w-full h-8 border rounded p-1 m-1 bg-gray-300");
    diver.setAttribute("class", "h-8 border rounded p-1 m-1 bg-gray-300");
    diver.setAttribute("id", 'item' + data[i].US_ID +',' + data[i].PRE_CODE + ',E' + data[i].US_TEACHING_LEVEL + ',' + data[i].US_ID);
    diver.setAttribute("draggable", "true");
    diver.setAttribute("ondragstart", "drag(event)");
@@ -186,7 +187,6 @@ function validateAllCombination(){
        for(let j = 0; j < children.length; j++){
          if(children[j].id.split(',')[1] === 'PA-60-GP'){
            counterCheck++;
            if(element.style.backgroundColor === 'rgb(254 202 202)')
            element.style.backgroundColor = 'rgb(229 231 235)';
            return true;
          }
@@ -200,7 +200,6 @@ function validateAllCombination(){
              let targetItemsSplit2 = children[j].id.split(',')[2];
              if(validatePalanqueCombinate[targetItemsSplit].includes(targetItemsSplit2)){
                counterCheck++;
                if(element.style.backgroundColor === 'rgb(254 202 202)')
                element.style.backgroundColor = 'rgb(229 231 235)';
                return true;
              }
@@ -269,6 +268,7 @@ function sendPalanque() {
        console.log("Request successful");
        const responseData = JSON.parse(xhr.responseText);
        console.log("Additional Data:", responseData.additionalData);
        document.getElementById(("toast-success")).classList.remove("hidden");
      } else {
        const responseData = JSON.parse(xhr.responseText);
        console.error("Request failed", responseData.errData);
@@ -286,6 +286,7 @@ function fillZoneWithAlreadyExistingPalanque(diverList) {
      let zone = document.getElementById("zone" + dgNumber);
      if (zone) {
        zone.appendChild(diver);
        zoneList[dgNumber].updateCounterPos(setDropZoneSize(diver));
        if(zoneStart.contains(diver))
          zoneStart.removeChild(diver);
      }else{
@@ -295,10 +296,13 @@ function fillZoneWithAlreadyExistingPalanque(diverList) {
        palanque.setAttribute("ondrop", "drop(event)");
        palanque.setAttribute("ondragover", "allowDrop(event)");
        zoneList.push(new DropZoneClass(dgNumber));
        zoneList[dgNumber].updateCounterPos(setDropZoneSize(diver));
        DropZone.appendChild(palanque);
        palanque.appendChild(diver);
        if(zoneStart.contains(diver))
        if(zoneStart.contains(diver)){
            zoneStart.removeChild(diver);
        }

        countZone++;
      }
    }
+27 −3
Original line number Diff line number Diff line
@@ -73,12 +73,36 @@ class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">

            </div>

            <div class="my-3 text-center">
                <button type='button' id="addPal" class="mt-1 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Ajouter une palanquée</button>
            <div class="my-3 flex justify-center gap-2">
                <button type='button' id="removePal" class="mt-1 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6  h-6">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14" />
                    </svg>
                </button>
                <button type='button' id="validatePal" class="mt-1 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Valider</button>
                <button type='button' id="removePal" class="mt-1 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Supprimer une palanquée</button>
                <button type='button' id="addPal" class="mt-1 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
                    </svg>
                </button>
            </div>
        </div>
    </div>

    <div id="toast-success" class="hidden fixed right-8 bottom-8 flex items-center w-full max-w-xs p-4 mb-4 text-gray-500 bg-white rounded-lg shadow" role="alert">
        <div class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg">
            <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
                <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
            </svg>
            <span class="sr-only">Check icon</span>
        </div>
        <div class="ms-3 text-sm font-normal">Enregistrement de la palanquée effectué</div>
        <button type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8" data-dismiss-target="#toast-success" aria-label="Close">
            <span class="sr-only">Close</span>
            <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
            </svg>
        </button>
    </div>
</x-layout>
<script src=" {{ asset('js/Palanque/manualPalanque.js') }} "></script>