OJET: Bug with Routing in TypeScript Template
Oracle JET supports officially TypeScript for your application development.
OJET CLI does NOT include templates which uses by default TypeScript.
However, in the Oracle website they provide an starting point template in case you want to use TypeScript.
JET TypeScript Starter Template - Web NavBar
In my GitHub you can find the app fixed: (ojet-typescript-template)
https://github.com/DanielMerchan/ojet-examples
The application has a minor bug in its Router configuration which makes the following strange behaviour:
If you copy any module URL such as http://localhost:8000/?root=incidents in your browsers it always load the default module which is the dashboard
OJET CLI does NOT include templates which uses by default TypeScript.
However, in the Oracle website they provide an starting point template in case you want to use TypeScript.
JET TypeScript Starter Template - Web NavBar
In my GitHub you can find the app fixed: (ojet-typescript-template)
https://github.com/DanielMerchan/ojet-examples
The application has a minor bug in its Router configuration which makes the following strange behaviour:
If you copy any module URL such as http://localhost:8000/?root=incidents in your browsers it always load the default module which is the dashboard
Why? How to fix it?
In the TypeScript template there is a duplication of the Router configuration. You can find a self.router.configure in:- root.ts which acts as the "main.js" of the Oralce JET Out-of-the-box basic templates created with OJET CLI
- appController.ts which is the appController.js of the Oralce JET Out-of-the-box basic templates created with OJET CLI
- Remove the configuration of the Router in root.ts
- Initialise the Router before to apply the bindings.
- Apply the bindings with the new created variable
import * as ko from "knockout"; import "ojs/ojknockout"; import RootViewModel = require ('./appController'); import Router = require('ojs/ojrouter'); import Logger = require('ojs/ojlogger'); class Root { router: Router; constructor() { let self = this; self.router = Router.rootInstance; const rootVM = new RootViewModel(); Router.defaults['urlAdapter'] = new Router.urlParamAdapter(); Router.sync().then( function() { // bind your ViewModel for the content of the whole page body. ko.applyBindings(rootVM, document.getElementById('globalBody')); }, function(error) { Logger.error('Error in root start: ' + error.message); } ); } } export = Root;
Non relevant, checked with latest 8.1.0 cli
ReplyDeleteJust check if this article helps. We have configured our entire OJS platform through this article. Read here OJS Installation and Optimization Services
ReplyDelete