/**
|
* Created by wisestone on 2018-02-06.
|
*/
|
'use strict';
|
|
define(['app',
|
'angular'],
|
function (app, angular) {
|
app.directive('cardContent', ["$log", "$rootScope", "$compile",
|
function ($log, $rootScope, $compile) {
|
return {
|
restrict : 'AE',
|
compile : function (tElement, tAttrs) {
|
return function (scope, element, attrs) {
|
var makeTag = "";
|
scope.task = scope[attrs["cardContent"]];
|
|
if (angular.isDefined(scope.task)) {
|
if (scope.task.priorityVo != null) {
|
|
switch(scope.task.priorityVo.color) {
|
case "btn-danger" :
|
$(element).addClass("item-danger");
|
break;
|
case "btn-primary" :
|
$(element).addClass("item-primary");
|
break;
|
case "btn-info" :
|
$(element).addClass("item-info");
|
break;
|
}
|
}
|
|
// 지연 여부 확인
|
if ($rootScope.isDefined(scope.task.completeDate)) {
|
var completeDate = new Date(scope.task.completeDate);
|
var year = new Date().getFullYear();
|
var month = new String(new Date().getMonth() + 1);
|
var day = new String(new Date().getDate());
|
var nowDate = new Date(year + "-" + month + "-" + day);
|
|
if (completeDate.getTime() < nowDate.getTime()) {
|
makeTag += "<div class='temp-pi-controls'><span class='badge badge-danger'>지연</span></div>";
|
}
|
}
|
|
// Body 영역
|
makeTag += "<div class='temp-pi-body'>";
|
makeTag += "<div class='temp-pi-info'>";
|
makeTag += "<div class='h6 temp-pi-name'>" + scope.task.title + "</div>";
|
|
if (angular.isDefined(scope.task.description) && scope.task.description != null && scope.task.description.length > 0) {
|
makeTag += "<div class='temp-pi-cont'>" + scope.task.description + "</div>";
|
}
|
|
makeTag += "</div>";
|
makeTag += "</div>"; // temp-pi-body 종료
|
|
if (scope.task.taskCommentCount > 0 || scope.task.attachedFileCount > 0 || scope.task.userVos.length > 0 || $rootScope.isDefined(scope.task.startDate)) {
|
// Footer 영역
|
makeTag += "<div class='temp-pi-footer'>";
|
makeTag += "<div class='temp-tag'>";
|
|
makeTag += "<a class='temp-extra-info' href=''><i class='os-icon os-icon-mail-12'></i><span>" + scope.task.taskCommentCount + "</span></a>";
|
makeTag += "<a class='temp-extra-info' href=''><i class='os-icon os-icon-ui-51'></i><span>"+ scope.task.attachedFileCount +"</span></a>";
|
|
if ($rootScope.isDefined(scope.task.completeDate)) {
|
var year = new Date().getFullYear();
|
var completeDateYear = scope.task.completeDate.substr(0, 4);
|
|
// 같은 년도면
|
if (year == completeDateYear) {
|
makeTag += "<span class='temp-exdate'>" + scope.task.completeDate.substr(5, scope.task.completeDate.length) + "</span>";
|
}
|
else {
|
makeTag += "<span class='temp-exdate'>" + scope.task.completeDate + "</span>";
|
}
|
}
|
else {
|
makeTag += "<span class='temp-exdate'></span>";
|
}
|
|
makeTag += "</div>"; // temp-tag 종료
|
|
makeTag += "<div class='temp-extra-info2'>";
|
|
for (var count = 0; count < scope.task.userVos.length; count++) {
|
var user = scope.task.userVos[count];
|
|
if (count > 1) {
|
makeTag += "<div class='os-dropdown-trigger os-dropdown-position-left'>";
|
makeTag += "<span class='avatar'>";
|
makeTag += "<img alt='' ng-src='" + user.profile + "'/>";
|
makeTag += "</span>";
|
makeTag += "<div class='os-dropdown light message-list'>";
|
makeTag += "<ul>";
|
|
var innerCount = count;
|
|
// 나머지 사용자 정보를 여기서 셋팅한다.
|
for (innerCount; innerCount < scope.task.userVos.length; innerCount++) {
|
makeTag += "<li> <a href=''> <div class='user-avatar-w'> <img alt='' ng-src='" + user.profile + "'> </div> <div class='message-content'>";
|
makeTag += "<h6 class='message-from'> " + user.name + " </h6>";
|
makeTag += "<h6 class='message-title'>" + user.account + "</h6>";
|
makeTag += "</div> </a> </li> ";
|
}
|
|
makeTag += "</ul> </div> </div>";
|
makeTag += "<div class='more'>" + "+" +(innerCount - count) + "</div>";
|
}
|
else {
|
makeTag += "<div class='os-dropdown-trigger os-dropdown-position-left'>";
|
makeTag += "<span class='avatar'>";
|
makeTag += "<img alt='' ng-src='" + user.profile + "'/>";
|
makeTag += "</span>";
|
makeTag += "<div class='os-dropdown light message-list'>";
|
makeTag += "<ul> <li> <a href=''> <div class='user-avatar-w'> <img alt='' ng-src='" + user.profile + "'> </div> <div class='message-content'>";
|
makeTag += "<h6 class='message-from'> " + user.name + " </h6>";
|
makeTag += "<h6 class='message-title'>" + user.account + "</h6>";
|
makeTag += "</div> </a> </li> </ul> </div> </div>";
|
}
|
}
|
|
makeTag += "</div>"; // temp-extra-info 종료
|
makeTag += "</div>"; // temp-footer 종료
|
}
|
|
var linkFn = $compile(makeTag);
|
var content = linkFn(scope);
|
element.append(content);
|
}
|
};
|
}
|
}
|
}])
|
});
|