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

Fix: Restore _returnToPreviousLocation option (fix #55) #56

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Navigation bar component which can contain some or all of the following buttons:

- `_root`: Navigates to the top level menu
- `_up`: Navigates to the menu that is the next level up in the hierarchy. For instance, a sub menu.
- `_returnToPreviousLocation`: Navigates to the previous location. For example, if the user navigates to a help page that is not part of the normal flow, this would take them back to the previous page that they visited
- `_previous`: Navigates to the previous page if it exists and is unlocked
- `_next`: Navigates to the next page if it exists and is unlocked
- `_close`: Closes the course window. Only possible if the course was launched in a popup window
Expand All @@ -34,13 +35,14 @@ The **PageNav** buttons will respect any [locking](https://github.com/adaptlearn
**instruction** (string): This optional text appears above the component. It is frequently used to guide the learner’s interaction with the component.

**\_loopStyle** (string): Acceptable values are `allPages`, `siblings`, and `none`. Defaults to `none`.

- `allPages`: Loop sequentially through all pages in course
- `siblings`: Loop sequentially through all pages in current parent object
- `none`: Disable previous and next buttons at start and end of the pages in the current parent object.

**\_shouldSkipOptionalPages** (boolean): Skip pages that are set to `"_isOptional": true`. Default is `false`.

**\_buttons** (object): The following attributes configure the defaults for the **Quickanv** buttons. These attributes are available on all of the following buttons **\_previous**, **\_root**, **\_up**, **\_next**, and **\_close**.
**\_buttons** (object): The following attributes configure the defaults for the **Page Nav** buttons. These attributes are available on all of the following buttons: **\_root**, **\_up**, **\_returnToPreviousLocation**, **\_previous**, **\_next**, and **\_close**.

#### Global button configurations

Expand Down Expand Up @@ -72,7 +74,6 @@ The **PageNav** buttons will respect any [locking](https://github.com/adaptlearn

----------------------------

**Framework versions:** 5.30.2+<br>
**Vanilla versions:** 5.1.1+<br>
**Author / maintainer:** Kineo<br>
**Accessibility support:** WAI AA<br>
Expand Down
14 changes: 14 additions & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
},
"_customRouteId": ""
},
"_returnToPreviousLocation": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "icon-controls-left",
"_iconAlignment": "auto",
"text": "Return",
"ariaLabel": "Return to previous location",
"_tooltip": {
"_isEnabled": true,
"text": "{{displayTitle}}"
}
},
"_previous": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
Expand Down
7 changes: 7 additions & 0 deletions js/PageNavModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ class PageNavModel extends ComponentModel {
return {
_page: this.getCurrentPage(),
_up: this.getCurrentMenu(),
_returnToPreviousLocation: this.getReturnToPreviousLocation(),
_root: Adapt.course,
_next: this.getNextPage(),
_previous: this.getPrevPage(),
_close: this.getClose()
};
}

getReturnToPreviousLocation() {
if (!location._previousId) return;

return data.findById(location._previousId);
};

getCurrentPage() {
return location._currentModel;
};
Expand Down
97 changes: 97 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,103 @@
}
}
},
"_returnToPreviousLocation": {
"type": "object",
"required": true,
"legend": "Return to previous location button",
"properties": {
"_isEnabled": {
"type": "boolean",
"required": true,
"title": "Show",
"default": false,
"inputType": "Checkbox",
"validators": []
},
"_lockUntilPageComplete": {
"type": "boolean",
"required": true,
"title": "Lock until page complete",
"default": false,
"inputType": "Checkbox",
"validators": [],
"help": "For use when the standard Adapt locking system doesn't apply, such as in a start page before the main menu"
},
"_order": {
"type": "number",
"required": true,
"default": 0,
"title": "Order",
"inputType": "Number",
"validators": ["required", "number"],
"help": "Button display order"
},
"_classes": {
"type": "string",
"required": false,
"title": "Classes",
"default": "",
"inputType": "Text",
"validators": []
},
"_iconClass": {
"type": "string",
"required": false,
"title": "Icon class",
"default": "icon-controls-left",
"help": "CSS class name to be applied to the button icon. Suggested: icon-controls-left",
"inputType": "Text",
"validators": []
},
"_iconAlignment": {
"type": "string",
"required": false,
"default": "auto",
"inputType": {"type":"Select", "options":["auto","left","right","top","bottom"]},
"title": "Icon alignment",
"help": "Determines how the icon is aligned to the text."
},
"text": {
"type": "string",
"required": true,
"default": "Return",
"inputType": "Text",
"validators": [],
"translatable": true
},
"ariaLabel": {
"type": "string",
"required": true,
"title": "ARIA label",
"default": "Return to previous location",
"inputType": "Text",
"validators": [],
"translatable": true
},
"_navTooltip": {
"type": "object",
"title": "Navigation tooltip",
"properties": {
"_isEnabled": {
"type": "boolean",
"default": true,
"title": "Enable tooltip for navigation button",
"inputType": "Checkbox",
"validators": []
},
"text": {
"type": "string",
"title": "",
"default": "Return to previous location",
"help": "The tooltip text to display on hover over this item",
"inputType": "Text",
"validators": [],
"translatable": true
}
}
}
}
},
"_next": {
"type": "object",
"required": true,
Expand Down
87 changes: 87 additions & 0 deletions schema/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"_previous",
"_root",
"_up",
"_returnToPreviousLocation",
"_next",
"_close"
],
Expand Down Expand Up @@ -331,6 +332,92 @@
}
}
},
"_returnToPreviousLocation": {
"type": "object",
"title": "Return to previous location button",
"description": "Navigates to the previous location. For example, if the user navigates to a help page that is not part of the normal flow, this would take them back to the previous page that they visited",
"properties": {
"_isEnabled": {
"type": "boolean",
"title": "Show",
"default": false
},
"_lockUntilPageComplete": {
"type": "boolean",
"title": "Lock until page complete",
"description": "For use when the standard Adapt locking system doesn't apply, such as in a start page before the main menu",
"default": false
},
"_order": {
"type": "number",
"title": "Order",
"description": "Button display order",
"default": 0
},
"_classes": {
"type": "string",
"title": "Classes",
"default": ""
},
"_iconClass": {
"type": "string",
"title": "Icon class",
"description": "CSS class name to be applied to the button icon. Suggested: icon-controls-left",
"default": "icon-controls-left"
},
"_iconAlignment": {
"type": "string",
"title": "Icon alignment",
"description": "Determines how the icon is aligned to the text.",
"default": "auto",
"enum": [
"auto",
"left",
"right",
"top",
"bottom"
],
"_backboneForms": "Select"
},
"text": {
"type": "string",
"title": "Button text",
"description": "Text that appears on the button. Optional since you can only use an icon.",
"default": "Return",
"_adapt": {
"translatable": true
}
},
"ariaLabel": {
"type": "string",
"title": "ARIA label",
"default": "Return to previous location",
"_adapt": {
"translatable": true
}
},
"_navTooltip": {
"type": "object",
"title": "Button tooltip",
"default": {},
"properties": {
"_isEnabled": {
"type": "boolean",
"title": "Enable tooltip for this button",
"default": true
},
"text": {
"type": "string",
"title": "",
"default": "Return to previous location",
"_adapt": {
"translatable": true
}
}
}
}
}
},
"_next": {
"type": "object",
"title": "Next button",
Expand Down
Loading