-
Notifications
You must be signed in to change notification settings - Fork 34
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 #2056 from FrenjaminBanklin/issue/2000-filter-modu…
…le-library Adds a filter to the Module Library page.
- Loading branch information
Showing
15 changed files
with
356 additions
and
64 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
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
4 changes: 4 additions & 0 deletions
4
packages/app/obojobo-repository/shared/components/pages/page-library-client.jsx
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,4 @@ | ||
import { hydrateElWithoutStore } from '../../react-utils' | ||
import PageLibrary from './page-library.jsx' | ||
|
||
hydrateElWithoutStore(PageLibrary, '#react-hydrate-root') |
17 changes: 17 additions & 0 deletions
17
packages/app/obojobo-repository/shared/components/pages/page-library-server.jsx
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,17 @@ | ||
const React = require('react') | ||
const DefaultLayout = require('../layouts/default') | ||
const { convertPropsToString } = require('../../react-utils') | ||
|
||
const PageLibraryServer = props => { | ||
return ( | ||
<DefaultLayout | ||
title={`Obojobo Module Library`} | ||
appScriptUrl={props.appJsUrl} | ||
appCSSUrl={props.appCSSUrl} | ||
> | ||
<span id="react-hydrate-root" data-react-props={convertPropsToString(props)} /> | ||
</DefaultLayout> | ||
) | ||
} | ||
|
||
module.exports = PageLibraryServer |
93 changes: 64 additions & 29 deletions
93
packages/app/obojobo-repository/shared/components/pages/page-library.jsx
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 |
---|---|---|
@@ -1,54 +1,89 @@ | ||
require('./page-library.scss') | ||
|
||
const React = require('react') | ||
import LayoutDefault from '../layouts/default' | ||
import RepositoryNav from '../repository-nav' | ||
import RepositoryBanner from '../repository-banner' | ||
import Module from '../module' | ||
|
||
const Search = require('../search') | ||
|
||
const { filterModules } = require('../../util/filter-functions') | ||
|
||
const title = 'Module Library' | ||
|
||
const PageLibrary = props => ( | ||
<LayoutDefault | ||
title={title} | ||
className="repository--library" | ||
appCSSUrl={props.appCSSUrl /* provided by resp.render() */} | ||
> | ||
<RepositoryNav | ||
userId={props.currentUser.id} | ||
userPerms={props.currentUser.perms} | ||
avatarUrl={props.currentUser.avatarUrl} | ||
displayName={`${props.currentUser.firstName} ${props.currentUser.lastName}`} | ||
noticeCount={0} | ||
/> | ||
<RepositoryBanner className="default-bg" title={title} /> | ||
|
||
<div className="repository--section-wrapper"> | ||
<section className="repository--main-content"> | ||
<p>Find modules for your course.</p> | ||
{props.collections.map(collection => ( | ||
<span key={collection.id}> | ||
const PageLibrary = props => { | ||
const [filterString, setFilterString] = React.useState('') | ||
|
||
let filteredDisplay = props.collections | ||
.map(collection => { | ||
const visibleModulesInCollection = filterModules(collection.drafts, filterString, false) | ||
const modulesInCollectionRender = visibleModulesInCollection.map(draft => ( | ||
<Module key={draft.draftId} {...draft}></Module> | ||
)) | ||
|
||
if (visibleModulesInCollection.length) { | ||
return ( | ||
<span | ||
key={collection.id} | ||
className="repository--main-content--item-list--collection-wrapper" | ||
> | ||
<div className="repository--main-content--title"> | ||
<span>{collection.title}</span> | ||
</div> | ||
<div className="repository--item-list--collection"> | ||
<div className="repository--item-list--collection--item-wrapper"> | ||
<div className="repository--item-list--row"> | ||
<div className="repository--item-list--collection--item--multi-wrapper"> | ||
{collection.drafts.map(draft => ( | ||
<Module key={draft.draftId} {...draft}></Module> | ||
))} | ||
{modulesInCollectionRender} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</span> | ||
))} | ||
</section> | ||
</div> | ||
</LayoutDefault> | ||
) | ||
) | ||
} | ||
return null | ||
}) | ||
.filter(c => c !== null) | ||
|
||
if (!filteredDisplay.length) { | ||
filteredDisplay = ( | ||
<span className="repository--main-content--no-filter-results-text"> | ||
No modules found matching provided filter! | ||
</span> | ||
) | ||
} | ||
|
||
return ( | ||
<LayoutDefault | ||
title={title} | ||
className="repository--library" | ||
appCSSUrl={props.appCSSUrl /* provided by resp.render() */} | ||
> | ||
<RepositoryNav | ||
userId={props.currentUser.id} | ||
userPerms={props.currentUser.perms} | ||
avatarUrl={props.currentUser.avatarUrl} | ||
displayName={`${props.currentUser.firstName} ${props.currentUser.lastName}`} | ||
noticeCount={0} | ||
/> | ||
<RepositoryBanner className="default-bg" title={title} /> | ||
|
||
<div className="repository--section-wrapper"> | ||
<section className="repository--main-content"> | ||
<p>Find modules for your course.</p> | ||
<Search value={filterString} placeholder="Filter Modules..." onChange={setFilterString} /> | ||
{filteredDisplay} | ||
</section> | ||
</div> | ||
</LayoutDefault> | ||
) | ||
} | ||
|
||
PageLibrary.defaultProps = { | ||
collections: [] | ||
} | ||
|
||
module.exports = PageLibrary | ||
// module.exports = PageLibrary | ||
export default PageLibrary |
14 changes: 14 additions & 0 deletions
14
packages/app/obojobo-repository/shared/components/pages/page-library.scss
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,14 @@ | ||
/* stylelint-disable */ | ||
@import '../../../client/css/defaults'; | ||
|
||
// reduce a larger font-size set on an ancestor in the library page | ||
.repository--nav--links--search { | ||
font-size: 0.9em; | ||
} | ||
|
||
.repository--main-content--no-filter-results-text { | ||
display: block; | ||
margin: 1em auto; | ||
color: $color-text-placeholder; | ||
text-align: center; | ||
} |
Oops, something went wrong.