Skip to content

Commit

Permalink
refactor: use constants from js-lib directly (DEV-799) (#712)
Browse files Browse the repository at this point in the history
* 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 374b5a8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
Expand Up @@ -53,7 +53,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'StillImageRepresentation',
iri: Constants.StillImageRepresentation,
label: 'Still Image',
icons: [
'photo',
Expand All @@ -80,7 +80,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'MovingImageRepresentation',
iri: Constants.MovingImageRepresentation,
label: 'Moving Image',
icons: [
'movie',
Expand All @@ -98,7 +98,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'AudioRepresentation',
iri: Constants.AudioRepresentation,
label: 'Audio',
icons: [
'audiotrack',
Expand All @@ -117,7 +117,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'TextRepresentation',
iri: Constants.TextRepresentation,
label: 'Text',
icons: [
'rtt',
Expand All @@ -127,7 +127,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'DocumentRepresentation',
iri: Constants.DocumentRepresentation,
label: 'Document (PDF, etc.)',
icons: [
'description',
Expand All @@ -142,7 +142,7 @@ export class DefaultResourceClasses {
]
},
{
iri: Constants.KnoraApiV2 + Constants.HashDelimiter + 'ArchiveRepresentation',
iri: Constants.ArchiveRepresentation,
label: 'Archive (zip, x-tar, gzip)',
icons: [
'archive',
Expand All @@ -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',
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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) => {
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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;

Expand All @@ -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,
};
}

Expand Down
Expand Up @@ -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.