Skip to content

Commit

Permalink
Merge pull request #2213 from guardian/aa-filename-chip
Browse files Browse the repository at this point in the history
add filename search as a chip
  • Loading branch information
akash1810 committed Jul 5, 2018
2 parents 69e55af + 11e0095 commit 69cf118
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ trait ImageFields {
def collectionsField(field: String) = s"collections.$field"
def usagesField(field: String) = s"usages.$field"

val aliases = Map(
"crops" -> "exports",
"croppedBy" -> "exports.author",
"filename" -> "uploadInfo.filename"
)

def getFieldPath(field: String) = field match {
case f if metadataFields.contains(f) => metadataField(f)
case f if usageRightsFields.contains(f) => usageRightsField(f)
case f if editsFields.contains(f) => editsField(f)
case f if collectionsFields.contains(f) => collectionsField(f)
case f if usagesFields.contains(f) => usagesField(f)
case "crops" => "exports"
case f => f
case f => aliases.getOrElse(f, f)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const filterFields = [
'usages@platform',
'usages@status',
'has',
'croppedBy'
'croppedBy',
'filename'
].sort();
// TODO: add date fields

Expand Down
4 changes: 2 additions & 2 deletions media-api/app/lib/querysyntax/QuerySyntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class QuerySyntax(val input: ParserInput) extends Parser with ImageFields {
"collection" |
"keyword" |
"label" |
"croppedBy"
"croppedBy" |
"filename"
}

def resolveNamedField(name: String): Field = (name match {
Expand All @@ -118,7 +119,6 @@ class QuerySyntax(val input: ParserInput) extends Parser with ImageFields {
case "location" => "subLocation"
case "by" | "photographer" => "byline"
case "keyword" => "keywords"
case "croppedBy" => "exports.author"
case fieldName => fieldName
}) match {
case "publication" => MultipleField(List("publicationName", "publicationCode"))
Expand Down

0 comments on commit 69cf118

Please sign in to comment.