Skip to content

Commit

Permalink
dnn-sxc-angular added metadata-for interface and improvements data
Browse files Browse the repository at this point in the history
  • Loading branch information
maaaximum-at-2sic committed Mar 9, 2022
1 parent de9e18b commit 9934c20
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { routeContent } from '../contants';
import { MetaDataFor } from './metedata-for';

/**
* A helper to access data from 2sxc
Expand Down Expand Up @@ -33,8 +34,22 @@ export class Data<T> {
/**
* Create new item
*/
create(item: T): Observable<T> {
create(item: T): Observable<T>;

/**
* Create new item as metadata for something
*/
create(item: T, metadataFor: MetaDataFor): Observable<T>;

/**
* Internal implementation of create
*/
create(item: T, metadataFor: MetaDataFor = null): Observable<T> {
const url = `${routeContent}/${this.contentType}`;
if (metadataFor != null) {
return this.http.post<T>(url, { ...item, For: metadataFor });
}

return this.http.post<T>(url, item);
}

Expand All @@ -59,12 +74,8 @@ export class Data<T> {
/**
* internal implementation with ID/with GUID
*/
delete(id: number | string): Observable<T[]> | Observable<T> {
delete(id: number | string): Observable<T> {
const url = `${routeContent}/${this.contentType}/${id}`;
if (typeof(id) === 'string') {
throw new Error('not implemented yet');
}

return this.http.delete<T>(url);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface MetaDataFor {
TargetType: number;
Number?: number;
String?: string;
Guid?: string;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpParams } from '@angular/common/http';

export interface QueryConstruction {
name: string;
params?: HttpParams;
streams?: string | string[]
}
name: string;
params?: HttpParams;
streams?: string | string[];
}

0 comments on commit 9934c20

Please sign in to comment.