(function () { 'use strict'; var app = angular.module('items'); // A controller for the myshowcases page app.controller('myShowcasesController', ['$scope', 'showcaseModals', 'showcasesDataContext', function ($scope, showcaseModals, showcasesDataContext) { // Get the showcases when the scope is loaded getShowcases(); // Update the showcases after a broadcast $scope.$on('UpdateShowcases', function () { return getShowcases(); }); // Loaded data $scope.data = { loaded: false, showcases: [] } // Options for the showcases $scope.options = { order: null, filters: { query: '', status: '' }, filterOptions: [ { name: 'Show all showcases', value: '' }, { name: 'Show draft showcases', value: { showcaseState: 'Draft' }, }, { name: 'Show published showcases', value: { showcaseState: 'Published' }, } ], orderOptions: [ { name: 'Creation Date', value: { predicate: 'createdDate', reverse: true }, }, { name: 'Name', value: { predicate: 'name', reverse: false }, }, { name: 'Status', value: { predicate: 'showcaseState', reverse: false }, } ] }; // Set the default options $scope.options.order = $scope.options.orderOptions[0]; $scope.options.filters.status = $scope.options.filterOptions[0]; // My items toolbar functions $scope.createShowcase = showcaseModals.createShowcase; // Get showcases for this user function getShowcases() { return showcasesDataContext.getShowcases().then(function (result) { $scope.data.loaded = true; $scope.data.showcases = result; }); } }]); })();