Skip to content

Commit

Permalink
SAK-46087 GBNG > import > item selection > no way to select all (saka…
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones86 authored Aug 31, 2021
1 parent 2be5b08 commit 2b1df9e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gradebookng/bundle/src/main/bundle/gradebookng.properties
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ importExport.confirmation.commentsdisplay = {0} (Comments)
importExport.confirmation.success = Gradebook items imported successfully!
importExport.confirmation.failure = Errors during gradebook item import.

importExport.label.selectAllNone = Select All / None
importExport.label.selectItem = Select Item
importExport.label.selectComment = Select Comment

#ProcessedGradeItem.Status map
importExport.status.UPDATE = Update
importExport.status.NEW = New
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2><wicket:message key="importExport.selection.heading" /></h2>
<table id="grade_import_selection" class="table table-condensed">
<thead>
<tr>
<th class="col-xs-1">&nbsp;</th>
<th class="col-xs-1"><input type="checkbox" id="selectAllNone" aria-controls="grade_import_selection" wicket:message="aria-label:importExport.label.selectAllNone" /></th>
<th class="col-xs-6"><wicket:message key="importExport.selection.title" /></th>
<th class="col-xs-2"><wicket:message key="importExport.selection.points" /></th>
<th class="col-xs-3"><wicket:message key="importExport.selection.status" /></th>
Expand All @@ -23,14 +23,14 @@ <h2><wicket:message key="importExport.selection.heading" /></h2>
<tbody>
<wicket:container wicket:id="items">
<tr wicket:id="gb_item" class="gb_item">
<td><input type="checkbox" wicket:id="checkbox"/></td>
<td><input type="checkbox" wicket:id="checkbox" class="import_selection_item" wicket:message="aria-label:importExport.label.selectItem" /></td>
<td class="item_title"><wicket:container wicket:id="title">[assignment 1]</wicket:container></td>
<td class="item_points"><wicket:container wicket:id="points">[50]</wicket:container></td>
<td class="item_status"><wicket:container wicket:id="status">[no changes/new]</wicket:container></td>
</tr>

<tr wicket:id="comments" class="comment">
<td><input type="checkbox" wicket:id="checkbox"/></td>
<td><input type="checkbox" wicket:id="checkbox" class="import_selection_comment" wicket:message="aria-label:importExport.label.selectComment" /></td>
<td class="item_title"><wicket:message key="importExport.commentname" /></td>
<td class="item_points">&nbsp;</td>
<td class="item_status"><wicket:container wicket:id="status">[no changes/new]</wicket:container></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
Expand All @@ -50,6 +53,7 @@
import org.sakaiproject.gradebookng.tool.model.ImportWizardModel;
import org.sakaiproject.gradebookng.tool.pages.ImportExportPage;
import org.sakaiproject.gradebookng.tool.panels.BasePanel;
import org.sakaiproject.portal.util.PortalUtils;

/**
* Page to allow the user to select which items in the imported file are to be imported
Expand Down Expand Up @@ -299,6 +303,10 @@ protected void onUpdate(final AjaxRequestTarget target) {

} else {
gbItemWrap.removeStyle(GbStyle.SELECTED);
if (commentItem.isSelectable()) {
commentItem.setSelected(false);
commentWrap.removeStyle(GbStyle.SELECTED);
}
}
gbItemWrap.style();
commentWrap.style();
Expand Down Expand Up @@ -439,4 +447,13 @@ private ProcessedGradeItem setupBlankCommentItem() {
rval.setStatus(Status.SKIP);
return rval;
}

@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = PortalUtils.getCDNQuery();
response.render(JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-import.js%s", version)));
response.render(OnDomReadyHeaderItem.forScript("$('#selectAllNone').click(function(){ GBI.selectAllNone(this); });"));
}
}
25 changes: 25 additions & 0 deletions gradebookng/tool/src/webapp/scripts/gradebook-import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**************************************************************************************
* Gradebook Import Javascript
*************************************************************************************/
var GBI = GBI || {};

GBI.selectAllNone = function( element )
{
const selectAll = $(element).prop( "checked" );

// Toggling the gradebook item checkbox will also toggle it's corresponding comment checkbox if it has one, but not vice versa; see below comment
$(".import_selection_item").each( function() { GBI.toggleCheckBox( selectAll, this ); });

// This is needed in the case where comment is selected but associated gradebook item is not
$(".import_selection_comment").each( function() { GBI.toggleCheckBox( selectAll, this ); });
};

GBI.toggleCheckBox = function( selectAll, element )
{
const checkbox = $(element);
if( (selectAll && !checkbox.prop( "checked" )) || (!selectAll && checkbox.prop( "checked" )) )
{
// Fire click handler so we don't have to duplicate the handler's logic here
checkbox.click();
}
};

0 comments on commit 2b1df9e

Please sign in to comment.