Created
May 7, 2014 21:23
-
-
Save amcdnl/cacaf72d7429959f5569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['angular', | |
'ngtable', | |
'common/services/search', | |
'common/utils/throttle', | |
'common/components/dd-checklist/dd-checklist', | |
'common/components/resizable/resizable', | |
'less!app/search/list/list'], function(angular){ | |
var module = angular.module('search.list', ['utils.throttle', 'ngTable', 'components.ddChecklist', 'components.resizable', 'services.search']); | |
module.controller('ListCtrl', function($rootScope, $scope, $filter, SearchModel, ngTableParams, debounce){ | |
// translate tableParams to reportObj | |
var translate = function(sort){ | |
}; | |
$scope.tableParams = new ngTableParams({ | |
page: 1, | |
count: 10 // move to 50 | |
}, { | |
getData: function ($defer, params) { | |
// when table params change directly, | |
// you will need to update the report | |
// this might cause recursive but shouldn't | |
// since the table apamrs should already reflect it | |
// report.pageSize | |
// report.offset | |
// report.sorts = [ { '3245234': 'ascending' } ] | |
// report will execute | |
SearchModel.findAll($scope.report, $scope.app).then(function (xhr) { | |
params.total(xhr.data.count); | |
$defer.resolve(xhr.data); | |
//if(){} | |
}); | |
} | |
}); | |
// TODO: IGNORE CERTAIN FIELDS such as chart options | |
$scope.$watch('report', debounce(function (newVal, oldVal, event) { | |
// ignore stuff | |
if ((newVal === oldVal && ($scope.results.length || | |
$scope.statsResults)) && $scope.tableParams) return; | |
$scope.columns = SearchModel.columns($scope.app, $scope.report); | |
// when report changes, set table params ( will need to translate ) | |
// $scope.tableParams.sort({}); | |
// this will trigger getData in table params | |
// otherwise page/sort changed? | |
// params.sorting() //- gets sorting - { "2345234asdf": "asc" } | |
// params.page() //- gets page - 1 | |
// translate it to the report object ... that will | |
// trigger a update and reload of data | |
}, 100), true); | |
}); | |
return module; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment