47 lines
2.1 KiB
JavaScript
47 lines
2.1 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('myitsmApp')
|
|
.directive('taskPhase', ['fieldValidationModel', 'events', function (fieldValidationModel, events) {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
templateUrl: 'views/custom-widgets/task-phase-directive.html',
|
|
scope: {
|
|
data: '=',
|
|
metadata: '=',
|
|
isEditable: '=',
|
|
isNew: '=?',
|
|
ticket: '='
|
|
},
|
|
link: function (scope, element) {
|
|
if (scope.$parent.isNew) {
|
|
scope.fieldLengthForSm6 = true;
|
|
}
|
|
else {
|
|
if (element.closest(".layout-renderer__child-column")[0]) {
|
|
scope.fieldLengthForSm6 = _.includes(element.closest(".layout-renderer__child-column")[0].className, 'col-sm-6');
|
|
scope.fieldLengthForSm4 = _.includes(element.closest(".layout-renderer__child-column")[0].className, 'col-sm-4');
|
|
}
|
|
}
|
|
scope.$watch('data.setValueFlag', function (value) {
|
|
if (value && value !== '#$#') {
|
|
var setValue = _.get(value, 'phaseName');
|
|
if (setValue) {
|
|
scope.ticket.selectedPhase = _.find(_.filter(scope.ticket.taskPhases, { name: setValue }));
|
|
}
|
|
scope.updatePhase();
|
|
scope.data.setValueFlag = '#$#';
|
|
}
|
|
});
|
|
scope.updatePhase = function () {
|
|
scope.data.value.phaseGuid = scope.ticket.selectedPhase.guid;
|
|
scope.data.value.phaseName = scope.ticket.selectedPhase.name;
|
|
scope.$emit(events.WIDGET_VALUE_CHANGE, { fieldName: scope.data.name });
|
|
};
|
|
}
|
|
};
|
|
}
|
|
]);
|
|
})();
|