(function () { 'use strict'; var serviceId = 'showcasesDataContext'; angular.module('showcases').factory(serviceId, ['appDataContext', 'showcasesConfig', 'config', dataContext]); function dataContext(appDataContext, config, appConfig) { var service = {}; /*** * Get the showcase summary (list of showcases) */ service.getShowcaseSummary = function () { return appDataContext.get(config.showcaseRemoteServiceUrl + "summary", config.cache, config.showcaseSummaryCacheItem); } /*** * Get all showcases for the user */ service.getShowcases = function () { return appDataContext.get(config.showcaseRemoteServiceUrl, config.cache, config.showcasesCacheItem); } /*** * Get a specific showcase using its id */ service.getShowcase = function (id) { return appDataContext.get(config.showcaseRemoteServiceUrl + id); } /** * Get showcase using the framework id */ service.getShowcaseByFrameworkId = function (frameworkId) { return appDataContext.get(config.showcaseRemoteServiceUrl + "showcasebyframework/" + frameworkId); } /** * Get the showcases that are available to add an item to (showcases that don't already have that item) */ service.getShowcasesAvailableForItem = function (itemId) { return appDataContext.get(config.showcaseRemoteServiceUrl + "availableformitem/" + itemId); } /** * Get the showcases that are linked to an item */ service.getShowcasesLinkedToItem = function (itemId) { return appDataContext.get(config.showcaseRemoteServiceUrl + "linkedtoitem/" + itemId); } /** * Get all items in a showcase */ service.getItemsForShowcase = function (showcaseId) { return appDataContext.get(config.showcaseRemoteServiceUrl + showcaseId + "/items"); } /** * Publish a showcase */ service.publishShowcase = function (showcaseId) { appDataContext.clearCaches(config.cache); return appDataContext.get(config.showcaseRemoteServiceUrl + showcaseId + "/publish"); } /** * Clone / copy an existing showcase */ service.cloneShowcase = function (showcaseId) { appDataContext.clearCaches(config.cache); return appDataContext.get(config.showcaseRemoteServiceUrl + showcaseId + "/clone"); } /** * Commit a temporary showcase that the user has been editing */ service.commitTemporaryShowcase = function (showcaseId) { appDataContext.clearCaches(config.cache); return appDataContext.get(config.showcaseRemoteServiceUrl + showcaseId + "/committemporary"); } /** * Delete a temporary showcase (e.g. when a user cancels from an edit) */ service.deleteTemporaryShowcases = function (showcaseId) { appDataContext.clearCaches(config.cache); return appDataContext.delete(config.showcaseRemoteServiceUrl + showcaseId + "/temporary"); } /** * Get possible showcase themes */ service.getThemes = function () { return appDataContext.get(config.themesRemoteServiceUrl, config.cache, config.themesCacheItem); } /** * Create a new showcase */ service.createShowcase = function (showcase) { appDataContext.clearCaches(config.cache); return appDataContext.post(config.showcaseRemoteServiceUrl, showcase); } /** * Edit / manage an existing showcase */ service.manageShowcase = function (showcase) { appDataContext.clearCaches(config.cache); return appDataContext.post(config.showcaseRemoteServiceUrl + "manage", showcase); } /** * Delete a showcase using its id */ service.deleteShowcase = function (showcaseId) { appDataContext.clearCaches(config.cache); return appDataContext.delete(config.showcaseRemoteServiceUrl + showcaseId, config.cache); } /** * Send a message to someone to review a showcase */ service.sendShowcaseReviewMessage = function (showcase, shortcode) { appDataContext.clearCaches(config.cache); return appDataContext.post(config.showcaseRemoteServiceUrl + "send/" + shortcode, showcase); } /** * Mark a showcase as archived */ service.setShowcaseArchived = function (showcaseId, shouldArchive) { appDataContext.clearCaches(config.cache); return appDataContext.get(config.showcaseRemoteServiceUrl + showcaseId + "/setarchived/" + shouldArchive); } /** * Toggle the visibility of a showcase */ service.toggleShowcasePrivacy = function (showcaseId) { appDataContext.clearCaches(config.cache); return appDataContext.get(config.showcaseRemoteServiceUrl + showcaseId + "/togglepublicprivate"); } /** * Toggle the visibility of a showcase version */ service.toggleShowcaseVersionPrivacy = function (showcaseId, showcaseVersion) { return appDataContext.put(appConfig.siteUrl + "api/showcaseversions/" + showcaseId + '/' + showcaseVersion.version + '/publicity', showcaseVersion); } /** * Get the version history for a showcase */ service.getShowcaseVersions = function(showcaseId) { return appDataContext.get(appConfig.siteUrl + "api/showcaseversions/" + showcaseId); } /** * Get a specific version for a showcase */ service.getShowcaseVersion = function(showcaseId, version) { return appDataContext.get(appConfig.siteUrl + "api/showcaseversions/" + showcaseId + "/" + version); } /** * Get showcases for assignments */ service.getShowcasesForAssignments = function (connectionId) { return appDataContext.get(appConfig.apigatewayUrl + "MyShowcaseApi?connectionId=" + connectionId); } return service; } })();