"use strict";

var App = require('../app'),
    coreUtils = require('../core/utils'),
    models = require('./models'),
    views = require('./views');

var DataCatalogController = {
    dataCatalog: function() {
        App.map.setDataCatalogSize();

        App.state.set({
            'active_page': coreUtils.dataCatalogPageTitle,
        });

        var form = new models.SearchForm();

        var catalogs = new models.Catalogs([
            new models.Catalog({
                id: 'cinergi',
                name: 'CINERGI',
                active: true,
                results: new models.Results()
            }),
            new models.Catalog({
                id: 'hydroshare',
                name: 'HydroShare',
                results: new models.Results()
            }),
            new models.Catalog({
                id: 'cuahsi',
                name: 'WDC',
                description: 'Optional catalog description here...',
                results: new models.Results()
            })
        ]);

        var view = new views.DataCatalogWindow({
            model: form,
            collection: catalogs
        });
        App.rootView.sidebarRegion.show(view);
    }
};

module.exports = {
    DataCatalogController: DataCatalogController,
};

"use strict";

var App = require('../app'),
    router = require('../router').router,
    coreUtils = require('../core/utils'),
    models = require('./models'),
    views = require('./views');

var DataCatalogController = {
    dataCatalogPrepare: function() {
        if (!App.map.get('areaOfInterest')) {
            router.navigate('', { trigger: true });
            return false;
        }
    },

    dataCatalog: function() {
        App.map.setDataCatalogSize();

        App.state.set({
            'active_page': coreUtils.dataCatalogPageTitle,
        });

        var form = new models.SearchForm();

        var catalogs = new models.Catalogs([
            new models.Catalog({
                id: 'cinergi',
                name: 'CINERGI',
                active: true,
                results: new models.Results()
            }),
            new models.Catalog({
                id: 'hydroshare',
                name: 'HydroShare',
                results: new models.Results()
            }),
            new models.Catalog({
                id: 'cuahsi',
                name: 'WDC',
                description: 'Optional catalog description here...',
                results: new models.Results()
            })
        ]);

        var view = new views.DataCatalogWindow({
            model: form,
            collection: catalogs
        });
        App.rootView.sidebarRegion.show(view);
    }
};

module.exports = {
    DataCatalogController: DataCatalogController,
};

Exit /search if no area of interest
Exit /search if no area of interest

Previously we would query APIs with the bounding box of the
entire map in view. Now as we prepare to switch to searching
for the area of interest only, we disable being able to come
to this page without an area of interest drawn already.
