'use strict';
|
|
define(['app', 'angular'],
|
function (app, angular) {
|
|
app.directive('treeColumnGenerator', ['$compile', '$log', '$rootScope', '$tableProvider', '$filter',
|
function ($compile, $log, $rootScope, $tableProvider, $filter) {
|
return {
|
restrict : "A",
|
compile : function (tElement, tAttrs) {
|
return function (scope, element, attrs) {
|
scope.data = scope[attrs["treeColumnGenerator"]];
|
|
var makeTag = "";
|
var treeStartToken = "└";
|
|
scope.tableConfigs.forEach(function (tableConfig, index) {
|
|
if (tableConfig.colSpan > 0) {
|
return;
|
}
|
|
makeTag = '<li class="' + tableConfig.dAlign + ' ' + tableConfig.dVisible + '">';
|
|
if (tableConfig.dType === "checkbox") {
|
// 체크 박스일때
|
if (scope.data.defaultYn) {
|
makeTag += '<input type="checkbox" ng-checked="data.checked == true ? true : false" disabled ng-click="$root.$tableProvider.rowChecked(tableConfigs, data, fn.getResponseData())">';
|
}
|
else {
|
makeTag += '<input type="checkbox" ng-checked="data.checked == true ? true : false" ng-click="$root.$tableProvider.rowChecked(tableConfigs, data, fn.getResponseData())">';
|
}
|
|
tableConfig.hChecked = false;
|
}
|
else if (tableConfig.dType === "radio") {
|
// 라디오 버튼일때
|
makeTag += '<input type="radio" ng-checked="data.checked == true ? true : false" ng-click="$root.$tableProvider.rowChecked(tableConfigs, data, fn.getResponseData())">';
|
}
|
else if (tableConfig.dType === "date") {
|
makeTag += $filter('date')(scope.data[tableConfig.dName], $tableProvider.getDateFormat(tableConfig.dDateFormat, scope.data[tableConfig.dName]));
|
}
|
else {
|
if (angular.isDefined(scope.data[tableConfig.dName]) && scope.data[tableConfig.dName] != null) {
|
makeTag += '<span>' + scope.data[tableConfig.dName] + '</span>';
|
}
|
else {
|
makeTag += '<span></span>';
|
}
|
}
|
|
makeTag += '</li>';
|
|
var linkFn = $compile(makeTag);
|
var content = linkFn(scope);
|
|
element.append(content);
|
|
});
|
}
|
}
|
}
|
}]);
|
});
|