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

chore: created isFalsy pipe to handle no-negated-async linting rule #1299

Merged
merged 1 commit into from Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions apps/dsp-app/src/app/app.module.ts
Expand Up @@ -162,6 +162,7 @@ import { apiConnectionTokenProvider } from './providers/api-connection-token.pro
import { NgxsStoreModule } from '@dasch-swiss/vre/shared/app-state';
import { AppProgressIndicatorComponent } from "@dasch-swiss/vre/shared/app-progress-indicator";
import {AppStringLiteralComponent} from "@dasch-swiss/vre/shared/app-string-literal";
import { IsFalsyPipe } from './main/pipes/isFalsy.piipe';

// translate: AoT requires an exported function for factories
export function httpLoaderFactory(httpClient: HttpClient) {
Expand Down Expand Up @@ -293,6 +294,7 @@ export function httpLoaderFactory(httpClient: HttpClient) {
ProjectTileComponent,
CommentFormComponent,
DataModelsComponent,
IsFalsyPipe,
],
imports: [
AngularSplitModule,
Expand Down
11 changes: 11 additions & 0 deletions apps/dsp-app/src/app/main/pipes/isFalsy.piipe.ts
@@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'isFalsy',
pure: false,
})
export class IsFalsyPipe implements PipeTransform {
transform(value: any): any {
return value ? false : true;
}
}
8 changes: 4 additions & 4 deletions apps/dsp-app/src/app/project/ontology/ontology.component.html
Expand Up @@ -33,7 +33,7 @@
<p class="mat-caption space-reducer">Data model configuration</p>
<span
[matTooltip]="((isAdmin$ | async) ? ((lastModificationDate$ | async) ? 'Edit data model info' : 'This data model can\'t be edited because of missing lastModificationDate!') : null)">
<button *ngIf="(currentOntology$ | async) as currentOntology" color="primary" mat-button [disabled]="!!(lastModificationDate$ | async) || (isAdmin$ | async) === false"
<button *ngIf="(currentOntology$ | async) as currentOntology" color="primary" mat-button [disabled]="(lastModificationDate$ | async | isFalsy) || (isAdmin$ | async) === false"
(click)="$event.stopPropagation(); openOntologyForm('editOntology', currentOntology.id)">
<mat-icon>edit</mat-icon>
Edit
Expand All @@ -43,7 +43,7 @@
[matTooltip]="((isAdmin$ | async) ? ((lastModificationDate$ | async) ? ((currentOntologyCanBeDeleted$ | async) ? 'Delete data model' : 'This data model can\'t be deleted because it is in use!') : 'This data model can\'t be deleted because of missing lastModificationDate!') : null)">
<button color="warn" mat-button
*ngIf="(currentOntology$ | async) as currentOntology"
[disabled]="(!!(lastModificationDate$ | async) || (currentOntologyCanBeDeleted$ | async) === false) || ((isAdmin$ | async) === false)"
[disabled]="((lastModificationDate$ | async | isFalsy) || (currentOntologyCanBeDeleted$ | async) === false) || ((isAdmin$ | async) === false)"
(click)="$event.stopPropagation(); delete('Ontology', {iri: currentOntology.id, label: currentOntology.label})">
<mat-icon>delete</mat-icon>
Delete
Expand All @@ -69,7 +69,7 @@
[matTooltip]="'This data model can\'t be edited because of missing \'lastModificationDate\'!'"
[matTooltipDisabled]="lastModificationDate$ | async">
<button mat-button [matMenuTriggerFor]="addResClassMenu"
[disabled]="!!(lastModificationDate$ | async)">
[disabled]="lastModificationDate$ | async | isFalsy">
<mat-icon>add</mat-icon>
Create new class
</button>
Expand All @@ -88,7 +88,7 @@
[matTooltip]="'This data model can\'t be edited because of missing \'lastModificationDate\'!'"
[matTooltipDisabled]="lastModificationDate$ | async">
<button mat-button *ngIf="view === 'properties'" [matMenuTriggerFor]="addPropertyMenu"
[disabled]="!!(lastModificationDate$ | async)">
[disabled]="lastModificationDate$ | async | isFalsy">
<mat-icon>add</mat-icon>
Create new property
</button>
Expand Down
4 changes: 2 additions & 2 deletions apps/dsp-app/src/app/user/overview/overview.component.html
Expand Up @@ -33,7 +33,7 @@
</div>
</div>
<!-- user is logged in and not a system admin -->
<div *ngIf="(isSysAdmin$ | async) === false && !!(user$ | async)">
<div *ngIf="(isSysAdmin$ | async) === false && (user$ | async | isFalsy)">
<div class="title-bar">
<div class="title">
<p>My Projects</p>
Expand Down Expand Up @@ -69,7 +69,7 @@
</div>

<!-- user is not logged in -->
<div *ngIf="((isProjectsLoading$ | async) === false) && !!((user$ | async))">
<div *ngIf="((isProjectsLoading$ | async) === false) && user$ | async | isFalsy">
<!-- list all projects -->
<div class="title-bar admin">
<div class="title">
Expand Down
2 changes: 1 addition & 1 deletion apps/dsp-app/src/app/user/profile/profile.component.html
@@ -1,4 +1,4 @@
<dasch-swiss-app-progress-indicator *ngIf="(isLoading$ | async) === true && !!(user$ | async)"></dasch-swiss-app-progress-indicator>
<dasch-swiss-app-progress-indicator *ngIf="(isLoading$ | async) === true && (user$ | async | isFalsy)"></dasch-swiss-app-progress-indicator>

<ng-container *ngIf="(isLoading$ | async) === false && loggedInUser">
<ng-container *ngIf="(user$ | async) as user">
Expand Down