Skip to content

Commit

Permalink
Merge pull request #495 from guardian/dblatcher/display-hint-put-endp…
Browse files Browse the repository at this point in the history
…oint

display hint put endpoint
  • Loading branch information
dblatcher authored Feb 3, 2025
2 parents 5c883c6 + 16c35ef commit 25eb1cf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/controllers/Api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ class Api(
)}
}

def putStubDisplayHint(stubId: Long) = {
def getDisplayHintOpt(input: String): Option[String] = if(input.length > 0) Some(input) else None
APIAuthAction.async { request =>
ApiResponseFt[Long](for {
json <- readJsonFromRequestResponse(request.body)
displayHint <- extractDataResponse[String](json)
displayHintOpt = getDisplayHintOpt(displayHint)
id <- stubsApi.putStubDisplayHint(stubId, displayHintOpt)
} yield id
)}
}

def putStubStatus(stubId: Long) = {
APIAuthAction.async { request =>
ApiResponseFt[Long](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 @@ -95,6 +95,13 @@ class StubAPI(
item <- extractDataResponse[Long](json)
} yield item

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

def putStubTrashed(id: Long, trashed: Boolean): ApiResponseFt[Long] =
for {
res <- ApiResponseFt.Async.Right(putRequest(s"stubs/$id/updateTrashed", trashed.asJson))
Expand Down
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ POST /api/stubs controllers.Api.creat
PUT /api/stubs/:stubId controllers.Api.putStub(stubId: Long)
PUT /api/stubs/:stubId/assignee controllers.Api.putStubAssignee(stubId: Long)
PUT /api/stubs/:stubId/assigneeEmail controllers.Api.putStubAssigneeEmail(stubId: Long)
PUT /api/stubs/:stubId/displayHint controllers.Api.putStubDisplayHint(stubId: Long)
PUT /api/stubs/:stubId/dueDate controllers.Api.putStubDueDate(stubId: Long)
PUT /api/stubs/:stubId/note controllers.Api.putStubNote(stubId: Long)
PUT /api/stubs/:stubId/needsLegal controllers.Api.putStubLegalStatus(stubId: Long)
Expand Down
1 change: 1 addition & 0 deletions public/components/content-list-item/content-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function wfContentItemParser(config, wfFormatDateTime, statusLabels, sections) {

this.contentType = item.contentType;
this.contentTypeTitle = toTitleCase(item.contentType);
this.displayHintDescription = item.displayHint ?? 'No Display Hint';
this.office = item.prodOffice;
this.officeTitle = getFullOfficeString(item.prodOffice);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<td class="content-list-item__field--content-type" title="{{ contentItem.contentTypeTitle }}">
<td class="content-list-item__field--content-type" title="{{ contentItem.contentTypeTitle }}" data-display-hint="{{ contentItem.displayHintDescription }}">
<i class="content-list-item__icon--content-type" wf-icon="{{ contentItem.contentType }}"/>
</td>

0 comments on commit 25eb1cf

Please sign in to comment.