Skip to content

Commit

Permalink
YDA-6077: prevent incompatible metadata schema configuration for depo…
Browse files Browse the repository at this point in the history
…sit groups
  • Loading branch information
claudisa-uu authored Jan 30, 2025
1 parent ad69266 commit fafd784
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions group_manager/static/group_manager/js/group_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ $(function () {
/// The default prefix when adding a new group.
GROUP_DEFAULT_PREFIX: 'research-',

DEPOSIT_COMPATIBLE_SCHEMAS: ['dag-0'],

unloading: false, /// < Set to true when a navigation action is detected. Used for better error reporting.

groupHierarchy: null, /// < A group hierarchy object. See Yoda.groupManager.load().
Expand Down Expand Up @@ -1557,10 +1559,15 @@ $(function () {

schemas.forEach(function (schema) {
if (schema.startsWith(query)) {
results.push({
id: schema,
text: schema
})
// If group is deposit only load compatible schemas
const prefix = $('#f-group-create-name').attr('data-prefix')

if (prefix !== 'deposit-' || that.DEPOSIT_COMPATIBLE_SCHEMAS.includes(schema)) {
results.push({
id: schema,
text: schema
})
}
}
})

Expand Down Expand Up @@ -2336,6 +2343,14 @@ $(function () {
}
}

// If deposit group is selected then automatically switch schema to the compatible one
if (newPrefix === 'deposit-') {
const defaultDepositSchema = that.DEPOSIT_COMPATIBLE_SCHEMAS[0]
const depositSchemaOption = new Option(defaultDepositSchema, defaultDepositSchema, true, true)
$('#f-group-create-schema-id').append(depositSchemaOption).trigger('change')
$('#f-group-create-schema-id').val(defaultDepositSchema).trigger('change')
}

const hadRetentionPeriod = that.prefixHasExpirationDate(oldPrefix)
const haveRetentionPeriod = that.prefixHasExpirationDate(newPrefix)

Expand Down

0 comments on commit fafd784

Please sign in to comment.