EventBus.getInstance().addObserver(UpdatedGroupResponseEvent.class, new Observer<UpdatedGroupResponseEvent>()
{
public void update(final UpdatedGroupResponseEvent arg1)
{
Session.getInstance().getEventBus().notifyObservers(
new UpdateHistoryEvent(new CreateUrlRequest(Page.GROUPS, arg1.getResponse().getShortName())));
Session.getInstance().getEventBus().notifyObservers(
new ShowNotificationEvent(new Notification("Your group has been successfully saved")));
}
});
form.addFormElement(new ValueOnlyFormElement(DomainGroupModelView.ID_KEY, Long.toString(entity.getId())));
form.addFormElement(new ValueOnlyFormElement(DomainGroupModelView.SHORT_NAME_KEY, entity.getShortName()));
AvatarUploadFormElement avatarFormEl = new AvatarUploadFormElement("Avatar",
"Select a JPG, PNG or GIF image from your computer. The maxium file size is 4MB",
"/eurekastreams/groupavatarupload?groupName=" + entity.getShortName(), Session.getInstance()
.getActionProcessor(), new AvatarUploadStrategy<DomainGroupModelView>(entity,
"resizeGroupAvatar", EntityType.GROUP));
form.addWidget(avatarFormEl);
form.addFormDivider();
form.addFormElement(new BasicTextBoxFormElement(MAX_NAME, false, "Group Name", DomainGroupModelView.NAME_KEY,
entity.getName(), "", true));
form.addFormDivider();
form.addFormElement(new BasicTextAreaFormElement(DomainGroup.MAX_DESCRIPTION_LENGTH, "Description",
DomainGroupModelView.DESCRIPTION_KEY, entity.getDescription(),
"Enter a few sentences that describe the purpose of your group's stream. "
+ "This description will appear beneath your avatar "
+ "and in the profile search results pages.", false));
form.addFormDivider();
AutoCompleteItemDropDownFormElement keywords = new AutoCompleteItemDropDownFormElement("Keywords",
DomainGroupModelView.KEYWORDS_KEY, DomainFormatUtility.buildCapabilitiesStringFromStrings(entity
.getCapabilities()),
"Add keywords that describe your group and the topics your members will be talking about. Separate "
+ "keywords with a comma. Including keywords helps others find your group when searching "
+ "profiles.", false, "/resources/autocomplete/capability/", "itemNames", ",");
keywords.setMaxLength(MAX_KEYWORDS);
form.addFormElement(keywords);
form.addFormDivider();
form.addFormElement(new BasicTextBoxFormElement("Website URL", "url", entity.getUrl(),
"If your group has a website, you can enter the URL above", false));
form.addFormDivider();
String coordinstructions = "The group coordinators will be responsible for managing the organization profile, "
+ "and moderating the group's activity stream";
form.addFormElement(new PersonModelViewLookupFormElement("Group Coordinators", "Add Coordinator",
coordinstructions, DomainGroupModelView.COORDINATORS_KEY, entity.getCoordinators(), true));
form.addFormDivider();
final Label currentPrivacySettingLabel = new Label();
currentPrivacySettingLabel.setText("Privacy Settings");
currentPrivacySettingLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel());
final FlowPanel currentPrivacySettingDescription = new FlowPanel();
final Label currentPrivacySettingDescriptionTitle = new Label();
currentPrivacySettingDescriptionTitle.setText(entity.isPublic() ? "Public" : "Private");
currentPrivacySettingDescriptionTitle.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formStaticValue());
final Label currentPrivacySettingDescriptionInfo = new Label();
if (entity.isPublic())
{
currentPrivacySettingDescriptionInfo.setText("Public groups are visible to all users and accessible "
+ "through a profile search.");
}
else
{
currentPrivacySettingDescriptionInfo.setText("Access to private groups is restricted to employees"
+ " approved by the group's coordinators. Group coordinators can view a list of pending "
+ "requests by going to the admin tab on the group's profile.");
}
currentPrivacySettingDescriptionInfo.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formInstructions());
currentPrivacySettingDescription.add(currentPrivacySettingDescriptionTitle);
currentPrivacySettingDescription.add(currentPrivacySettingDescriptionInfo);
currentPrivacySettingDescription.addStyleName(StaticResourceBundle.INSTANCE.coreCss().privacySettingsValue());
final FlowPanel currentPrivacySettingPanel = new FlowPanel();
currentPrivacySettingPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formElement());
currentPrivacySettingPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().privacySettings());
currentPrivacySettingPanel.add(currentPrivacySettingLabel);
currentPrivacySettingPanel.add(currentPrivacySettingDescription);
form.addWidget(currentPrivacySettingPanel);
if (!entity.isPublic())
{
final HTML privateNote = new HTML("<span class=\"form-static-value\">Please Note:</span> "
+ "This group's name and description will be visible whenever employees browse or"
+ " search profiles.");
privateNote.addStyleName(StaticResourceBundle.INSTANCE.coreCss().privacySettingsNote());
privateNote.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formInstructions());
currentPrivacySettingPanel.add(privateNote);
}
form.addFormDivider();
// TODO: evidently this is supposed to go away
BasicCheckBoxFormElement blockWallPost = new BasicCheckBoxFormElement("Stream Moderation",
DomainGroupModelView.STREAM_POSTABLE_KEY, "Allow others to post to your group's stream", false, entity
.isStreamPostable());
BasicCheckBoxFormElement blockCommentPost = new BasicCheckBoxFormElement(null,
DomainGroupModelView.STREAM_COMMENTABLE_KEY,
"Allow others to comment on activity in your group's stream", false, entity.isCommentable());
blockWallPost.addStyleName(StaticResourceBundle.INSTANCE.coreCss().streamModeration());
blockCommentPost.addStyleName(StaticResourceBundle.INSTANCE.coreCss().streamModeration());
blockCommentPost.addStyleName(StaticResourceBundle.INSTANCE.coreCss().commentModeration());
form.addFormElement(blockWallPost);
form.addFormElement(blockCommentPost);
form.addFormDivider();
// ---- Action buttons ----
deleteButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formDeleteGroupButton());
deleteButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());
deleteButton.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
if (new WidgetJSNIFacadeImpl().confirm("Are sure that you want to delete this group? "
+ "Deleting the group will remove the profile from the system along with "
+ "all of the activity that has been posted to its stream."))
{
form.turnOffChangeCheck();
processingSpinny.setVisible(true);
deleteButton.setVisible(false);
// TODO - might should put this in GroupModel (and mark it as Deletable) but there's no
// custom onFailure ability there yet.
Session.getInstance().getActionProcessor().makeRequest("deleteGroupAction", entity.getId(),
new AsyncCallback<Boolean>()
{
public void onSuccess(final Boolean result)
{
// adds notification to top of page
Session.getInstance().getEventBus().notifyObservers(
new ShowNotificationEvent(new Notification("The group '"
+ entity.getName() + "' has been deleted")));
// navigates away from settings page to the parent org profile page
Session.getInstance().getEventBus().notifyObservers(
new UpdateHistoryEvent(new CreateUrlRequest(Page.PEOPLE, Session
.getInstance().getCurrentPerson().getAccountId())));
}
public void onFailure(final Throwable caught)
{