Skip to content

Commit

Permalink
Fixes #3465 : Improve wide/tall popup management
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Apr 15, 2013
1 parent ef421c1 commit 8736b66
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class AsyncDeployment extends CometActor with CometListener with Loggable {
}

private[this] def showPendingPopup : JsCmd = (
JsRaw("createPopup('%s', 150, 850)".format(pendingPopupHtmlId)) &
JsRaw(s"createPopup('${pendingPopupHtmlId}')") &
eventList.initJs(gridName)

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ class DirectiveEditForm(
private[this] def clone(): JsCmd = {
SetHtml(CreateCloneDirectivePopup.htmlId_popup,
newCreationPopup(technique, activeTechnique)) &
JsRaw(""" createPopup("%s",300,400); """
.format(CreateCloneDirectivePopup.htmlId_popup))
JsRaw(s""" createPopup("${CreateCloneDirectivePopup.htmlId_popup}"); """)
}

////////////// Callbacks //////////////
Expand All @@ -225,12 +224,12 @@ class DirectiveEditForm(
formTracker.addFormError(error("The form contains some errors, please correct them."))
showErrorNotifications()
}

private[this] def onNothingToDo() : JsCmd = {
formTracker.addFormError(error("There are no modification to save."))
showErrorNotifications()
}

private[this] def showErrorNotifications() : JsCmd = {
onFailureCallback() & Replace("editForm", showDirectiveForm) &
JsRaw("""scrollToElement("notifications");""")
Expand Down Expand Up @@ -415,7 +414,7 @@ class DirectiveEditForm(
, parentFormTracker = Some(formTracker)
)
} else {
val callback = {
val callback = {
if (action == "delete") {
val nSeq = <div id={ htmlId_policyConf }>Directive successfully deleted</div>
cr : ChangeRequestId => JsRaw("$.modal.close();") &onRemoveSuccessCallBack() & SetHtml(htmlId_policyConf, nSeq) &
Expand Down Expand Up @@ -447,7 +446,7 @@ class DirectiveEditForm(


SetHtml("confirmUpdateActionDialog", popup.popupContent) &
JsRaw("""createPopup("confirmUpdateActionDialog",400,800)""")
JsRaw("""createPopup("confirmUpdateActionDialog")""")
}

private[this] def updateAndDisplayNotifications() : NodeSeq = {
Expand Down Expand Up @@ -479,12 +478,12 @@ class DirectiveEditForm(
///////////// success pop-up ///////////////

private[this] def successPopup(message: NodeSeq) : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350) """) &
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog") """) &
JsRaw(s""" $$("#successDialogContent").html('${message}') """)
}

private[this] def failurePopup(message: NodeSeq) : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350) """) &
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog") """) &
JsRaw(s""" $$("#successDialogContent").html('${message}') """)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class NodeGroupCategoryForm(
) ++
Script(JsRaw("""
$('#removeButton').click(function() {
createPopup("removeActionDialog",140,850);
createPopup("removeActionDialog");
return false;
});
"""))
Expand Down Expand Up @@ -331,9 +331,7 @@ class NodeGroupCategoryForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw("""
callPopupWithTimeout(200, "successConfirmationDialog", 100, 350);
""")
JsRaw("""callPopupWithTimeout(200, "successConfirmationDialog");""")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ class NodeGroupForm(
s.split("\\|").toList match {
case _ :: id :: _ =>
SetHtml("serverDetails", (new ShowNodeDetailsFromNode(new NodeId(id))).display(true)) &
JsRaw( """ createPopup("nodeDetailsPopup",500,1000)
""")
createPopup("nodeDetailsPopup")

case _ => Alert("Error when trying to display node details: received bad parameter for node ID: %s".format(s))
}
Expand Down Expand Up @@ -350,7 +349,7 @@ class NodeGroupForm(
Script(JsRaw("""
correctButtons();
$('#removeButton').click(function() {
createPopup("removeActionDialog",140,850);
createPopup("removeActionDialog");
return false;
});
"""))
Expand Down Expand Up @@ -607,11 +606,11 @@ class NodeGroupForm(
, container : String): JsCmd = {
SetHtml("confirmUpdateActionDialog", showUpdatePopupForm(checkAndUpdateGroup(
nodeGroup, name, description, query, isDynamic, srvList, container))) &
createPopup("updateActionDialog",140,850)
createPopup("updateActionDialog")
}

def createPopup(name:String,height:Int,width:Int) :JsCmd = {
JsRaw("""createPopup("%s",%s,%s);""".format(name,height,width))
def createPopup(name:String) :JsCmd = {
JsRaw(s"""createPopup("${name}");""")
}

private[this] def showCloneGroupPopup() : JsCmd = {
Expand All @@ -627,7 +626,7 @@ class NodeGroupForm(
case Full(popup) => popup.popupContent()
}
SetHtml("createCloneGroupContainer", nodeSeqPopup) &
JsRaw("""createPopup("createCloneGroupPopup", 300, 400)""")
createPopup("createCloneGroupPopup")
}

private[this] def htmlTreeNodeId(id:String) = "jsTree-" + id
Expand Down Expand Up @@ -788,8 +787,7 @@ class NodeGroupForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350)
""")
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
}

private[this] def updateAndDisplayNotifications(formTracker : FormTracker) : NodeSeq = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ class RuleEditForm(
}


// def createPopup(name:String,height:Int,width:Int) :JsCmd = {
// JsRaw("""createPopup("%s",%s,%s);""".format(name,height,width))
// }

////////////// Callbacks //////////////

private[this] def updateFormClientSide() : JsCmd = {
Expand All @@ -371,7 +367,7 @@ class RuleEditForm(
formTracker.addFormError(error("There are no modification to save."))
onFailure()
}

/*
* Create the ajax save button
*/
Expand Down Expand Up @@ -487,7 +483,7 @@ class RuleEditForm(
popup.onSubmit
} else {
SetHtml("confirmUpdateActionDialog", popup.popupContent) &
JsRaw("""createPopup("confirmUpdateActionDialog",400,800)""")
JsRaw("""createPopup("confirmUpdateActionDialog")""")
}
}

Expand All @@ -496,7 +492,7 @@ class RuleEditForm(
JsRaw("$.modal.close();") & onSuccessCallback() & SetHtml("editRuleZone",
<div id="editRuleZone">Rule successfully deleted</div>
) &
SetHtml(htmlId_rule,
SetHtml(htmlId_rule,
<div id={htmlId_rule}>Rule successfully deleted</div>
)
} else {
Expand Down Expand Up @@ -528,8 +524,7 @@ class RuleEditForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350)
""")
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
}

/********************************************
Expand Down Expand Up @@ -1197,7 +1192,7 @@ class RuleEditForm(
case None => Text("Not Applied")
}
}

val batch = reportingService.findImmediateReportsByRule(rule.id)

<div>
Expand Down Expand Up @@ -1668,7 +1663,7 @@ class RuleEditForm(
}

/**
* Unfold the report to (Seq[ComponentValueRuleStatusReport], DirectiveId)
* Unfold the report to (Seq[ComponentValueRuleStatusReport], DirectiveId)
*/
def getComponentValueRule(report: RuleStatusReport): (Seq[ComponentValueRuleStatusReport], DirectiveId) = {
report match {
Expand All @@ -1680,7 +1675,7 @@ class RuleEditForm(
(Seq(value), value.directiveid)
}
}

/**
* convert the componentvaluesrules to componentValueRule and Directive
* Checks as well that all componentvaluesrules belong to the same directive
Expand Down Expand Up @@ -1790,7 +1785,7 @@ class RuleEditForm(
}
val (reports, directiveId) = getComponentValueRule(directiveByNode)
val tab = showReportsByType(reports, directiveId)
xml++tab}
xml++tab}
).apply(popupXml)
}

Expand Down Expand Up @@ -1838,7 +1833,7 @@ class RuleEditForm(
val htmlId_reportsPopup = "popup_" + htmlId_rulesGridZone
val htmlId_modalReportsPopup = "modal_" + htmlId_rulesGridZone


/**
* Create the popup
*/
Expand All @@ -1850,9 +1845,9 @@ class RuleEditForm(
"""
) //& initJsCallBack(tableId)
) &
JsRaw( """ createPopup("%s",600,900)""".format(htmlId_modalReportsPopup))
JsRaw( s""" createPopup("${htmlId_modalReportsPopup}")""")
}

/**
* We need to have a Popup with all the ComponentValueRuleStatusReports for
* cases when differents nodes have differents values
Expand All @@ -1867,7 +1862,7 @@ class RuleEditForm(
"""
) //& initJsCallBack(tableId)
) &
JsRaw( """ createPopup("%s",600,900)""".format(htmlId_modalReportsPopup))
JsRaw( s""" createPopup("${htmlId_modalReportsPopup}")""")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class RuleGrid(
""".replaceAll("#table_var#",jsVarNameForId(htmlId_rulesGridId))) &
//pop-ups for multiple Directives
JsRaw( """var openMultiPiPopup = function(popupid) {
createPopup(popupid,300,520);
createPopup(popupid);
}""") &
OnLoad(JsRaw("""
/* Event handler function */
Expand Down Expand Up @@ -431,7 +431,7 @@ class RuleGrid(
val trackerVariables: Box[Seq[(Directive,ActiveTechnique,Technique)]] =
sequence(rule.directiveIds.toSeq) { id =>
directiveCache.getOrElseUpdate(id, directiveRepository.getActiveTechniqueAndDirective(id)) match {
case Full((activeTechnique, directive)) =>
case Full((activeTechnique, directive)) =>
techniqueRepository.getLastTechniqueByName(activeTechnique.techniqueName) match {
case None => Failure("Can not find Technique for activeTechnique with name %s referenced in Rule with ID %s".format(activeTechnique.techniqueName, rule.id))
case Some(technique) => Full((directive,activeTechnique,technique))
Expand Down Expand Up @@ -734,7 +734,7 @@ class RuleGrid(
moveFilterAndFullPaginateArea('#%1$s');""".format( tableId_reportsPopup).replaceAll("#table_var#",jsVarNameForId(tableId_reportsPopup))
) //& initJsCallBack(tableId)
) &
JsRaw( """ createPopup("%s",300,500)""".format(htmlId_modalReportsPopup))
JsRaw( s""" createPopup("${htmlId_modalReportsPopup}")""")
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ class TechniqueCategoryEditForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350)
""")
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ class TechniqueEditForm(
correctButtons();
$('#deleteButton').click(function() {
createPopup("deleteActionDialog",140,400);
createPopup("deleteActionDialog");
return false;
});
$('#disableButton').click(function() {
createPopup("disableActionDialog",140,500);
createPopup("disableActionDialog");
return false;
});
""")))
Expand Down Expand Up @@ -647,7 +647,7 @@ class TechniqueEditForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350)
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")
""")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def jsInit(nodeId:NodeId, softIds:Seq[SoftwareUuid], salt:String="", tabContaine


SetHtml(deleteNodePopupHtmlId, popupHtml) &
JsRaw( """ createPopup("%s",300,400) """.format(deleteNodePopupHtmlId))
JsRaw(s""" createPopup("${deleteNodePopupHtmlId}") """)

}

Expand Down Expand Up @@ -741,7 +741,7 @@ def jsInit(nodeId:NodeId, softIds:Seq[SoftwareUuid], salt:String="", tabContaine

JsRaw( """$.modal.close();""") &
SetHtml(errorPopupHtmlId, popupHtml) &
JsRaw( """ callPopupWithTimeout(200,"%s",300,400) """.format(errorPopupHtmlId))
JsRaw( s""" callPopupWithTimeout(200,"${errorPopupHtmlId}")""")
}

private[this] def onSuccess : JsCmd = {
Expand Down Expand Up @@ -772,7 +772,7 @@ def jsInit(nodeId:NodeId, softIds:Seq[SoftwareUuid], salt:String="", tabContaine

JsRaw( """$.modal.close();""") &
SetHtml(successPopupHtmlId, popupHtml) &
JsRaw( """ callPopupWithTimeout(200,"%s",300,400) """.format(successPopupHtmlId))
JsRaw( s""" callPopupWithTimeout(200,"${successPopupHtmlId}") """)
}

private [this] def isRootNode(n: NodeId): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,6 @@ class Archives extends DispatchSnippet with Loggable {

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw("""callPopupWithTimeout(200, "successConfirmationDialog", 100, 350)""")
JsRaw("""callPopupWithTimeout(200, "successConfirmationDialog")""")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class ChangeRequestDetails extends DispatchSnippet with Loggable {
SetHtml("changeRequestChanges", new ChangeRequestChangesForm(cr).dispatch("changes")(NodeSeq.Empty)) &
JsRaw("""correctButtons();
$.modal.close();
callPopupWithTimeout(200, "successWorkflow", 100, 350); """)
callPopupWithTimeout(200, "successWorkflow"); """)

var nextChosen = nextSteps.head._2
val nextSelect =
Expand Down Expand Up @@ -375,7 +375,7 @@ class ChangeRequestDetails extends DispatchSnippet with Loggable {
}

SetHtml("popupContent",content) &
JsRaw("createPopup('changeStatePopup', 150, 850)")
JsRaw("createPopup('changeStatePopup')")

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class EditPolicyServerAllowedNetwork extends DispatchSnippet with Loggable {

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog", 100, 350)
""")
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
}
}

0 comments on commit 8736b66

Please sign in to comment.