use of cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication in project perun by CESNET.
the class VoApplicationsTabItem method draw.
public Widget draw() {
// request
final GetApplicationsForVo applicationsRequest = new GetApplicationsForVo(vo.getId());
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
applicationsRequest.setCheckable(false);
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "applications");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
/*
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
request.verifyApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, events));
request.verifyApplication(list.get(i).getId());
}
}
}
}
});
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
request.approveApplication(list.get(i));
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, events));
request.approveApplication(list.get(i));
}
}
}
}
});
//reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
public void onClick(ClickEvent event) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
request.rejectApplication(list.get(i).getId(), reason.getText());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, events));
request.rejectApplication(list.get(i).getId(), reason.getText());
}
}
}
}, true);
c.show();
}
}
});
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
request.deleteApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, events));
request.deleteApplication(list.get(i).getId());
}
}
}
}
});
menu.addWidget(verify);
menu.addWidget(approve);
menu.addWidget(reject);
menu.addWidget(delete);
*/
// FILTER
menu.addWidget(new HTML("<strong>State: </strong>"));
// state
final ListBox stateListBox = new ListBox();
stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
stateListBox.addItem("Pending", "NEW,VERIFIED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
stateListBox.setSelectedIndex(selectedIndex);
menu.addWidget(stateListBox);
stateListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
selectedIndex = stateListBox.getSelectedIndex();
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
applicationsRequest.clearTable();
applicationsRequest.retrieveData();
}
});
// FILTER 2
menu.addWidget(new HTML("<strong>Submitted by: </strong>"));
menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
applicationsRequest.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterApplications());
// TABLE
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {
public void update(int index, Application object, String value) {
session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
/*
verify.setEnabled(false);
approve.setEnabled(false);
reject.setEnabled(false);
delete.setEnabled(false);
if (session.isVoAdmin(voId)) {
JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
}
if (session.isPerunAdmin()) {
JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
}
*/
session.getUiElements().resizePerunTable(sp, 100);
firstTabPanel.add(sp);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication in project perun by CESNET.
the class GroupApplicationsTabItem method draw.
public Widget draw() {
// request
final GetApplicationsForGroup applicationsRequest = new GetApplicationsForGroup(group.getId());
final JsonCallbackEvents refreshEvent = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "applications");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
/*
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
request.verifyApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, refreshEvent));
request.verifyApplication(list.get(i).getId());
}
}
}
}
});
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
request.approveApplication(list.get(i));
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, refreshEvent));
request.approveApplication(list.get(i));
}
}
}
}
});
//reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
public void onClick(ClickEvent event) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
request.rejectApplication(list.get(i).getId(), reason.getText());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, refreshEvent));
request.rejectApplication(list.get(i).getId(), reason.getText());
}
}
}
}, true);
c.show();
}
}
});
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
request.deleteApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, refreshEvent));
request.deleteApplication(list.get(i).getId());
}
}
}
}
});
menu.addWidget(verify);
menu.addWidget(approve);
menu.addWidget(reject);
menu.addWidget(delete);
*/
// FILTER
menu.addWidget(new HTML("<strong>State: </strong>"));
// state
final ListBox stateListBox = new ListBox();
stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
stateListBox.addItem("Pending", "NEW,VERIFIED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
stateListBox.setSelectedIndex(selectedIndex);
menu.addWidget(stateListBox);
stateListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
selectedIndex = stateListBox.getSelectedIndex();
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
applicationsRequest.clearTable();
applicationsRequest.retrieveData();
}
});
// FILTER 2
menu.addWidget(new HTML("<strong>Submitted by: </strong>"));
menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
applicationsRequest.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterApplications());
// TABLE
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {
public void update(int index, Application object, String value) {
session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 100);
firstTabPanel.add(sp);
/*
verify.setEnabled(false);
approve.setEnabled(false);
reject.setEnabled(false);
delete.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId())) {
JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
if (session.isPerunAdmin()) {
JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
}
} else {
}
*/
applicationsRequest.setCheckable(false);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication in project perun by CESNET.
the class MemberApplicationsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": applications");
// main widget panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// set proper request
if (session.isVoAdmin(member.getVoId())) {
applicationsRequest = new GetApplicationsForMember(memberId, 0);
} else if (session.isGroupAdmin(groupId)) {
// group admin can see only apps for his group
applicationsRequest = new GetApplicationsForMember(memberId, groupId);
} else if (session.isVoObserver(member.getVoId())) {
applicationsRequest = new GetApplicationsForMember(memberId, 0);
}
applicationsRequest.setCheckable(false);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
/*
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
request.verifyApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, events));
request.verifyApplication(list.get(i).getId());
}
}
}
}
});
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
request.approveApplication(list.get(i));
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, events));
request.approveApplication(list.get(i));
}
}
}
}
});
//reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
public void onClick(ClickEvent event) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
request.rejectApplication(list.get(i).getId(), reason.getText());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, events));
request.rejectApplication(list.get(i).getId(), reason.getText());
}
}
}
}, true);
c.show();
}
}
});
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
request.deleteApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, events));
request.deleteApplication(list.get(i).getId());
}
}
}
}
});
menu.addWidget(verify);
menu.addWidget(approve);
menu.addWidget(reject);
menu.addWidget(delete);
*/
menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
applicationsRequest.filterTable(text);
}
}, "Filter by group");
CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {
@Override
public void update(int i, Application application, String s) {
session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(application), true);
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(sp);
/*
verify.setEnabled(false);
approve.setEnabled(false);
reject.setEnabled(false);
delete.setEnabled(false);
if (session.isVoAdmin(member.getVoId()) || session.isGroupAdmin(groupId)) {
JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
}
*/
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication in project perun by CESNET.
the class ApplicationDetailTabItem method draw.
public Widget draw() {
tab = this;
row = 0;
boolean buttonsEnabled = ((session.isVoAdmin(app.getVo().getId())) || (app.getGroup() != null && session.isGroupAdmin(app.getGroup().getId())));
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final FlexTable ft = new FlexTable();
String text = "<strong>Submitted by:</strong> ";
if (app.getUser() != null) {
text += SafeHtmlUtils.fromString(app.getUser().getFullNameWithTitles() + " (" + app.getCreatedBy() + ")").asString();
} else {
text += SafeHtmlUtils.fromString(app.getCreatedBy()).asString();
}
text += " <strong>from External Source:</strong> " + SafeHtmlUtils.fromString(app.getExtSourceName()).asString() + " <strong>with Level of Assurance:</strong> " + app.getExtSourceLoa();
text += " <strong>on: </strong> " + app.getCreatedAt().split("\\.")[0];
ft.setHTML(row, 0, text);
ft.setCellSpacing(5);
row++;
if (app.getGroup() != null) {
ft.setHTML(row, 0, "<strong>Application for group: </strong>" + SafeHtmlUtils.fromString((app.getGroup().getName() != null) ? app.getGroup().getName() : "").asString() + "<strong> in VO: </strong>" + SafeHtmlUtils.fromString((app.getVo().getName() != null) ? app.getVo().getName() : "").asString());
} else {
ft.setHTML(row, 0, "<strong>Application for VO: </strong>" + SafeHtmlUtils.fromString((app.getVo().getName() != null) ? app.getVo().getName() : "").asString());
}
if (app.getState().equalsIgnoreCase("APPROVED")) {
row++;
ft.setHTML(row, 0, "<strong>Approved by:</strong> " + ((app.getModifiedBy().equalsIgnoreCase("perunRegistrar")) ? "automatically" : Utils.convertCertCN(app.getModifiedBy())) + " <strong>on: </strong> " + app.getModifiedAt().split("\\.")[0]);
}
if (app.getState().equalsIgnoreCase("REJECTED")) {
row++;
ft.setHTML(row, 0, "<strong>Rejected by:</strong> " + ((app.getModifiedBy().equalsIgnoreCase("perunRegistrar")) ? "automatically" : Utils.convertCertCN(app.getModifiedBy())) + " <strong>on: </strong> " + app.getModifiedAt().split("\\.")[0]);
}
// for extension in VO if not approved or rejected
if (app.getType().equalsIgnoreCase("EXTENSION") && app.getUser() != null && !app.getState().equalsIgnoreCase("APPROVED") && !app.getState().equalsIgnoreCase("REJECTED")) {
GetNewExtendMembership ex = new GetNewExtendMembership(app.getVo().getId(), app.getUser().getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (jso != null) {
BasicOverlayType basic = jso.cast();
row++;
ft.setHTML(row, 0, "<strong>New membership expiration:</strong> " + SafeHtmlUtils.fromString(basic.getString()).asString());
}
}
});
ex.retrieveData();
}
// for initial in VO, if not approved or rejected
if (app.getType().equalsIgnoreCase("INITIAL") && app.getGroup() == null && !app.getState().equalsIgnoreCase("APPROVED") && !app.getState().equalsIgnoreCase("REJECTED")) {
GetNewExtendMembershipLoa ex = new GetNewExtendMembershipLoa(app.getVo().getId(), app.getExtSourceLoa(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (jso != null) {
BasicOverlayType basic = jso.cast();
row++;
ft.setHTML(row, 0, "<strong>New membership expiration:</strong> " + SafeHtmlUtils.fromString(basic.getString()).asString());
}
}
});
ex.retrieveData();
}
vp.add(ft);
vp.add(new HTML("<hr size=\"1\" style=\"color: #ccc;\"/>"));
// only NEW apps can be Verified
if (app.getState().equals("NEW")) {
if (session.isPerunAdmin()) {
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
menu.addWidget(verify);
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
app = jso.cast();
draw();
refreshParent = true;
}
}));
request.verifyApplication(appId);
}
});
}
}
// only VERIFIED apps can be approved/rejected
if (app.getState().equals("VERIFIED") || app.getState().equals("NEW")) {
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.setEnabled(buttonsEnabled);
menu.addWidget(approve);
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
refreshParent = true;
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
request.approveApplication(app);
}
});
// reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.setEnabled(buttonsEnabled);
menu.addWidget(reject);
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler() {
public void onClick(ClickEvent event) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
refreshParent = true;
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
request.rejectApplication(appId, reason.getText());
}
}, true);
c.show();
}
});
}
if (app.getState().equals("NEW") || app.getState().equals("REJECTED")) {
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.setEnabled(buttonsEnabled);
menu.addWidget(delete);
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
refreshParent = true;
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
request.deleteApplication(appId);
}
});
}
// NOTIFICATION SENDER
final CustomButton send = new CustomButton("Re-send notifications...", SmallIcons.INSTANCE.emailIcon());
send.setEnabled(buttonsEnabled);
menu.addWidget(send);
send.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final FlexTable ft = new FlexTable();
ft.setStyleName("inputFormFlexTable");
ft.setWidth("400px");
final ListBox selection = new ListBox();
selection.setWidth("200px");
if (session.isPerunAdmin()) {
// add all except user invite
for (ApplicationMail.MailType mail : ApplicationMail.MailType.values()) {
if (!mail.equals(ApplicationMail.MailType.USER_INVITE)) {
selection.addItem(ApplicationMail.getTranslatedMailType(mail.toString()), mail.toString());
}
}
} else {
// add TYPEs based on actual APP-STATE
if (app.getState().equals("NEW")) {
selection.addItem(ApplicationMail.getTranslatedMailType("APP_CREATED_USER"), "APP_CREATED_USER");
selection.addItem(ApplicationMail.getTranslatedMailType("APP_CREATED_VO_ADMIN"), "APP_CREATED_VO_ADMIN");
selection.addItem(ApplicationMail.getTranslatedMailType("MAIL_VALIDATION"), "MAIL_VALIDATION");
} else if (app.getState().equals("VERIFIED")) {
selection.addItem(ApplicationMail.getTranslatedMailType("APP_CREATED_USER"), "APP_CREATED_USER");
selection.addItem(ApplicationMail.getTranslatedMailType("APP_CREATED_VO_ADMIN"), "APP_CREATED_VO_ADMIN");
} else if (app.getState().equals("APPROVED")) {
selection.addItem(ApplicationMail.getTranslatedMailType("APP_APPROVED_USER"), "APP_APPROVED_USER");
} else if (app.getState().equals("REJECTED")) {
selection.addItem(ApplicationMail.getTranslatedMailType("APP_REJECTED_USER"), "APP_REJECTED_USER");
}
// FIXME - how to handle APPROVABLE_GROUP_APP_USER
}
ft.setHTML(0, 0, "Select notification:");
ft.getFlexCellFormatter().setStyleName(0, 0, "itemName");
ft.setWidget(0, 1, selection);
final TextArea reason = new TextArea();
reason.setSize("250px", "100px");
selection.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (selection.getValue(selection.getSelectedIndex()).equals("APP_REJECTED_USER")) {
ft.setHTML(1, 0, "Reason:");
ft.getFlexCellFormatter().setStyleName(1, 0, "itemName");
ft.setWidget(1, 1, reason);
} else {
ft.setHTML(1, 0, "");
ft.setHTML(1, 1, "");
}
}
});
// if pre-selected
if (selection.getValue(selection.getSelectedIndex()).equals("APP_REJECTED_USER")) {
ft.setHTML(1, 0, "Reason:");
ft.getFlexCellFormatter().setStyleName(1, 0, "itemName");
ft.setWidget(1, 1, reason);
} else {
ft.setHTML(1, 0, "");
ft.setHTML(1, 1, "");
}
final Confirm c = new Confirm("Re-send notifications", ft, null, true);
c.setOkIcon(SmallIcons.INSTANCE.emailIcon());
c.setOkButtonText("Send");
c.setNonScrollable(true);
c.setOkClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ResendNotification call = new ResendNotification(appId, JsonCallbackEvents.disableButtonEvents(c.getOkButton(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
c.hide();
}
}));
if (selection.getValue(selection.getSelectedIndex()).equals("APP_REJECTED_USER")) {
call.resendNotification(selection.getValue(selection.getSelectedIndex()), reason.getValue().trim());
} else {
call.resendNotification(selection.getValue(selection.getSelectedIndex()), null);
}
}
});
c.setCancelClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
c.hide();
}
});
c.show();
}
});
menu.addWidget(new HTML("<strong>TYPE: </strong>" + Application.getTranslatedType(app.getType())));
menu.addWidget(new HTML("<strong>STATE: </strong>" + Application.getTranslatedState(app.getState())));
GetApplicationDataById data = new GetApplicationDataById(appId);
data.setEditable(app.getState().equals("VERIFIED") || app.getState().equals("NEW"));
data.setEmbedded(app.getType().equals("EMBEDDED"), app.getUser());
data.retrieveData();
ScrollPanel sp = new ScrollPanel(data.getContents());
sp.setSize("100%", "100%");
vp.add(sp);
vp.setCellHeight(sp, "100%");
vp.setCellHorizontalAlignment(sp, HasHorizontalAlignment.ALIGN_CENTER);
session.getUiElements().resizePerunTable(sp, 400, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations