MDL-71528 usertours: End button text for one step user tours
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("tool_usertours/usertours",["core/ajax","tool_usertours/tour","jquery","core/templates","core/str","core/log","core/notification"],function(a,b,c,d,e,f,g){var h={tourId:null,currentTour:null,init:function init(a,b){for(var d=[],e=0;e<b.length;e++){d[e]="tool_usertours/filter_"+b[e]}require(d,function(){var d=null;for(var k in a){for(var e=a[k],f=0,g;f<b.length;f++){g=arguments[f];if(g.filterMatches(e)){d=e}else{d=null;break}}if(d){break}}if(null===d){return}h.tourId=d.tourId;var j=d.startTour;if("undefined"==typeof j){j=!0}if(j){h.fetchTour(h.tourId)}h.addResetLink();c("body").on("click","[data-action=\"tool_usertours/resetpagetour\"]",function(a){a.preventDefault();h.resetTourState(h.tourId)})})},fetchTour:function fetchTour(b){M.util.js_pending("admin_usertour_fetchTour"+b);c.when(a.call([{methodname:"tool_usertours_fetch_and_start_tour",args:{tourid:b,context:M.cfg.contextid,pageurl:window.location.href}}])[0],d.render("tool_usertours/tourstep",{})).then(function(a,c){if(!a.hasOwnProperty("tourconfig")){return}return h.startBootstrapTour(b,c[0],a.tourconfig)}).always(function(){M.util.js_complete("admin_usertour_fetchTour"+b)}).fail(g.exception)},addResetLink:function addResetLink(){var a;M.util.js_pending("admin_usertour_addResetLink");if(c(".tool_usertours-resettourcontainer").length){a=c(".tool_usertours-resettourcontainer")}else if(c(".logininfo").length){a=c(".logininfo")}else if(c("footer").length){a=c("footer")}else{a=c("body")}d.render("tool_usertours/resettour",{}).then(function(b,c){d.appendNodeContents(a,b,c)}).always(function(){M.util.js_complete("admin_usertour_addResetLink")}).fail()},startBootstrapTour:function startBootstrapTour(a,c,d){if(h.currentTour){d.onEnd=null;h.currentTour.endTour();delete h.currentTour}d.eventHandlers={afterEnd:[h.markTourComplete],afterRender:[h.markStepShown]};d.tourName=d.name;delete d.name;d.template=c;d.steps=d.steps.map(function(a){if("undefined"!=typeof a.element){a.target=a.element;delete a.element}if("undefined"!=typeof a.reflex){a.moveOnClick=!!a.reflex;delete a.reflex}if("undefined"!=typeof a.content){a.body=a.content;delete a.content}return a});h.currentTour=new b(d);return h.currentTour.startTour()},markStepShown:function markStepShown(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_step_shown",args:{tourid:h.tourId,context:M.cfg.contextid,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},markTourComplete:function markTourComplete(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_complete_tour",args:{tourid:h.tourId,context:M.cfg.contextid,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},resetTourState:function resetTourState(b){c.when(a.call([{methodname:"tool_usertours_reset_tour",args:{tourid:b,context:M.cfg.contextid,pageurl:window.location.href}}])[0]).then(function(a){if(a.startTour){h.fetchTour(a.startTour)}}).fail(g.exception)}};return{init:h.init,resetTourState:h.resetTourState}});
|
||||
function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}f(void 0)})}}define ("tool_usertours/usertours",["core/ajax","tool_usertours/tour","jquery","core/templates","core/str","core/log","core/notification"],function(a,b,c,d,e,f,g){var h={tourId:null,currentTour:null,init:function init(a,b){for(var d=[],e=0;e<b.length;e++){d[e]="tool_usertours/filter_"+b[e]}require(d,function(){var d=null;for(var k in a){for(var e=a[k],f=0,g;f<b.length;f++){g=arguments[f];if(g.filterMatches(e)){d=e}else{d=null;break}}if(d){break}}if(null===d){return}h.tourId=d.tourId;var j=d.startTour;if("undefined"==typeof j){j=!0}if(j){h.fetchTour(h.tourId)}h.addResetLink();c("body").on("click","[data-action=\"tool_usertours/resetpagetour\"]",function(a){a.preventDefault();h.resetTourState(h.tourId)})})},fetchTour:function(){var b=_asyncToGenerator(regeneratorRuntime.mark(function b(c){var e,f;return regeneratorRuntime.wrap(function(b){while(1){switch(b.prev=b.next){case 0:M.util.js_pending("admin_usertour_fetchTour"+c);b.prev=1;b.next=4;return a.call([{methodname:"tool_usertours_fetch_and_start_tour",args:{tourid:c,context:M.cfg.contextid,pageurl:window.location.href}}])[0];case 4:e=b.sent;if(!e.hasOwnProperty("tourconfig")){b.next=10;break}b.next=8;return d.renderForPromise("tool_usertours/tourstep",e.tourconfig);case 8:f=b.sent;h.startBootstrapTour(c,f.html,e.tourconfig);case 10:b.next=15;break;case 12:b.prev=12;b.t0=b["catch"](1);g.exception(b.t0);case 15:M.util.js_complete("admin_usertour_fetchTour"+c);case 16:case"end":return b.stop();}}},b,null,[[1,12]])}));return function fetchTour(){return b.apply(this,arguments)}}(),addResetLink:function addResetLink(){var a;M.util.js_pending("admin_usertour_addResetLink");if(c(".tool_usertours-resettourcontainer").length){a=c(".tool_usertours-resettourcontainer")}else if(c(".logininfo").length){a=c(".logininfo")}else if(c("footer").length){a=c("footer")}else{a=c("body")}d.render("tool_usertours/resettour",{}).then(function(b,c){d.appendNodeContents(a,b,c)}).always(function(){M.util.js_complete("admin_usertour_addResetLink")}).fail()},startBootstrapTour:function startBootstrapTour(a,c,d){if(h.currentTour){d.onEnd=null;h.currentTour.endTour();delete h.currentTour}d.eventHandlers={afterEnd:[h.markTourComplete],afterRender:[h.markStepShown]};d.tourName=d.name;delete d.name;d.template=c;d.steps=d.steps.map(function(a){if("undefined"!=typeof a.element){a.target=a.element;delete a.element}if("undefined"!=typeof a.reflex){a.moveOnClick=!!a.reflex;delete a.reflex}if("undefined"!=typeof a.content){a.body=a.content;delete a.content}return a});h.currentTour=new b(d);return h.currentTour.startTour()},markStepShown:function markStepShown(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_step_shown",args:{tourid:h.tourId,context:M.cfg.contextid,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},markTourComplete:function markTourComplete(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_complete_tour",args:{tourid:h.tourId,context:M.cfg.contextid,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},resetTourState:function resetTourState(b){c.when(a.call([{methodname:"tool_usertours_reset_tour",args:{tourid:b,context:M.cfg.contextid,pageurl:window.location.href}}])[0]).then(function(a){if(a.startTour){h.fetchTour(a.startTour)}}).fail(g.exception)}};return{init:h.init,resetTourState:h.resetTourState}});
|
||||
//# sourceMappingURL=usertours.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -79,37 +79,32 @@ function(ajax, BootstrapTour, $, templates, str, log, notification) {
|
||||
* @method fetchTour
|
||||
* @param {Number} tourId The ID of the tour to start.
|
||||
*/
|
||||
fetchTour: function(tourId) {
|
||||
fetchTour: async function(tourId) {
|
||||
M.util.js_pending('admin_usertour_fetchTour' + tourId);
|
||||
$.when(
|
||||
ajax.call([
|
||||
|
||||
try {
|
||||
const response = await ajax.call([
|
||||
{
|
||||
methodname: 'tool_usertours_fetch_and_start_tour',
|
||||
args: {
|
||||
tourid: tourId,
|
||||
context: M.cfg.contextid,
|
||||
pageurl: window.location.href,
|
||||
tourid: tourId,
|
||||
context: M.cfg.contextid,
|
||||
pageurl: window.location.href,
|
||||
}
|
||||
}
|
||||
])[0],
|
||||
templates.render('tool_usertours/tourstep', {})
|
||||
)
|
||||
.then(function(response, template) {
|
||||
// If we don't have any tour config (because it doesn't need showing for the current user), return early.
|
||||
if (!response.hasOwnProperty('tourconfig')) {
|
||||
return;
|
||||
])[0];
|
||||
if (response.hasOwnProperty('tourconfig')) {
|
||||
const template = await templates.renderForPromise('tool_usertours/tourstep', response.tourconfig);
|
||||
|
||||
usertours.startBootstrapTour(tourId, template.html, response.tourconfig);
|
||||
}
|
||||
|
||||
return usertours.startBootstrapTour(tourId, template[0], response.tourconfig);
|
||||
})
|
||||
.always(function() {
|
||||
M.util.js_complete('admin_usertour_fetchTour' + tourId);
|
||||
|
||||
return;
|
||||
})
|
||||
.fail(notification.exception);
|
||||
} catch (error) {
|
||||
notification.exception(error);
|
||||
}
|
||||
M.util.js_complete('admin_usertour_fetchTour' + tourId);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Add a reset link to the page.
|
||||
*
|
||||
|
||||
+4
-3
@@ -101,9 +101,10 @@ class tour extends external_api {
|
||||
*/
|
||||
public static function fetch_and_start_tour_returns() {
|
||||
return new external_single_structure([
|
||||
'tourconfig' => new external_single_structure([
|
||||
'name' => new external_value(PARAM_RAW, 'Tour Name'),
|
||||
'steps' => new external_multiple_structure(self::step_structure_returns()),
|
||||
'tourconfig' => new external_single_structure([
|
||||
'name' => new external_value(PARAM_RAW, 'Tour Name'),
|
||||
'steps' => new external_multiple_structure(self::step_structure_returns()),
|
||||
'onesteptour' => new external_value(PARAM_BOOL, 'Is a one step tour', VALUE_DEFAULT, false),
|
||||
], 'Tour config', VALUE_OPTIONAL)
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -60,12 +60,18 @@ class tour implements \renderable {
|
||||
$result = (object) [
|
||||
'name' => $this->tour->get_tour_key(),
|
||||
'steps' => [],
|
||||
'onesteptour' => false,
|
||||
];
|
||||
|
||||
foreach ($this->tour->get_steps() as $step) {
|
||||
$result->steps[] = (new step($step))->export_for_template($output);
|
||||
}
|
||||
|
||||
// Check if its a only one step tour.
|
||||
if (count($result->steps) == 1) {
|
||||
$result->onesteptour = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ $string['tourlist_explanation'] = 'You can create as many tours as you like and
|
||||
$string['tours'] = 'Tours';
|
||||
$string['pausetour'] = 'Pause';
|
||||
$string['resumetour'] = 'Resume';
|
||||
$string['endonesteptour'] = 'Got it!';
|
||||
$string['endtour'] = 'End tour';
|
||||
$string['orphan'] = 'Show if target not found';
|
||||
$string['orphan_help'] = 'Show the step if the target could not be found on the page.';
|
||||
|
||||
@@ -42,6 +42,14 @@
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name" : "tour_activity_completion",
|
||||
"onesteptour" : true,
|
||||
"steps": [
|
||||
{
|
||||
"stepid": 10,
|
||||
"title": "Activity information"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -60,7 +68,12 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-role="previous">{{# str }} previousstep, tool_usertours {{/ str }}</button>
|
||||
<button type="button" class="btn btn-primary" data-role="next">{{# str }} nextstep, tool_usertours {{/ str }}</button>
|
||||
<button class="btn btn-secondary" data-role="end"> {{# str }} endtour, tool_usertours {{/ str }} </button>
|
||||
{{#onesteptour}}
|
||||
<button class="btn btn-secondary" data-role="end"> {{# str }} endonesteptour, tool_usertours {{/ str }} </button>
|
||||
{{/onesteptour}}
|
||||
{{^onesteptour}}
|
||||
<button class="btn btn-secondary" data-role="end"> {{# str }} endtour, tool_usertours {{/ str }} </button>
|
||||
{{/onesteptour}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,7 +37,7 @@ Feature: Apply tour filters to a tour
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Welcome to your course tour."
|
||||
And I click on "End tour" "button"
|
||||
And I click on "Got it!" "button"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
@@ -22,3 +22,41 @@ Feature: Steps can be navigated within a tour
|
||||
When I click on ".block_calendar_month .calendar-controls .next" "css_element"
|
||||
And I wait until the page is ready
|
||||
Then I should see "Calendar events"
|
||||
|
||||
@javascript
|
||||
Scenario: End tour button text for one step tours
|
||||
Given I log in as "admin"
|
||||
And I add a new user tour with:
|
||||
| Name | Calendar tour |
|
||||
| Description | Calendar tour |
|
||||
| Apply to URL match | /my/% |
|
||||
| Tour is enabled | 1 |
|
||||
And I add steps to the "Calendar tour" tour:
|
||||
| targettype | Block | Title | Content |
|
||||
| Block | Calendar | Calendar events | This is the calendar block |
|
||||
And I change window size to "large"
|
||||
And I follow "Dashboard" in the user menu
|
||||
And I wait until the page is ready
|
||||
And I should see "This is the calendar block"
|
||||
Then I should see "Got it!"
|
||||
|
||||
@javascript
|
||||
Scenario: End tour button text for multiple step tours
|
||||
Given I log in as "admin"
|
||||
And I add a new user tour with:
|
||||
| Name | First tour |
|
||||
| Description | My first tour |
|
||||
| Apply to URL match | /my/% |
|
||||
| Tour is enabled | 1 |
|
||||
And I add steps to the "First tour" tour:
|
||||
| targettype | Title | Content |
|
||||
| Display in middle of page | Welcome | Welcome to your personal learning space. We'd like to give you a quick tour to show you some of the areas you may find helpful |
|
||||
And I add steps to the "First tour" tour:
|
||||
| targettype | targetvalue_block | Title | Content |
|
||||
| Block | Course overview | Course overview | This area shows you what's happening in some of your courses |
|
||||
| Block | Calendar | Calendar | This is the Calendar. All of your assignments and due dates can be found here |
|
||||
When I am on homepage
|
||||
Then I should see "End tour"
|
||||
And I should see "Next"
|
||||
And I click on "Next" "button"
|
||||
And I should see "End tour"
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
This files describes API changes in the tool_usertours code.
|
||||
|
||||
=== 4.0 ===
|
||||
* The `tourconfig` property returned by the `tool_usertours_fetch_and_start_tour`
|
||||
external method has also a `onsteptour` property to differentiate between
|
||||
one step tours and multiple step tours.
|
||||
|
||||
=== 3.9 ===
|
||||
* The `tourconfig` property returned by the `tool_usertours_fetch_and_start_tour`
|
||||
external method is now optional, and will be omitted if the tour shouldn't be
|
||||
|
||||
Reference in New Issue
Block a user