-
Notifications
You must be signed in to change notification settings - Fork 6
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
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 09efe33
feat: add parameters to human readable error pipe
derschnee68 bfea6cb
wip
derschnee68 7608169
Merge branch 'main' into julien/form
derschnee68 81c103d
Merge remote-tracking branch 'origin/main' into julien/form
derschnee68 6e728fd
refactor: eslint -fix on the project folder
derschnee68 ec3e1d0
Merge branch 'main' into julien/form
derschnee68 f37cfa4
fix: improve maintability
derschnee68 bab9571
feat: add centered layout
derschnee68 fbf38e5
fix
derschnee68 36f49ed
fix: remove unused code
derschnee68 1db9f39
feat: add 2nd version of string literal component
derschnee68 dbe54ab
chore: add original version of string literal component
derschnee68 f6a283b
wip
derschnee68 889f3ec
feat: edit description in formbuilder
derschnee68 ffa7e48
fix: improve dasch-swiss-string-literal-2.component.ts
derschnee68 9959bf6
fix: improve dasch-swiss-string-literal-2.component.ts
derschnee68 fb5e4f2
fix: improve upload in state management
derschnee68 2f048d2
fix: improve template
derschnee68 12a4554
feat: do not use state management
derschnee68 74e5bb8
feat: improve dasch-swiss-string-literal-2.component.ts
derschnee68 1cca1dc
fix: textarea rows
derschnee68 91a8833
fix: chipListInput issue
derschnee68 130ea67
feat: first draft
derschnee68 8afdfff
feat: create create-resource-class-dialog
derschnee68 b62d604
fix: various fixes
derschnee68 7cd0f3a
feat: edit resource class, wip buggy
derschnee68 e9e0093
feat: improve loading button directive
derschnee68 1ae3af8
fix: tap instead of finalize
derschnee68 614b216
feat: create list info form
derschnee68 a2d12e6
feat: edit list form
derschnee68 cabde13
refactor: delete list-info-form
derschnee68 124f149
refactor: delete project-form
derschnee68 b6eb62c
refactor: add confirm-dialog
derschnee68 6d5a80a
refactor: remove dialog component
derschnee68 74aca2f
refactor: deleteListNode
derschnee68 2da2a0c
refactor: deleteList
derschnee68 4cc7c8a
refactor: remove unused code
derschnee68 f7083cf
feat: dasch-swiss-string-literal-2-input
derschnee68 a5a5707
feat: add dasch-swiss-string-literal-service
derschnee68 c25a507
fix: lint
derschnee68 1cc2c08
fix: lint
derschnee68 468be32
fix
derschnee68 17818bc
refactor: rename string-literal to multi-language
derschnee68 17bbd34
fix
derschnee68 9e9b360
fix
derschnee68 cf08223
Merge remote-tracking branch 'origin/main' into julien/resource-form
derschnee68 3f7b064
fix
derschnee68 1fbeed4
fix
derschnee68 1fd4144
fix
derschnee68 2603fc6
fix dialog
derschnee68 87f82ce
feat: add create-list-item-dialog
derschnee68 a3677ad
wip
derschnee68 6e0f615
feat: improve style
derschnee68 5adee19
refactor: service name
derschnee68 aed32a8
refactor: delete unused file
derschnee68 0c59491
refactor: pr issue
derschnee68 e6b1f7e
fix: project does not reload everytime
derschnee68 16a1832
fix
derschnee68 dcbae03
Merge branch 'julien/resource-form' into julien/list-item-form
derschnee68 4172229
fix: reload route issue
derschnee68 cc2cde3
fix
derschnee68 c9ccdfe
fix
derschnee68 8762667
Merge branch 'julien/resource-form' into julien/list-item-form
derschnee68 1492e3d
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 e989f6f
fix
derschnee68 6f614dd
wip
derschnee68 4c741a9
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 541897a
wip
derschnee68 290a510
wip
derschnee68 b8bf818
refactor: introduce listItemService
derschnee68 33ad6d1
wip: still need the reposition of items
derschnee68 50c1e59
fix: reposition node
derschnee68 1bdc74d
refactor: add confirm dialog service
derschnee68 dd59a24
Merge branch 'main' into julien/dialog
derschnee68 8cc722e
Merge branch 'julien/dialog' into julien/list-item-form
derschnee68 babcaee
fix: merging issue
derschnee68 7eb9f4f
fix: confirm dialog
derschnee68 ac86cdf
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 76c316a
wip
derschnee68 9e28966
refactor: add multi language type
derschnee68 d7667c7
refactor: improvements to listItemService
derschnee68 19cc2d4
wip
derschnee68 db5a7c7
refactor: edit working
derschnee68 74dc0f3
refactor: insert working
derschnee68 ccb71d4
fix: remove console logs
derschnee68 a297a13
fix: remove edit-list-item
derschnee68 aa8e9e4
fix: linter
derschnee68 09a8f92
fix: various fixes
derschnee68 420db0b
refactor: remove full-list-item-form
derschnee68 1e24881
fix
derschnee68 85ae5e4
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 80461a2
fix: remove unused button
derschnee68 0fc25a9
fix: multi language form language bug
derschnee68 1d224cc
feat: add reusable-list-item-form
derschnee68 550f67c
fix: various fixes
derschnee68 9971b11
Merge remote-tracking branch 'origin/main' into julien/list-item-form
derschnee68 801d64e
fix: lint
derschnee68 1c9d9b3
fix
derschnee68 3f42344
fix
derschnee68 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
apps/dsp-app/src/app/main/action/confirm-dialog/confirm-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const DIALOG_LARGE = { | ||
width: '100%', | ||
minWidth: 500, | ||
maxWidth: 1000, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...t-item-form/list-item-form.component.scss → ...ction-bubble/action-bubble.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
apps/dsp-app/src/app/project/list/action-bubble/action-bubble.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | ||
.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(); | ||
}); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
apps/dsp-app/src/app/project/list/list-item-element/list-item-element.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dialog automatically unsubscribes