Skip to content

Commit

Permalink
SAK-32760 Add NYU customization to introduce Lessons subpage navigati…
Browse files Browse the repository at this point in the history
…on to the site's tool menu (sakaiproject#4681)
  • Loading branch information
payten authored and jonespm committed Aug 17, 2017
1 parent 3a29fd0 commit cbc66c1
Show file tree
Hide file tree
Showing 16 changed files with 1,338 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2517,8 +2517,45 @@ public SimplePageItem getCurrentPageItem(Long itemId) {
public String adjustPath(String op, Long pageId, Long pageItemId, String title) {
List<PathEntry> path = (List<PathEntry>)sessionManager.getCurrentToolSession().getAttribute(LESSONBUILDER_PATH);

// Allow the new portal lessons subnav to push a subpage on the context
if (op.equals("clear_and_push")) {
// clear path for top level subpage
path = new ArrayList<PathEntry>();

// add an entry for the parent page
SimplePage parentPage = null;

// the current page may have a parent
if (currentPage.getParent() != null && currentPage.getParent() != 0) {
parentPage = getPage(currentPage.getParent());

// try and get it from the current item
} else if (currentPageItemId != null) {
SimplePageItem item = getCurrentPageItem(currentPageItemId);
parentPage = getPage(item.getPageId());
}

PathEntry parentEntry = new PathEntry();
parentEntry.pageItemId = -1L;
if (parentPage == null) {
// we tried our best, default these values so things don't break
parentEntry.pageId = -1L;
parentEntry.title = "";
} else {
parentEntry.pageId = parentPage.getPageId();
parentEntry.title = parentPage.getTitle();
}
path.add(parentEntry);

// add the subpage
PathEntry entry = new PathEntry();
entry.pageId = pageId;
entry.pageItemId = pageItemId;
entry.title = title;
path.add(entry); // put it on the end

// if no current path, op doesn't matter. we can just do the current page
if (path == null || path.size() == 0) {
} else if (path == null || path.size() == 0) {
PathEntry entry = new PathEntry();
entry.pageId = pageId;
entry.pageItemId = pageItemId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3478,6 +3478,24 @@ else if(questionStatus == Status.FAILED)
}

createDialogs(tofill, currentPage, pageItem, cssLink);

// Add pageids to the page so the portal lessons subnav menu can update its state
List<SimplePageBean.PathEntry> path = simplePageBean.getHierarchy();
if (path.size() > 2) {
SimplePageBean.PathEntry topLevelSubPage = path.get(1);
UIOutput.make(tofill, "lessonsSubnavTopLevelPageId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(topLevelSubPage.pageId)));
} else {
UIOutput.make(tofill, "lessonsSubnavPageId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(simplePageBean.getCurrentPage().getPageId())));
}
UIOutput.make(tofill, "lessonsSubnavToolId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(placement.getId())));
UIOutput.make(tofill, "lessonsSubnavItemId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(pageItem.getId())));

UIOutput.make(tofill, "lessonsCurrentPageId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(simplePageBean.getCurrentPage().getPageId())));
}

public void makeCsrf(UIContainer tofill, String rsfid) {
Expand Down
13 changes: 13 additions & 0 deletions lessonbuilder/tool/src/webapp/templates/ShowPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@
</head>

<body rsf:id="scr=sakai-body">
<input type='hidden' rsf:id="lessonsSubnavToolId" id="lessonsSubnavToolId"/>
<input type='hidden' rsf:id="lessonsSubnavTopLevelPageId" id="lessonsSubnavTopLevelPageId"/>
<input type='hidden' rsf:id="lessonsSubnavPageId" id="lessonsSubnavPageId"/>
<input type='hidden' rsf:id="lessonsSubnavItemId" id="lessonsSubnavItemId"/>
<input type='hidden' rsf:id="lessonsCurrentPageId" id="lessonsCurrentPageId"/>
<script>
if (sakai) {
if (sakai.lessons_subnav) {
// Notify the lessons_subnav that we're on a lessons page
sakai.lessons_subnav.set_current_lessons_page();
}
}
</script>
<script type="text/javascript" src="$context/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="$context/js/jquery-ui-1.11.1.custom.min.js"></script>
<script rsf:id="datepicker" type="text/javascript" src="/library/js/lang-datepicker/lang-datepicker.js"></script>
Expand Down
Loading

0 comments on commit cbc66c1

Please sign in to comment.