Skip to content

Commit

Permalink
feat(Transition): Add the transition source (url/sref) to TransitionO…
Browse files Browse the repository at this point in the history
…ptions
  • Loading branch information
christopherthielen committed Aug 31, 2016
1 parent 8d6090e commit 5d42d79
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/ng1/directives/stateDirectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ function clickHook(el: IAugmentedJQuery, $state: StateService, $timeout: ITimeou

/** @hidden */
function defaultOpts(el: IAugmentedJQuery, $state: StateService) {
return { relative: stateContext(el) || $state.$current, inherit: true };
return {
relative: stateContext(el) || $state.$current,
inherit: true,
source: "sref"
};
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/ng2/directives/uiSref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ export class UISref {
}

getOptions() {
let defOpts = { relative: this.parent && this.parent.context && this.parent.context.name, inherit: true };
let defOpts: TransitionOptions = {
relative: this.parent && this.parent.context && this.parent.context.name,
inherit: true ,
source: "sref"
};
return extend(defOpts, this.options || {});
}

Expand Down
2 changes: 1 addition & 1 deletion src/state/stateQueueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class StateQueueManager {

$urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match: RawParams, $stateParams: RawParams) {
if ($state.$current.navigable !== state || !equalForKeys($match, $stateParams)) {
$state.transitionTo(state, $match, { inherit: true, location: false });
$state.transitionTo(state, $match, { inherit: true, location: false, source: "url" });
}
}]);
}
Expand Down
8 changes: 5 additions & 3 deletions src/transition/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ export interface TransitionOptions {
* You can define your own Transition Options inside this property and use them, e.g., from a Transition Hook
*/
custom ?: any;
/** @internal */
/** @hidden @internal */
reloadState ?: (State);
/** @internal */
/** @hidden @internal */
previous ?: Transition;
/** @internal */
/** @hidden @internal */
current ?: () => Transition;
/** @hidden @internal */
source ?: "sref"|"url"|"unknown";
}

/** @hidden @internal */
Expand Down
3 changes: 2 additions & 1 deletion src/transition/transitionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export let defaultTransOpts: TransitionOptions = {
notify : true,
reload : false,
custom : {},
current : () => null
current : () => null,
source : "unknown"
};

/**
Expand Down
1 change: 1 addition & 0 deletions test/matchers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference path='../typings/jasmine/jasmine.d.ts' />
import {equals} from "../src/common/common";
declare var testablePromise;

beforeEach(function() {
jasmine.addMatchers(<any> {
Expand Down

0 comments on commit 5d42d79

Please sign in to comment.