Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
new build
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayton Nolan committed Mar 25, 2016
1 parent 1602f07 commit f674071
Show file tree
Hide file tree
Showing 5 changed files with 1,618 additions and 16 deletions.
3 changes: 0 additions & 3 deletions dist/robots.txt

This file was deleted.

49 changes: 46 additions & 3 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4313,16 +4313,23 @@ angular.module('specialCoverage.edit.directive', [

$scope.needsSave = false;

$scope.tunicCampaignIdMapping = {};

var modelId = $scope.getModelId();
if (modelId === 'new') {
// this is a new special coverage, build it
$scope.model = SpecialCoverage.$build();
$scope.isNew = true;
} else {
// this is an existing special coverage, find it
$scope.model = SpecialCoverage.$find($scope.getModelId());
$scope.model = SpecialCoverage.$find($scope.getModelId()).$then(function () {
$scope.model.$loadTunicCampaign().then(function (campaign) {
$scope.tunicCampaignIdMapping[campaign.id] = campaign;
});
});
}


window.onbeforeunload = function (e) {
if (!_.isEmpty($scope.model.$dirty()) || $scope.isNew || $scope.needsSave) {
// unsaved changes, show confirmation alert
Expand Down Expand Up @@ -4365,8 +4372,21 @@ angular.module('specialCoverage.edit.directive', [
});
};

$scope.tunicCampaignFormatter = function (campaignId) {
if (campaignId in $scope.tunicCampaignIdMapping) {
var campaign = $scope.tunicCampaignIdMapping[campaignId];
return campaign.name + ' - ' + campaign.number;
}
};

$scope.searchCampaigns = function (searchTerm) {
return Campaign.simpleSearch(searchTerm);
return $scope.model.$searchCampaigns({search: searchTerm}).then(function (campaigns) {
campaigns.forEach(function (campaign) {
$scope.tunicCampaignIdMapping[campaign.id] = campaign;
});
// Formatter expects list of IDs
return campaigns.map(function (campaign) { return campaign.id; });
});
};
},
restrict: 'E',
Expand Down Expand Up @@ -5366,10 +5386,11 @@ angular.module('apiServices.specialCoverage.factory', [
'apiServices',
'apiServices.campaign.factory',
'apiServices.mixins.fieldDisplay',
'cms.tunic.config',
'filters.moment',
'VideohubClient.api'
])
.factory('SpecialCoverage', function (_, $parse, restmod, Video) {
.factory('SpecialCoverage', function (_, $http, $parse, $q, restmod, TunicConfig, Video) {
var ACTIVE_STATES = {
INACTIVE: 'Inactive',
PROMOTED: 'Pin to HP'
Expand Down Expand Up @@ -5462,6 +5483,28 @@ angular.module('apiServices.specialCoverage.factory', [
video.$fetch();
});
},
/**
* Load campaign data from Tunic endpoint
*/
$loadTunicCampaign: function () {
if (_.isNumber(this.tunicCampaignId)) {
return $http.get(TunicConfig.buildBackendApiUrl('campaign/' + this.tunicCampaignId + '/')).then(function (result) {
return result.data;
});
}
return $q.reject();
},
/**
* Load campaign search results from Tunic endpoint
*/
$searchCampaigns: function (params) {

return $http.get(TunicConfig.buildBackendApiUrl('campaign/'), {
params: params,
}).then(function (response) {
return response.data.results;
});
},
/**
* Add a video by id.
*
Expand Down
14 changes: 7 additions & 7 deletions dist/scripts/scripts.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/scripts/templates.js

Large diffs are not rendered by default.

Loading

0 comments on commit f674071

Please sign in to comment.