Skip to content

Commit dfd0ce0

Browse files
authored
feat(ontology): new method to change gui order (DSP-1567/DSP-1646) (#440)
* fix(ontology): new method to change gui order * chore(deps): bump dsp-js to v2.3.0 * chore(deps): update dependencies * fix(ontology): use correct method to update gui order * fix(ontology): bug fix in gui-order and cardinality function * feat(ontology): init new drag'n'drop for gui-order * style(ontology): fix drag'n'drop style issue * feat(ontology): new setup to change gui order * refactor(ontology): bring back the old cardinality form * refactor(ontology): clean up * test(ontology): bug fix in test * feat(ontology): improve drag'n'drop functionality * test(ontology): add some imports * test(ontology): bug fixes in tests
1 parent a56a45b commit dfd0ce0

18 files changed

+776
-434
lines changed

package-lock.json

Lines changed: 506 additions & 361 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@angular/platform-browser-dynamic": "^11.2.9",
3434
"@angular/router": "^11.2.9",
3535
"@ckeditor/ckeditor5-angular": "^1.2.3",
36-
"@dasch-swiss/dsp-js": "^2.2.0",
36+
"@dasch-swiss/dsp-js": "^2.3.0",
3737
"@dasch-swiss/dsp-ui": "^1.3.0",
3838
"@ngx-translate/core": "^12.1.2",
3939
"@ngx-translate/http-loader": "5.0.0",
@@ -47,7 +47,7 @@
4747
"jdnconvertiblecalendar": "^0.0.6",
4848
"jdnconvertiblecalendardateadapter": "^0.0.16",
4949
"json2typescript": "^1.0.6",
50-
"jsonld": "^1.1.0",
50+
"jsonld": "^5.2.0",
5151
"moment": "^2.27.0",
5252
"ngx-color-picker": "^11.0.0",
5353
"openseadragon": "^2.4.0",
@@ -61,7 +61,7 @@
6161
"zone.js": "~0.10.2"
6262
},
6363
"devDependencies": {
64-
"@angular-devkit/build-angular": "~0.1102.8",
64+
"@angular-devkit/build-angular": "^0.1102.12",
6565
"@angular-eslint/eslint-plugin": "^1.2.0",
6666
"@angular/cli": "^11.2.8",
6767
"@angular/compiler-cli": "^11.2.9",

src/app/project/ontology/ontology.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ <h2 class="mat-title">
180180
<app-resource-class-info *ngFor="let resClass of ontoClasses" [resourceClass]="resClass"
181181
[expanded]="expandClasses"
182182
[projectCode]="projectCode"
183+
[lastModificationDate]="lastModificationDate"
184+
(updateParent)="lastModificationDate = $event"
183185
(editResourceClass)="openResourceClassForm('editResourceClass', $event)"
184186
(updateCardinality)="updateCard($event)"
185187
(deleteResourceClass)="delete('ResourceClass', $event)">
@@ -188,7 +190,7 @@ <h2 class="mat-title">
188190
<div class="ontology-editor-list properties" *ngIf="view === 'properties'">
189191
<!-- list of resource properties -->
190192
<mat-list>
191-
<span *ngFor="let prop of ontoProperties">
193+
<mat-list-item class="property" *ngFor="let prop of ontoProperties">
192194
<!-- display only properties with guiOrder and if they exist in list of properties;
193195
objectType is not a linkValue (otherwise we have the property twice) -->
194196
<app-property-info [propDef]="ontology?.properties[prop.id]"
@@ -197,7 +199,7 @@ <h2 class="mat-title">
197199
(deleteResourceProperty)="delete('Property', $event)"
198200
(clickedOnClass)="updateCard($event)">
199201
</app-property-info>
200-
</span>
202+
</mat-list-item>
201203
<!-- <mat-list-item *ngFor="let prop of ontoProperties">{{prop.label}}</mat-list-item> -->
202204
</mat-list>
203205
</div>

src/app/project/ontology/ontology.component.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ $width: 340px;
8282
&.properties {
8383
width: 80%;
8484
margin: 16px 10%;
85+
86+
.property {
87+
height: 56px !important;
88+
margin: 4px 0;
89+
90+
&:hover {
91+
background-color: $black-12-opacity;
92+
}
93+
}
8594
}
8695
}
8796
}

