Skip to content
Permalink
Browse files
refactor: use constants from js-lib directly (DEV-799) (#712)
* refactor: replace long constants

* chore(deps): bump js-lib to latest

* refactor: replace long constants
  • Loading branch information
kilchenmann committed Apr 12, 2022
1 parent 7768fb9 commit 374b5a80cfadf85b6a818c72e46f6bc7ae3a8425
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.

Some generated files are not rendered by default. Learn more.

@@ -34,7 +34,7 @@
"@angular/platform-browser-dynamic": "^13.2.6",
"@angular/router": "^13.2.6",
"@ckeditor/ckeditor5-angular": "^2.0.2",
"@dasch-swiss/dsp-js": "^7.0.2",
"@dasch-swiss/dsp-js": "^7.1.0",
"@datadog/browser-rum": "^3.11.0",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "6.0.0",
@@ -53,7 +53,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'StillImageRepresentation',
iri: Constants.StillImageRepresentation,
label: 'Still Image',
icons: [
'photo',
@@ -80,7 +80,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'MovingImageRepresentation',
iri: Constants.MovingImageRepresentation,
label: 'Moving Image',
icons: [
'movie',
@@ -98,7 +98,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'AudioRepresentation',
iri: Constants.AudioRepresentation,
label: 'Audio',
icons: [
'audiotrack',
@@ -117,7 +117,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'TextRepresentation',
iri: Constants.TextRepresentation,
label: 'Text',
icons: [
'rtt',
@@ -127,7 +127,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'DocumentRepresentation',
iri: Constants.DocumentRepresentation,
label: 'Document (PDF, etc.)',
icons: [
'description',
@@ -142,7 +142,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'ArchiveRepresentation',
iri: Constants.ArchiveRepresentation,
label: 'Archive (zip, x-tar, gzip)',
icons: [
'archive',
@@ -156,7 +156,7 @@ export class DefaultResourceClasses {
/* --> DSP-1559: disable RTI class;
the following object can be added again to the default classes as soon as a RTI viewer is implemented
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'DDDRepresentation',
iri: Constants.DDDRepresentation,
label: 'RTI Image',
icons: [
'view_in_ar',
@@ -133,7 +133,7 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {

booleanValueTypeIri = Constants.BooleanValue;

hasIncomingLinkIri = Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasIncomingLinkValue';
hasIncomingLinkIri = Constants.HasIncomingLinkValue;

project: ReadProject;
user: ReadUser;
@@ -303,7 +303,7 @@ export class StillImageComponent implements OnChanges, OnDestroy {

const geometry = geom.geometry;

const colorValues: ReadColorValue[] = geom.region.properties[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasColor'] as ReadColorValue[];
const colorValues: ReadColorValue[] = geom.region.properties[Constants.HasColor] as ReadColorValue[];

// if the geometry has a color property, use that value as the color for the line
if (colorValues && colorValues.length) {
@@ -435,7 +435,7 @@ export class StillImageComponent implements OnChanges, OnDestroy {
',"y":' + y1.toString() + '},{"x":' + x2.toString() + ',"y":' + y2.toString() + '}],"type":"rectangle"}';
const createResource = new CreateResource();
createResource.label = label;
createResource.type = Constants.KnoraApiV2 + Constants.HashDelimiter + 'Region';
createResource.type = Constants.Region;
createResource.attachedToProject = this.project;
const geomVal = new CreateGeomValue();
geomVal.type = Constants.GeomValue;
@@ -451,10 +451,10 @@ export class StillImageComponent implements OnChanges, OnDestroy {
commentVal.text = comment;

createResource.properties = {
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasComment']: [commentVal],
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasColor']: [colorVal],
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'isRegionOfValue']: [linkVal],
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasGeometry']: [geomVal]
[Constants.HasComment]: [commentVal],
[Constants.HasColor]: [colorVal],
[Constants.IsRegionOfValue]: [linkVal],
[Constants.HasGeometry]: [geomVal]
};
this._dspApiConnection.v2.res.createResource(createResource).subscribe(
(res: ReadResource) => {
@@ -270,11 +270,11 @@ describe('ResourceLinkFormComponent', () => {
createVal.push(linkVal);
});

props[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasLinkToValue'] = createVal;
props[Constants.HasLinkToValue] = createVal;

const expectedCreateResource = new CreateResource();
expectedCreateResource.label = 'My Label';
expectedCreateResource.type = Constants.KnoraApiV2 + Constants.HashDelimiter + 'LinkObj';
expectedCreateResource.type = Constants.LinkObj;
expectedCreateResource.properties = props;

// --> TODO create a Router spy to mock the navigation
@@ -120,7 +120,7 @@ export class ResourceLinkFormComponent implements OnInit {

linkObj.label = this.form.controls['label'].value;

linkObj.type = Constants.KnoraApiV2 + Constants.HashDelimiter + 'LinkObj';
linkObj.type = Constants.LinkObj;

linkObj.attachedToProject = this.selectedProject;

@@ -139,12 +139,12 @@ export class ResourceLinkFormComponent implements OnInit {
commentVal.type = Constants.TextValue;
commentVal.text = comment;
linkObj.properties = {
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasLinkToValue']: hasLinkToValue,
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasComment']: [commentVal],
[Constants.HasLinkToValue]: hasLinkToValue,
[Constants.HasComment]: [commentVal],
};
} else {
linkObj.properties = {
[Constants.KnoraApiV2 + Constants.HashDelimiter + 'hasLinkToValue']: hasLinkToValue,
[Constants.HasLinkToValue]: hasLinkToValue,
};
}

@@ -29,5 +29,5 @@ export class ComparisonOperatorConstants {
static MatchComparisonOperator = 'contains';
static MatchComparisonLabel = 'matches';

static MatchFunction = Constants.KnoraApiV2 + Constants.HashDelimiter + 'matchText';
static MatchFunction = Constants.MatchText;
}

0 comments on commit 374b5a8

Please sign in to comment.