Merged submission module code

This commit is contained in:
Giuseppe
2018-07-26 18:36:36 +02:00
parent b6e4e2562d
commit 6f60cd68e2
179 changed files with 9143 additions and 77 deletions

View File

@@ -0,0 +1,45 @@
/**
* Combines a variable number of strings representing parts
* of a relative REST URL in to a single, absolute REST URL
*
*/
import { isNotUndefined } from '../../../shared/empty.util';
export interface JsonPatchOperationPathObject {
rootElement: string;
subRootElement: string;
path: string;
}
export class JsonPatchOperationPathCombiner {
private _rootElement: string;
private _subRootElement: string;
constructor(rootElement, ...subRootElements: string[]) {
this._rootElement = rootElement;
this._subRootElement = subRootElements.join('/');
}
get rootElement(): string {
return this._rootElement;
}
get subRootElement(): string {
return this._subRootElement;
}
public getPath(fragment?: string|string[]): JsonPatchOperationPathObject {
if (isNotUndefined(fragment) && Array.isArray(fragment)) {
fragment = fragment.join('/');
}
let path;
if (isNotUndefined(fragment)) {
path = '/' + this._rootElement + '/' + this._subRootElement + '/' + fragment;
} else {
path = '/' + this._rootElement + '/' + this._subRootElement;
}
return {rootElement: this._rootElement, subRootElement: this._subRootElement, path: path};
}
}