harbor/static/ng/resources/js/components/project/publicity-button.directive.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-05-01 19:46:50 +02:00
(function() {
'use strict';
angular
.module('harbor.project')
.directive('publicityButton', publicityButton);
PublicityButtonController.$inject = ['EditProjectService'];
function PublicityButtonController(EditProjectService) {
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;
}
EditProjectService(vm.projectId, vm.isPublic)
.success(editProjectSuccess)
.error(editProjectFailed);
}
function editProjectSuccess(data, status) {
console.log('edit project successfully:' + status);
}
function editProjectFailed(e) {
console.log('edit project failed:' + e);
}
}
function publicityButton() {
var directive = {
'restrict': 'E',
'templateUrl': '/static/ng/resources/js/components/project/publicity-button.directive.html',
'scope': {
'isPublic': '=',
'owned': '=',
'projectId': '='
},
'link': link,
'controller': PublicityButtonController,
'controllerAs': 'vm',
'bindToController': true
};
return directive;
function link(scope, element, attr, ctrl) {
}
}
})();