64503: Prevent submit when harvest type is NONE and not changed

This commit is contained in:
Kristof De Langhe
2019-11-12 11:59:44 +01:00
parent 404729faa3
commit 2d3d7ae71e
2 changed files with 24 additions and 15 deletions

View File

@@ -11,7 +11,7 @@
class="fas fa-undo-alt"></i>
<span class="d-none d-sm-inline">&nbsp;{{"item.edit.metadata.reinstate-button" | translate}}</span>
</button>
<button class="btn btn-primary" [disabled]="!(hasChanges() | async) || !isValid()"
<button class="btn btn-primary" [disabled]="!(hasChanges() | async) || !isValid() || (initialHarvestType === harvestTypeNone && contentSource.harvestType === initialHarvestType)"
(click)="onSubmit()"><i
class="fas fa-save"></i>
<span class="d-none d-sm-inline">&nbsp;{{"item.edit.metadata.save-button" | translate}}</span>
@@ -47,7 +47,7 @@
class="fas fa-undo-alt"></i>
<span class="d-none d-sm-inline">&nbsp;{{"item.edit.metadata.reinstate-button" | translate}}</span>
</button>
<button class="btn btn-primary" [disabled]="!(hasChanges() | async) || !isValid()"
<button class="btn btn-primary" [disabled]="!(hasChanges() | async) || !isValid() || (initialHarvestType === harvestTypeNone && contentSource.harvestType === initialHarvestType)"
(click)="onSubmit()"><i
class="fas fa-save"></i>
<span class="d-none d-sm-inline">&nbsp;{{"item.edit.metadata.save-button" | translate}}</span>

View File

@@ -55,6 +55,12 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
*/
update$: Observable<FieldUpdate>;
/**
* The initial harvest type we started off with
* Used to compare changes
*/
initialHarvestType: ContentSourceHarvestType;
/**
* @type {string} Key prefix used to generate form labels
*/
@@ -268,6 +274,7 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
*/
initializeOriginalContentSource(contentSource: ContentSource) {
this.contentSource = contentSource;
this.initialHarvestType = contentSource.harvestType;
this.initializeMetadataConfigs();
const initialContentSource = cloneDeep(this.contentSource);
this.objectUpdatesService.initialize(this.url, [initialContentSource], new Date());
@@ -281,19 +288,21 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
if (hasValue(this.contentSource) && isNotEmpty(this.contentSource.metadataConfigs)) {
defaultConfigId = this.contentSource.metadataConfigs[0].id;
}
this.formGroup.patchValue({
oaiSourceContainer: {
oaiSource: field.oaiSource
},
oaiSetContainer: {
oaiSetId: field.oaiSetId,
metadataConfigId: field.metadataConfigId || defaultConfigId
},
harvestTypeContainer: {
harvestType: field.harvestType
}
});
this.contentSource = cloneDeep(field);
if (hasValue(field)) {
this.formGroup.patchValue({
oaiSourceContainer: {
oaiSource: field.oaiSource
},
oaiSetContainer: {
oaiSetId: field.oaiSetId,
metadataConfigId: field.metadataConfigId || defaultConfigId
},
harvestTypeContainer: {
harvestType: field.harvestType
}
});
this.contentSource = cloneDeep(field);
}
this.contentSource.metadataConfigId = defaultConfigId;
}
});