forked from instructure/canvas-lms
-
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.
allow filtering assignment columns by module
closes CNVS-36724 test plan: * Create a course with multiple modules and at least one student * Ensure each module has at least two assignments * Create an assignment outside of any modules as well * Go to Gradezilla * Verify that you see a column for each assignment you created for that course, including assignments from all modules and assignments that aren't part of any module * From the View menu, ensure "Modules" is selected in the Filters menu group * Verify that a button labelled "All Modules" shows up next to the other filters (or next to the Search field if no other filters are in play) * Click on the "All Modules" button and verify that you see the names of all the modules you created for this course * Choose one of the modules * Verify the button now changes to say the name of the module instead of "All Modules" * Verify that there is no page reload * Verify that only columns for assignments from the selected module are now visible * Select a different filter from the module filter * Verify the button now changes to say the name of the new module * Verify that there is no page reload * Verify that only columns for assignments from the selected module are now visible * Select "All Modules" again * Verify that you see a column for each assignment you created for that course, including assignments from all modules and assignments that aren't part of any module Change-Id: I657c65f54f209bdd245a0d1c103436164c16e147 Reviewed-on: https://gerrit.instructure.com/114222 Tested-by: Jenkins Reviewed-by: Keith T. Garner <[email protected]> Reviewed-by: Derek Bender <[email protected]> QA-Review: KC Naegle <[email protected]> Product-Review: Christi Wruck
- Loading branch information
Showing
7 changed files
with
365 additions
and
11 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
84 changes: 84 additions & 0 deletions
84
app/jsx/gradezilla/default_gradebook/components/ModuleFilter.js
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,84 @@ | ||
/* | ||
* Copyright (C) 2017 - present Instructure, Inc. | ||
* | ||
* This file is part of Canvas. | ||
* | ||
* Canvas is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License as published by the Free | ||
* Software Foundation, version 3 of the License. | ||
* | ||
* Canvas 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 Affero General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { arrayOf, func, number, shape, string } from 'prop-types'; | ||
import IconMiniArrowDownSolid from 'instructure-icons/lib/Solid/IconMiniArrowDownSolid'; | ||
import Button from 'instructure-ui/lib/components/Button'; | ||
import { MenuItem } from 'instructure-ui/lib/components/Menu'; | ||
import PopoverMenu from 'instructure-ui/lib/components/PopoverMenu'; | ||
|
||
function currentlySelectedModule (modules, selectedModuleId) { | ||
const selectedModule = modules.find(module => module.id === selectedModuleId); | ||
|
||
return selectedModule || {}; | ||
} | ||
|
||
function sortedModules (modules) { | ||
return modules.sort((a, b) => (a.position - b.position)); | ||
} | ||
|
||
class ModuleFilter extends React.Component { | ||
static propTypes = { | ||
modules: arrayOf( | ||
shape({ | ||
id: string.isRequired, | ||
name: string.isRequired, | ||
position: number.isRequired | ||
})).isRequired, | ||
onSelect: func.isRequired, | ||
selectedModuleId: string.isRequired | ||
}; | ||
|
||
onSelectModule = (_event, value) => { | ||
this.props.onSelect(value); | ||
} | ||
|
||
bindMenuContent = (menuContent) => { | ||
this.menuContent = menuContent; | ||
} | ||
|
||
render () { | ||
const { name } = currentlySelectedModule(this.props.modules, this.props.selectedModuleId); | ||
|
||
return ( | ||
<PopoverMenu | ||
trigger={ | ||
<Button> | ||
{name}<IconMiniArrowDownSolid /> | ||
</Button> | ||
} | ||
contentRef={this.bindMenuContent} | ||
onSelect={this.onSelectModule} | ||
> | ||
{ | ||
sortedModules(this.props.modules).map(module => ( | ||
<MenuItem | ||
key={module.id} | ||
value={module.id} | ||
> | ||
{module.name} | ||
</MenuItem> | ||
)) | ||
} | ||
</PopoverMenu> | ||
) | ||
} | ||
} | ||
|
||
export default ModuleFilter; |
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
Oops, something went wrong.