Skip to content

Commit

Permalink
Hide move & delete buttons for new resources in list view [notarize]
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Mar 24, 2023
1 parent b47d9fe commit 2f8b386
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
13 changes: 11 additions & 2 deletions desktop/src/app/components/resources/list/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class RowComponent implements AfterViewInit, OnChanges {
? 'resource-' + this.document.resource.identifier
: 'new-resource';

public isNewResource = () => !this.document.resource.id;


ngAfterViewInit() {

Expand Down Expand Up @@ -151,7 +153,14 @@ export class RowComponent implements AfterViewInit, OnChanges {

public isMoveOptionAvailable(): boolean {

return this.projectConfiguration.getHierarchyParentCategories(this.document.resource.category).length > 0;
return !this.isNewResource()
&& this.projectConfiguration.getHierarchyParentCategories(this.document.resource.category).length > 0;
}


public isDeleteOptionAvailable(): boolean {

return !this.isNewResource();
}


Expand Down Expand Up @@ -199,7 +208,7 @@ export class RowComponent implements AfterViewInit, OnChanges {
private async save() {

if (!this.document.resource.identifier || this.document.resource.identifier.trim() === '') {
if (this.document.resource.id) await this.restoreIdentifier(this.document);
if (!this.isNewResource()) await this.restoreIdentifier(this.document);
return;
}

Expand Down
15 changes: 8 additions & 7 deletions desktop/src/app/components/resources/list/row.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="{{makeId()}}"
class="row-wrapper">
<div class="label-field">
<div class="category-label" [class.text-info]="!document.resource.id">
<div class="category-label" [class.text-info]="isNewResource()">
<i>{{getCategoryLabel()}}</i>
</div>

Expand Down Expand Up @@ -92,31 +92,32 @@
(click)="editDocument()">
<span class="mdi mdi-pencil mdi-18px"></span>
</button>
<button *ngIf="isMoveOptionAvailable()"
<button [class.hidden-option]="!isMoveOptionAvailable()"
class="btn btn-small btn-link float-right list-move-button"
ngbTooltip="Verschieben"
i18n-ngbTooltip="@@resources.list.moveButton.tooltip"
placement="bottom"
container="body"
triggers="manual"
#moveTooltip="ngbTooltip"
(mouseover)="moveTooltip.open()"
(mouseover)="isMoveOptionAvailable() && moveTooltip.open()"
(mouseleave)="moveTooltip.close()"
(mousedown)="moveTooltip.close()"
(click)="moveDocument()">
(click)="isMoveOptionAvailable() && moveDocument()">
<span class="mdi mdi-file-tree mdi-18px"></span>
</button>
<button class="btn btn-small btn-link float-right list-delete-button"
<button [class.hidden-option]="!isDeleteOptionAvailable()"
class="btn btn-small btn-link float-right list-delete-button"
ngbTooltip="Löschen"
i18n-ngbTooltip="@@resources.list.deleteButton.tooltip"
placement="bottom"
container="body"
triggers="manual"
#deleteTooltip="ngbTooltip"
(mouseover)="deleteTooltip.open()"
(mouseover)="isMoveOptionAvailable() && deleteTooltip.open()"
(mouseleave)="deleteTooltip.close()"
(mousedown)="deleteTooltip.close()"
(click)="deleteDocument()">
(click)="isDeleteOptionAvailable() && deleteDocument()">
<span class="mdi mdi-delete mdi-18px"></span>
</button>
</div>
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/app/components/resources/list/row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@
.list-delete-button {
border-radius: 32px !important;
}

.hidden-option {
opacity: 0;
}
}

0 comments on commit 2f8b386

Please sign in to comment.