/**
|
* Created by wisestone on 2018-09-05.
|
*/
|
'use strict';
|
|
define(['app', 'angular'],
|
function (app, angular) {
|
app.directive('issueSearchFieldKeyViewElement', ["$log", "$compile",
|
function ($log, $compile) {
|
return {
|
restrict: 'AE',
|
scope: {
|
lists : "=",
|
keys : "="
|
},
|
link: function ($scope, $element, $attrs) {
|
|
$scope.fn = {
|
makeSearchElements : makeSearchElements, // 선택한 검색 대상 값을 화면에 표시한다.
|
remove : remove // 선택한 대상 값을 초기화한다.
|
};
|
|
$scope.$watch("keys", function () {
|
$element.empty();
|
$scope.fn.makeSearchElements();
|
}, true);
|
|
function remove(fieldKey) {
|
var tempKeys = [];
|
|
angular.forEach($scope.keys, function (key) {
|
if (key.fieldKey != fieldKey) {
|
tempKeys.push(key);
|
}
|
});
|
|
$scope.keys = angular.copy(tempKeys);
|
}
|
|
function makeSearchElements() {
|
var makeTag = "";
|
|
angular.forEach($scope.keys, function (key) {
|
makeTag += "<p>";
|
|
for (var count in $scope.lists) {
|
var target = $scope.lists[count];
|
|
if (target.fieldKey == key.fieldKey) {
|
makeTag += target.fieldValue;
|
break;
|
}
|
}
|
|
makeTag += "<span ng-click='fn.remove(" + key.fieldKey + ")'>×</span>";
|
makeTag += "</p>";
|
});
|
|
var linkFn = $compile(makeTag);
|
var content = linkFn($scope);
|
$element.append(content);
|
}
|
|
}
|
};
|
}])
|
});
|