src/app/project/ontology/ontology.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
ListsResponse,
1616
OntologiesMetadata,
1717
OntologyMetadata,
18-
ProjectResponse,
1918
PropertyDefinition,
2019
ReadOntology,
2120
ReadProject,
@@ -26,7 +25,7 @@ import { DspApiConnectionToken, Session, SessionService, SortingService } from '
2625
import { CacheService } from 'src/app/main/cache/cache.service';
2726
import { DialogComponent } from 'src/app/main/dialog/dialog.component';
2827
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
29-
import { DefaultProperties, DefaultProperty, PropertyCategory, PropertyInfoObject } from './default-data/default-properties';
28+
import { DefaultProperties, PropertyCategory, PropertyInfoObject } from './default-data/default-properties';
3029
import { DefaultClass, DefaultResourceClasses } from './default-data/default-resource-classes';
3130
import { ResourceClassFormService } from './resource-class-form/resource-class-form.service';
3231

@@ -70,6 +69,8 @@ export class OntologyComponent implements OnInit {
7069
// current/selected ontology
7170
ontology: ReadOntology;
7271

72+
lastModificationDate: string;
73+
7374
ontoClasses: ClassDefinition[];
7475
expandClasses = false;
7576

@@ -222,6 +223,7 @@ export class OntologyComponent implements OnInit {
222223
// with all classes, properties and connected lists
223224
this.loadOntology = true;
224225
this.ontology = readOnto;
226+
this.lastModificationDate = this.ontology.lastModificationDate;
225227
this._cache.set('currentOntology', this.ontology);
226228

227229
// grab the onto class information to display

src/app/project/ontology/property-form/property-form.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe('PropertyFormComponent', () => {
136136

137137
const ontologyEndpointSpyObj = {
138138
v2: {
139-
ontologyEndpoint: jasmine.createSpyObj('onto', ['updateResourceProperty', 'createResourceProperty'])
139+
onto: jasmine.createSpyObj('onto', ['updateResourceProperty', 'createResourceProperty'])
140140
}
141141
};
142142

src/app/project/ontology/property-info/property-info.component.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<mat-list-item (mouseenter)="mouseEnter()" (mouseleave)="mouseLeave()">
2-
<span *ngIf="propCard && propCard.guiOrder >=0" mat-list-icon
3-
class="order additional-info">{{propCard.guiOrder}})</span>
1+
<div class="property-info" (mouseenter)="mouseEnter()" (mouseleave)="mouseLeave()">
42

53
<div mat-line class="title">
64
<span class="icon" *ngIf="propType" [matTooltip]="propType?.group + ': ' + propType?.label"
@@ -60,4 +58,4 @@
6058
</span>
6159
</div>
6260
</div>
63-
</mat-list-item>
61+
</div>

src/app/project/ontology/property-info/property-info.component.scss

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
@import "~@angular/material/theming";
22
@import "../../../../assets/style/config";
33

4-
.mat-list-item {
5-
height: 56px !important;
6-
margin: 4px 0;
7-
&:hover {
8-
background-color: $black-12-opacity;
9-
}
4+
:host {
5+
width: 100%;
106
}
117

128
.additional-info {
139
color: $primary_700;
1410
}
1511

16-
.mat-list-icon.order {
17-
font-size: 16px;
18-
height: 16px;
19-
width: 16px;
20-
}
21-
2212
.mat-line.title {
2313
line-height: 1.8;
2414
.mat-icon {

src/app/project/ontology/resource-class-form/resource-class-form.component.html

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,12 @@
6363
</mat-form-field>
6464

6565
<!-- propertiy: one line, with "add" icon to add additional properties -->
66-
<div cdkDropList class="properties-list" (cdkDropListDropped)="drop($event)">
67-
<div cdkDrag class="property-line"
66+
<div class="properties-list">
67+
<div class="property-line"
6868
*ngFor="let prop of properties?.controls; let last = last; let i = index;">
6969

7070
<!-- <div *ngIf="prop.value.objectType !== 'http://api.knora.org/ontology/knora-api/v2#LinkValue'"> -->
7171

72-
<div class="drag-n-drop-placeholder" *cdkDragPlaceholder></div>
73-
74-
<button *ngIf="properties.length > 1" cdkDragHandle mat-icon-button type="button"
75-
aria-label="Change order of properties" class="prefix drag-n-drop-line">
76-
<mat-icon>drag_indicator</mat-icon>
77-
</button>
78-
7972
<app-resource-class-property-form [propertyForm]="prop" [index]="i" [resClassIri]="iri">
8073
</app-resource-class-property-form>
8174

src/app/project/ontology/resource-class-form/resource-class-form.component.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,4 @@ button {
103103
}
104104
}
105105

106-
.drag-n-drop-placeholder {
107-
background: #ccc;
108-
border: dotted 3px #999;
109-
min-height: 100px;
110-
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
111-
}
106+

0 commit comments

Comments
 (0)