Skip to content

Commit

Permalink
Add missing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Fweddi committed Nov 20, 2024
1 parent 4dacd6a commit cde31f6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
15 changes: 13 additions & 2 deletions app/controllers/Api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,23 @@ class Api(
APIAuthAction.async { request =>
ApiResponseFt[Long](for {
json <- readJsonFromRequestResponse(request.body)
status <- extractDataResponse[Option[Int]](json)
id <- stubsApi.updateContentCommissionedLength(stubId, status)
commissionedLength <- extractDataResponse[Option[Int]](json)
id <- stubsApi.updateContentCommissionedLength(stubId, commissionedLength)
} yield id
)}
}

def putStubMissingCommissionedLengthReason(stubId: Long) = {
APIAuthAction.async { request =>
ApiResponseFt[Long](for {
json <- readJsonFromRequestResponse(request.body)
missingCommissionedLengthReason <- extractDataResponse[Option[String]](json)
id <- stubsApi.updateContentMissingCommissionedLengthReason(stubId, missingCommissionedLengthReason)
} yield id
)
}
}

def putStubStatusByComposerId(composerId: String) = {
APIAuthAction.async { request =>
ApiResponseFt[String](for {
Expand Down
7 changes: 7 additions & 0 deletions common-lib/src/main/scala/com/gu/workflow/api/StubAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ class StubAPI(
item <- extractDataResponse[Long](json)
} yield item

def updateContentMissingCommissionedLengthReason(stubId: Long, missingCommissionedLengthReason: Option[String]): ApiResponseFt[Long] =
for {
res <- ApiResponseFt.Async.Right(putRequest(s"stubs/$stubId/missingCommissionedLengthReason", missingCommissionedLengthReason.asJson))
json <- parseBody(res.body)
item <- extractDataResponse[Long](json)
} yield item

def updateContentStatusByComposerId(composerId: String, status: String): ApiResponseFt[String] =
for {
res <- ApiResponseFt.Async.Right(putRequest(s"content/$composerId/status", status.asJson))
Expand Down
2 changes: 2 additions & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ PUT /api/stubs/:stubId/plannedBookSectionId controllers.Api.putSt
PUT /api/stubs/:stubId/plannedNewspaperPageNumber controllers.Api.putStubPlannedNewspaperPageNumber(stubId: Long)
PUT /api/stubs/:stubId/plannedNewspaperPublicationDate controllers.Api.putStubPlannedNewspaperPublicationDate(stubId: Long)
PUT /api/stubs/:stubId/rightsReviewed controllers.Api.putStubRightsReviewed(stubId: Long)
PUT /api/stubs/:stubId/commissionedLength controllers.Api.putStubCommissionedLength(stubId: Long)
PUT /api/stubs/:stubId/missingCommissionedLengthReason controllers.Api.putStubMissingCommissionedLengthReason(stubId: Long)
DELETE /api/stubs/:stubId controllers.Api.deleteStub(stubId: Long)

GET /api/statuses controllers.Api.statusus
Expand Down
20 changes: 19 additions & 1 deletion public/components/content-list-drawer/content-list-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,36 @@ export function wfContentListDrawer($rootScope, config, $timeout, $window, conte
// Don't allow commissioned length to be unset
if(newValue === "") return;
if ($scope.contentItem.missingCommissionedLengthReason !== null && $scope.contentItem.missingCommissionedLengthReason !== undefined) {
// workflow stub
updateField("missingCommissionedLengthReason", null);
// composer preview
wfComposerService.deleteField(
$scope.contentItem.composerId,
"missingCommissionedLengthReason"
"missingCommissionedLengthReason",
false
);
// composer live
wfComposerService.deleteField(
$scope.contentItem.composerId,
"missingCommissionedLengthReason",
true
);
}
// workflow stub
updateField("commissionedLength", newValue);
// composer preview
wfComposerService.updateField(
$scope.contentItem.composerId,
"commissionedLength",
newValue
);
// composer live
wfComposerService.updateField(
$scope.contentItem.composerId,
"commissionedLength",
newValue,
true
);
};

$scope.formatReason = (missingCommissionedLengthReason) => {
Expand Down

0 comments on commit cde31f6

Please sign in to comment.