mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 04:23:04 +00:00
58789: Force reload list after editing and deleting metadata as well
This commit is contained in:
@@ -6,8 +6,7 @@
|
||||
|
||||
<p id="description" class="pb-2">{{'admin.registries.metadata.description' | translate}}</p>
|
||||
|
||||
<ds-metadata-schema-form
|
||||
(submitForm)="createdSchema($event)"></ds-metadata-schema-form>
|
||||
<ds-metadata-schema-form (submitForm)="forceUpdateSchemas()"></ds-metadata-schema-form>
|
||||
|
||||
<ds-pagination
|
||||
*ngIf="(metadataSchemas | async)?.payload?.totalElements > 0"
|
||||
|
@@ -9,6 +9,7 @@ import { map } from 'rxjs/operators';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { zip } from 'rxjs/internal/observable/zip';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-metadata-registry',
|
||||
@@ -23,7 +24,8 @@ export class MetadataRegistryComponent {
|
||||
pageSize: 2
|
||||
});
|
||||
|
||||
constructor(private registryService: RegistryService) {
|
||||
constructor(private registryService: RegistryService,
|
||||
private notificationsService: NotificationsService) {
|
||||
this.updateSchemas();
|
||||
}
|
||||
|
||||
@@ -36,6 +38,11 @@ export class MetadataRegistryComponent {
|
||||
this.metadataSchemas = this.registryService.getMetadataSchemas(this.config);
|
||||
}
|
||||
|
||||
private forceUpdateSchemas() {
|
||||
this.registryService.clearMetadataSchemaRequests().subscribe();
|
||||
this.updateSchemas();
|
||||
}
|
||||
|
||||
editSchema(schema: MetadataSchema) {
|
||||
this.registryService.editMetadataSchema(schema);
|
||||
}
|
||||
@@ -62,11 +69,6 @@ export class MetadataRegistryComponent {
|
||||
);
|
||||
}
|
||||
|
||||
createdSchema(event) {
|
||||
this.registryService.clearMetadataSchemaRequests().subscribe((value) => console.log('cleared for substring: ' + value));
|
||||
this.updateSchemas();
|
||||
}
|
||||
|
||||
deleteSchemas() {
|
||||
this.registryService.getSelectedMetadataSchemas().subscribe(
|
||||
(schemas) => {
|
||||
@@ -77,8 +79,15 @@ export class MetadataRegistryComponent {
|
||||
}
|
||||
}
|
||||
zip(...tasks$).subscribe((responses: RestResponse[]) => {
|
||||
console.log('deleted ' + responses.length + ' schemas');
|
||||
// TODO: Reload the list of schemas
|
||||
const successResponses = responses.filter((response: RestResponse) => response.isSuccessful);
|
||||
const failedResponses = responses.filter((response: RestResponse) => !response.isSuccessful);
|
||||
if (successResponses.length > 0) {
|
||||
this.notificationsService.success('Success', `Successfully deleted ${successResponses.length} metadata schemas`);
|
||||
}
|
||||
if (failedResponses.length > 0) {
|
||||
this.notificationsService.error('Error', `Failed to delete ${failedResponses.length} metadata schemas`);
|
||||
}
|
||||
this.forceUpdateSchemas();
|
||||
});
|
||||
}
|
||||
)
|
||||
|
@@ -103,9 +103,7 @@ export class MetadataSchemaFormComponent implements OnInit {
|
||||
};
|
||||
if (schema == null) {
|
||||
this.registryService.createOrUpdateMetadataSchema(Object.assign(new MetadataSchema(), values)).subscribe((newSchema) => {
|
||||
console.log(newSchema);
|
||||
this.submitForm.emit(newSchema);
|
||||
// TODO: Reload the list of schemas
|
||||
});
|
||||
} else {
|
||||
this.registryService.createOrUpdateMetadataSchema(Object.assign(new MetadataSchema(), {
|
||||
@@ -113,8 +111,7 @@ export class MetadataSchemaFormComponent implements OnInit {
|
||||
prefix: (values.prefix ? values.prefix : schema.prefix),
|
||||
namespace: (values.namespace ? values.namespace : schema.namespace)
|
||||
})).subscribe((updatedSchema) => {
|
||||
console.log(updatedSchema);
|
||||
// TODO: Reload the list of schemas
|
||||
this.submitForm.emit(updatedSchema);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user