Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into assets-12024
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivani gupta committed May 9, 2024
2 parents 664b9f5 + d564007 commit 5e14728
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
57 changes: 36 additions & 21 deletions contenthub/hydration/hydration-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ export function formIsComplete(metadataSchema, formValues) {
const incomplete = metadataSchema.find((schema) => {
if(!schema.required) return;
if(schema.requires) return;
return Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === '';
return !(schema.mapToProperty in formValues) || Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === '';
});

if(incomplete) return false;

if(formValues['gmo:campaignName']){
if(!formValues['gmo:programName']) return false;
if(!formValues['gmo:deliverableType']) return false;
}

if(formValues['gmo:licensedContent'] !== 'no'){
if(!formValues['gmo:usageTerms']) return false;
if(formValues['gmo:licensedContent'] === 'yes-expire' && !formValues['gmo:licenseExpiryDate']) return false;
if(formValues['gmo:licensedContent'] === 'yes-expires' && !formValues['gmo:licenseExpiryDate']) return false;
}
return true;
};
Expand All @@ -47,7 +46,7 @@ export const licenseDateFieldShow = {
placeholder: 'Select date',
required: true,
element: 'datepicker',
requires: [{ property: 'gmo:licensedContent', expectedValue: 'yes-expire' }],
requires: [{ property: 'gmo:licensedContent', expectedValue: 'yes-expires' }],
};

const licenseExpirePerpitytity = new Date();
Expand Down Expand Up @@ -195,16 +194,30 @@ export function getMetadataSchema(facetOptions){
{
mapToProperty: 'gmo:campaignName',
label: 'Campaign',
placeholder: 'Select campaign',
element: 'dropdown',
dropdownOptions: [{id: '', name: 'N/A'}, ...facetOptions['gmo-campaignName']],
placeholder: 'Select one',
element: 'text',
getSuggestions: async (value) => {
return facetOptions['gmo-campaignName'].filter(
(option) => {
const name = option.name.toLowerCase();
return value.toLowerCase().split(' ').every((val) => name.includes(val));
}
)
},
},
{
mapToProperty: 'gmo:programName',
label: 'Program',
placeholder: 'Select program name',
element: 'dropdown',
dropdownOptions: facetOptions['gmo-programName'],
placeholder: 'Select one',
element: 'text',
getSuggestions: async (value) => {
return facetOptions['gmo-programName'].filter(
(option) => {
const name = option.name.toLowerCase();
return value.toLowerCase().split(' ').every((val) => name.includes(val));
}
)
},
required: true,
requires: [{
property: 'gmo:campaignName',
Expand All @@ -215,6 +228,7 @@ export function getMetadataSchema(facetOptions){
{
mapToProperty: 'gmo:deliverableType',
label: 'Select deliverable type',
placeholder: 'Select one',
element: 'dropdown',
required: true,
dropdownOptions: [
Expand Down Expand Up @@ -255,11 +269,6 @@ export function getMetadataSchema(facetOptions){
name: 'Tutorial',
},
],
requires: [{
property: 'gmo:campaignName',
expectedValue: '',
operator: '!=='
}]
},
{
mapToProperty: 'gmo:licensedContent',
Expand All @@ -273,11 +282,11 @@ export function getMetadataSchema(facetOptions){
name: 'No',
},
{
id: 'yes-expire',
id: 'yes-expires',
name: 'Yes (Expires)',
},
{
id: 'yes-perpetuity',
id: 'yes-in-perpetuity',
name: 'Yes (in Perpetuity)',
},
],
Expand All @@ -294,6 +303,12 @@ export function getMetadataSchema(facetOptions){
{ property: 'gmo:licensedContent', expectedValue: '', operator: '!==' }
],
},
{
mapToProperty: 'gmo:owner',
label:'Campaign/Asset Owner',
element: 'textarea',
required: true,
},
{
mapToProperty: 'gmo:contentType',
label: 'Content Type',
Expand Down Expand Up @@ -344,7 +359,7 @@ export function getMetadataSchema(facetOptions){
{
mapToProperty: 'gmo:ddomStage',
label: 'DDOM Stage',
placeholder: 'Select multiple',
placeholder: 'Select one or more',
element: 'tags',
dropdownOptions: [
{
Expand Down Expand Up @@ -372,8 +387,8 @@ export function getMetadataSchema(facetOptions){
{
mapToProperty: 'gmo:p0TargetMarketGeo',
label: 'Target Market',
placeholder: 'Select One',
element: 'dropdown',
placeholder: 'Select one or more',
element: 'tags',
dropdownOptions: [
{
id: 'apac',
Expand Down
6 changes: 6 additions & 0 deletions scripts/metadata-html-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export async function fetchMetadataAndCreateHTML(metadataViewConfig, assetData,
if (assetData === undefined || assetJSON === undefined) {
assetJSON = await getAssetMetadata(getAssetIdFromURL());
}
// Remove "urn:aaid:aem:" prefix from displayed 'assetId' value
if (assetJSON.assetId) {
// A deep copy of the assetJSON object is created to avoid modifying the original object
assetJSON = JSON.parse(JSON.stringify(assetJSON));
assetJSON.assetId = assetJSON.assetId.replace('urn:aaid:aem:', '');
}

const metadataContainer = document.createElement('div');
metadataContainer.classList.add('metadata-container');
Expand Down
1 change: 1 addition & 0 deletions scripts/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { fetchCached } from './fetch-util.js';
import { getBaseConfigPath, getMetadataConfigs } from './site-config.js';

const SEARCH_FIELD_TO_POLARIS_API_MAP = {
uuid: 'assetId',
'dc-format': 'repositoryMetadata.dc:format',
'repo-name': 'repositoryMetadata.repo:name',
'repo-createDate': 'repositoryMetadata.repo:createDate',
Expand Down

0 comments on commit 5e14728

Please sign in to comment.