Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make list forms files clearer #1338

Merged
merged 100 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
817baa3
refactor: reusable project form and common imput
derschnee68 Dec 15, 2023
09efe33
feat: add parameters to human readable error pipe
derschnee68 Dec 18, 2023
bfea6cb
wip
derschnee68 Dec 18, 2023
7608169
Merge branch 'main' into julien/form
derschnee68 Dec 19, 2023
81c103d
Merge remote-tracking branch 'origin/main' into julien/form
derschnee68 Dec 19, 2023
6e728fd
refactor: eslint -fix on the project folder
derschnee68 Dec 19, 2023
ec3e1d0
Merge branch 'main' into julien/form
derschnee68 Dec 20, 2023
f37cfa4
fix: improve maintability
derschnee68 Dec 20, 2023
bab9571
feat: add centered layout
derschnee68 Dec 20, 2023
fbf38e5
fix
derschnee68 Dec 20, 2023
36f49ed
fix: remove unused code
derschnee68 Dec 20, 2023
1db9f39
feat: add 2nd version of string literal component
derschnee68 Dec 20, 2023
dbe54ab
chore: add original version of string literal component
derschnee68 Dec 20, 2023
f6a283b
wip
derschnee68 Dec 20, 2023
889f3ec
feat: edit description in formbuilder
derschnee68 Dec 20, 2023
ffa7e48
fix: improve dasch-swiss-string-literal-2.component.ts
derschnee68 Dec 21, 2023
9959bf6
fix: improve dasch-swiss-string-literal-2.component.ts
derschnee68 Dec 21, 2023
fb5e4f2
fix: improve upload in state management
derschnee68 Dec 21, 2023
2f048d2
fix: improve template
derschnee68 Dec 21, 2023
12a4554
feat: do not use state management
derschnee68 Dec 21, 2023
74e5bb8
feat: improve dasch-swiss-string-literal-2.component.ts
derschnee68 Dec 22, 2023
1cca1dc
fix: textarea rows
derschnee68 Dec 22, 2023
91a8833
fix: chipListInput issue
derschnee68 Dec 22, 2023
130ea67
feat: first draft
derschnee68 Dec 23, 2023
8afdfff
feat: create create-resource-class-dialog
derschnee68 Dec 23, 2023
b62d604
fix: various fixes
derschnee68 Dec 23, 2023
7cd0f3a
feat: edit resource class, wip buggy
derschnee68 Dec 23, 2023
e9e0093
feat: improve loading button directive
derschnee68 Dec 27, 2023
1ae3af8
fix: tap instead of finalize
derschnee68 Dec 27, 2023
614b216
feat: create list info form
derschnee68 Dec 27, 2023
a2d12e6
feat: edit list form
derschnee68 Dec 27, 2023
cabde13
refactor: delete list-info-form
derschnee68 Dec 28, 2023
124f149
refactor: delete project-form
derschnee68 Dec 28, 2023
b6eb62c
refactor: add confirm-dialog
derschnee68 Dec 28, 2023
6d5a80a
refactor: remove dialog component
derschnee68 Dec 28, 2023
74aca2f
refactor: deleteListNode
derschnee68 Dec 28, 2023
2da2a0c
refactor: deleteList
derschnee68 Dec 28, 2023
4cc7c8a
refactor: remove unused code
derschnee68 Dec 28, 2023
f7083cf
feat: dasch-swiss-string-literal-2-input
derschnee68 Dec 29, 2023
a5a5707
feat: add dasch-swiss-string-literal-service
derschnee68 Dec 29, 2023
c25a507
fix: lint
derschnee68 Jan 2, 2024
1cc2c08
fix: lint
derschnee68 Jan 2, 2024
468be32
fix
derschnee68 Jan 2, 2024
17818bc
refactor: rename string-literal to multi-language
derschnee68 Jan 2, 2024
17bbd34
fix
derschnee68 Jan 2, 2024
9e9b360
fix
derschnee68 Jan 2, 2024
cf08223
Merge remote-tracking branch 'origin/main' into julien/resource-form
derschnee68 Jan 2, 2024
3f7b064
fix
derschnee68 Jan 3, 2024
1fbeed4
fix
derschnee68 Jan 3, 2024
1fd4144
fix
derschnee68 Jan 3, 2024
2603fc6
fix dialog
derschnee68 Jan 3, 2024
87f82ce
feat: add create-list-item-dialog
derschnee68 Jan 3, 2024
a3677ad
wip
derschnee68 Jan 3, 2024
6e0f615
feat: improve style
derschnee68 Jan 3, 2024
5adee19
refactor: service name
derschnee68 Jan 3, 2024
aed32a8
refactor: delete unused file
derschnee68 Jan 3, 2024
0c59491
refactor: pr issue
derschnee68 Jan 3, 2024
e6b1f7e
fix: project does not reload everytime
derschnee68 Jan 3, 2024
16a1832
fix
derschnee68 Jan 3, 2024
dcbae03
Merge branch 'julien/resource-form' into julien/list-item-form
derschnee68 Jan 3, 2024
4172229
fix: reload route issue
derschnee68 Jan 3, 2024
cc2cde3
fix
derschnee68 Jan 3, 2024
c9ccdfe
fix
derschnee68 Jan 3, 2024
8762667
Merge branch 'julien/resource-form' into julien/list-item-form
derschnee68 Jan 3, 2024
1492e3d
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 Jan 8, 2024
e989f6f
fix
derschnee68 Jan 8, 2024
6f614dd
wip
derschnee68 Jan 8, 2024
4c741a9
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 Jan 8, 2024
541897a
wip
derschnee68 Jan 8, 2024
290a510
wip
derschnee68 Jan 8, 2024
b8bf818
refactor: introduce listItemService
derschnee68 Jan 8, 2024
33ad6d1
wip: still need the reposition of items
derschnee68 Jan 8, 2024
50c1e59
fix: reposition node
derschnee68 Jan 9, 2024
1bdc74d
refactor: add confirm dialog service
derschnee68 Jan 9, 2024
dd59a24
Merge branch 'main' into julien/dialog
derschnee68 Jan 9, 2024
8cc722e
Merge branch 'julien/dialog' into julien/list-item-form
derschnee68 Jan 9, 2024
babcaee
fix: merging issue
derschnee68 Jan 9, 2024
7eb9f4f
fix: confirm dialog
derschnee68 Jan 9, 2024
ac86cdf
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 Jan 9, 2024
76c316a
wip
derschnee68 Jan 9, 2024
9e28966
refactor: add multi language type
derschnee68 Jan 9, 2024
d7667c7
refactor: improvements to listItemService
derschnee68 Jan 9, 2024
19cc2d4
wip
derschnee68 Jan 9, 2024
db5a7c7
refactor: edit working
derschnee68 Jan 9, 2024
74dc0f3
refactor: insert working
derschnee68 Jan 9, 2024
ccb71d4
fix: remove console logs
derschnee68 Jan 9, 2024
a297a13
fix: remove edit-list-item
derschnee68 Jan 9, 2024
aa8e9e4
fix: linter
derschnee68 Jan 9, 2024
09a8f92
fix: various fixes
derschnee68 Jan 9, 2024
420db0b
refactor: remove full-list-item-form
derschnee68 Jan 9, 2024
1e24881
fix
derschnee68 Jan 10, 2024
85ae5e4
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 Jan 10, 2024
80461a2
fix: remove unused button
derschnee68 Jan 10, 2024
0fc25a9
fix: multi language form language bug
derschnee68 Jan 10, 2024
1d224cc
feat: add reusable-list-item-form
derschnee68 Jan 10, 2024
550f67c
fix: various fixes
derschnee68 Jan 10, 2024
9971b11
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 Jan 11, 2024
801d64e
fix: lint
derschnee68 Jan 11, 2024
1c9d9b3
fix
derschnee68 Jan 11, 2024
3f42344
fix
derschnee68 Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/dsp-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ import { CreateProjectFormPageComponent } from './project/create-project-form-pa
import { DataModelsComponent } from './project/data-models/data-models.component';
import { DescriptionComponent } from './project/description/description.component';
import { EditProjectFormPageComponent } from './project/edit-project-form-page/edit-project-form-page.component';
import { ActionBubbleComponent } from './project/list/action-bubble/action-bubble.component';
import { ListItemComponent } from './project/list/list-item/list-item.component';
import { EditListItemComponent } from './project/list/list-item-form/edit-list-item/edit-list-item.component';
import { ListItemElementComponent } from './project/list/list-item-element/list-item-element.component';
import { CreateListItemDialogComponent } from './project/list/list-item-form/edit-list-item/create-list-item-dialog.component';
import { EditListItemDialogComponent } from './project/list/list-item-form/edit-list-item/edit-list-item-dialog.component';
import { ListItemFormComponent } from './project/list/list-item-form/list-item-form.component';
import { ReusableListItemFormComponent } from './project/list/list-item-form/reusable-list-item-form.component';
import { ListComponent } from './project/list/list.component';
import { CreateListInfoPageComponent } from './project/list/reusable-list-info-form/create-list-info-page.component';
import { EditListInfoDialogComponent } from './project/list/reusable-list-info-form/edit-list-info-dialog.component';
Expand Down Expand Up @@ -183,6 +187,7 @@ export function httpLoaderFactory(httpClient: HttpClient) {
@NgModule({
declarations: [
AccountComponent,
ActionBubbleComponent,
AddRegionFormComponent,
AddUserComponent,
AddValueComponent,
Expand Down Expand Up @@ -218,7 +223,6 @@ export function httpLoaderFactory(httpClient: HttpClient) {
DisplayEditComponent,
DocumentComponent,
DragDropDirective,
EditListItemComponent,
EditResourceClassDialogComponent,
ExpertSearchComponent,
FooterComponent,
Expand All @@ -240,9 +244,12 @@ export function httpLoaderFactory(httpClient: HttpClient) {
LinkValueComponent,
ListComponent,
EditListInfoDialogComponent,
EditListItemDialogComponent,
CreateListInfoPageComponent,
ReusableListInfoFormComponent,
ReusableListItemFormComponent,
ListItemComponent,
ListItemElementComponent,
ListItemFormComponent,
ListValueComponent,
ListViewComponent,
Expand Down Expand Up @@ -316,6 +323,7 @@ export function httpLoaderFactory(httpClient: HttpClient) {
CommentFormComponent,
DataModelsComponent,
IsFalsyPipe,
CreateListItemDialogComponent,
],
imports: [
AngularSplitModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';

export interface ConfirmDialogProps {
message: string;
title: string | null;
subtitle: string | null;
}
@Component({
selector: 'app-confirm-dialog',
template: `
<h1 mat-dialog-title>{{ data.title ?? 'Confirmation' }}</h1>
<app-dialog-header
[title]="data.title ?? 'Confirmation needed'"
[subtitle]="data.subtitle ?? ''"></app-dialog-header>
<div mat-dialog-content>
<p>{{ data.message }}</p>
</div>
<div mat-dialog-actions align="end">
<button mat-button (click)="dialogRef.close(false)">No</button>
<button mat-button (click)="dialogRef.close(true)">Yes</button>
<button mat-raised-button color="warn" (click)="dialogRef.close(true)">Yes</button>
</div>
`,
})
export class ConfirmDialogComponent {
constructor(
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: { title: string | undefined; message: string }
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogProps
) {}
}
27 changes: 0 additions & 27 deletions apps/dsp-app/src/app/main/dialog/dialog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,6 @@
</mat-dialog-actions>
</div>

<!-- all about PROJECT -->

<!-- all about LISTS -->

<!-- Insert list child node -->
<div *ngSwitchCase="'insertListNode'">
<app-dialog-header [title]="'Insert new child node'" [subtitle]=""> </app-dialog-header>
<app-edit-list-item
[iri]="data.id"
[projectIri]="data.project"
mode="insert"
[parentIri]="data.parentIri"
[position]="data.position"
(closeDialog)="dialogRef.close($event)">
</app-edit-list-item>
</div>

<!-- Update list child node -->
<div *ngSwitchCase="'editListNode'">
<app-dialog-header [title]="data.title" [subtitle]="'Edit child node'"> </app-dialog-header>
<app-edit-list-item
[iri]="data.id"
[projectIri]="data.project"
mode="update"
(closeDialog)="dialogRef.close($event)"></app-edit-list-item>
</div>

<!-- Ontology editor: create new ontology -->
<div *ngSwitchCase="'createOntology'">
<app-dialog-header [title]="data.title" [subtitle]="'Create new'"></app-dialog-header>
Expand Down
5 changes: 5 additions & 0 deletions apps/dsp-app/src/app/main/services/dialog-sizes.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const DIALOG_LARGE = {
width: '100%',
minWidth: 500,
maxWidth: 1000,
};
9 changes: 5 additions & 4 deletions apps/dsp-app/src/app/main/services/dialog.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { filter } from 'rxjs/operators';
import { ConfirmDialogComponent } from '../action/confirm-dialog/confirm-dialog.component';
import { ConfirmDialogComponent, ConfirmDialogProps } from '../action/confirm-dialog/confirm-dialog.component';

@Injectable({ providedIn: 'root' })
export class DialogService {
constructor(private _dialog: MatDialog) {}

afterConfirmation(message: string, title: string | null = null) {
afterConfirmation(message: string, title: string | null = null, subtitle: string | null = null) {
return this._dialog
.open<ConfirmDialogComponent, any, boolean>(ConfirmDialogComponent, {
.open<ConfirmDialogComponent, ConfirmDialogProps, boolean>(ConfirmDialogComponent, {
data: {
title,
message,
title,
subtitle,
},
})
.afterClosed()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
:host {
display: block;
position: absolute;
top: 0;
right: 0;
}
.d-flex {
display: flex;
}
.node-item ::ng-deep .mat-mdc-form-field-subscript-wrapper {
display: none;
}

.medium-field {
margin-top: -6px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import { Component, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ListNode } from '@dasch-swiss/dsp-js';
import { ListApiService } from '@dasch-swiss/vre/shared/app-api';
import { MultiLanguages } from '@dasch-swiss/vre/shared/app-string-literal';
import { filter, switchMap } from 'rxjs/operators';
import { DIALOG_LARGE } from '../../../main/services/dialog-sizes.constant';
import { DialogService } from '../../../main/services/dialog.service';
import { ListItemService } from '../list-item/list-item.service';
import {
CreateListItemDialogComponent,
CreateListItemDialogProps,
} from '../list-item-form/edit-list-item/create-list-item-dialog.component';
import {
EditListItemDialogComponent,
EditListItemDialogProps,
} from '../list-item-form/edit-list-item/edit-list-item-dialog.component';

@Component({
selector: 'app-action-bubble',
template: ` <div class="action-bubble" [@simpleFadeAnimation]="'in'">
<div class="button-container d-flex">
<button
mat-button
*ngIf="position > 0"
title="move up"
(click)="$event.stopPropagation(); repositionNode('up')"
class="reposition up">
<mat-icon>arrow_upward</mat-icon>
</button>
<button
mat-button
*ngIf="position < length - 1"
title="move down"
(click)="$event.stopPropagation(); repositionNode('down')"
class="reposition down">
<mat-icon>arrow_downward</mat-icon>
</button>
<button
mat-button
title="insert new child node above"
(click)="$event.stopPropagation(); askToInsertNode()"
class="insert">
<mat-icon>vertical_align_top</mat-icon>
</button>
<button mat-button class="edit" title="edit" (click)="$event.stopPropagation(); askToEditNode()">
<mat-icon>edit</mat-icon>
</button>
<button mat-button class="delete" title="delete" (click)="$event.stopPropagation(); askToDeleteListNode()">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>`,
animations: [
// https://www.kdechant.com/blog/angular-animations-fade-in-and-fade-out
trigger('simpleFadeAnimation', [
state('in', style({ opacity: 1 })),
transition(':enter', [style({ opacity: 0 }), animate(150)]),
transition(':leave', animate(150, style({ opacity: 0 }))),
]),
],
styleUrls: ['./action-bubble.component.scss'],
})
export class ActionBubbleComponent {
@Input() position: number;
@Input() length: number;
@Input() node: ListNode;

constructor(
private _dialog: DialogService,
private _matDialog: MatDialog,
private _listItemService: ListItemService,
private _listApiService: ListApiService
) {}

askToDeleteListNode() {
this._dialog
.afterConfirmation('Do you want to delete this node?', this.node.labels[0].value)
.pipe(switchMap(() => this._listApiService.deleteListNode(this.node.id)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsubscribe by using .pipe(take(1))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dialog automatically unsubscribes

.subscribe(() => {
this._listItemService.onUpdate$.next();
});
}

askToInsertNode() {
this._matDialog
.open<CreateListItemDialogComponent, CreateListItemDialogProps, boolean>(CreateListItemDialogComponent, {
...DIALOG_LARGE,
data: {
nodeIri: this.node.id,
projectIri: this._listItemService.projectInfos.projectIri,
parentIri: this._listItemService.projectInfos.rootNodeIri,
position: this.position,
},
})
.afterClosed()
.pipe(filter(response => response === true))
.subscribe(() => {
this._listItemService.onUpdate$.next();
});
}

askToEditNode() {
this._matDialog
.open<EditListItemDialogComponent, EditListItemDialogProps, boolean>(EditListItemDialogComponent, {
...DIALOG_LARGE,
data: {
nodeIri: this.node.id,
projectIri: this._listItemService.projectInfos.projectIri,
formData: {
labels: this.node.labels as MultiLanguages,
comments: this.node.comments as MultiLanguages,
},
},
})
.afterClosed()
.pipe(filter(response => response === true))
.subscribe(() => {
this._listItemService.onUpdate$.next();
});
}

repositionNode(direction: 'up' | 'down') {
this._listApiService
.repositionChildNode(this.node.id, {
parentNodeIri: this._listItemService.projectInfos.rootNodeIri,
position: direction === 'up' ? this.position - 1 : this.position + 1,
})
.subscribe(() => {
this._listItemService.onUpdate$.next();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ListNode } from '@dasch-swiss/dsp-js';
import { ListItemService } from '../list-item/list-item.service';

@Component({
selector: 'app-list-item-element',
template: `
<div style="display: flex">
<button type="button" color="primary" mat-icon-button (click)="showChildren = !showChildren">
<mat-icon>{{ showChildren ? 'expand_more' : 'chevron_right' }} </mat-icon>
</button>

<div style="flex: 1">
<div (mouseenter)="mouseEnter()" (mouseleave)="mouseLeave()" style="position: relative">
<dasch-swiss-multi-language-input
[placeholder]="node.labels | appStringifyStringLiteral: 'all' | appTruncate: 128"
[editable]="false"
[formGroup]="readOnlyForm"
controlName="labels">
</dasch-swiss-multi-language-input>

<app-action-bubble
*ngIf="showActionBubble"
[position]="position"
[length]="length"
[node]="node"></app-action-bubble>
</div>

<app-list-item
*ngIf="showChildren"
[projectUuid]="listItemService.projectInfos.projectIri"
[rootNodeIri]="node.id"
[isAdmin]="isAdmin">
</app-list-item>
</div>
</div>
`,
styles: [':host ::ng-deep dasch-swiss-multi-language-input .mat-mdc-form-field-bottom-align { display: none;}'],
})
export class ListItemElementComponent implements OnInit {
@Input() node: ListNode;
@Input() position: number;
@Input() length: number;

@Output() refreshChildren = new EventEmitter<ListNode[]>();
@Output() updateView = new EventEmitter<unknown>();

@Input() isAdmin = false;
showChildren = false;
showActionBubble = false;

readOnlyForm: FormGroup;

constructor(
private _fb: FormBuilder,
public listItemService: ListItemService
) {}

ngOnInit() {
this.readOnlyForm = this._fb.group({
labels: this._fb.array(
this.node.labels.map(({ language, value }) =>
this._fb.group({
language,
value,
})
)
),
});
}

mouseEnter() {
if (this.isAdmin) {
this.showActionBubble = true;
}
}
mouseLeave() {
this.showActionBubble = false;
}
}