Skip to content

Commit

Permalink
Fixes #26075: Trying to save a group with empty criteria removes all …
Browse files Browse the repository at this point in the history
…entries
  • Loading branch information
clarktsiory committed Dec 19, 2024
1 parent 36eacd2 commit 742be8e
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class SearchNodeComponent(
}
query = Some(Query(rType, composition, transform, lines.toList))
initUpdate = false
ajaxCriteriaRefresh(isGroupsPage)
ajaxCriteriaRefresh(isGroupsPage, preventSave = true)
}

def removeLine(i: Int): JsCmd = {
Expand All @@ -190,7 +190,7 @@ class SearchNodeComponent(
query = Some(Query(rType, composition, transform, lines.toList))
}
initUpdate = false
ajaxCriteriaRefresh(isGroupsPage)
ajaxCriteriaRefresh(isGroupsPage, preventSave = true)
}

def processForm(isGroupPage: Boolean): JsCmd = {
Expand Down Expand Up @@ -220,16 +220,16 @@ class SearchNodeComponent(
srvList = Empty
searchFormHasError = true
}
ajaxCriteriaRefresh(isGroupsPage) & ajaxGridRefresh(isGroupsPage)
ajaxCriteriaRefresh(isGroupsPage, preventSave = false) & gridResult(isGroupPage)
// ajaxGroupCriteriaRefresh & ajaxNodesTableRefresh()
}

/**
* Refresh the query parameter part
*/
def ajaxCriteriaRefresh(isGroupPage: Boolean): JsCmd = {
def ajaxCriteriaRefresh(isGroupPage: Boolean, preventSave: Boolean): JsCmd = {
lines.clear()
SetHtml("SearchForm", displayQuery(content, isGroupPage)) & activateButtonOnChange()
SetHtml("SearchForm", displayQuery(content, isGroupPage)) & activateButtonOnChange(preventSave)
}
def displayQueryLine(cl: CriterionLine, index: Int, addRemove: Boolean): NodeSeq = {

Expand Down Expand Up @@ -386,7 +386,7 @@ class SearchNodeComponent(
* @return
*/
def ajaxGridRefresh(isGroupPage: Boolean): JsCmd = {
activateButtonOnChange() &
activateButtonOnChange(preventSave = false) &
gridResult(isGroupPage)
}

Expand Down Expand Up @@ -418,7 +418,7 @@ class SearchNodeComponent(
* When we change the form, we can update the query
* @return
*/
def activateButtonOnChange(): JsCmd = {
def activateButtonOnChange(preventSave: Boolean): JsCmd = {
// If saved button id is not defined do not disable save button
val disableGridOnChange: JsCmd = if (saveButtonId != "") {
JE.JsRaw(
Expand All @@ -428,7 +428,8 @@ class SearchNodeComponent(
} else {
Noop
}
onSearchCallback(searchFormHasError, query) & disableGridOnChange
val disableSave = searchFormHasError || preventSave
onSearchCallback(disableSave, query) & disableGridOnChange
}

/**
Expand Down

0 comments on commit 742be8e

Please sign in to comment.