Skip to content

Commit

Permalink
Merge branch 'branches/rudder/8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins CI committed Oct 23, 2023
2 parents 8bf4956 + 91ebbab commit d2da4ff
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,16 @@ object SearchNodeComponent {
}

def setIsEnableFor(comparator: String, valueEltId: String): JsCmd = {
val e = OrderedComparators.comparatorForString(comparator) match {
val e = isComparatorHasValue(comparator)
if (e) SetExp(ElemById(valueEltId, "disabled"), JsFalse)
else SetExp(ElemById(valueEltId, "disabled"), JsTrue)
}

def isComparatorHasValue(comparator: String): Boolean = {
OrderedComparators.comparatorForString(comparator) match {
case None => true
case Some(comp) => comp.hasValue
}
if (e) SetExp(ElemById(valueEltId, "disabled"), JsFalse)
else SetExp(ElemById(valueEltId, "disabled"), JsTrue)
}

def updateCompAndValue(
Expand Down Expand Up @@ -507,6 +511,18 @@ object SearchNodeComponent {
"""))
}

def updateValue(
comparator: String,
valueEltId: String
): JsCmd = {
val update = {
if (isComparatorHasValue(comparator)) Noop
else SetExp(ElemById(valueEltId, "value"), "")
}
setIsEnableFor(comparator, valueEltId) &
update
}

def replaceAttributes(func: String => Any)(ajaxParam: String): JsCmd = {
parseAttrParam(ajaxParam) match {
case None => Alert("Can't parse for attribute: " + ajaxParam)
Expand Down Expand Up @@ -539,7 +555,7 @@ object SearchNodeComponent {
def replaceValue(ajaxParam: String): JsCmd = { // elementId:String, comp:String, oldValue:String) : JsCmd = {
parseValParam(ajaxParam) match {
case None => Alert("Can't parse for value: " + ajaxParam)
case Some((c_val, v_eltid)) => setIsEnableFor(c_val, v_eltid)
case Some((c_val, v_eltid)) => updateValue(c_val, v_eltid)
}
}

Expand Down

0 comments on commit d2da4ff

Please sign in to comment.