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