editRule function

Last updated: 2026-03-04T23:21:38.433Z

Metrics

LOC: 37 Complexity: 6 Params: 1

Signature

editRule(rule: FieldRule): : void

Source Code

function editRule(rule: FieldRule): void {
  currentEditingRuleId = rule.id;

  (document.getElementById("rule-url") as HTMLInputElement).value =
    rule.urlPattern;
  (document.getElementById("rule-selector") as HTMLInputElement).value =
    rule.fieldSelector;
  (document.getElementById("rule-field-name") as HTMLInputElement).value =
    rule.fieldName || "";
  (document.getElementById("rule-fixed") as HTMLInputElement).value =
    rule.fixedValue || "";
  (document.getElementById("rule-priority") as HTMLInputElement).value = String(
    rule.priority,
  );

  // Setar os valores nos SearchableSelects
  ruleTypeSelect?.setValue(rule.fieldType);
  ruleGeneratorSelect?.setValue(rule.generator);
  setTimeout(() => {
    updateRuleParamsSection(rule.generatorParams);
  }, 0);

  // Scroll to form
  const form = document.querySelector(".card:last-of-type") as HTMLElement;
  if (form) form.scrollIntoView({ behavior: "smooth" });

  // Update button state
  const btn = document.getElementById("btn-save-rule");
  const cancelBtn = document.getElementById("btn-cancel-rule");
  if (btn) {
    btn.textContent = t("btnUpdateRule");
    btn.dataset.editing = "true";
  }
  if (cancelBtn) {
    cancelBtn.style.display = "block";
  }
}

Dependencies (Outgoing)

graph LR editRule["editRule"] updateRuleParamsSection["updateRuleParamsSection"] editRule -->|calls| updateRuleParamsSection style editRule fill:#dbeafe,stroke:#2563eb,stroke-width:2px click editRule "238046fb2c80772c.html" click updateRuleParamsSection "40c364fb8f9a0ec0.html"
TargetType
updateRuleParamsSection calls

Impact (Incoming)

graph LR editRule["editRule"] loadRules["loadRules"] loadRules -->|calls| editRule style editRule fill:#dbeafe,stroke:#2563eb,stroke-width:2px click editRule "238046fb2c80772c.html" click loadRules "9993895f2b3163a1.html"
SourceType
loadRules calls