forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sakaiproject#1712 from payten/1596-popover-links
1596 introduce links to header flag popovers
- Loading branch information
Showing
10 changed files
with
184 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...bookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/HeaderFlagPopoverPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" > | ||
|
||
<body> | ||
<wicket:panel> | ||
|
||
<ul class="gb-popover-notifications"> | ||
<li class="text-info"> | ||
<p class="gb-popover-message"> | ||
<wicket:container wicket:id="message" /> | ||
</p> | ||
<a wicket:id="link" class="gb-popover-link"> | ||
<wicket:container wicket:id="linkText" /> | ||
</a> | ||
</li> | ||
</ul> | ||
|
||
</wicket:panel> | ||
</body> | ||
</html> |
114 changes: 114 additions & 0 deletions
114
...bookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/HeaderFlagPopoverPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package org.sakaiproject.gradebookng.tool.panels; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.behavior.AttributeAppender; | ||
import org.apache.wicket.markup.html.link.Link; | ||
import org.apache.wicket.ajax.markup.html.AjaxLink; | ||
import org.apache.wicket.core.util.string.ComponentRenderer; | ||
import org.apache.wicket.markup.html.WebMarkupContainer; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.model.Model; | ||
import org.apache.wicket.model.ResourceModel; | ||
import org.apache.wicket.model.StringResourceModel; | ||
import org.apache.wicket.spring.injection.annot.SpringBean; | ||
import org.sakaiproject.gradebookng.business.GbRole; | ||
import org.sakaiproject.gradebookng.business.GradebookNgBusinessService; | ||
import org.sakaiproject.gradebookng.tool.pages.SettingsPage; | ||
import org.sakaiproject.user.api.User; | ||
|
||
public class HeaderFlagPopoverPanel extends Panel { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@SpringBean(name = "org.sakaiproject.gradebookng.business.GradebookNgBusinessService") | ||
private GradebookNgBusinessService businessService; | ||
|
||
public enum Flag { | ||
GRADE_ITEM_EXTRA_CREDIT("label.gradeitem.extracredit"), | ||
GRADE_ITEM_RELEASED("label.gradeitem.released"), | ||
GRADE_ITEM_NOT_RELEASED("label.gradeitem.released"), | ||
GRADE_ITEM_COUNTED("label.gradeitem.counted"), | ||
GRADE_ITEM_NOT_COUNTED("label.gradeitem.notcounted"), | ||
COURSE_GRADE_RELEASED("label.coursegrade.released"), | ||
COURSE_GRADE_NOT_RELEASED("label.coursegrade.notreleased"); | ||
|
||
private String messageKey; | ||
|
||
Flag(final String messageKey) { | ||
this.messageKey = messageKey; | ||
} | ||
|
||
public String getMessageKey() { | ||
return this.messageKey; | ||
} | ||
} | ||
|
||
|
||
Flag flag; | ||
Long assignmentId; | ||
|
||
|
||
public HeaderFlagPopoverPanel(final String id, final Flag flag, final Long assignmentId) { | ||
super(id); | ||
|
||
this.flag = flag; | ||
this.assignmentId = assignmentId; | ||
} | ||
|
||
|
||
public HeaderFlagPopoverPanel(final String id, final Flag flag) { | ||
super(id); | ||
|
||
this.flag = flag; | ||
} | ||
|
||
@Override | ||
public void onInitialize() { | ||
super.onInitialize(); | ||
|
||
add(new Label("message", getString(flag.getMessageKey()))); | ||
|
||
GbRole role = businessService.getUserRole(); | ||
boolean isInstructor = GbRole.INSTRUCTOR == role; | ||
|
||
if (isInstructor) { | ||
if (flag == Flag.COURSE_GRADE_NOT_RELEASED || flag == Flag.COURSE_GRADE_RELEASED) { | ||
Link link = new Link("link") { | ||
@Override | ||
public void onClick() { | ||
setResponsePage(new SettingsPage()); | ||
} | ||
}; | ||
link.add(new Label("linkText", getString("label.coursegrade.editsettings"))); | ||
add(link); | ||
} else if (assignmentId != null) { | ||
AjaxLink link = new AjaxLink("link") { | ||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
// do nothing | ||
} | ||
}; | ||
String javascript = String.format("sakai.gradebookng.spreadsheet.editAssignmentFromFlag('%s');", | ||
String.valueOf(assignmentId)); | ||
link.add(new AttributeAppender("onclick", javascript)); | ||
link.add(new Label("linkText", getString("assignment.option.edit"))); | ||
add(link); | ||
} else { | ||
add(new WebMarkupContainer("link").setVisible(false)); | ||
} | ||
} else { | ||
add(new WebMarkupContainer("link").setVisible(false)); | ||
} | ||
} | ||
|
||
public String toPopoverString() { | ||
return ComponentRenderer.renderComponent(this).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters