Index: lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java =================================================================== diff -u -re99f2a23689fd7b7311fedb74b6d2c475d402cc4 -r07578aaa7f526c0c1b537c127cf5f88e0410d472 --- lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java (.../DisplayGroupAction.java) (revision e99f2a23689fd7b7311fedb74b6d2c475d402cc4) +++ lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java (.../DisplayGroupAction.java) (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletResponse; import javax.sql.DataSource; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; @@ -63,6 +64,8 @@ * @author jliew * * @struts.action path="/displayGroup" validate="false" + * @struts.action-forward name="groupHeader" path="/groupHeader.jsp" + * @struts.action-forward name="groupContents" path="/groupContents.jsp" * @struts.action-forward name="group" path="/group.jsp" */ public class DisplayGroupAction extends Action { @@ -77,13 +80,16 @@ HttpServletRequest request, HttpServletResponse response) throws Exception { + String display = WebUtil.readStrParam(request, "display", false); stateId = WebUtil.readIntParam(request, "stateId", false); Integer orgId = WebUtil.readIntParam(request, "orgId", false); + Organisation org = null; if (orgId != null) { org = (Organisation)getService().findById(Organisation.class, orgId); } + String forwardPath = "group"; if (org != null) { boolean allowSorting = false; List roles = new ArrayList(); @@ -95,18 +101,29 @@ allowSorting = true; } } - IndexOrgBean iob = createOrgBean(org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN)); + + IndexOrgBean iob; + if (StringUtils.equals(display, "contents")) { + iob = new IndexOrgBean(org.getOrganisationId(), org.getName(), org.getOrganisationType().getOrganisationTypeId()); + iob = populateContentsOrgBean(iob, org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN)); + forwardPath = "groupContents"; + } else if (StringUtils.equals(display, "header")) { + iob = createHeaderOrgBean(org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN), false); + forwardPath = "groupHeader"; + } else { + iob = createHeaderOrgBean(org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN), true); + } + request.setAttribute("orgBean", iob); request.setAttribute("allowSorting", allowSorting); } - return mapping.findForward("group"); + return mapping.findForward(forwardPath); } @SuppressWarnings({"unchecked"}) - private IndexOrgBean createOrgBean(Organisation org, List roles, String username, boolean isSysAdmin) + private IndexOrgBean createHeaderOrgBean(Organisation org, List roles, String username, boolean isSysAdmin, boolean includeContents) throws SQLException, NamingException { - User user = (User)getService().findByProperty(User.class, "login", username).get(0); IndexOrgBean orgBean = new IndexOrgBean(org.getOrganisationId(), org.getName(), org.getOrganisationType().getOrganisationTypeId()); // set org links @@ -136,7 +153,18 @@ orgBean.setArchivedDate(org.getArchivedDate()); } - // set lesson beans + if (includeContents) { + orgBean = populateContentsOrgBean(orgBean, org, roles, username, isSysAdmin); + } + + return orgBean; + } + + private IndexOrgBean populateContentsOrgBean(IndexOrgBean orgBean, Organisation org, List roles, String username, boolean isSysAdmin) + throws SQLException, NamingException { + User user = (User)getService().findByProperty(User.class, "login", username).get(0); + + // set lesson beans List lessonBeans = null; try { lessonBeans = getLessonBeans(user.getUserId(), org.getOrganisationId(), roles, org.getOrderedLessonIds()); @@ -166,7 +194,7 @@ classRoles.add(userOrganisationRole.getRole().getRoleId()); } if(contains(roles,Role.ROLE_GROUP_MANAGER)) classRoles.add(Role.ROLE_GROUP_MANAGER); - childOrgBeans.add(createOrgBean(organisation,classRoles,username,isSysAdmin)); + childOrgBeans.add(createHeaderOrgBean(organisation,classRoles,username,isSysAdmin,true)); } } Collections.sort(childOrgBeans); Index: lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java =================================================================== diff -u -rb1a3f31300216ef2e6a6ecfd7ed348920ab9dd0e -r07578aaa7f526c0c1b537c127cf5f88e0410d472 --- lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java (.../IndexAction.java) (revision b1a3f31300216ef2e6a6ecfd7ed348920ab9dd0e) +++ lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java (.../IndexAction.java) (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -89,8 +89,8 @@ String tab = WebUtil.readStrParam(request, "tab", true); if (StringUtils.equals(tab, "profile")) { - List courseIds = getService().getArchivedCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); - request.setAttribute("courseIds", courseIds); + List collapsedOrgDTOs = getService().getArchivedCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); + request.setAttribute("collapsedOrgDTOs", collapsedOrgDTOs); return mapping.findForward("profile"); } else if (StringUtils.equals(tab, "editprofile")) { return mapping.findForward("editprofile"); @@ -108,8 +108,8 @@ return mapping.findForward("community"); } - List courseIds = getService().getActiveCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); - request.setAttribute("courseIds", courseIds); + List collapsedOrgDTOs = getService().getActiveCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); + request.setAttribute("collapsedOrgDTOs", collapsedOrgDTOs); return mapping.findForward("main"); } Index: lams_central/src/java/org/lamsfoundation/lams/web/UpdateCollapsedGroupServlet.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/UpdateCollapsedGroupServlet.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/UpdateCollapsedGroupServlet.java (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -0,0 +1,84 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.web; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.usermanagement.Organisation; +import org.lamsfoundation.lams.usermanagement.Role; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.UserOrganisation; +import org.lamsfoundation.lams.usermanagement.UserOrganisationCollapsed; +import org.lamsfoundation.lams.usermanagement.service.UserManagementService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.HttpSessionManager; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author jliew + * + * @web:servlet name="updateCollapsedGroup" + * @web:servlet-mapping url-pattern="/servlet/updateCollapsedGroup" + */ +public class UpdateCollapsedGroupServlet extends HttpServlet { + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // get request parameters + Integer orgId = WebUtil.readIntParam(request, "orgId", false); + String collapsed = request.getParameter("collapsed"); + + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager.getInstance().getServletContext()); + UserManagementService service = (UserManagementService) ctx.getBean("userManagementService"); + + Organisation org = (Organisation)service.findById(Organisation.class, orgId); + User user = service.getUserByLogin(request.getRemoteUser()); + + // sysadmins always have non-collapsed groups; they aren't always members of the org anyway + if (request.isUserInRole(Role.SYSADMIN)) return; + + // insert or update userorg's collapsed status + if (org != null && collapsed != null && user != null) { + UserOrganisation uo = (UserOrganisation)service.getUserOrganisation(user.getUserId(), orgId); + UserOrganisationCollapsed uoc = uo.getUserOrganisationCollapsed(); + if (uoc != null) { + uoc.setCollapsed(new Boolean(collapsed)); + } else { + // new row in lams_user_organisation_collapsed + uoc = new UserOrganisationCollapsed(new Boolean(collapsed), uo); + } + service.save(uoc); + } + } + +} + \ No newline at end of file Index: lams_central/web/group.jsp =================================================================== diff -u -re99f2a23689fd7b7311fedb74b6d2c475d402cc4 -r07578aaa7f526c0c1b537c127cf5f88e0410d472 --- lams_central/web/group.jsp (.../group.jsp) (revision e99f2a23689fd7b7311fedb74b6d2c475d402cc4) +++ lams_central/web/group.jsp (.../group.jsp) (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -1,101 +1,5 @@ <%@ page contentType="text/html; charset=utf-8" language="java"%> -<%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-logic" prefix="logic"%> -<%@ taglib uri="tags-lams" prefix="lams"%> - -
-
-
-

- ( ) -

-
- -
- - - -
-
-
- -
- -
-
-lessons" class="j-lessons"> -

" class="j-single-lesson"> - - " class="disabled-sequence-name-link"> -  () -  () - - - " href="" class="sequence-name-link"> - - - - - - - - -

-
-
- - -
-

- - - ( ) - - - - - - - - -

- -
-
" class="j-subgroup-lessons"> -

" class="j-single-subgroup-lesson"> - - " class="disabled-sequence-name-link"> -  () -  () - - - " href="" class="sequence-name-link"> - - - - - - - - -

-
-
-
-
- -
-
- - - - - -
- + + \ No newline at end of file Index: lams_central/web/groupContents.jsp =================================================================== diff -u --- lams_central/web/groupContents.jsp (revision 0) +++ lams_central/web/groupContents.jsp (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -0,0 +1,79 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-lams" prefix="lams"%> + +
+ +
+
-lessons" class="j-lessons"> +

" class="j-single-lesson"> + + " class="disabled-sequence-name-link"> +  () +  () + + + " href="" class="sequence-name-link"> + + + + + + + + +

+
+
+ + +
+

+ + + ( ) + + + + + + + + +

+ +
+
" class="j-subgroup-lessons"> +

" class="j-single-subgroup-lesson"> + + " class="disabled-sequence-name-link"> +  () +  () + + + " href="" class="sequence-name-link"> + + + + + + + + +

+
+
+
+
+ +
+ + + + Index: lams_central/web/groupHeader.jsp =================================================================== diff -u --- lams_central/web/groupHeader.jsp (revision 0) +++ lams_central/web/groupHeader.jsp (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -0,0 +1,20 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-lams" prefix="lams"%> + +
+
+

+ ( ) +

+
+ +
+ + + +
+
+
+ Index: lams_central/web/includes/javascript/groupDisplay.js =================================================================== diff -u --- lams_central/web/includes/javascript/groupDisplay.js (revision 0) +++ lams_central/web/includes/javascript/groupDisplay.js (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -0,0 +1,110 @@ + + function initLoadGroup(element, stateId, display, orgId) { + jQuery(element).load( + "displayGroup.do", + { + display: display, + stateId: stateId, + orgId: orgId + }, + function() { + toggleGroupContents(element, stateId); + registerToolTip(element); + } + ); + } + + function toggleGroupContents(element, stateId) { + jQuery("a.j-group-header", element).click(function() { + var row = jQuery(this).parent("h2").parent("div.left-buttons").parent("div.row"); + var orgId = jQuery(row).parent("div.course-bg").attr("id"); + var course = jQuery(row).next("div.j-course-contents"); + if (jQuery(course).html() == null) { + loadGroupContents(orgId, stateId); + saveCollapsed(orgId, "false"); + } else { + var display = course.css("display"); + if (jQuery.browser.msie && jQuery.browser.version == '6.0') { + course.slideToggle("fast"); + } else { + course.toggle("fast"); + } + if (display == "none") { + saveCollapsed(orgId, "false"); + } else if (display == "block") { + saveCollapsed(orgId, "true"); + } + } + }); + } + + function saveCollapsed(orgId, collapsed) { + jQuery.ajax({ + url: "servlet/updateCollapsedGroup", + data: { + orgId: orgId, + collapsed: collapsed + } + }); + } + + function loadGroupContents(orgId, stateId) { + jQuery.ajax({ + url: "displayGroup.do", + data: { + orgId: orgId, + stateId: stateId, + display: 'contents' + }, + success: function(html) { + jQuery("#"+orgId).append(html); + registerToolTip(this); + } + }); + } + + function registerToolTip(element) { + jQuery("a.disabled-sequence-name-link, a.sequence-name-link", element).ToolTip({ + className: 'sequence-description-tooltip', + position: 'mouse', + delay: 300 + }); + jQuery("a.disabled-sequence-name-link, a.sequence-name-link", element).each(function(i, element) { + var title = jQuery(element).attr("title"); + if (title!=null) { + var newTitle = title.replace(/\r\n/g,"
").replace(/\n/g,"
") + jQuery(element).attr("title", newTitle); + } + }); + } + + function makeSortable(element, acceptClass) { + jQuery(element).Sortable({ + accept: acceptClass, + axis: "vertically", + containment: [jQuery(element).offset().left, + jQuery(element).offset().top, + jQuery(element).width(), + jQuery(element).height()], + onStop: function() { + var ids = []; + jQuery(this).parent().children("p").each(function(i, element) { + ids.push(element.id); + }); + var jLessonsId = jQuery(this).parent().attr("id"); + var dashIndex = jLessonsId.indexOf("-"); + var orgId = (dashIndex>0 ? jLessonsId.substring(0, dashIndex) : jLessonsId); + jQuery.ajax({ + url: "servlet/saveLessonOrder", + data: { + orgId: orgId, + ids: ids.join(",") + }, + error: function(a,b) { + refresh(); + } + }); + } + }); + } + \ No newline at end of file Index: lams_central/web/main.jsp =================================================================== diff -u -re99f2a23689fd7b7311fedb74b6d2c475d402cc4 -r07578aaa7f526c0c1b537c127cf5f88e0410d472 --- lams_central/web/main.jsp (.../main.jsp) (revision e99f2a23689fd7b7311fedb74b6d2c475d402cc4) +++ lams_central/web/main.jsp (.../main.jsp) (revision 07578aaa7f526c0c1b537c127cf5f88e0410d472) @@ -29,73 +29,13 @@ + + +