MDL-67585 core_course: use new content item service to load the chooser
authorJake Dallimore <jake@moodle.com>
Fri, 31 Jan 2020 06:35:47 +0000 (14:35 +0800)
committerJake Dallimore <jake@moodle.com>
Thu, 20 Feb 2020 03:42:23 +0000 (11:42 +0800)
course/amd/build/activitychooser.min.js
course/amd/build/activitychooser.min.js.map
course/amd/build/local/activitychooser/dialogue.min.js
course/amd/build/local/activitychooser/dialogue.min.js.map
course/amd/build/local/activitychooser/repository.min.js
course/amd/build/local/activitychooser/repository.min.js.map
course/amd/src/activitychooser.js
course/amd/src/local/activitychooser/dialogue.js
course/amd/src/local/activitychooser/repository.js
course/templates/chooser_help.mustache
course/templates/chooser_item.mustache

index eabdac2..929586d 100644 (file)
Binary files a/course/amd/build/activitychooser.min.js and b/course/amd/build/activitychooser.min.js differ
index 4a79805..c5fc3df 100644 (file)
Binary files a/course/amd/build/activitychooser.min.js.map and b/course/amd/build/activitychooser.min.js.map differ
index c9ef8b7..b28b3db 100644 (file)
Binary files a/course/amd/build/local/activitychooser/dialogue.min.js and b/course/amd/build/local/activitychooser/dialogue.min.js differ
index 391f7f6..5ca8140 100644 (file)
Binary files a/course/amd/build/local/activitychooser/dialogue.min.js.map and b/course/amd/build/local/activitychooser/dialogue.min.js.map differ
index da5b3c7..a821358 100644 (file)
Binary files a/course/amd/build/local/activitychooser/repository.min.js and b/course/amd/build/local/activitychooser/repository.min.js differ
index 67b1590..0d35705 100644 (file)
Binary files a/course/amd/build/local/activitychooser/repository.min.js.map and b/course/amd/build/local/activitychooser/repository.min.js.map differ
index 5659961..2e5ecfc 100644 (file)
@@ -100,10 +100,10 @@ const registerListenerEvents = (courseId) => {
 const sectionIdMapper = (webServiceData, id) => {
     // We need to take a fresh deep copy of the original data as an object is a reference type.
     const newData = JSON.parse(JSON.stringify(webServiceData));
-    newData.allmodules.forEach((module) => {
-        module.urls.addoption += '&section=' + id;
+    newData.content_items.forEach((module) => {
+        module.link += '&section=' + id;
     });
-    return newData.allmodules;
+    return newData.content_items;
 };
 
 /**
index b8407e0..f443d9a 100644 (file)
@@ -318,7 +318,7 @@ export const displayChooser = (origin, modal, sectionModules) => {
     // Make a map so we can quickly fetch a specific module's object for either rendering or searching.
     const mappedModules = new Map();
     sectionModules.forEach((module) => {
-        mappedModules.set(module.modulename, module);
+        mappedModules.set(module.componentname + '_' + module.link, module);
     });
 
     // Register event listeners.
index 1e6f1a5..e6a09c5 100644 (file)
@@ -31,7 +31,7 @@ import ajax from 'core/ajax';
  */
 export const activityModules = (courseid) => {
     const request = {
-        methodname: 'core_course_get_activity_picker_info',
+        methodname: 'core_course_get_course_content_items',
         args: {
             courseid: courseid,
         },
index ad4dda2..aaf4190 100644 (file)
 
     Example context (json):
     {
-        "label": "Option name",
-        "description": "Option description",
-        "urls": {
-            "addoption": "http://addoptionurl.com"
-        },
-        "icon": "<img class='icon' src='http://urltooptionicon'>"
+        "id": 125,
+        "name": "assign",
+        "title": "Assignment",
+        "link": "http://yourmoodle/modedit.php?id=x&itemtype=y",
+        "icon": "<img class='icon' src='http://urltooptionicon'>",
+        "help": "This is a description of the assignment activity",
+        "archetype": 0,
+        "componentname": "mod_assign",
+        "favourite": 1
     }
 }}
 <div class="optionsummary" tabindex="-1" data-region="chooser-option-summary-container" aria-labelledby="optionsummary_label" aria-describedby="optionsumary_desc">
     <div class="content text-left mb-5 px-5 py-4" data-region="chooser-option-summary-content-container">
         <div class="heading mb-4">
             <h5 id="optionsummary_label">
-                {{#icon}}
-                    {{>core/pix_icon}}
-                {{/icon}}
-                {{label}}
+                {{{icon}}}
+                {{title}}
             </h5>
         </div>
         <div id="optionsumary_desc" class="description" data-region="summary-description" tabindex="0">
-            {{{description}}}
+            {{{help}}}
         </div>
     </div>
     <div class="actions fixed-bottom w-100 d-flex justify-content-between position-absolute py-3 px-4" data-region="chooser-option-summary-actions-container">
-        <button data-action="close-chooser-option-summary" class="closeoptionsummary btn btn-secondary" tabindex="0" data-modname="{{modulename}}">
+        <button data-action="close-chooser-option-summary" class="closeoptionsummary btn btn-secondary" tabindex="0" data-modname="{{componentname}}_{{link}}">
             {{#str}} back {{/str}}
         </button>
-        <a href="{{urls.addoption}}" title="{{#str}} addnew, moodle, {{label}} {{/str}}" data-action="add-chooser-option" class="addoption btn btn-primary" tabindex="0">
+        <a href="{{link}}" title="{{#str}} addnew, moodle, {{title}} {{/str}}" data-action="add-chooser-option" class="addoption btn btn-primary" tabindex="0">
             {{#str}} add {{/str}}
         </a>
     </div>
index 92b930f..dd75b6a 100644 (file)
         "icon": "<img class='icon' src='http://urltooptionicon'>"
     }
 }}
-<div role="menuitem" tabindex="-1" aria-label="{{label}}" class="option d-block text-center py-3 px-2" data-region="chooser-option-container" data-modname="{{modulename}}">
+<div role="menuitem" tabindex="-1" aria-label="{{label}}" class="option d-block text-center py-3 px-2" data-region="chooser-option-container" data-modname="{{componentname}}_{{link}}">
     <div class="optioninfo w-100" data-region="chooser-option-info-container">
-        <a class="d-block" href="{{urls.addoption}}" title="{{#str}} addnew, moodle, {{label}} {{/str}}" tabindex="-1" data-action="add-chooser-option">
+        <a class="d-block" href="{{link}}" title="{{#str}} addnew, moodle, {{title}} {{/str}}" tabindex="-1" data-action="add-chooser-option">
             <span class="optionicon d-block">
-                {{#icon}}
-                    {{>core/pix_icon}}
-                {{/icon}}
+                {{{icon}}}
             </span>
-            <span class="optionname d-block">{{label}}</span>
+            <span class="optionname d-block">{{title}}</span>
         </a>
         <div class="optionactions btn-group" role="group" data-region="chooser-option-actions-container">
             <button class="btn btn-icon icon-no-margin icon-size-3 m-0 optionaction" data-action="show-option-summary" tabindex="-1">
                 <span aria-hidden="true">{{#pix}} docs, core {{/pix}}</span>
-                <span class="sr-only">{{#str}} informationformodule, core_course, {{label}} {{/str}}</span>
+                <span class="sr-only">{{#str}} informationformodule, core_course, {{title}} {{/str}}</span>
             </button>
         </div>
     </div>