瀏覽代碼

Ajuste de persistencia do campo preview.
Melhoria no modal, funcionalidade da telca space

Ranghetti 4 周之前
父節點
當前提交
de65a43d7a
共有 1 個文件被更改,包括 30 次插入16 次删除
  1. 30 16
      src/routes/cpr/monitoring/+page.svelte

+ 30 - 16
src/routes/cpr/monitoring/+page.svelte

@@ -305,18 +305,20 @@
 
     createLoading = true;
     try {
+      const createPayload = {
+        cpr_id: cprId,
+        preview: createPreview === true,
+        description,
+        link
+      };
+
       const res = await fetch(`${apiUrl}/cpr/monitoring/create`, {
         method: 'POST',
         headers: {
           'content-type': 'application/json',
           Authorization: `Bearer ${token}`
         },
-        body: JSON.stringify({
-          cpr_id: cprId,
-          preview: Boolean(createPreview),
-          description,
-          link
-        })
+        body: JSON.stringify(createPayload)
       });
 
       const raw = await res.text();
@@ -368,18 +370,20 @@
 
     editLoading = true;
     try {
+      const editPayload = {
+        id,
+        preview: editPreview === true,
+        description,
+        link
+      };
+
       const res = await fetch(`${apiUrl}/cpr/monitoring/update`, {
         method: 'POST',
         headers: {
           'content-type': 'application/json',
           Authorization: `Bearer ${token}`
         },
-        body: JSON.stringify({
-          id,
-          preview: Boolean(editPreview),
-          description,
-          link
-        })
+        body: JSON.stringify(editPayload)
       });
 
       if (res.status === 204) {
@@ -554,10 +558,15 @@
             if (e.target === e.currentTarget && !createLoading) closeCreate();
           }}
           on:keydown={(e) => {
-            if ((e.key === 'Escape' || e.key === 'Enter' || e.key === ' ') && !createLoading) closeCreate();
+            if (e.key === 'Escape' && !createLoading) closeCreate();
           }}
         >
-          <div class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg w-full max-w-2xl p-6" role="dialog" aria-modal="true">
+          <div
+            class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg w-full max-w-2xl p-6"
+            role="dialog"
+            aria-modal="true"
+            on:keydown|stopPropagation
+          >
             <div class="flex items-center justify-between mb-4">
               <h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100">Criar registro</h4>
               <button type="button" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200" on:click={() => (!createLoading ? closeCreate() : null)}>✕</button>
@@ -646,10 +655,15 @@
             if (e.target === e.currentTarget && !editLoading) closeEdit();
           }}
           on:keydown={(e) => {
-            if ((e.key === 'Escape' || e.key === 'Enter' || e.key === ' ') && !editLoading) closeEdit();
+            if (e.key === 'Escape' && !editLoading) closeEdit();
           }}
         >
-          <div class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg w-full max-w-2xl p-6" role="dialog" aria-modal="true">
+          <div
+            class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg w-full max-w-2xl p-6"
+            role="dialog"
+            aria-modal="true"
+            on:keydown|stopPropagation
+          >
             <div class="flex items-center justify-between mb-4">
               <h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100">Editar registro #{editId}</h4>
               <button type="button" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200" on:click={() => (!editLoading ? closeEdit() : null)}>✕</button>