refactor(point): fold binding into edit action
This commit is contained in:
parent
e55c1d5efb
commit
6cdc51a249
|
|
@ -59,7 +59,7 @@
|
|||
<th style="width:10%">质量</th>
|
||||
<th style="width:18%">设备/角色</th>
|
||||
<th style="width:21%">更新时间</th>
|
||||
<th style="width:7%"></th>
|
||||
<th style="width:120px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="pointList"></tbody>
|
||||
|
|
|
|||
|
|
@ -225,10 +225,11 @@ export async function loadPoints() {
|
|||
selectCell.appendChild(checkbox);
|
||||
|
||||
const actionCell = tr.lastElementChild;
|
||||
const bindBtn = document.createElement("button");
|
||||
bindBtn.className = "secondary";
|
||||
bindBtn.textContent = "Bind";
|
||||
bindBtn.addEventListener("click", (event) => {
|
||||
actionCell.className = "point-actions";
|
||||
const editBtn = document.createElement("button");
|
||||
editBtn.className = "secondary";
|
||||
editBtn.textContent = "Edit";
|
||||
editBtn.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
openPointBinding(point);
|
||||
});
|
||||
|
|
@ -243,7 +244,7 @@ export async function loadPoints() {
|
|||
});
|
||||
});
|
||||
|
||||
actionCell.append(bindBtn, deleteBtn);
|
||||
actionCell.append(editBtn, deleteBtn);
|
||||
dom.pointList.appendChild(tr);
|
||||
|
||||
state.pointEls.set(point.id, {
|
||||
|
|
@ -266,6 +267,18 @@ export async function loadPoints() {
|
|||
export function openPointBinding(point) {
|
||||
dom.bindingPointId.value = point.id;
|
||||
dom.bindingPointName.value = point.name || "";
|
||||
dom.bindingPointName.disabled = false;
|
||||
const modalTitle = dom.pointBindingModal.querySelector("h3");
|
||||
if (modalTitle) {
|
||||
modalTitle.textContent = "Edit Point";
|
||||
}
|
||||
if (dom.clearPointBindingBtn) {
|
||||
dom.clearPointBindingBtn.textContent = "Clear Equipment";
|
||||
}
|
||||
const saveButton = dom.pointBindingForm?.querySelector('button[type="submit"]');
|
||||
if (saveButton) {
|
||||
saveButton.textContent = "Save";
|
||||
}
|
||||
renderBindingEquipmentOptions(point.equipment_id || "");
|
||||
dom.bindingSignalRole.innerHTML = renderRoleOptions(point.signal_role || "");
|
||||
dom.pointBindingModal.classList.remove("hidden");
|
||||
|
|
@ -277,6 +290,7 @@ export async function savePointBinding(event) {
|
|||
await apiFetch(`/api/point/${dom.bindingPointId.value}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
name: dom.bindingPointName.value.trim() || null,
|
||||
equipment_id: dom.bindingEquipmentId.value || null,
|
||||
signal_role: dom.bindingSignalRole.value || null,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -300,6 +300,20 @@ button.danger:hover { background: var(--danger-hover); }
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.data-table td.point-actions {
|
||||
overflow: visible;
|
||||
text-overflow: clip;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.point-actions {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.point-actions button + button {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.data-table tbody tr {
|
||||
transition: background 0.1s;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue