Navigation Menu

Skip to content

Commit

Permalink
table search: reflect unit change
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 4, 2015
1 parent 6a253c7 commit f49919b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions app/scripts/controllers/table-search-controller.js
Expand Up @@ -327,20 +327,23 @@ angular.module('groongaAdminApp')
},
syncToRange: function() {
this.unit = TimeUnit.findByDateRange(this.start, this.end);
if (this.start && this.end) {
this.updateRangeByDateRange(this.start, this.end);
},
updateRangeByDateRange: function(start, end) {
if (start && end) {
this.range = [
this.unit.dateToPercent(this.start) * 100,
this.unit.dateToPercent(this.end) * 100
this.unit.dateToPercent(start) * 100,
this.unit.dateToPercent(end) * 100
];
} else if (this.start) {
} else if (start) {
this.range = [
this.unit.dateToPercent(this.start) * 100,
this.unit.dateToPercent(start) * 100,
100
];
} else if (this.end) {
} else if (end) {
this.range = [
0,
this.unit.dateToPercent(this.end) * 100
this.unit.dateToPercent(end) * 100
];
} else {
this.range = [0, 0];
Expand All @@ -349,6 +352,10 @@ angular.module('groongaAdminApp')
formater: function(value) {
var date = timeColumnInfo.unit.percentToDate(value / 100);
return date.toLocaleString();
},
onUnitChanged: function() {
timeColumnInfo.updateRangeByDateRange(timeColumnInfo.start,
timeColumnInfo.end);
}
};
$scope.table.timeColumns.push(timeColumnInfo);
Expand Down
3 changes: 2 additions & 1 deletion app/views/tables/search.html
Expand Up @@ -119,7 +119,8 @@ <h2 class="panel-title">
tooltip="always"
tooltipsplit="true"></slider>
<select ng-options="unit.label for unit in orderedTimeColumnUnits"
ng-model="timeColumn.unit"></select>
ng-model="timeColumn.unit"
ng-change="timeColumn.onUnitChanged()"></select>
</div>
</div>
</form>
Expand Down

0 comments on commit f49919b

Please sign in to comment.