62 lines
2.9 KiB
JavaScript
62 lines
2.9 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('assetModule')
|
|
.directive('listCi', ['$state', '$modal', '$filter', 'ciExplorerModel', function ($state, $modal, $filter, ciExplorerModel) {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
templateUrl: 'views/asset/list-ci.html',
|
|
scope: {
|
|
model: '='
|
|
},
|
|
link: function (scope) {
|
|
var modalInstance;
|
|
scope.openAssetDetails = function (asset) {
|
|
modalInstance = $modal.open({
|
|
templateUrl: 'views/change/ci-relation-preview.html',
|
|
windowClass: 'action-blade',
|
|
size: 'lg',
|
|
controller: ['$scope', function ($scope) {
|
|
$scope.assetIdsObject = buildAssetIdObject(asset);
|
|
}]
|
|
});
|
|
};
|
|
scope.$on('$stateChangeStart', function () {
|
|
if (modalInstance) {
|
|
modalInstance.dismiss();
|
|
}
|
|
});
|
|
scope.getRelationshipTypesLabel = function (asset) {
|
|
var labels = [];
|
|
if (asset.relationshipClassId) {
|
|
labels.push(ciExplorerModel.getRelationshipTypeLabel(asset.relationshipClassId));
|
|
}
|
|
if (asset.realObject.isChild) {
|
|
labels.push($filter('i18n')('asset.relationship.child.short'));
|
|
}
|
|
if (asset.realObject.isParent) {
|
|
labels.push($filter('i18n')('asset.relationship.parent.short'));
|
|
}
|
|
if (!asset.realObject.isChild && !asset.realObject.isParent) {
|
|
labels.push($filter('i18n')('asset.explorer.relatives.non-directional'));
|
|
}
|
|
return labels.join(", ");
|
|
};
|
|
scope.getStatusLabel = function (asset) {
|
|
var status = asset && asset.realObject && asset.realObject.status && asset.realObject.status.value;
|
|
return status
|
|
? $filter('localizeLabel')(status, 'status', EntityVO.TYPE_ASSET) || status
|
|
: $filter('i18n')('asset.explorer.field.na');
|
|
};
|
|
function buildAssetIdObject(asset) {
|
|
return {
|
|
assetId: asset.reconciliationId || asset.realObject.reconciliationId,
|
|
assetClassId: asset.classId || asset.realObject.classId
|
|
};
|
|
}
|
|
}
|
|
};
|
|
}]);
|
|
}());
|