Add selectedDatasetInformation service
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/e387ac55 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/e387ac55 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/e387ac55 Branch: refs/heads/master Commit: e387ac554328307567a4ce30367af81546f7fd73 Parents: f57aa93 Author: Michael Joyce <[email protected]> Authored: Wed Jul 16 10:25:58 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Wed Jul 16 10:25:58 2014 -0700 ---------------------------------------------------------------------- ocw-ui/frontend-new/app/index.html | 1 + .../services/selecteddatasetinformation.js | 38 ++++++++++++++++++++ .../spec/services/selecteddatasetinformation.js | 18 ++++++++++ 3 files changed, 57 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/e387ac55/ocw-ui/frontend-new/app/index.html ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/app/index.html b/ocw-ui/frontend-new/app/index.html index 2941cf1..ff26c5c 100644 --- a/ocw-ui/frontend-new/app/index.html +++ b/ocw-ui/frontend-new/app/index.html @@ -107,6 +107,7 @@ <script src="scripts/filters/isodatetomiddleendian.js"></script> <script src="scripts/services/evaluationsettings.js"></script> <script src="scripts/services/regionselectparams.js"></script> + <script src="scripts/services/selecteddatasetinformation.js"></script> <!-- endbuild --> </body> </html> http://git-wip-us.apache.org/repos/asf/climate/blob/e387ac55/ocw-ui/frontend-new/app/scripts/services/selecteddatasetinformation.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/app/scripts/services/selecteddatasetinformation.js b/ocw-ui/frontend-new/app/scripts/services/selecteddatasetinformation.js new file mode 100644 index 0000000..9034c96 --- /dev/null +++ b/ocw-ui/frontend-new/app/scripts/services/selecteddatasetinformation.js @@ -0,0 +1,38 @@ +'use strict'; + +/** + * @ngdoc service + * @name ocwUiApp.selectedDatasetInformation + * @description + * # selectedDatasetInformation + * Service in the ocwUiApp. + */ +angular.module('ocwUiApp') +.service('selectedDatasetInformation', function() { + var datasets = []; + + return { + getDatasets: function() { + return datasets; + }, + getDatasetCount: function() { + return datasets.length; + }, + // TODO: Define the structure of the objects that are added with addDataset. + addDataset: function(dataset) { + // All datasets need a shouldDisplay attribute that is used when rendering + // the overlays on the map! + dataset.shouldDisplay = false; + // The regrid attribute indicates which dataset should be used for spatial regridding + dataset.regrid = false; + + datasets.push(dataset); + }, + removeDataset: function(index) { + datasets.splice(index, 1); + }, + clearDatasets: function() { + datasets.length = 0; + }, + }; +}); http://git-wip-us.apache.org/repos/asf/climate/blob/e387ac55/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js b/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js new file mode 100644 index 0000000..9d13bba --- /dev/null +++ b/ocw-ui/frontend-new/test/spec/services/selecteddatasetinformation.js @@ -0,0 +1,18 @@ +'use strict'; + +describe('Service: selectedDatasetInformation', function () { + + // load the service's module + beforeEach(module('ocwUiApp')); + + // instantiate service + var selectedDatasetInformation; + beforeEach(inject(function (_selectedDatasetInformation_) { + selectedDatasetInformation = _selectedDatasetInformation_; + })); + + it('should do something', function () { + expect(!!selectedDatasetInformation).toBe(true); + }); + +});
