Search in sources :

Example 1 with GetApplicationsForGroup

use of cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForGroup 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&nbsp;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();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) GetApplicationsForGroup(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForGroup) ApplicationDetailTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application) HandleApplication(cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 GetApplicationsForGroup (cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForGroup)1 HandleApplication (cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)1 Application (cz.metacentrum.perun.webgui.model.Application)1 ApplicationDetailTabItem (cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem)1 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1