mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 14:33:03 +00:00
54472: Intermediate commit
This commit is contained in:
@@ -66,20 +66,4 @@ export abstract class ComColDataService<TNormalized extends NormalizedObject, TD
|
||||
}
|
||||
}
|
||||
|
||||
public buildFormData(comcol, parentUUID): FormData {
|
||||
const form: FormData = new FormData();
|
||||
form.append('name', comcol.name);
|
||||
if (isNotEmpty(parentUUID)) {
|
||||
form.append('parent', parentUUID);
|
||||
}
|
||||
if (comcol.metadata) {
|
||||
for (const i of Object.keys(comcol.metadata)) {
|
||||
if (isNotEmpty(comcol.metadata[i].value)) {
|
||||
form.append(comcol.metadata[i].key, comcol.metadata[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -121,12 +121,13 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
const endpoint$ = this.halService.getEndpoint(this.linkPath).pipe(
|
||||
isNotEmptyOperator(),
|
||||
distinctUntilChanged()
|
||||
distinctUntilChanged(),
|
||||
map((endpoint: string) => parentUUID ? `${endpoint}?parent=${parentUUID}` : endpoint)
|
||||
);
|
||||
|
||||
const request$ = endpoint$.pipe(
|
||||
take(1),
|
||||
map((endpoint: string) => new CreateRequest(requestId, endpoint, this.buildFormData(dso, parentUUID))),
|
||||
map((endpoint: string) => new CreateRequest(requestId, endpoint, dso)),
|
||||
configureRequest(this.requestService)
|
||||
);
|
||||
|
||||
@@ -153,6 +154,4 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
return this.rdbService.toRemoteDataObservable(requestEntry$, responseCache$, payload$);
|
||||
}
|
||||
|
||||
public abstract buildFormData(dso: TDomain, parentUUID: string): FormData;
|
||||
|
||||
}
|
||||
|
@@ -37,10 +37,6 @@ class DataServiceImpl extends DataService<NormalizedDSpaceObject, DSpaceObject>
|
||||
getFindByIDHref(endpoint, resourceID): string {
|
||||
return endpoint.replace(/\{\?uuid\}/,`?uuid=${resourceID}`);
|
||||
}
|
||||
|
||||
buildFormData(dso: DSpaceObject, parentUUID: string): FormData {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
@@ -47,9 +47,4 @@ export class ItemDataService extends DataService<NormalizedItem, Item> {
|
||||
}
|
||||
}
|
||||
|
||||
buildFormData(dso: Item, parentUUID: string): FormData {
|
||||
// TODO: build FormData for creating an Item
|
||||
return undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ export class RequestEffects {
|
||||
}),
|
||||
map((entry: RequestEntry) => entry.request),
|
||||
flatMap((request: RestRequest) => {
|
||||
let body = request.body;
|
||||
let body;
|
||||
if (isNotEmpty(request.body)) {
|
||||
const serializer = new DSpaceRESTv2Serializer(NormalizedObjectFactory.getConstructor(request.body.type));
|
||||
body = serializer.serialize(request.body);
|
||||
|
@@ -6,6 +6,8 @@ import { RestRequestMethod } from '../data/request.models';
|
||||
|
||||
import { DSpaceRESTV2Response } from './dspace-rest-v2-response.model';
|
||||
import { HttpObserve } from '@angular/common/http/src/client';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
|
||||
export interface HttpOptions {
|
||||
body?: any;
|
||||
@@ -59,6 +61,9 @@ export class DSpaceRESTv2Service {
|
||||
request(method: RestRequestMethod, url: string, body?: any, options?: HttpOptions): Observable<DSpaceRESTV2Response> {
|
||||
const requestOptions: HttpOptions = {};
|
||||
requestOptions.body = body;
|
||||
if (method === RestRequestMethod.Post && isNotEmpty(body)) {
|
||||
requestOptions.body = this.buildFormData(body);
|
||||
}
|
||||
requestOptions.observe = 'response';
|
||||
if (options && options.headers) {
|
||||
requestOptions.headers = Object.assign(new HttpHeaders(), options.headers);
|
||||
@@ -74,4 +79,17 @@ export class DSpaceRESTv2Service {
|
||||
});
|
||||
}
|
||||
|
||||
buildFormData(dso: DSpaceObject): FormData {
|
||||
const form: FormData = new FormData();
|
||||
form.append('name', dso.name);
|
||||
if (dso.metadata) {
|
||||
for (const i of Object.keys(dso.metadata)) {
|
||||
if (isNotEmpty(dso.metadata[i].value)) {
|
||||
form.append(dso.metadata[i].key, dso.metadata[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user