Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
feat(search): Charts navigate to file tab filtered
Browse files Browse the repository at this point in the history
Closes #776
  • Loading branch information
Matthew Schranz authored and mjschranz committed May 25, 2015
1 parent 1b51d82 commit da5e187
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
19 changes: 15 additions & 4 deletions app/scripts/components/charts/chart.directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ module ngApp.components.charts {
gPath.attr("d", arc)
.style("fill", function(d, i) { return color(i); })
.attr("state", function(d) {
return config.state && config.state[d.data.key] ? "true" : "false";
return config.state ? "true" : "false";
})
.on("click", goToState)
.on("mouseover.text", function(d) {
Expand Down Expand Up @@ -304,13 +304,24 @@ module ngApp.components.charts {
}

function goToState(d) {
if (!config.state || !config.state[d.data.key]) {
if (!config.state || (!config.state[d.data.key] &&
!config.state["default"])) {
return;
}

var state = config.state[d.data.key];
if (config.state[d.data.key]) {
var state = config.state[d.data.key];

$state.go(state.name, state.params, {inherit: false});
$state.go(state.name, state.params, {inherit: false});
return;
}

var state = config.state["default"],
params = {
filters: state.params.filters(d.data.key)
};

$state.go(state.name, params, {inherit: false});
}

function arcTween(outerRadius, delay) {
Expand Down
39 changes: 37 additions & 2 deletions app/scripts/search/search.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module ngApp.search.controllers {
private LocationService: ILocationService,
private UserService: IUserService,
public CoreService: ICoreService,
$filter: ng.IFilterService,
private SearchTableFilesModel: TableiciousConfig,
private SearchTableParticipantsModel: TableiciousConfig,
public FacetService) {
Expand Down Expand Up @@ -82,7 +83,24 @@ module ngApp.search.controllers {
textFilter: "size",
label: "file",
sortKey: "doc_count",
defaultText: "project"
defaultText: "project",
state: {
"default": {
name: "search.files",
params: {
filters: function(value) {
return $filter("makeFilter")([
{
name: "participants.project.project_id",
value: [
value
]
}
], true);
}
}
}
}
};

this.primarySiteChartConfig = {
Expand All @@ -91,7 +109,24 @@ module ngApp.search.controllers {
textFilter: "size",
label: "file",
sortKey: "doc_count",
defaultText: "primary site"
defaultText: "primary site",
state: {
"default": {
name: "search.files",
params: {
filters: function(value) {
return $filter("makeFilter")([
{
name: "participants.project.primary_site",
value: [
value
]
}
], true);
}
}
}
}
};
}

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var AUTOPREFIXER_BROWSERS = [
'bb >= 10'
];

var production = false; // process.env.NODE_ENV === "production";
var production = process.env.NODE_ENV === "production";
$.util.log('Environment', $.util.colors.blue(production ? 'Production' : 'Development'));

// <paths>
Expand Down

0 comments on commit da5e187

Please sign in to comment.