Shortcut Component

The Shortcut component is an Angular component that provides the functionality to render links in the navigation bar in SmartEdit.

Overview

The Shortcut component is an Angular component that provides the functionality to render the links in the navigation bar in the SmartEdit interface. SmartEdit users select the links to access quickly SmartEdit functionality, such as Pages view, Navigation Management, the Storefront, and the Your Sites page. In the interface, SmartEdit uses the ShortcutLinkComponent to display the shortcut links. The ShortcutLinkComponent uses the SeRouteService. The following image shows the shortcut links rendered in the Navigation Bar:

SeRouteService API

To register a new route, use the SeRouteService API. You can use the service with the AngularJS and Angular module. The SeRouteService is a static service, so you can use it in the configuration section of an AngularJS module or in the imports section of an Angular module. If you don't use the SeRouteService to register your route, it won't be available as a shortcut link.

The SeRouteService is as follows:

class SeRouteService {
	static provideLegacyRoute(legacyRoute: SeLegacyRoute): ng.route.IRouteProvider
	static provideNgRoute(routes: SeRoutes, config?: ExtraOptions): ModuleWithProviders<RouterModule>
}

ShortcutLinkComponent

The ShortcutLinkComponent uses the SeRouteService to retrieve all routes that can be used as shortcut links. SmartEdit renders the links in the navigation bar. Users can click the links to access the desired functionality. All active links have a visible underline.

Registering a Route

You use the SeRouteService to register a route. Use the following methods to register a route:

  • To register an Angular route, use the SeRouteService.provideNgRoute method. This method accepts a list of routes.
  • To register an AngularJS route, use the SeRouteService.provideLegacyRoute method. This method can accept only one route at a time.

You can use the following attributes when registering your routes:

  • titleI18nKey: Specifies the routes title.
  • priority: Specifies the order of the shortcut links in the component.
  • shortcutComponent: Indicates that the route is to be rendered as a shortcut link.

The ShortcutLinkComponent only displays routes that include the titleI18nKey or shortcutComponent attribute. If you specify both the titleI18nKey and the shortcutComponent attributes in the same route, SmartEdit only uses the titleI18nKey.

Registering a Route in Angular

To add an Angular route, use the SeRouteService.provideNgRoute method. The following code excerpt shows how to register a route in Angular:

@NgModule({
	schemas: [CUSTOM_ELEMENTS_SCHEMA],
	imports: [
		...some modules,
		SeRouteService.provideNgRoute([
			{
				path: NG_ROUTE_PREFIX,
				children: [
					{
						path: '',
						pathMatch: 'full',
						component: InvalidRouteComponent
					}
				]
			},
			{
				path: '',
				pathMatch: 'full',
				component: InvalidRouteComponent
			}
		], {useHash: true, initialNavigation: true})
	],
	declarations: [
	]
    ...
})

Registering a Route in AngularJS

To add an AngularJS route, use the SeRouteService.provideLegacyRoute method. The method accepts the list of routes as a first attribute and a configuration as the second one. The following code excerpt shows how to register a route in AngularJS:

@SeModule({
	declarations: [
		... some declarations
	],
	imports: [
		... some module imports
		
	],
	config: (
		$routeProvider: angular.route.IRouteProvider,
		$logProvider: angular.ILogProvider,
		catalogAwareRouteResolverFunctions: any
	) => {
		'ngInject';

		SeRouteService.init($routeProvider);
		SeRouteService.provideLegacyRoute({
			path: LANDING_PAGE_PATH,
			route: {
				template: '<landing-page></landing-page>'
			},
			priority: 1,
			shortcutComponent: SitesLinkComponent
		});

		SeRouteService.provideLegacyRoute({
			path: STORE_FRONT_CONTEXT,
			route: {
				templateUrl: 'mainview.html',
				controller: SmarteditDefaultController,
				resolve: {
					setExperience: catalogAwareRouteResolverFunctions.storefrontResolve
				}
			},
			priority: 30,
			titleI18nKey: 'se.route.storefront.title'
		});

	},
	...
})