Skip to content

Commit

Permalink
#144 Update the case creation dialog to specify the case template
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Mar 15, 2017
1 parent 89259e8 commit 3338efa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
15 changes: 7 additions & 8 deletions thehive-backend/app/services/CaseSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ class CaseSrv @Inject() (
case Some(t) applyTemplate(t, fieldsWithOwner)
}
createSrv[CaseModel, Case](caseModel, templatedCaseFields.unset("tasks"))
.andThen {
case Success(caze)
val taskFields = fields.getValues("tasks").collect {
case task: JsObject Fields(task)
} ++ template.map(_.tasks().map(Fields(_))).getOrElse(Nil)
createSrv[TaskModel, Task, Case](taskModel, taskFields.map(caze _))
.map(_ caze)
.flatMap { caze
val taskFields = fields.getValues("tasks").collect {
case task: JsObject Fields(task)
} ++ template.map(_.tasks().map(Fields(_))).getOrElse(Nil)
createSrv[TaskModel, Task, Case](taskModel, taskFields.map(caze _))
.map(_ caze)
}
}

Expand Down Expand Up @@ -118,4 +117,4 @@ class CaseSrv @Inject() (
}
.mapMaterializedValue(_ NotUsed)
}
}
}
12 changes: 1 addition & 11 deletions ui/app/scripts/controllers/case/CaseCreationCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,7 @@

// Append title prefix
if ($scope.fromTemplate) {
$scope.newCase.title = $scope.template.titlePrefix + ' ' + $scope.temp.titleSuffix;

$scope.newCase.tasks = _.map($scope.template.tasks, function (task) {
return {
title: task.title,
description: task.description,
flag: false,
status: 'Waiting'
};
});

$scope.newCase.template = $scope.template.name;
} else {
$scope.newCase.tasks = _.map($scope.tasks, function (task) {
return {
Expand Down
2 changes: 2 additions & 0 deletions ui/app/scripts/services/StreamSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
},

runCallbacks: function(id, objectType, message) {
console.debug('stream:' + id + '-' + objectType);

$rootScope.$broadcast('stream:' + id + '-' + objectType, message);
},

Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/partials/case/case.creation.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4 class="vpad10 text-primary">Case details</h4>

<div class="input-group" ng-if="fromTemplate">
<span class="input-group-addon">{{template.titlePrefix}}</span>
<input class="form-control" name="title" ng-model="temp.titleSuffix" placeholder="Title" required type="text"/>
<input class="form-control" name="title" ng-model="newCase.title" placeholder="Title" required type="text"/>
</div>

<p class="help-block" ng-show="caseCreateForm.title.$invalid && !caseCreateForm.title.$pristine">The case title is required.</p>
Expand Down

0 comments on commit 3338efa

Please sign in to comment.