Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
42
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
f861fc1a
Commit
f861fc1a
authored
6 years ago
by
Giuseppe Digilio
Browse files
Options
Downloads
Patches
Plain Diff
Refactored JsonPatchOperationPathCombiner extending URLCombiner
parent
22ebbd5c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/core/json-patch/builder/json-patch-operation-path-combiner.ts
+8
-8
8 additions, 8 deletions
.../json-patch/builder/json-patch-operation-path-combiner.ts
with
8 additions
and
8 deletions
src/app/core/json-patch/builder/json-patch-operation-path-combiner.ts
+
8
−
8
View file @
f861fc1a
import
{
isNotUndefined
}
from
'
../../../shared/empty.util
'
;
import
{
URLCombiner
}
from
'
../../url-combiner/url-combiner
'
;
/**
* Interface used to represent a JSON-PATCH path member
...
...
@@ -14,11 +15,12 @@ export interface JsonPatchOperationPathObject {
* Combines a variable number of strings representing parts
* of a JSON-PATCH path
*/
export
class
JsonPatchOperationPathCombiner
{
export
class
JsonPatchOperationPathCombiner
extends
URLCombiner
{
private
_rootElement
:
string
;
private
_subRootElement
:
string
;
constructor
(
rootElement
,
...
subRootElements
:
string
[])
{
super
(
rootElement
,
...
subRootElements
);
this
.
_rootElement
=
rootElement
;
this
.
_subRootElement
=
subRootElements
.
join
(
'
/
'
);
}
...
...
@@ -35,21 +37,19 @@ export class JsonPatchOperationPathCombiner {
* Combines the parts of this JsonPatchOperationPathCombiner in to a JSON-PATCH path member
*
* e.g. new JsonPatchOperationPathCombiner('sections', 'basic').getPath(['dc.title', '0'])
* returns: sections/basic/dc.title/0
* returns:
{rootElement: 'sections', subRootElement: 'basic', path: '/
sections/basic/dc.title/0
'}
*
* @return {
string
}
* The combined path
* @return {
JsonPatchOperationPathObject
}
* The combined path
object
*/
public
getPath
(
fragment
?:
string
|
string
[]):
JsonPatchOperationPathObject
{
if
(
isNotUndefined
(
fragment
)
&&
Array
.
isArray
(
fragment
))
{
fragment
=
fragment
.
join
(
'
/
'
);
}
let
path
;
let
path
=
'
/
'
+
this
.
toString
()
;
if
(
isNotUndefined
(
fragment
))
{
path
=
'
/
'
+
this
.
_rootElement
+
'
/
'
+
this
.
_subRootElement
+
'
/
'
+
fragment
;
}
else
{
path
=
'
/
'
+
this
.
_rootElement
+
'
/
'
+
this
.
_subRootElement
;
path
+=
'
/
'
+
fragment
;
}
return
{
rootElement
:
this
.
_rootElement
,
subRootElement
:
this
.
_subRootElement
,
path
:
path
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment