2015-06-21 19:27:48 +00:00
|
|
|
angular.module('SeHub').controller('newTasksController', ['$scope',
|
|
|
|
function($scope) {
|
|
|
|
|
2015-06-25 19:40:26 +00:00
|
|
|
$scope.newComp = {};
|
|
|
|
$scope.newComp.isMandatory = false;
|
2015-06-21 19:27:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
$scope.componentTypes = [{
|
|
|
|
"type": "textbox"
|
|
|
|
}, {
|
|
|
|
"type": "textarea"
|
|
|
|
}, {
|
|
|
|
"type": "checkbox"
|
2015-06-25 19:40:26 +00:00
|
|
|
}, {
|
|
|
|
"type": "link"
|
|
|
|
}, {
|
|
|
|
"type": "radiobuttons"
|
2015-06-21 19:27:48 +00:00
|
|
|
}];
|
|
|
|
|
2015-06-22 19:37:47 +00:00
|
|
|
$scope.task = {};
|
|
|
|
$scope.task.task = {};
|
2015-06-25 19:40:26 +00:00
|
|
|
$scope.task.components = [];
|
|
|
|
$scope.task.isPersonal = false;
|
2015-06-21 19:27:48 +00:00
|
|
|
|
2015-06-22 19:37:47 +00:00
|
|
|
// $scope.task = [];
|
2015-06-21 19:27:48 +00:00
|
|
|
|
2015-06-22 19:37:47 +00:00
|
|
|
$scope.addComponent = function() {
|
2015-06-25 19:40:26 +00:00
|
|
|
var comp = {};
|
|
|
|
var type = $scope.newComp.type;
|
|
|
|
comp.type = type;
|
|
|
|
comp.isMandatory = $scope.newComp.isMandatory;
|
|
|
|
comp.label = "";
|
|
|
|
var i = 0
|
|
|
|
if (!(type === 'textbox' || type === 'textarea' || type === 'checkbox'))
|
|
|
|
while ($scope.newComp.label[i]) {
|
|
|
|
comp.label += $scope.newComp.label[i] + "|";
|
|
|
|
i++;
|
|
|
|
} else
|
|
|
|
comp.label = $scope.newComp.label[i];
|
|
|
|
|
|
|
|
console.log(comp);
|
|
|
|
$scope.task.components.push(comp);
|
|
|
|
|
|
|
|
// console.log($scope.newComp);
|
2015-06-21 19:27:48 +00:00
|
|
|
$scope.newComp = {};
|
2015-06-25 19:40:26 +00:00
|
|
|
$scope.newComp.isMandatory = false;
|
|
|
|
$scope.compDetails = [];
|
|
|
|
$scope.isRadioButton = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.ComponentType = function(type) {
|
|
|
|
if (type === 'textbox' || type === 'textarea' || type === 'checkbox')
|
|
|
|
$scope.compDetails = [{
|
|
|
|
detail: "Label"
|
|
|
|
}];
|
|
|
|
else if (type === 'radiobuttons') {
|
|
|
|
$scope.compDetails = [{
|
|
|
|
detail: "Label"
|
|
|
|
}];
|
|
|
|
$scope.compDetails.push({
|
|
|
|
detail: "Option" + $scope.compDetails.length + ": "
|
|
|
|
});
|
|
|
|
} else if (type === 'link')
|
|
|
|
$scope.compDetails = [{
|
|
|
|
detail: "Label"
|
|
|
|
}, {
|
|
|
|
detail: "URL Path"
|
|
|
|
}];
|
|
|
|
|
|
|
|
if (type === 'radiobuttons')
|
|
|
|
$scope.isRadioButton = true;
|
|
|
|
else
|
|
|
|
$scope.isRadioButton = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.addMoreOptions = function() {
|
|
|
|
$scope.compDetails.push({
|
|
|
|
detail: "Option" + $scope.compDetails.length + ": "
|
|
|
|
});
|
2015-06-21 19:27:48 +00:00
|
|
|
}
|
2015-06-22 19:37:47 +00:00
|
|
|
|
2015-06-25 19:40:26 +00:00
|
|
|
$scope.dueTime = function() {
|
|
|
|
if (!$scope.task.date || $scope.task.date === '')
|
|
|
|
$scope.dueTimeFromNow = "";
|
2015-06-22 19:37:47 +00:00
|
|
|
var d = new Date($scope.task.date);
|
2015-06-25 19:40:26 +00:00
|
|
|
$scope.dueTimeFromNow = moment(d).fromNow();
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.initLinkComp = function(component){
|
|
|
|
var arr = component.label.split("|");
|
|
|
|
for (var i = 0; i < arr.length - 1; i++) {
|
|
|
|
if(i == 0)
|
|
|
|
component.title = arr[i];
|
|
|
|
else
|
|
|
|
component.href = arr[i];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.initRadioButtonsComp = function(component){
|
|
|
|
var arr = component.label.split("|");
|
|
|
|
component.values = [];
|
|
|
|
for (var i = 0; i < arr.length - 1; i++) {
|
|
|
|
if(i == 0)
|
|
|
|
component.title = arr[i];
|
|
|
|
else
|
|
|
|
component.values.push({text: arr[i], id: i});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.RB = function(comp){
|
|
|
|
console.info(comp);
|
2015-06-22 19:37:47 +00:00
|
|
|
}
|
2015-06-25 19:40:26 +00:00
|
|
|
|
2015-06-21 19:27:48 +00:00
|
|
|
}
|
|
|
|
]);
|