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