Skip to content

Commit

Permalink
Refine translation fallback behavior, add basic auth doc
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Apr 15, 2016
1 parent 29d1c0e commit 057e283
Show file tree
Hide file tree
Showing 7 changed files with 807 additions and 765 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Version 2.3.0 (?)

* [new] Add support for HTML5 mode (pretty urls)
* [new] Add support for HTML5 mode (pretty urls).
* [new] Add the ability to specify an `optional` attribute on any fragment configuration, allowing application to load anyway.
* [new] Add the ability to specify an `ignore` attribute on any fragment configuration to avoid loading it.
* [new] Add the ability to specify a `translationFallback` boolean in the `culture` module configuration. If true, missing translations will fallback to their value in the default language. Note: the default culture bundle will always be loaded if the option is activated.
* [new] Add the ability to specify an `ignore` attribute on any fragment configuration to avoid loading it (useful for development).
* [new] Implement best-effort credentials cleanup for basic authentication (forcing the browser to forget credentials).
* [chg] Fallback to default culture when a translation is missing in active culture is no longer active by default. Sets `translationFallback` to `true` on the `culture` module configuration to force the fallback behavior.
* [fix] When translation fallback is active, always load default translations even when another culture is stored in preferences (#66).
* [fix] Fix translation of "Close all" notification dismiss link (#67).
* [fix] Catch JSON parsing error when persisted state is corrupted and fallback to default value (#68).
* [fix] Do not prevent `redirectAfterLogin` page to be shown after manual logout (#69).
* [brk] Remove `text` module which has been moved to `w20-extras` add-on.

# Version 2.2.2 (2016-02-15)
Expand Down
33 changes: 18 additions & 15 deletions modules/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ define([
* ...
* }
*/
var w20CoreApplication = angular.module('w20CoreApplication', [ 'w20CoreEnv', 'ngRoute', 'ngSanitize' ]),
var w20CoreApplication = angular.module('w20CoreApplication', ['w20CoreEnv', 'ngRoute', 'ngSanitize']),
config = module && module.config() || {},
appId = config.id || 'w20app',
allRoutes = {},
allRouteHandlers = {},
sceUrlWhiteList = [],
Expand All @@ -100,7 +101,7 @@ define([
};

// Routes configuration
w20CoreApplication.config([ '$routeProvider', '$locationProvider', '$sceDelegateProvider', function ($routeProvider, $locationProvider, $sceDelegateProvider) {
w20CoreApplication.config(['$routeProvider', '$locationProvider', '$sceDelegateProvider', function ($routeProvider, $locationProvider, $sceDelegateProvider) {
$locationProvider.hashPrefix('!');
if (config.prettyUrls) {
$locationProvider.html5Mode(true);
Expand Down Expand Up @@ -133,7 +134,7 @@ define([
return deferred !== null ? deferred.then(checkSecurity, checkSecurity) : checkSecurity();
}],

routeCheck: [ '$q', '$injector', function ($q, $injector) {
routeCheck: ['$q', '$injector', function ($q, $injector) {
if (typeof route.check === 'undefined') {
return $q.defer().resolve();
}
Expand All @@ -154,17 +155,17 @@ define([
// Home route
var homeRoute;
if (typeof allRoutes[config.home] !== 'undefined') {
homeRoute = _.extend(_.extend({}, allRoutes[config.home]), { path: '', hidden: true });
homeRoute = _.extend(_.extend({}, allRoutes[config.home]), {path: '', hidden: true});
}
$routeProvider.when('/', homeRoute || { template: '' });
$routeProvider.when('/', homeRoute || {template: ''});

// Fallback route
var fallbackRoute;
if (typeof allRoutes[config.notFound] !== 'undefined') {
fallbackRoute = _.extend(_.extend({}, allRoutes[config.notFound]), { path: undefined, hidden: true });
fallbackRoute = _.extend(_.extend({}, allRoutes[config.notFound]), {path: undefined, hidden: true});
$routeProvider.otherwise(fallbackRoute);
}
} ]);
}]);

// Cache busting
w20CoreApplication.config(['$provide', function ($provide) {
Expand Down Expand Up @@ -211,7 +212,7 @@ define([
*
* This id can be used to disambiguate between multiple W20 applications when necessary.
*/
applicationId: config.id || 'w20app',
applicationId: appId,

/**
* @ngdoc function
Expand Down Expand Up @@ -266,7 +267,7 @@ define([
return first.stack === second.stack;
}

this.$get = [ '$log', '$injector', function ($log, $injector) {
this.$get = ['$log', '$injector', function ($log, $injector) {
return function (exception, cause) {
try {
$injector.invoke(['$timeout', 'EventService', function ($timeout, eventService) {
Expand Down Expand Up @@ -321,7 +322,7 @@ define([
}];
});

w20CoreApplication.run([ 'EventService', '$location', '$rootScope', function (eventService, $location, $rootScope) {
w20CoreApplication.run(['EventService', '$location', '$rootScope', function (eventService, $location, $rootScope) {
if (typeof config.redirectAfterRouteError === 'string') {
eventService.on('$routeChangeError', function () {
$location.path(config.redirectAfterRouteError);
Expand All @@ -331,7 +332,7 @@ define([
eventService.on('$routeChangeSuccess', function (current) {
$rootScope.currentRoute = current && current.$$route;
});
} ]);
}]);

function registerRouteHandler(type, handlerFn) {
allRouteHandlers[type] = handlerFn;
Expand Down Expand Up @@ -360,13 +361,13 @@ define([
registerRouteHandler('sandbox', function (route) {
var sandboxPermissions = route.sandboxPermissions || config.defaultSandboxPermissions;
route.template = '<div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; margin: 0; padding: 0;" class="w20-top-shift w20-right-shift w20-bottom-shift w20-left-shift">' +
'<iframe id="' + (route.sandboxId || config.defaultSandboxId || 'frmMain') + '" style="border: none; width: 100%; height: 100%;"' + (sandboxPermissions ? ' sandbox="' + sandboxPermissions + '"' : '') + ' data-ng-src="' + require.toUrl(route.url) + '"></iframe>' +
'</div>';
'<iframe id="' + (route.sandboxId || config.defaultSandboxId || 'frmMain') + '" style="border: none; width: 100%; height: 100%;"' + (sandboxPermissions ? ' sandbox="' + sandboxPermissions + '"' : '') + ' data-ng-src="' + require.toUrl(route.url) + '"></iframe>' +
'</div>';
return route;
});

return {
angularModules: [ 'w20CoreApplication' ],
angularModules: ['w20CoreApplication'],

lifecycle: {
pre: function (modules, fragments, callback) {
Expand Down Expand Up @@ -428,6 +429,8 @@ define([
}
},

registerRouteHandler: registerRouteHandler
registerRouteHandler: registerRouteHandler,

id: appId
};
});
Loading

0 comments on commit 057e283

Please sign in to comment.