forked from ucfopen/Obojobo
-
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.
ucfopen#2000 Module library page now hydrates to enable live filtrati…
…on. Module/collection filter functions were moved into their own file to be shared easily between components. Added a function to the collection backend model to enable looking up all public collections, whenever that becomes necessary.
- Loading branch information
1 parent
63e28c3
commit 0bbf5a6
Showing
13 changed files
with
327 additions
and
69 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
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 |
98 changes: 60 additions & 38 deletions
98
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,76 @@ | ||
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}> | ||
<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> | ||
))} | ||
</div> | ||
const PageLibrary = props => { | ||
const [filterString, setFilterString] = React.useState('') | ||
|
||
const 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}> | ||
<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"> | ||
{modulesInCollectionRender} | ||
</div> | ||
</div> | ||
</div> | ||
</span> | ||
))} | ||
</section> | ||
</div> | ||
</LayoutDefault> | ||
) | ||
</div> | ||
</span> | ||
) | ||
} | ||
return null | ||
}) | ||
|
||
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 |
4 changes: 4 additions & 0 deletions
4
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,4 @@ | ||
// reduce a larger font-size set on an ancestor in the library page | ||
.repository--nav--links--search { | ||
font-size: 0.9em; | ||
} |
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
Oops, something went wrong.