Created
July 9, 2015 14:17
-
-
Save MerrittMelker/e635b1f5784dc3dafc78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var designerModule = angular.module('designer'); | |
angular.module('designer').requires.push('sfSelectors'); | |
designerModule.controller('SimpleCtrl', ['$scope', 'propertyService', function ($scope, propertyService) { | |
$scope.feedback.showLoadingIndicator = true; | |
$scope.productionIds = null; | |
$scope.selectedProductionItems = null; | |
$scope.advertisementIds = null; | |
$scope.selectedAdvertisementItems = null; | |
//Makes call to the controlPropertyService to get the properties for the widgets. | |
propertyService.get() | |
.then(function (data) { | |
if (data) { | |
$scope.properties = propertyService.toAssociativeArray(data.Items); | |
} | |
}, | |
function (data) { | |
$scope.feedback.showError = true; | |
if (data) | |
$scope.feedback.errorMessage = data.Detail; | |
}) | |
.finally(function () { | |
$scope.feedback.showLoadingIndicator = false; | |
}); | |
$scope.$watch('properties.SelectedProductionItems.PropertyValue', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.selectedProductionItems = JSON.parse(newValue); | |
} | |
}); | |
$scope.$watch('selectedProductionItems', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.properties.SelectedProductionItems.PropertyValue = JSON.stringify(newValue); | |
} | |
}); | |
$scope.$watch('properties.SelectedProductionIds.PropertyValue', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.productionIds = JSON.parse(newValue); | |
} | |
}); | |
$scope.$watch('productionIds', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.properties.SelectedProductionIds.PropertyValue = JSON.stringify(newValue); | |
} | |
}); | |
$scope.$watch('properties.SelectedAdvertisementItems.PropertyValue', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.selectedAdvertisementItems = JSON.parse(newValue); | |
} | |
}); | |
$scope.$watch('selectedAdvertisementItems', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.properties.SelectedAdvertisementItems.PropertyValue = JSON.stringify(newValue); | |
} | |
}); | |
$scope.$watch('properties.SelectedAdvertisementIds.PropertyValue', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.advertisementIds = JSON.parse(newValue); | |
} | |
}); | |
$scope.$watch('advertisementIds', function (newValue, oldValue) { | |
if (newValue) { | |
$scope.properties.SelectedAdvertisementIds.PropertyValue = JSON.stringify(newValue); | |
} | |
}); | |
// top Productions list (allow us to select just one Production) | |
$scope.$watch('properties.SelectedProductionItem.PropertyValue', function (newValue, oldValue) { | |
$scope.selectedProductionItem = JSON.parse(newValue); | |
}); | |
$scope.$watch('selectedProductionItem', function (newValue, oldValue) { | |
$scope.properties.SelectedProductionItem.PropertyValue = JSON.stringify(newValue); | |
}); | |
$scope.$watch('properties.SelectedProductionItemId.PropertyValue', function (newValue, oldValue) { | |
$scope.productionId = JSON.parse(newValue); | |
}); | |
$scope.$watch('productionId', function (newValue, oldValue) { | |
$scope.properties.SelectedProductionItemId.PropertyValue = JSON.stringify(newValue); | |
}); | |
}]); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment