Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue/2714 Decoupled menu, page, article, block and component #2716

Merged
merged 21 commits into from
Apr 20, 2020

Conversation

oliverfoster
Copy link
Member

@oliverfoster oliverfoster commented Apr 2, 2020

fixes #2714

PR goes into #2713 then into #2711 then into master

Views and models no longer have hard-coded relationships, instead they are determined by the JSON. All core views and models can be replaced. Multi-menu support is now possible by simply registering the menu view with Adapt.register('course menu boxmenu', { view: BoxMenuView });

Added

  • Adapt.store which is the Adapt.componentStore extended to contain all content views and models not just component views and models
  • AdaptModel functions for matching type groups such as "blocks", "components", "pages" etc: getTypeGroup(), getTypeGroups(), isTypeGroup(typegroup)
  • Adapt functions for fetching model and view classes: getViewName, getViewClass, getModelName, getModelClass
  • AdaptModel property hasManagedChildren to signify which models automatically render and listen to their children models
  • New json properties _model and _view specify the name of the registered model or view to use on instantiation. Adapt will use properties _type, _component, _model and _type, _component, _view in order to determine which model or view should be used respectively
  • Adapt.log.warnOnce
  • Adapt is now JSON filename agnostic in the language folder (build.js and config.json are still fixed filenames outside of the language folders).
  • Each file must contain an object or an array of objects with, at minimum a { "_type": "" }, { "_component": "" } or { "_model": "" } attribute on each JSON file object as this denotes the corresponding model inside the framework.
  • Each language folder must have a { "_type": "course" } object.
  • grunt task language-data-manifests

Changed

  • The Adapt.register name parameter can take an arrray or space separated list of names
  • Registered all core content views and models with the Adapt.store
  • Router uses Adapt.store to lookup ContentObject views
  • AdaptView addChildren uses Adapt.store to lookup child views
  • Adapt.data is now a collection of all models
  • Adapt.data.filter is used to filter all data models throughout
  • Adapt.data uses Adapt.store to lookup models
  • Reworked findRelativeModel so that it doesn't use hard-coded type groups and so that it returns the rootModel when requested
  • Adapt.parseRelativeString so that it doesn't use hard-coded type groups
  • Menus will only be rendered by the event router:menu if aViewClass isn't found for them
  • All core functions which accept type groups now use the new typegroup functions findAncestor, findDescendantModels, findRelativeModel
  • Reworked src/core/js/data.js to load manifest, files and become the collection for all models. It now has no references to the menu, page, article, block and component structure
  • Moved menu, page, article, block and component controller parts from data into src/core/js/mpabc.js
  • AdaptCollection so that it is no longer a data loader, only a container.
  • Improved babel sourcemapping so that it works best in dev build mode.

Deprecated

  • AdaptModel properties, _parent, _children, _siblings
  • Adapt.contentObjects, Adapt.articles, Adapt.blocks, Adapt.components in favour of Adapt.data

Removed

  • All hard-coded references to type groups such as "blocks", "components", "pages" etc,

Testing

Tested with languagePicker, works as normal.
change events trigger from Adapt.data and Adapt.blocks, Adapt.components etc as intended

Already merged #2645 into this pr.

src/core/js/adapt.js Outdated Show resolved Hide resolved
src/core/js/adapt.js Outdated Show resolved Hide resolved
src/core/js/adapt.js Outdated Show resolved Hide resolved
src/core/js/data.js Outdated Show resolved Hide resolved
src/core/js/models/adaptModel.js Outdated Show resolved Hide resolved
@oliverfoster oliverfoster linked an issue Apr 4, 2020 that may be closed by this pull request
@oliverfoster oliverfoster changed the base branch from issue/2712 to master April 7, 2020 12:17
@oliverfoster oliverfoster changed the base branch from master to issue/2712 April 7, 2020 12:17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor

@tomgreenfield tomgreenfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️

src/core/js/models/adaptModel.js Outdated Show resolved Hide resolved
@olivermartinfoster olivermartinfoster merged commit 61c1a97 into issue/2712 Apr 20, 2020
@olivermartinfoster olivermartinfoster deleted the issue/2714 branch April 20, 2020 09:47
@oliverfoster oliverfoster mentioned this pull request Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decouple core views
4 participants