Skip to content

Commit

Permalink
image type names come from configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-nowak committed Sep 30, 2024
1 parent 18f06a1 commit 500787c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 31 deletions.
4 changes: 3 additions & 1 deletion kahuna/app/controllers/KahunaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class KahunaController(
Html(s""""${config.staffPhotographerOrganisation}-owned"""")
else
Html("undefined")
val imageTypes = Json.toJson(config.imageTypes).toString()

Ok(views.html.main(
s"${config.authUri}/login?redirectUri=$returnUri",
Expand All @@ -84,7 +85,8 @@ class KahunaController(
costFilterChargeable,
maybeOrgOwnedValue,
config,
featureSwitchesJson
featureSwitchesJson,
imageTypes
))
}

Expand Down
2 changes: 2 additions & 0 deletions kahuna/app/lib/KahunaConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class KahunaConfig(resources: GridConfigResources) extends CommonConfig(resource

val announcements: Seq[Announcement] = configuration.getOptional[Seq[Announcement]]("announcements").getOrElse(Seq.empty)

val imageTypes: Seq[String] = configuration.getOptional[Seq[String]]("imageTypes").getOrElse(Seq.empty)

//BBC custom warning text
val warningTextHeader: String = configuration.getOptional[String]("warningText.header")
.getOrElse("This image can be used, but has warnings:")
Expand Down
2 changes: 2 additions & 0 deletions kahuna/app/views/main.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
maybeOrgOwnedValueHtml: Html,
kahunaConfig: KahunaConfig,
featureSwitches: String,
imageTypes: String,
)
<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -85,6 +86,7 @@
defaultShouldBlurGraphicImages: @kahunaConfig.defaultShouldBlurGraphicImages,
shouldUploadStraightToBucket: @kahunaConfig.shouldUploadStraightToBucket,
announcements: @Html(announcements),
imageTypes: @Html(imageTypes),
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
</dl>
</div>

<div class="image-info__group" role="region" aria-label="Image type">
<div class="image-info__group" role="region" aria-label="Image type"
ng-if="Array.isArray(ctrl.validImageTypes) && ctrl.validImageTypes.length > 0"
>
<dl class="image-info__wrap metadata-line image-info__image-type">
<dt class="metadata-line__key">Image type</dt>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import '../../services/label';
import '../../search/query-filter';
import '../gr-usagerights-summary/gr-usagerights-summary';
import { List } from 'immutable';
import { validImageTypes } from "../../util/constants/imageTypes";

export const module = angular.module('gr.imageMetadata', [
'gr.image.service',
Expand Down Expand Up @@ -64,7 +63,7 @@ module.controller('grImageMetadataCtrl', [
ctrl.usageRightsSummary = window._clientConfig.usageRightsSummary;
ctrl.metadataUpdatedByTemplate = [];

ctrl.validImageTypes = validImageTypes;
ctrl.validImageTypes = window._clientConfig.imageTypes;

ctrl.$onInit = () => {
$scope.$watchCollection('ctrl.selectedImages', function () {
Expand Down
50 changes: 26 additions & 24 deletions kahuna/public/js/upload/jobs/required-metadata-editor.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
<form class="job-editor" name="jobEditor" ng-submit="ctrl.save()"
novalidate ng-class="{'job-editor__disabled': !ctrl.userCanEdit}"
aria-label="Image metadata">
<div class="job-editor__inputs">
<label class="job-info--editor__field">
<div class="job-info--editor__label job-info--editor__multiline text-small">Image type</div>
<select
name="imageType"
ng-model="ctrl.metadata.imageType"
ng-model-options="{updateOn: 'default blur', debounce: { default: ctrl.saveOnTime, blur: 0 }}"
ng-change="ctrl.save()"
ng-class="{ 'job-info--editor__input--with-batch': ctrl.withBatch, 'job-info--editor__input-preview': ctrl.originalMetadata['imageType'] !== ctrl.metadata['imageType'] }"
ng-disabled="!ctrl.userCanEdit"
ng-readonly="ctrl.metadataUpdatedByTemplate.length > 0"
ng-options="type for type in ctrl.validImageTypes"
>
<option value="">-- choose type --</option>
</select>

<button
class="job-editor__apply-to-all"
title="Apply this image type to all your current uploads"
type="button"
ng-if="ctrl.withBatch && ctrl.userCanEdit && (ctrl.originalMetadata['imageType'] === ctrl.metadata['imageType'])"
ng-click="ctrl.batchApplyMetadata('imageType')"
></button>
</label>
<div class="job-editor__ianputs">
<span ng-if="Array.isArray(ctrl.validImageTypes) && ctrl.validImageTypes.length > 0">
<label class="job-info--editor__field">
<div class="job-info--editor__label job-info--editor__multiline text-small">Image type</div>
<select
name="imageType"
ng-model="ctrl.metadata.imageType"
ng-model-options="{updateOn: 'default blur', debounce: { default: ctrl.saveOnTime, blur: 0 }}"
ng-change="ctrl.save()"
ng-class="{ 'job-info--editor__input--with-batch': ctrl.withBatch, 'job-info--editor__input-preview': ctrl.originalMetadata['imageType'] !== ctrl.metadata['imageType'] }"
ng-disabled="!ctrl.userCanEdit"
ng-readonly="ctrl.metadataUpdatedByTemplate.length > 0"
ng-options="type for type in ctrl.validImageTypes"
>
<option value="">-- choose type --</option>
</select>

<button
class="job-editor__apply-to-all"
title="Apply this image type to all your current uploads"
type="button"
ng-if="ctrl.withBatch && ctrl.userCanEdit && (ctrl.originalMetadata['imageType'] === ctrl.metadata['imageType'])"
ng-click="ctrl.batchApplyMetadata('imageType')"
></button>
</label>
</span>

<label class="job-info--editor__field">
<div class="job-info--editor__label job-info--editor__multiline text-small">Description</div>
Expand Down
3 changes: 1 addition & 2 deletions kahuna/public/js/upload/jobs/required-metadata-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '../../forms/datalist';
import '../../components/gr-description-warning/gr-description-warning';

import strings from '../../strings.json';
import {validImageTypes} from "../../util/constants/imageTypes";

export var jobs = angular.module('kahuna.upload.jobs.requiredMetadataEditor', [
'kahuna.edits.service',
Expand Down Expand Up @@ -36,7 +35,7 @@ jobs.controller('RequiredMetadataEditorCtrl',
// if we set it to "".
ctrl.copyrightWasInitiallyThere = !!ctrl.originalMetadata.copyright;
ctrl.metadataUpdatedByTemplate = [];
ctrl.validImageTypes = validImageTypes;
ctrl.validImageTypes = window._clientConfig.imageTypes;

ctrl.save = function() {
ctrl.saving = true;
Expand Down
1 change: 0 additions & 1 deletion kahuna/public/js/util/constants/imageTypes.ts

This file was deleted.

0 comments on commit 500787c

Please sign in to comment.