(path, args, options)
| 630 | } |
| 631 | |
| 632 | routeDirectly (path, args, options) { |
| 633 | if (args == null) { args = [] } |
| 634 | if (options == null) { options = {} } |
| 635 | this.vueRouter.push(`/${Backbone.history.getFragment()}`).catch(e => console.error('vue router push warning:', e)) |
| 636 | |
| 637 | if (window.alreadyLoadedView) { |
| 638 | path = window.alreadyLoadedView |
| 639 | } |
| 640 | |
| 641 | if (!options.recursive) { this.viewLoad = new ViewLoadTimer() } |
| 642 | if (options.redirectStudents && me.isStudent() && !me.isAdmin()) { |
| 643 | return this.redirectHome() |
| 644 | } |
| 645 | if (options.redirectTeachers && me.isTeacher() && !me.isAdmin()) { |
| 646 | return this.redirectHome() |
| 647 | } |
| 648 | if (options.teachersOnly && !(me.isTeacher() || me.isAdmin())) { |
| 649 | return this.routeDirectly('teachers/RestrictedToTeachersView') |
| 650 | } |
| 651 | if (options.studentsOnly && !(me.isStudent() || me.isAdmin())) { |
| 652 | return this.routeDirectly('courses/RestrictedToStudentsView') |
| 653 | } |
| 654 | const leavingMessage = _.result(globalVar.currentView, 'onLeaveMessage') |
| 655 | if (leavingMessage) { |
| 656 | // Custom messages don't work any more, main browsers just show generic ones. So, this could be refactored. |
| 657 | if (!confirm(leavingMessage)) { |
| 658 | return this.navigate(this.path, { replace: true }) |
| 659 | } else { |
| 660 | globalVar.currentView.onLeaveMessage = _.noop // to stop repeat confirm calls |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | // TODO: Combine these two? |
| 665 | if (features.playViewsOnly && !(_.string.startsWith(document.location.pathname, '/play') || (document.location.pathname === '/admin'))) { |
| 666 | delete window.alreadyLoadedView |
| 667 | return this.navigate('/play', { trigger: true, replace: true }) |
| 668 | } |
| 669 | if (features.playOnly && !/^(views)?\/?play/.test(path)) { |
| 670 | delete window.alreadyLoadedView |
| 671 | path = 'play/CampaignView' |
| 672 | } |
| 673 | |
| 674 | if (!_.string.startsWith(path, 'views/')) { path = `views/${path}` } |
| 675 | return Promise.all([ |
| 676 | dynamicRequire[path](), // Load the view file |
| 677 | // The locale load is already initialized by `application`, just need the promise |
| 678 | locale.load(me.get('preferredLanguage', true)), |
| 679 | ]).then((...args1) => { |
| 680 | let view |
| 681 | const [ViewClass] = Array.from(args1[0]) |
| 682 | if (!ViewClass) { return go('NotFoundView') } |
| 683 | |
| 684 | // send url info to teachers |
| 685 | if (utils.useWebsocket && me.isStudent()) { |
| 686 | const { |
| 687 | wsBus, |
| 688 | } = globalVar.application |
| 689 | Object.entries((wsBus.wsInfos != null ? wsBus.wsInfos.friends : undefined) != null ? (wsBus.wsInfos != null ? wsBus.wsInfos.friends : undefined) : {}).forEach((...args2) => { |
no test coverage detected