Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRE-19827 Delete and saveas operations to reload table form #164

Merged
merged 4 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -148,6 +149,8 @@ public void delete(Script script) {
try {
new ScriptDao().delete(script.getId());
scriptEvent.fire(new ModifiedScriptMessage(script, this));
messages.info("Script " + script.getName() + " has been deleted.");
refresh();
} catch (Exception e) {
LOG.error("Error deleting Script: " + e.toString());
exceptionHandler.handle(e);
Expand All @@ -162,7 +165,9 @@ public void delete(Script script) {
public List<Script> getEntityList(ViewFilterType viewFilter) {
VersionContainer<Script> container = scriptLoader.getVersionContainer(viewFilter);
this.version = container.getVersion();
return container.getEntities();
List<Script> all = new ScriptDao().findFiltered(viewFilter);
Collections.sort(all);
return all;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you re-pulling the data? isn't the refresh enough.
Why are you sorting it? That should be done by the UI.

}

/**
Expand Down Expand Up @@ -195,6 +200,7 @@ public void saveAs(Script script) {
securityContext.getCallerPrincipal().getName(),
saveAsName, script);
copyScript = new ScriptDao().saveOrUpdate(copyScript);
refresh();
scriptEvent.fire(new ModifiedScriptMessage(copyScript, this));
messages.info("Script " + originalName + " has been saved as "
+ copyScript.getName() + ".");
Expand Down
12 changes: 6 additions & 6 deletions web/web_ui/src/main/webapp/scripts/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@
message="Are you sure you want to delete Script #{scriptBean.selectedScript.entity.name}?">
<h:form id="confirmDeletemainForm">
<p:commandButton value="OK" id="confirmDeleteOkBtn"
action="#{scriptBean.delete(scriptBean.selectedScript.entity)}"
onsuccess="PF('confirmDelete').hide()"
update=":mainForm:scriptTableId" ajax="true" />
action="#{scriptBean.delete(scriptBean.selectedScript.entity)}"
onsuccess="PF('confirmDelete').hide();"
update=":mainForm:scriptTableId, :mainForm:messages" ajax="true" />
<h:panelGroup styleClass="horizontal-spacer" />
<p:commandButton value="Cancel"
onclick="PF('confirmDelete').hide();" type="button">
Expand All @@ -249,9 +249,9 @@
<h:outputText styleClass="pa"
value="Intuit Tank supports only .xml files as Scripts but can accept .zip files. Zip files will be searched recursively for all .xml files." />
<div class="vertical-spacer" />
<p:fileUpload id="fileUploadControl" oncomplete="PF('xmlUploadDialog').hide()"
<p:fileUpload id="fileUploadControl" oncomplete="PF('xmlUploadDialog').hide();"
listener="#{tankXmlUploadBean.handleFileUpload}" mode="advanced"
allowTypes="/(\.|\/)(xml|zip)$/" update=":mainForm:scriptTableId" multiple="true" />
allowTypes="/(\.|\/)(xml|zip)$/" update=":mainForm:scriptTableId, :mainForm:messages" multiple="true" />
<p:poll interval="#{Math.toIntExact(session.maxInactiveInterval - 10)}" async="true" />
<div class="vertical-spacer" />
</p:outputPanel>
Expand All @@ -268,7 +268,7 @@
</f:facet>
<p:commandButton value="OK" id="SaveAsOk" ajax="true"
action="#{scriptBean.saveAs(scriptBean.selectedScript.entity)}"
update=":mainForm:scriptTableId"
update=":mainForm:scriptTableId, :mainForm:messages"
onsuccess="PF('saveAsConfirm').hide();" />
<h:panelGroup styleClass="horizontal-spacer" />
<p:commandButton value="Cancel"
Expand Down