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:10%">质量</th>
|
||||||
<th style="width:18%">设备/角色</th>
|
<th style="width:18%">设备/角色</th>
|
||||||
<th style="width:21%">更新时间</th>
|
<th style="width:21%">更新时间</th>
|
||||||
<th style="width:7%"></th>
|
<th style="width:120px"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="pointList"></tbody>
|
<tbody id="pointList"></tbody>
|
||||||
|
|
|
||||||
|
|
@ -225,10 +225,11 @@ export async function loadPoints() {
|
||||||
selectCell.appendChild(checkbox);
|
selectCell.appendChild(checkbox);
|
||||||
|
|
||||||
const actionCell = tr.lastElementChild;
|
const actionCell = tr.lastElementChild;
|
||||||
const bindBtn = document.createElement("button");
|
actionCell.className = "point-actions";
|
||||||
bindBtn.className = "secondary";
|
const editBtn = document.createElement("button");
|
||||||
bindBtn.textContent = "Bind";
|
editBtn.className = "secondary";
|
||||||
bindBtn.addEventListener("click", (event) => {
|
editBtn.textContent = "Edit";
|
||||||
|
editBtn.addEventListener("click", (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
openPointBinding(point);
|
openPointBinding(point);
|
||||||
});
|
});
|
||||||
|
|
@ -243,7 +244,7 @@ export async function loadPoints() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
actionCell.append(bindBtn, deleteBtn);
|
actionCell.append(editBtn, deleteBtn);
|
||||||
dom.pointList.appendChild(tr);
|
dom.pointList.appendChild(tr);
|
||||||
|
|
||||||
state.pointEls.set(point.id, {
|
state.pointEls.set(point.id, {
|
||||||
|
|
@ -266,6 +267,18 @@ export async function loadPoints() {
|
||||||
export function openPointBinding(point) {
|
export function openPointBinding(point) {
|
||||||
dom.bindingPointId.value = point.id;
|
dom.bindingPointId.value = point.id;
|
||||||
dom.bindingPointName.value = point.name || "";
|
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 || "");
|
renderBindingEquipmentOptions(point.equipment_id || "");
|
||||||
dom.bindingSignalRole.innerHTML = renderRoleOptions(point.signal_role || "");
|
dom.bindingSignalRole.innerHTML = renderRoleOptions(point.signal_role || "");
|
||||||
dom.pointBindingModal.classList.remove("hidden");
|
dom.pointBindingModal.classList.remove("hidden");
|
||||||
|
|
@ -277,6 +290,7 @@ export async function savePointBinding(event) {
|
||||||
await apiFetch(`/api/point/${dom.bindingPointId.value}`, {
|
await apiFetch(`/api/point/${dom.bindingPointId.value}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
name: dom.bindingPointName.value.trim() || null,
|
||||||
equipment_id: dom.bindingEquipmentId.value || null,
|
equipment_id: dom.bindingEquipmentId.value || null,
|
||||||
signal_role: dom.bindingSignalRole.value || null,
|
signal_role: dom.bindingSignalRole.value || null,
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,20 @@ button.danger:hover { background: var(--danger-hover); }
|
||||||
white-space: nowrap;
|
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 {
|
.data-table tbody tr {
|
||||||
transition: background 0.1s;
|
transition: background 0.1s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue