2016-05-01 19:46:50 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.project')
|
|
|
|
.directive('publicityButton', publicityButton);
|
|
|
|
|
2016-06-15 12:31:02 +02:00
|
|
|
PublicityButtonController.$inject = ['ToggleProjectPublicityService'];
|
2016-05-01 19:46:50 +02:00
|
|
|
|
2016-06-15 12:31:02 +02:00
|
|
|
function PublicityButtonController(ToggleProjectPublicityService) {
|
2016-05-01 19:46:50 +02:00
|
|
|
var vm = this;
|
|
|
|
vm.toggle = toggle;
|
|
|
|
|
2016-05-23 12:29:17 +02:00
|
|
|
if(vm.isPublic === 1) {
|
2016-05-01 19:46:50 +02:00
|
|
|
vm.isPublic = true;
|
|
|
|
}else{
|
|
|
|
vm.isPublic = false;
|
|
|
|
}
|
2016-05-13 12:48:06 +02:00
|
|
|
|
2016-05-01 19:46:50 +02:00
|
|
|
function toggle() {
|
|
|
|
|
|
|
|
if(vm.isPublic) {
|
|
|
|
vm.isPublic = false;
|
|
|
|
}else{
|
|
|
|
vm.isPublic = true;
|
|
|
|
}
|
|
|
|
|
2016-06-15 12:31:02 +02:00
|
|
|
ToggleProjectPublicityService(vm.projectId, vm.isPublic)
|
|
|
|
.success(toggleProjectPublicitySuccess)
|
|
|
|
.error(toggleProjectPublicityFailed);
|
2016-05-01 19:46:50 +02:00
|
|
|
}
|
|
|
|
|
2016-06-15 12:31:02 +02:00
|
|
|
function toggleProjectPublicitySuccess(data, status) {
|
|
|
|
console.log('Successful toggle project publicity.');
|
2016-05-01 19:46:50 +02:00
|
|
|
}
|
|
|
|
|
2016-06-15 12:31:02 +02:00
|
|
|
function toggleProjectPublicityFailed(e) {
|
|
|
|
console.log('Failed toggle project publicity:' + e);
|
2016-05-01 19:46:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function publicityButton() {
|
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
'templateUrl': '/static/resources/js/components/project/publicity-button.directive.html',
|
2016-05-01 19:46:50 +02:00
|
|
|
'scope': {
|
|
|
|
'isPublic': '=',
|
|
|
|
'owned': '=',
|
|
|
|
'projectId': '='
|
|
|
|
},
|
|
|
|
'link': link,
|
|
|
|
'controller': PublicityButtonController,
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
return directive;
|
|
|
|
|
|
|
|
function link(scope, element, attr, ctrl) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|