Compare commits

..

No commits in common. "master" and "RED-9321" have entirely different histories.

140 changed files with 741 additions and 1141 deletions

View File

@ -206,7 +206,6 @@ module.exports = {
], ],
rules: { rules: {
'rxjs/no-ignored-subscription': 'error', 'rxjs/no-ignored-subscription': 'error',
'@angular-eslint/prefer-standalone': 'off',
'@angular-eslint/directive-selector': [ '@angular-eslint/directive-selector': [
'error', 'error',
{ {

View File

@ -1,19 +0,0 @@
sonarqube:
stage: test
image:
name: sonarsource/sonar-scanner-cli:11.1
entrypoint:
- ''
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: '0'
cache:
key: "${CI_JOB_NAME}"
paths:
- ".sonar/cache"
script:
- sonar-scanner
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
- if: "$CI_COMMIT_BRANCH =~ /^release/"

View File

@ -1,2 +0,0 @@
sonar.projectKey=common-ui
sonar.qualitygate.wait=false

View File

@ -1,3 +0,0 @@
<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 7.4L0 1.4L1.4 0L6 4.6L10.6 0L12 1.4L6 7.4Z" fill="currentColor" />
</svg>

Before

Width:  |  Height:  |  Size: 184 B

View File

@ -1,3 +0,0 @@
<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 2.8L1.4 7.4L0 6L6 0L12 6L10.6 7.4L6 2.8Z" fill="currentColor" />
</svg>

Before

Width:  |  Height:  |  Size: 182 B

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="100px" version="1.1" viewBox="0 0 100 100" width="100px"
xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd" id="minimize" stroke="none" stroke-width="1">
<path
d="M40,60 L40,90 L30,90 L30,77 L7,100 L0,93 L23,70 L10,70 L10,60 L40,60 Z M90,60 L90,70 L77,70 L100,93 L93,100 L70,77 L70,90 L60,90 L60,60 L90,60 Z M93,0 L100,7 L77,30 L90,30 L90,40 L60,40 L60,10 L70,10 L70,23 L93,0 Z M7,0 L30,23 L30,10 L40,10 L40,40 L10,40 L10,30 L23,30 L0,7 L7,0 Z"
fill="currentColor" fill-rule="nonzero" id="Combined-Shape"></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 642 B

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="100px" version="1.1" viewBox="0 0 100 100" width="100px"
xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd" id="full-screen" stroke="none" stroke-width="1">
<path
d="M36.5,56.5 L43.5,63.5 L17,90 L30,90 L30,100 L0,100 L0,70 L10,70 L10,83 L36.5,56.5 Z M63.5,56.5 L90,83 L90,70 L100,70 L100,100 L70,100 L70,90 L83,90 L56.5,63.5 L63.5,56.5 Z M100,0 L100,30 L90,30 L90,17 L63.5,43.5 L56.5,36.5 L83,10 L70,10 L70,0 L100,0 Z M30,0 L30,10 L17,10 L43.5,36.5 L36.5,43.5 L10,17 L10,30 L0,30 L0,0 L30,0 Z"
fill="currentColor" fill-rule="nonzero" id="Combined-Shape"></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 691 B

View File

@ -5,7 +5,6 @@ $ripple-size: 26px;
flex: 0 0 $checkbox-size; flex: 0 0 $checkbox-size;
width: $checkbox-size; width: $checkbox-size;
height: $checkbox-size; height: $checkbox-size;
margin-top: 4px;
} }
.mat-mdc-checkbox, .mat-mdc-checkbox,
@ -25,14 +24,10 @@ $ripple-size: 26px;
--mdc-checkbox-selected-hover-state-layer-color: var(--iqser-primary); --mdc-checkbox-selected-hover-state-layer-color: var(--iqser-primary);
--mdc-checkbox-selected-pressed-state-layer-color: var(--iqser-primary); --mdc-checkbox-selected-pressed-state-layer-color: var(--iqser-primary);
.mdc-form-field { .mdc-form-field > label {
align-items: start; padding-left: 8px;
line-height: 24px;
& > label { white-space: nowrap;
padding-left: 8px;
line-height: 24px;
white-space: normal;
}
} }
.mdc-checkbox__ripple { .mdc-checkbox__ripple {

View File

@ -22,14 +22,6 @@
font-size: var(--iqser-font-size); font-size: var(--iqser-font-size);
} }
&.extra-small {
height: 16px;
width: 16px;
min-width: 16px;
font-size: 10px;
font-weight: lighter;
}
&.gray-dark { &.gray-dark {
background-color: var(--iqser-user-avatar-1); background-color: var(--iqser-user-avatar-1);
color: var(--iqser-text); color: var(--iqser-text);

View File

@ -47,10 +47,7 @@
font-weight: bold; font-weight: bold;
padding-bottom: 8px; padding-bottom: 8px;
} }
}
&.redaction,
&.force-annotation {
iqser-details-radio { iqser-details-radio {
padding-top: 20px; padding-top: 20px;
} }
@ -75,7 +72,3 @@
margin-left: auto; margin-left: auto;
} }
} }
.large-form-dialog .dialog > form {
display: contents;
}

View File

@ -7,7 +7,6 @@
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
background: var(--iqser-alt-background); background: var(--iqser-alt-background);
height: 68px;
&.drag-over { &.drag-over {
background-color: var(--iqser-file-drop-drag-over); background-color: var(--iqser-file-drop-drag-over);
@ -16,6 +15,7 @@
.upload-area { .upload-area {
gap: 16px; gap: 16px;
height: 88px;
cursor: pointer; cursor: pointer;
padding: 0 32px; padding: 0 32px;
@ -33,6 +33,7 @@
.file-area { .file-area {
gap: 10px; gap: 10px;
height: 48px;
mat-icon:first-child { mat-icon:first-child {
opacity: 0.5; opacity: 0.5;

View File

@ -156,15 +156,13 @@ section.settings {
box-sizing: border-box; box-sizing: border-box;
background: var(--iqser-background); background: var(--iqser-background);
overflow: hidden; overflow: hidden;
&.with-transition { transition:
transition: width ease-in-out 0.2s,
width ease-in-out 0.2s, min-width ease-in-out 0.2s;
min-width ease-in-out 0.2s;
}
@include common-mixins.scroll-bar;
&:hover { &:hover {
overflow-y: auto; overflow-y: auto;
@include common-mixins.scroll-bar;
} }
.collapsed-wrapper { .collapsed-wrapper {
@ -256,10 +254,6 @@ section.settings {
cursor: pointer; cursor: pointer;
} }
.cursor-default {
cursor: default;
}
.fit-content { .fit-content {
width: fit-content; width: fit-content;
} }

View File

@ -25,7 +25,7 @@
.mat-mdc-menu-item { .mat-mdc-menu-item {
font-size: var(--iqser-font-size); font-size: var(--iqser-font-size);
color: var(--iqser-text); color: var(--iqser-text);
padding: 0 26px 0 8px !important; padding: 0 26px 0 8px;
margin: var(--iqser-menu-item-margin); margin: var(--iqser-menu-item-margin);
border-radius: 4px; border-radius: 4px;
width: -webkit-fill-available; width: -webkit-fill-available;
@ -58,7 +58,7 @@
} }
&.padding-left { &.padding-left {
padding-left: 56px !important; padding-left: 56px;
} }
&:last-of-type { &:last-of-type {

View File

@ -1,5 +1,3 @@
@use 'sass:string';
@use 'sass:list';
/* Margins, paddings */ /* Margins, paddings */
$start: 0; $start: 0;
@ -9,19 +7,19 @@ $values: '';
$sides: (top, bottom, left, right); $sides: (top, bottom, left, right);
@for $i from $start + 1 through $end { @for $i from $start + 1 through $end {
$values: list.append($values, $i, comma); $values: append($values, $i, comma);
$values: list.set-nth($values, 1, $start); $values: set-nth($values, 1, $start);
} }
// TODO: Check if !important can be avoided // TODO: Check if !important can be avoided
@each $space in $values { @each $space in $values {
@each $side in $sides { @each $side in $sides {
.m#{string.slice($side, 0, 1)}-#{$space} { .m#{str-slice($side, 0, 1)}-#{$space} {
margin-#{$side}: #{$space}px !important; margin-#{$side}: #{$space}px !important;
} }
.p#{string.slice($side, 0, 1)}-#{$space} { .p#{str-slice($side, 0, 1)}-#{$space} {
padding-#{$side}: #{$space}px !important; padding-#{$side}: #{$space}px !important;
} }
} }

View File

@ -3,11 +3,13 @@ export * from './lib/dialog';
export * from './lib/form'; export * from './lib/form';
export * from './lib/listing'; export * from './lib/listing';
export * from './lib/help-mode'; export * from './lib/help-mode';
export * from './lib/inputs';
export * from './lib/services'; export * from './lib/services';
export * from './lib/loading'; export * from './lib/loading';
export * from './lib/error'; export * from './lib/error';
export * from './lib/search'; export * from './lib/search';
export * from './lib/upload-file'; export * from './lib/upload-file';
export * from './lib/empty-state';
export * from './lib/caching'; export * from './lib/caching';
export * from './lib/translations'; export * from './lib/translations';
export * from './lib/pipes'; export * from './lib/pipes';

View File

@ -8,6 +8,7 @@ import { randomString } from '../../utils';
templateUrl: './chevron-button.component.html', templateUrl: './chevron-button.component.html',
styleUrls: ['./chevron-button.component.scss'], styleUrls: ['./chevron-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [MatIconModule, MatButtonModule], imports: [MatIconModule, MatButtonModule],
}) })
export class ChevronButtonComponent { export class ChevronButtonComponent {

View File

@ -1 +0,0 @@
export * from './chevron-button.component';

View File

@ -24,6 +24,7 @@ import { CircleButtonType, CircleButtonTypes } from '../types/circle-button.type
templateUrl: './circle-button.component.html', templateUrl: './circle-button.component.html',
styleUrls: ['./circle-button.component.scss'], styleUrls: ['./circle-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [MatTooltipModule, MatIconModule, MatButtonModule, StopPropagationDirective], imports: [MatTooltipModule, MatIconModule, MatButtonModule, StopPropagationDirective],
}) })
export class CircleButtonComponent { export class CircleButtonComponent {

View File

@ -1,5 +1,5 @@
<button <button
(click)="!disabled() && emitAction($event)" (click)="!disabled() && action.emit($event)"
[disabled]="disabled()" [disabled]="disabled()"
[id]="buttonId()" [id]="buttonId()"
[iqserStopPropagation]="action.observed && !_hasRouterLink" [iqserStopPropagation]="action.observed && !_hasRouterLink"

View File

@ -11,6 +11,7 @@ import { IconButtonType, IconButtonTypes } from '../types/icon-button.type';
selector: 'iqser-icon-button', selector: 'iqser-icon-button',
templateUrl: './icon-button.component.html', templateUrl: './icon-button.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [NgClass, MatButtonModule, MatIconModule, StopPropagationDirective], imports: [NgClass, MatButtonModule, MatIconModule, StopPropagationDirective],
}) })
export class IconButtonComponent { export class IconButtonComponent {
@ -32,11 +33,4 @@ export class IconButtonComponent {
}; };
}); });
@Output() readonly action = new EventEmitter<MouseEvent>(); @Output() readonly action = new EventEmitter<MouseEvent>();
emitAction($event: MouseEvent) {
const activeElement = document.activeElement as HTMLElement;
if (activeElement.tagName?.toLowerCase() === 'button') {
this.action.emit($event);
}
}
} }

View File

@ -3,3 +3,4 @@ export * from './types/circle-button.type';
export * from './icon-button/icon-button.component'; export * from './icon-button/icon-button.component';
export * from './circle-button/circle-button.component'; export * from './circle-button/circle-button.component';
export * from './chevron-button/chevron-button.component';

View File

@ -11,10 +11,6 @@
} }
<div class="dialog-content"> <div class="dialog-content">
@if (config.component) {
<ng-container #detailsComponent></ng-container>
}
<p [class.heading]="isDeleteAction" [innerHTML]="config.question" class="mt-0 mb-8"></p> <p [class.heading]="isDeleteAction" [innerHTML]="config.question" class="mt-0 mb-8"></p>
@if (config.details) { @if (config.details) {
<p [innerHTML]="config.details" class="mt-0"></p> <p [innerHTML]="config.details" class="mt-0"></p>
@ -39,20 +35,14 @@
} }
</div> </div>
<div class="dialog-actions" [class.reverse]="config.cancelButtonPrimary"> <div class="dialog-actions">
@if (!config.cancelButtonPrimary) { <iqser-icon-button
<iqser-icon-button (action)="confirm(confirmOption)"
(action)="confirm(confirmOption)" [disabled]="(config.requireInput && confirmationDoesNotMatch()) || config.disableConfirm"
[disabled]="(config.requireInput && confirmationDoesNotMatch()) || config.disableConfirm" [label]="config.confirmationText"
[label]="config.confirmationText" [type]="iconButtonTypes.primary"
[type]="iconButtonTypes.primary" buttonId="confirm"
buttonId="confirm" ></iqser-icon-button>
></iqser-icon-button>
} @else {
<div (click)="confirm(confirmOption)" class="all-caps-label cancel no-uppercase" id="confirm">
{{ config.confirmationText }}
</div>
}
@if (config.alternativeConfirmationText) { @if (config.alternativeConfirmationText) {
<iqser-icon-button <iqser-icon-button
@ -70,13 +60,9 @@
} }
@if (!config.discardChangesText) { @if (!config.discardChangesText) {
@if (config.cancelButtonPrimary) { <div (click)="deny()" class="all-caps-label cancel">
<iqser-icon-button (click)="deny()" [label]="config.denyText" [type]="iconButtonTypes.primary"></iqser-icon-button> {{ config.denyText }}
} @else { </div>
<div (click)="deny()" class="all-caps-label cancel">
{{ config.denyText }}
</div>
}
} }
</div> </div>

View File

@ -6,12 +6,3 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.reverse {
flex-direction: row-reverse;
justify-content: flex-end;
}
.no-uppercase {
text-transform: unset;
}

View File

@ -1,24 +1,15 @@
import { NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { import { ChangeDetectionStrategy, Component, HostListener, inject, TemplateRef } from '@angular/core';
AfterViewInit,
ChangeDetectionStrategy,
Component,
HostListener,
inject,
TemplateRef,
Type,
viewChild,
ViewContainerRef,
} from '@angular/core';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { CircleButtonComponent, IconButtonTypes } from '../../buttons'; import { CircleButtonComponent } from '../../buttons/circle-button/circle-button.component';
import { IconButtonComponent } from '../../buttons'; import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
import { ValuesOf } from '../../utils'; import { IconButtonTypes } from '../../buttons/types/icon-button.type';
import { ValuesOf } from '../../utils/types/utility-types';
export const TitleColors = { export const TitleColors = {
DEFAULT: 'default', DEFAULT: 'default',
@ -57,9 +48,6 @@ interface InternalConfirmationDialogData {
readonly checkboxes: CheckBox[]; readonly checkboxes: CheckBox[];
readonly checkboxesValidation: boolean; readonly checkboxesValidation: boolean;
readonly toastMessage?: string; readonly toastMessage?: string;
readonly component?: Type<unknown>;
readonly componentInputs?: { [key: string]: unknown };
readonly cancelButtonPrimary?: boolean;
} }
export type IConfirmationDialogData = Partial<InternalConfirmationDialogData>; export type IConfirmationDialogData = Partial<InternalConfirmationDialogData>;
@ -77,9 +65,6 @@ function getConfig(options?: IConfirmationDialogData): InternalConfirmationDialo
denyText: options?.denyText ?? _('common.confirmation-dialog.deny'), denyText: options?.denyText ?? _('common.confirmation-dialog.deny'),
checkboxes: options?.checkboxes ?? [], checkboxes: options?.checkboxes ?? [],
checkboxesValidation: typeof options?.checkboxesValidation === 'boolean' ? options.checkboxesValidation : true, checkboxesValidation: typeof options?.checkboxesValidation === 'boolean' ? options.checkboxesValidation : true,
component: options?.component,
componentInputs: options?.componentInputs,
cancelButtonPrimary: options?.cancelButtonPrimary ?? false,
}; };
} }
@ -87,6 +72,7 @@ function getConfig(options?: IConfirmationDialogData): InternalConfirmationDialo
templateUrl: './confirmation-dialog.component.html', templateUrl: './confirmation-dialog.component.html',
styleUrls: ['./confirmation-dialog.component.scss'], styleUrls: ['./confirmation-dialog.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [ imports: [
MatIconModule, MatIconModule,
FormsModule, FormsModule,
@ -98,14 +84,13 @@ function getConfig(options?: IConfirmationDialogData): InternalConfirmationDialo
MatDialogModule, MatDialogModule,
], ],
}) })
export class ConfirmationDialogComponent implements AfterViewInit { export class ConfirmationDialogComponent {
readonly config = getConfig(inject(MAT_DIALOG_DATA)); readonly config = getConfig(inject(MAT_DIALOG_DATA));
inputValue = ''; inputValue = '';
showToast = false; showToast = false;
readonly inputLabel: string; readonly inputLabel: string;
readonly confirmOptions = ConfirmOptions; readonly confirmOptions = ConfirmOptions;
readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
readonly detailsComponentRef = viewChild.required('detailsComponent', { read: ViewContainerRef });
constructor( constructor(
private readonly _dialogRef: MatDialogRef<ConfirmationDialogComponent, ConfirmOption>, private readonly _dialogRef: MatDialogRef<ConfirmationDialogComponent, ConfirmOption>,
@ -130,19 +115,13 @@ export class ConfirmationDialogComponent implements AfterViewInit {
return ConfirmOptions.CONFIRM; return ConfirmOptions.CONFIRM;
} }
@HostListener('window:keyup.enter', ['$event']) @HostListener('window:keyup.enter')
onKeyupEnter(event: KeyboardEvent): void { onKeyupEnter(): void {
event?.stopImmediatePropagation(); if (this.config.requireInput && !this.confirmationDoesNotMatch()) {
if (!this.config.requireInput || !this.confirmationDoesNotMatch()) { this.confirm(ConfirmOptions.CONFIRM);
if (!this.config.cancelButtonPrimary) this.confirm(ConfirmOptions.CONFIRM);
else this.deny();
} }
} }
ngAfterViewInit() {
this.#initializeDetailsComponent();
}
confirmationDoesNotMatch(): boolean { confirmationDoesNotMatch(): boolean {
return this.inputValue.toLowerCase() !== this.config.confirmationText.toLowerCase(); return this.inputValue.toLowerCase() !== this.config.confirmationText.toLowerCase();
} }
@ -177,13 +156,9 @@ export class ConfirmationDialogComponent implements AfterViewInit {
}); });
} }
#initializeDetailsComponent() { @HostListener('window:keydown.Enter', ['$event'])
if (!this.config.component) return; onEnter(event: KeyboardEvent): void {
const component = this.detailsComponentRef().createComponent(this.config.component); event?.stopImmediatePropagation();
if (this.config.componentInputs) { this.confirm(ConfirmOptions.CONFIRM);
for (const [key, value] of Object.entries(this.config.componentInputs)) {
(component.instance as any)[key] = value;
}
}
} }
} }

View File

@ -2,8 +2,9 @@ import { Directive, HostListener, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { IconButtonTypes } from '../buttons'; import { IconButtonTypes } from '../buttons/types/icon-button.type';
import { hasFormChanged, IqserEventTarget } from '../utils'; import { hasFormChanged } from '../utils/functions';
import { IqserEventTarget } from '../utils/types/events.type';
const DIALOG_CONTAINER = 'mat-dialog-container'; const DIALOG_CONTAINER = 'mat-dialog-container';
const DATA_TYPE_SYMBOL = Symbol.for('DATA_TYPE'); const DATA_TYPE_SYMBOL = Symbol.for('DATA_TYPE');
@ -13,7 +14,7 @@ export type DATA_TYPE = typeof DATA_TYPE_SYMBOL;
export type RETURN_TYPE = typeof RETURN_TYPE_SYMBOL; export type RETURN_TYPE = typeof RETURN_TYPE_SYMBOL;
@Directive() @Directive()
export abstract class IqserDialogComponent<ComponentType, DataType = null, ReturnType = void> { export abstract class IqserDialogComponent<ComponentType, DataType, ReturnType> {
readonly [DATA_TYPE_SYMBOL]!: DataType; readonly [DATA_TYPE_SYMBOL]!: DataType;
readonly [RETURN_TYPE_SYMBOL]!: ReturnType; readonly [RETURN_TYPE_SYMBOL]!: ReturnType;
@ -22,8 +23,6 @@ export abstract class IqserDialogComponent<ComponentType, DataType = null, Retur
readonly data = inject<DataType>(MAT_DIALOG_DATA); readonly data = inject<DataType>(MAT_DIALOG_DATA);
readonly dialog = inject(MatDialog); readonly dialog = inject(MatDialog);
readonly form?: FormGroup; readonly form?: FormGroup;
readonly ignoredKeys: string[] = [];
initialFormValue: Record<string, unknown> = {}; initialFormValue: Record<string, unknown> = {};
constructor(private readonly _editMode = false) { constructor(private readonly _editMode = false) {
@ -39,7 +38,7 @@ export abstract class IqserDialogComponent<ComponentType, DataType = null, Retur
} }
get changed(): boolean { get changed(): boolean {
return !this.form || hasFormChanged(this.form, this.initialFormValue, this.ignoredKeys); return !this.form || hasFormChanged(this.form, this.initialFormValue);
} }
get disabled(): boolean { get disabled(): boolean {

View File

@ -1,8 +1,9 @@
import { booleanAttribute, Directive, input } from '@angular/core'; import { booleanAttribute, Directive, Input } from '@angular/core';
@Directive({ @Directive({
selector: '[iqserDisableStopPropagation]', selector: '[iqserDisableStopPropagation]',
standalone: true,
}) })
export class DisableStopPropagationDirective { export class DisableStopPropagationDirective {
readonly iqserDisableStopPropagation = input(true, { transform: booleanAttribute }); @Input({ transform: booleanAttribute }) iqserDisableStopPropagation = true;
} }

View File

@ -1,35 +1,39 @@
import { Directive, ElementRef, OnDestroy, OnInit, signal } from '@angular/core'; import { ChangeDetectorRef, Directive, ElementRef, HostBinding, OnDestroy, OnInit } from '@angular/core';
@Directive({ @Directive({
selector: '[iqserHasScrollbar]', selector: '[iqserHasScrollbar]',
host: { standalone: true,
'[class]': '_class()',
},
}) })
export class HasScrollbarDirective implements OnInit, OnDestroy { export class HasScrollbarDirective implements OnInit, OnDestroy {
@HostBinding('class') class = '';
private readonly _resizeObserver: ResizeObserver; private readonly _resizeObserver: ResizeObserver;
protected readonly _class = signal('');
constructor(protected readonly _elementRef: ElementRef) { get hasScrollbar() {
this._resizeObserver = new ResizeObserver(() => { const element = this._elementRef?.nativeElement as HTMLElement;
return element.clientHeight < element.scrollHeight;
}
constructor(
protected readonly _elementRef: ElementRef,
protected readonly _changeDetector: ChangeDetectorRef,
) {
this._resizeObserver = new ResizeObserver(entry => {
this.process(); this.process();
}); });
this._resizeObserver.observe(this._elementRef.nativeElement); this._resizeObserver.observe(this._elementRef.nativeElement);
} }
private get _hasScrollbar() {
const element = this._elementRef?.nativeElement as HTMLElement;
return element.clientHeight < element.scrollHeight;
}
ngOnInit() { ngOnInit() {
setTimeout(() => this.process(), 0); setTimeout(() => this.process(), 0);
} }
process() { process() {
const newClass = this._hasScrollbar ? 'has-scrollbar' : ''; const newClass = this.hasScrollbar ? 'has-scrollbar' : '';
this._class.set(newClass); if (this.class !== newClass) {
this.class = newClass;
this._changeDetector.markForCheck();
}
} }
ngOnDestroy() { ngOnDestroy() {

View File

@ -2,6 +2,7 @@ import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/c
@Directive({ @Directive({
selector: '[iqserHiddenAction]', selector: '[iqserHiddenAction]',
standalone: true,
}) })
export class HiddenActionDirective { export class HiddenActionDirective {
@Input() requiredClicks = 4; @Input() requiredClicks = 4;

View File

@ -3,6 +3,7 @@ import { NGXLogger } from 'ngx-logger';
@Directive({ @Directive({
selector: '[iqserPreventDefault]', selector: '[iqserPreventDefault]',
standalone: true,
}) })
export class PreventDefaultDirective { export class PreventDefaultDirective {
readonly #logger = inject(NGXLogger); readonly #logger = inject(NGXLogger);

View File

@ -1,9 +1,10 @@
import { booleanAttribute, Directive, HostListener, inject, Input } from '@angular/core'; import { booleanAttribute, Directive, HostListener, inject, Input } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { DisableStopPropagationDirective } from './disable-stop-propagation.directive'; import { DisableStopPropagationDirective } from './disable-stop-propagation.directive';
import { NGXLogger } from 'ngx-logger';
@Directive({ @Directive({
selector: '[iqserStopPropagation]', selector: '[iqserStopPropagation]',
standalone: true,
}) })
export class StopPropagationDirective { export class StopPropagationDirective {
readonly #disableStopPropagation = inject(DisableStopPropagationDirective, { optional: true }); readonly #disableStopPropagation = inject(DisableStopPropagationDirective, { optional: true });
@ -12,7 +13,7 @@ export class StopPropagationDirective {
@HostListener('click', ['$event']) @HostListener('click', ['$event'])
onClick($event: Event) { onClick($event: Event) {
if (this.#disableStopPropagation?.iqserDisableStopPropagation()) { if (this.#disableStopPropagation?.iqserDisableStopPropagation) {
this.#logger.info('[CLICK] iqserStopPropagation is disabled by iqserDisableStopPropagation'); this.#logger.info('[CLICK] iqserStopPropagation is disabled by iqserDisableStopPropagation');
return; return;
} }

View File

@ -2,6 +2,7 @@ import { Directive, ElementRef, HostListener, Input, OnDestroy } from '@angular/
@Directive({ @Directive({
selector: '[iqserSyncWidth]', selector: '[iqserSyncWidth]',
standalone: true,
}) })
export class SyncWidthDirective implements OnDestroy { export class SyncWidthDirective implements OnDestroy {
@Input() iqserSyncWidth!: string; @Input() iqserSyncWidth!: string;

View File

@ -1,5 +1,12 @@
<div [ngStyle]="styles()" class="empty-state"> <div
@if (icon(); as icon) { [ngStyle]="{
'padding-top': verticalPadding + 'px',
'padding-left': horizontalPadding + 'px',
'padding-right': horizontalPadding + 'px',
}"
class="empty-state"
>
@if (icon) {
<mat-icon [svgIcon]="icon"></mat-icon> <mat-icon [svgIcon]="icon"></mat-icon>
} }
@ -7,15 +14,15 @@
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>
<div [innerHTML]="text()" class="heading-l"></div> <div [innerHTML]="text" class="heading-l"></div>
@if (showButton() && this.action.observed) { @if (showButton) {
<iqser-icon-button <iqser-icon-button
(action)="action.emit()" (action)="action.emit()"
[buttonId]="buttonId()" [buttonId]="buttonId"
[icon]="buttonIcon()" [icon]="buttonIcon"
[attr.help-mode-key]="helpModeKey()" [attr.help-mode-key]="helpModeKey"
[label]="buttonLabel()" [label]="buttonLabel"
[type]="iconButtonTypes.primary" [type]="iconButtonTypes.primary"
></iqser-icon-button> ></iqser-icon-button>
} }

View File

@ -1,42 +1,32 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { IconButtonComponent, IconButtonTypes } from '../buttons';
import { randomString } from '../utils';
import { NgStyle } from '@angular/common'; import { NgStyle } from '@angular/common';
import {
booleanAttribute,
ChangeDetectionStrategy,
Component,
computed,
EventEmitter,
input,
numberAttribute,
Output,
} from '@angular/core';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { IconButtonComponent } from '../buttons/icon-button/icon-button.component';
import { IconButtonTypes } from '../buttons/types/icon-button.type';
import { randomString } from '../utils/functions';
@Component({ @Component({
selector: 'iqser-empty-state', selector: 'iqser-empty-state [text]',
templateUrl: './empty-state.component.html', templateUrl: './empty-state.component.html',
styleUrls: ['./empty-state.component.scss'], styleUrls: ['./empty-state.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [NgStyle, MatIconModule, IconButtonComponent], imports: [NgStyle, MatIconModule, IconButtonComponent],
}) })
export class EmptyStateComponent { export class EmptyStateComponent implements OnInit {
protected readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
readonly text = input.required<string>(); @Input() text!: string;
readonly icon = input<string>(); @Input() icon?: string;
readonly showButton = input(true, { transform: booleanAttribute }); @Input() showButton = true;
readonly buttonIcon = input('iqser:plus'); @Input() buttonIcon = 'iqser:plus';
readonly buttonLabel = input<string>(); @Input() buttonLabel?: string;
readonly buttonId = input(`${randomString()}-icon-button`); @Input() buttonId = `${randomString()}-icon-button`;
readonly horizontalPadding = input(100, { transform: numberAttribute }); @Input() horizontalPadding = 100;
readonly verticalPadding = input(120, { transform: numberAttribute }); @Input() verticalPadding = 120;
protected readonly styles = computed(() => ({ @Input() helpModeKey?: string;
'padding-top': this.verticalPadding() + 'px',
'padding-left': this.horizontalPadding() + 'px',
'padding-right': this.horizontalPadding() + 'px',
}));
readonly helpModeKey = input<string>();
@Output() readonly action = new EventEmitter(); @Output() readonly action = new EventEmitter();
ngOnInit(): void {
this.showButton = this.showButton && this.action.observed;
}
} }

View File

@ -1,4 +1,4 @@
@if (connectionStatus(); as status) { @if (errorService.connectionStatus$ | async; as status) {
<div [@animateOpenClose]="status" [ngClass]="status" class="indicator flex-align-items-center"> <div [@animateOpenClose]="status" [ngClass]="status" class="indicator flex-align-items-center">
<span [translate]="connectionStatusTranslations[status]"></span> <span [translate]="connectionStatusTranslations[status]"></span>
</div> </div>

View File

@ -1,7 +1,6 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { connectionStatusTranslations } from '../../translations'; import { connectionStatusTranslations } from '../../translations';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { ErrorService } from '../error.service'; import { ErrorService } from '../error.service';
@Component({ @Component({
@ -17,9 +16,8 @@ import { ErrorService } from '../error.service';
]), ]),
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
}) })
export class ConnectionStatusComponent { export class ConnectionStatusComponent {
protected readonly connectionStatusTranslations = connectionStatusTranslations; connectionStatusTranslations = connectionStatusTranslations;
protected readonly connectionStatus = toSignal(inject(ErrorService).connectionStatus$); protected readonly errorService = inject(ErrorService);
} }

View File

@ -1,18 +1,18 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; import { ChangeDetectionStrategy, Component } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { IconButtonTypes } from '../../buttons'; import { IconButtonTypes } from '../../buttons';
import { CustomError, ErrorService, ErrorType } from '../error.service'; import { CustomError, ErrorService, ErrorType } from '../error.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Component({ @Component({
selector: 'iqser-full-page-error', selector: 'iqser-full-page-error',
templateUrl: './full-page-error.component.html', templateUrl: './full-page-error.component.html',
styleUrls: ['./full-page-error.component.scss'], styleUrls: ['./full-page-error.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
}) })
export class FullPageErrorComponent { export class FullPageErrorComponent {
protected readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
protected readonly errorService = inject(ErrorService);
constructor(readonly errorService: ErrorService) {}
errorTitle(error: ErrorType): string { errorTitle(error: ErrorType): string {
return error instanceof CustomError ? error.label : _('error.title'); return error instanceof CustomError ? error.label : _('error.title');

View File

@ -9,12 +9,10 @@
></iqser-input-with-action> ></iqser-input-with-action>
</div> </div>
} }
<ng-container *ngTemplateOutlet="filterHeader"></ng-container> <ng-container *ngTemplateOutlet="filterHeader"></ng-container>
@if (primaryFilters$ | async; as filters) { @if (primaryFilters$ | async; as filters) {
<div class="filter-content"> <div class="filter-content">
@for (filter of filters; track filter.id) { @for (filter of filters; track filter) {
<ng-container <ng-container
[ngTemplateOutletContext]="{ [ngTemplateOutletContext]="{
filter: filter, filter: filter,
@ -26,14 +24,12 @@
} }
</div> </div>
} }
@if (secondaryFilterGroup$ | async; as secondaryGroup) { @if (secondaryFilterGroup$ | async; as secondaryGroup) {
<div class="filter-options"> <div class="filter-options">
<div class="filter-menu-options"> <div class="filter-menu-options">
<div class="all-caps-label" translate="filter-menu.filter-options"></div> <div class="all-caps-label" translate="filter-menu.filter-options"></div>
</div> </div>
@for (filter of secondaryGroup.filters; track filter) {
@for (filter of secondaryGroup.filters; track filter.id) {
<ng-container <ng-container
[ngTemplateOutletContext]="{ [ngTemplateOutletContext]="{
filter: filter, filter: filter,
@ -55,11 +51,7 @@
<ng-template #filterHeader> <ng-template #filterHeader>
@if (primaryFilterGroup$ | async; as primaryGroup) { @if (primaryFilterGroup$ | async; as primaryGroup) {
<div class="filter-menu-header"> <div class="filter-menu-header">
<div <div [translateParams]="{ count: primaryGroup.filters.length }" [translate]="primaryFiltersLabel" class="all-caps-label"></div>
[translateParams]="{ count: primaryGroup.filters.length }"
[translate]="primaryFiltersLabel()"
class="all-caps-label"
></div>
<div class="actions"> <div class="actions">
@if (!primaryGroup.singleSelect) { @if (!primaryGroup.singleSelect) {
<div <div
@ -69,9 +61,8 @@
translate="actions.all" translate="actions.all"
></div> ></div>
} }
<div <div
(click)="deactivatePrimaryFilters()" (click)="deactivateFilters()"
class="all-caps-label primary pointer" class="all-caps-label primary pointer"
iqserStopPropagation iqserStopPropagation
translate="actions.none" translate="actions.none"
@ -113,27 +104,25 @@
></ng-container> ></ng-container>
</mat-checkbox> </mat-checkbox>
<ng-container [ngTemplateOutletContext]="{ filter: filter }" [ngTemplateOutlet]="actionsTemplate()"></ng-container> <ng-container [ngTemplateOutletContext]="{ filter: filter }" [ngTemplateOutlet]="actionsTemplate"></ng-container>
</div> </div>
@if (filter.children?.length && filter.expanded) { @if (filter.children?.length && filter.expanded) {
<div> <div>
@for (child of filter.children; track child) { @for (child of filter.children; track child) {
@if (!child.hidden) { <div class="padding-left mat-mdc-menu-item" iqserStopPropagation>
<div class="padding-left mat-mdc-menu-item" iqserStopPropagation> <mat-checkbox
<mat-checkbox (click)="filterCheckboxClicked(child, filterGroup, filter)"
(click)="filterCheckboxClicked(child, filterGroup, filter)" [checked]="child.checked"
[checked]="child.checked" iqserStopPropagation
iqserStopPropagation >
> <ng-container
<ng-container [ngTemplateOutletContext]="{ filter: child }"
[ngTemplateOutletContext]="{ filter: child }" [ngTemplateOutlet]="filterGroup.filterTemplate ?? defaultFilterLabelTemplate"
[ngTemplateOutlet]="filterGroup.filterTemplate ?? defaultFilterLabelTemplate" ></ng-container>
></ng-container> </mat-checkbox>
</mat-checkbox> <ng-container [ngTemplateOutletContext]="{ filter: child }" [ngTemplateOutlet]="actionsTemplate"></ng-container>
<ng-container [ngTemplateOutletContext]="{ filter: child }" [ngTemplateOutlet]="actionsTemplate()"></ng-container> </div>
</div>
}
} }
</div> </div>
} }

View File

@ -1,5 +1,5 @@
import { AsyncPipe, NgTemplateOutlet } from '@angular/common'; import { AsyncPipe, NgForOf, NgIf, NgTemplateOutlet } from '@angular/common';
import { ChangeDetectionStrategy, Component, effect, ElementRef, inject, input, numberAttribute, OnInit, TemplateRef } from '@angular/core'; import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, TemplateRef } from '@angular/core';
import { MAT_CHECKBOX_DEFAULT_OPTIONS, MatCheckbox } from '@angular/material/checkbox'; import { MAT_CHECKBOX_DEFAULT_OPTIONS, MatCheckbox } from '@angular/material/checkbox';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -23,7 +23,7 @@ const atLeastOneIsExpandable = pipe(
); );
@Component({ @Component({
selector: 'iqser-filter-card', selector: 'iqser-filter-card [primaryFiltersSlug]',
templateUrl: './filter-card.component.html', templateUrl: './filter-card.component.html',
styleUrls: ['./filter-card.component.scss'], styleUrls: ['./filter-card.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -37,29 +37,39 @@ const atLeastOneIsExpandable = pipe(
}, },
}, },
], ],
imports: [AsyncPipe, InputWithActionComponent, NgTemplateOutlet, TranslateModule, MatIcon, MatCheckbox, StopPropagationDirective], standalone: true,
imports: [
AsyncPipe,
InputWithActionComponent,
NgTemplateOutlet,
TranslateModule,
MatIcon,
MatCheckbox,
StopPropagationDirective,
NgIf,
NgForOf,
],
}) })
export class FilterCardComponent implements OnInit { export class FilterCardComponent implements OnInit {
readonly #filterService = inject(FilterService); @Input() primaryFiltersSlug!: string;
readonly #elementRef = inject(ElementRef); @Input() fileId?: string;
protected readonly searchService = inject<SearchService<Filter>>(SearchService); @Input() actionsTemplate?: TemplateRef<unknown>;
readonly primaryFiltersSlug = input.required<string>(); @Input() secondaryFiltersSlug = '';
readonly fileId = input<string>(); @Input() primaryFiltersLabel: string = _('filter-menu.filter-types');
readonly actionsTemplate = input<TemplateRef<unknown>>(); @Input() minWidth = 350;
readonly secondaryFiltersSlug = input('');
readonly primaryFiltersLabel = input<string>(_('filter-menu.filter-types'));
readonly minWidth = input(350, { transform: numberAttribute });
primaryFilterGroup$!: Observable<IFilterGroup | undefined>; primaryFilterGroup$!: Observable<IFilterGroup | undefined>;
secondaryFilterGroup$!: Observable<IFilterGroup | undefined>; secondaryFilterGroup$!: Observable<IFilterGroup | undefined>;
primaryFilters$!: Observable<IFilter[] | undefined>; primaryFilters$!: Observable<IFilter[] | undefined>;
atLeastOneFilterIsExpandable$?: Observable<boolean>; atLeastOneFilterIsExpandable$?: Observable<boolean>;
atLeastOneSecondaryFilterIsExpandable$?: Observable<boolean>; atLeastOneSecondaryFilterIsExpandable$?: Observable<boolean>;
constructor() { constructor(
effect(() => { readonly filterService: FilterService,
(this.#elementRef.nativeElement as HTMLElement).style.setProperty('--filter-card-min-width', `${this.minWidth()}px`); readonly searchService: SearchService<Filter>,
}); private readonly _elementRef: ElementRef,
} ) {}
private get _primaryFilters$(): Observable<IFilter[]> { private get _primaryFilters$(): Observable<IFilter[]> {
return combineLatest([this.primaryFilterGroup$, this.searchService.valueChanges$]).pipe( return combineLatest([this.primaryFilterGroup$, this.searchService.valueChanges$]).pipe(
@ -69,37 +79,37 @@ export class FilterCardComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.primaryFilterGroup$ = this.#filterService.getGroup$(this.primaryFiltersSlug()).pipe(shareLast()); this.primaryFilterGroup$ = this.filterService.getGroup$(this.primaryFiltersSlug).pipe(shareLast());
this.secondaryFilterGroup$ = this.#filterService.getGroup$(this.secondaryFiltersSlug()).pipe(shareLast()); this.secondaryFilterGroup$ = this.filterService.getGroup$(this.secondaryFiltersSlug).pipe(shareLast());
this.primaryFilters$ = this._primaryFilters$; this.primaryFilters$ = this._primaryFilters$;
this.atLeastOneFilterIsExpandable$ = atLeastOneIsExpandable(this.primaryFilterGroup$); this.atLeastOneFilterIsExpandable$ = atLeastOneIsExpandable(this.primaryFilterGroup$);
this.atLeastOneSecondaryFilterIsExpandable$ = atLeastOneIsExpandable(this.secondaryFilterGroup$); this.atLeastOneSecondaryFilterIsExpandable$ = atLeastOneIsExpandable(this.secondaryFilterGroup$);
(this._elementRef.nativeElement as HTMLElement).style.setProperty('--filter-card-min-width', `${this.minWidth}px`);
} }
filterCheckboxClicked(nestedFilter: INestedFilter, filterGroup: IFilterGroup, parent?: INestedFilter): void { filterCheckboxClicked(nestedFilter: INestedFilter, filterGroup: IFilterGroup, parent?: INestedFilter): void {
this.#filterService.filterCheckboxClicked({ this.filterService.filterCheckboxClicked({
nestedFilter, nestedFilter,
filterGroup, filterGroup,
parent, parent,
primaryFiltersSlug: this.primaryFiltersSlug(), primaryFiltersSlug: this.primaryFiltersSlug,
fileId: this.fileId,
}); });
this.#filterService.updateFiltersInLocalStorage(this.fileId());
} }
deactivatePrimaryFilters() { deactivateFilters() {
this.#filterService.deactivateFilters({ primaryFiltersSlug: this.primaryFiltersSlug() }); this.filterService.deactivateFilters({ primaryFiltersSlug: this.primaryFiltersSlug });
this.#filterService.updateFiltersInLocalStorage(this.fileId());
} }
activatePrimaryFilters(): void { activatePrimaryFilters(): void {
this.#filterService.setFilters(this.primaryFiltersSlug(), true); this.filterService.setFilters(this.primaryFiltersSlug, true);
this.#filterService.updateFiltersInLocalStorage(this.fileId());
} }
toggleFilterExpanded(nestedFilter: INestedFilter): void { toggleFilterExpanded(nestedFilter: INestedFilter): void {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
nestedFilter.expanded = !nestedFilter.expanded; nestedFilter.expanded = !nestedFilter.expanded;
this.#filterService.refresh(); this.filterService.refresh();
} }
} }

View File

@ -16,7 +16,6 @@ function copySettings(oldFilters: INestedFilter[], newFilters: INestedFilter[])
const newFilter = newFilters.find(f => f.id === filter.id); const newFilter = newFilters.find(f => f.id === filter.id);
if (newFilter) { if (newFilter) {
newFilter.checked = filter.checked; newFilter.checked = filter.checked;
newFilter.expanded = filter.expanded;
newFilter.indeterminate = filter.indeterminate; newFilter.indeterminate = filter.indeterminate;
if (filter.children && newFilter.children) { if (filter.children && newFilter.children) {
copySettings(filter.children, newFilter.children); copySettings(filter.children, newFilter.children);

View File

@ -14,6 +14,7 @@ export interface CheckboxClickedParams {
nestedFilter: INestedFilter; nestedFilter: INestedFilter;
filterGroup: IFilterGroup; filterGroup: IFilterGroup;
parent?: INestedFilter; parent?: INestedFilter;
fileId?: string;
primaryFiltersSlug: string; primaryFiltersSlug: string;
} }
@ -23,10 +24,6 @@ export interface DeactivateFiltersParams {
exceptedFilterId?: string; exceptedFilterId?: string;
} }
const PRIMARY_FILTERS = 'primaryFilters';
const SECONDARY_FILTERS = 'secondaryFilters';
const WORKLOAD_FILTERS_KEY = 'workload-filters';
@Injectable() @Injectable()
export class FilterService { export class FilterService {
readonly #singleFilters = new Map<string, BehaviorSubject<IFilter | undefined>>(); readonly #singleFilters = new Map<string, BehaviorSubject<IFilter | undefined>>();
@ -239,7 +236,7 @@ export class FilterService {
} }
filterCheckboxClicked(params: CheckboxClickedParams) { filterCheckboxClicked(params: CheckboxClickedParams) {
const { filterGroup, nestedFilter, parent, primaryFiltersSlug } = params; const { filterGroup, nestedFilter, parent, fileId, primaryFiltersSlug } = params;
if (filterGroup.singleSelect) { if (filterGroup.singleSelect) {
this.deactivateFilters({ primaryFiltersSlug, exceptedFilterId: nestedFilter.id }); this.deactivateFilters({ primaryFiltersSlug, exceptedFilterId: nestedFilter.id });
@ -262,22 +259,23 @@ export class FilterService {
} }
this.refresh(); this.refresh();
this.#updateFiltersInLocalStorage(fileId);
} }
updateFiltersInLocalStorage(fileId?: string) { #updateFiltersInLocalStorage(fileId?: string) {
if (fileId) { if (fileId) {
const primaryFilters = this.getGroup(PRIMARY_FILTERS); const primaryFilters = this.getGroup('primaryFilters');
const secondaryFilters = this.getGroup(SECONDARY_FILTERS); const secondaryFilters = this.getGroup('secondaryFilters');
const filters: LocalStorageFilters = { const filters: LocalStorageFilters = {
primaryFilters: extractFilterValues(primaryFilters?.filters), primaryFilters: extractFilterValues(primaryFilters?.filters),
secondaryFilters: extractFilterValues(secondaryFilters?.filters), secondaryFilters: extractFilterValues(secondaryFilters?.filters),
}; };
const workloadFiltersString = localStorage.getItem(WORKLOAD_FILTERS_KEY) ?? '{}'; const workloadFiltersString = localStorage.getItem('workload-filters') ?? '{}';
const workloadFilters = JSON.parse(workloadFiltersString); const workloadFilters = JSON.parse(workloadFiltersString);
workloadFilters[fileId] = filters; workloadFilters[fileId] = filters;
localStorage.setItem(WORKLOAD_FILTERS_KEY, JSON.stringify(workloadFilters)); localStorage.setItem('workload-filters', JSON.stringify(workloadFilters));
} }
} }
} }

View File

@ -1,16 +1,14 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ChevronButtonComponent } from '../buttons/chevron-button/chevron-button.component'; import { ChevronButtonComponent, IconButtonComponent } from '../buttons';
import { IconButtonComponent } from '../buttons/icon-button/icon-button.component';
import { PreventDefaultDirective } from '../directives/prevent-default.directive';
import { StopPropagationDirective } from '../directives/stop-propagation.directive';
import { InputWithActionComponent } from '../inputs/input-with-action/input-with-action.component';
import { QuickFiltersComponent } from './quick-filters/quick-filters.component'; import { QuickFiltersComponent } from './quick-filters/quick-filters.component';
import { SingleFilterComponent } from './single-filter/single-filter.component'; import { SingleFilterComponent } from './single-filter/single-filter.component';
import { MatIconModule } from '@angular/material/icon';
import { PreventDefaultDirective, StopPropagationDirective } from '../directives';
import { InputWithActionComponent } from '../inputs';
const components = [QuickFiltersComponent, SingleFilterComponent]; const components = [QuickFiltersComponent, SingleFilterComponent];

View File

@ -10,6 +10,5 @@ export interface IFilter {
readonly required?: boolean; readonly required?: boolean;
readonly disabled?: boolean; readonly disabled?: boolean;
readonly helpModeKey?: string; readonly helpModeKey?: string;
readonly hidden?: boolean;
readonly metadata?: Record<string, any>; readonly metadata?: Record<string, any>;
} }

View File

@ -10,7 +10,6 @@ export class Filter implements IFilter, IListable {
readonly checker?: (obj?: unknown) => boolean; readonly checker?: (obj?: unknown) => boolean;
readonly skipTranslation?: boolean; readonly skipTranslation?: boolean;
readonly metadata?: Record<string, any>; readonly metadata?: Record<string, any>;
readonly hidden?: boolean;
checked: boolean; checked: boolean;
matches?: number; matches?: number;
@ -26,7 +25,6 @@ export class Filter implements IFilter, IListable {
this.required = !!filter.required; this.required = !!filter.required;
this.skipTranslation = !!filter.skipTranslation; this.skipTranslation = !!filter.skipTranslation;
this.metadata = filter.metadata; this.metadata = filter.metadata;
this.hidden = !!filter.hidden;
} }
get searchKey(): string { get searchKey(): string {

View File

@ -8,8 +8,8 @@ export class NestedFilter extends Filter implements INestedFilter, IListable {
disabled?: boolean; disabled?: boolean;
helpModeKey?: string; helpModeKey?: string;
readonly children: Filter[]; readonly children: Filter[];
override readonly skipTranslation?: boolean; readonly skipTranslation?: boolean;
override readonly metadata?: Record<string, any>; readonly metadata?: Record<string, any>;
constructor(nestedFilter: INestedFilter) { constructor(nestedFilter: INestedFilter) {
super(nestedFilter); super(nestedFilter);

View File

@ -11,7 +11,6 @@
buttonId="{{ primaryGroup.slug }}" buttonId="{{ primaryGroup.slug }}"
></iqser-icon-button> ></iqser-icon-button>
} }
@if (!primaryGroup.icon) { @if (!primaryGroup.icon) {
<iqser-chevron-button <iqser-chevron-button
[attr.aria-expanded]="expanded$ | async" [attr.aria-expanded]="expanded$ | async"
@ -22,7 +21,6 @@
[showDot]="hasActiveFilters$ | async" [showDot]="hasActiveFilters$ | async"
></iqser-chevron-button> ></iqser-chevron-button>
} }
<mat-menu <mat-menu
#filterMenu="matMenu" #filterMenu="matMenu"
(closed)="expanded.next(false)" (closed)="expanded.next(false)"

View File

@ -1,4 +1,4 @@
import { AsyncPipe } from '@angular/common'; import { AsyncPipe, NgIf } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input, OnInit, TemplateRef } from '@angular/core'; import { ChangeDetectionStrategy, Component, Input, OnInit, TemplateRef } from '@angular/core';
import { MatMenu, MatMenuContent, MatMenuTrigger } from '@angular/material/menu'; import { MatMenu, MatMenuContent, MatMenuTrigger } from '@angular/material/menu';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -28,7 +28,9 @@ import { IFilterGroup } from '../models/filter-group.model';
FilterCardComponent, FilterCardComponent,
StopPropagationDirective, StopPropagationDirective,
MatMenuContent, MatMenuContent,
NgIf,
], ],
standalone: true,
}) })
export class PopupFilterComponent implements OnInit { export class PopupFilterComponent implements OnInit {
@Input() primaryFiltersSlug!: string; @Input() primaryFiltersSlug!: string;

View File

@ -1,5 +1,5 @@
@if (quickFilters$ | async; as filters) { @if (quickFilters$ | async; as filters) {
@for (filter of filters; track filter.id) { @for (filter of filters; track filter) {
<div <div
(click)="filterService.toggleFilter('quickFilters', filter.id)" (click)="filterService.toggleFilter('quickFilters', filter.id)"
[class.active]="filter.checked" [class.active]="filter.checked"

View File

@ -6,7 +6,6 @@ import { FilterService } from '../filter.service';
templateUrl: './quick-filters.component.html', templateUrl: './quick-filters.component.html',
styleUrls: ['./quick-filters.component.scss'], styleUrls: ['./quick-filters.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
}) })
export class QuickFiltersComponent { export class QuickFiltersComponent {
readonly quickFilters$ = this.filterService.getFilterModels$('quickFilters'); readonly quickFilters$ = this.filterService.getFilterModels$('quickFilters');

View File

@ -1,18 +1,18 @@
import { Component, computed, effect, input, output, signal, untracked } from '@angular/core'; import { Component, computed, effect, input, output, signal, untracked } from '@angular/core';
import { MatCheckbox } from '@angular/material/checkbox';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { CircleButtonComponent, IconButtonComponent } from '../../buttons'; import { MatCheckbox } from '@angular/material/checkbox';
import { ChevronButtonComponent } from '../../buttons/chevron-button/chevron-button.component'; import { ChevronButtonComponent, CircleButtonComponent, IconButtonComponent } from '../../buttons';
import { StopPropagationDirective } from '../../directives'; import { StopPropagationDirective } from '../../directives';
import { InputWithActionComponent } from '../../inputs/input-with-action/input-with-action.component'; import { InputWithActionComponent } from '../../inputs';
import { SimpleFilterOption } from '../models/simple-filter-option'; import { SimpleFilterOption } from '../models/simple-filter-option';
@Component({ @Component({
selector: 'iqser-simple-popup-filter', selector: 'iqser-simple-popup-filter',
templateUrl: './simple-popup-filter.component.html', templateUrl: './simple-popup-filter.component.html',
styleUrls: ['./simple-popup-filter.component.scss'], styleUrls: ['./simple-popup-filter.component.scss'],
standalone: true,
imports: [ imports: [
MatMenuModule, MatMenuModule,
IconButtonComponent, IconButtonComponent,
@ -22,6 +22,7 @@ import { SimpleFilterOption } from '../models/simple-filter-option';
TranslateModule, TranslateModule,
MatCheckbox, MatCheckbox,
IconButtonComponent, IconButtonComponent,
ChevronButtonComponent,
CircleButtonComponent, CircleButtonComponent,
], ],
}) })

View File

@ -7,7 +7,6 @@ import { IFilter } from '../models/filter.model';
selector: 'iqser-single-filter', selector: 'iqser-single-filter',
templateUrl: './single-filter.component.html', templateUrl: './single-filter.component.html',
styleUrls: ['./single-filter.component.scss'], styleUrls: ['./single-filter.component.scss'],
standalone: false,
}) })
export class SingleFilterComponent { export class SingleFilterComponent {
@Input() filter!: IFilter; @Input() filter!: IFilter;

View File

@ -2,14 +2,11 @@
[id]="buttonId" [id]="buttonId"
class="help-mode-slide-toggle" class="help-mode-slide-toggle"
[class.dialog-toggle]="dialogButton" [class.dialog-toggle]="dialogButton"
[class.active]="helpModeService.isHelpModeActive()" [class.active]="helpModeService.isHelpModeActive"
[matTooltip]="buttonTooltip"
#helpModeButton
> >
<input type="checkbox" class="toggle-input" [checked]="helpModeService.isHelpModeActive()" (change)="toggleHelpMode()" /> <input type="checkbox" class="toggle-input" [checked]="helpModeService.isHelpModeActive" (change)="toggleHelpMode()" />
<div class="toggle-track"> <div class="toggle-track"></div>
<div class="toggle-thumb"> <div class="toggle-thumb">
<mat-icon svgIcon="iqser:help-outline" [class.active-thumb]="helpModeService.isHelpModeActive()"></mat-icon> <mat-icon svgIcon="iqser:help-outline" [class.active-thumb]="helpModeService.isHelpModeActive"></mat-icon>
</div>
</div> </div>
</label> </label>

View File

@ -14,7 +14,7 @@
&.active, &.active,
&.dialog-toggle { &.dialog-toggle {
z-index: 1200; z-index: 1100;
} }
.toggle-input { .toggle-input {
@ -22,24 +22,27 @@
} }
.toggle-track { .toggle-track {
position: relative; position: absolute;
display: flex; top: 50%;
align-items: center; left: 0;
justify-content: start;
width: 100%; width: 100%;
height: 25px; height: 25px;
background-color: var(--iqser-grey-4); background-color: var(--iqser-grey-4);
border-radius: 20px; border-radius: 20px;
transform: translateY(-50%);
} }
.toggle-thumb { .toggle-thumb {
margin-left: 6%; position: absolute;
top: 50%;
left: 4px;
width: 20px; width: 20px;
height: 20px; height: 20px;
background-color: #fff; background-color: #fff;
border-radius: 50%; border-radius: 50%;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
transition: margin-left 0.3s ease; transform: translateY(-50%);
transition: left 0.3s ease;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -57,9 +60,7 @@
background: var(--iqser-helpmode-primary); background: var(--iqser-helpmode-primary);
} }
.toggle-input:checked + .toggle-track { .toggle-input:checked + .toggle-track + .toggle-thumb {
.toggle-thumb { left: calc(100% - 22px);
margin-left: 43.5%;
}
} }
} }

View File

@ -1,55 +1,28 @@
/* eslint-disable @angular-eslint/prefer-on-push-component-change-detection */ /* eslint-disable @angular-eslint/prefer-on-push-component-change-detection */
import { Component, effect, ElementRef, HostListener, Input, OnDestroy, OnInit, viewChild } from '@angular/core'; import { AfterViewInit, Component, ElementRef, HostListener, Input, OnDestroy, OnInit } from '@angular/core';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
import { HelpModeService } from '../help-mode.service'; import { HelpModeService } from '../help-mode.service';
import { MatTooltip } from '@angular/material/tooltip';
import { TranslateService } from '@ngx-translate/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Component({ @Component({
selector: 'iqser-help-button', selector: 'iqser-help-button',
templateUrl: './help-button.component.html', templateUrl: './help-button.component.html',
styleUrls: ['./help-button.component.scss'], styleUrls: ['./help-button.component.scss'],
imports: [MatIcon, MatTooltip], standalone: true,
imports: [MatIcon],
}) })
export class HelpButtonComponent implements OnInit, OnDestroy { export class HelpButtonComponent implements OnInit, AfterViewInit, OnDestroy {
#helpModeHasBeenActivated = false;
readonly helpModeButton = viewChild.required<ElementRef>('helpModeButton');
@Input() dialogButton = true; @Input() dialogButton = true;
helpModeButton: HTMLElement;
constructor( constructor(
private readonly _elementRef: ElementRef, private readonly _elementRef: ElementRef,
private readonly _translateService: TranslateService,
readonly helpModeService: HelpModeService, readonly helpModeService: HelpModeService,
) { ) {}
effect(() => {
if (this.helpModeService.isHelpModeActive()) {
this.#helpModeHasBeenActivated = true;
setTimeout(() => this.#applyActiveButtonStyles(), 300);
} else if (this.#helpModeHasBeenActivated) {
setTimeout(() => this.#applyInactiveButtonStyles(), 300);
}
});
}
get buttonTooltip() {
const translation = this.helpModeService.isHelpModeActive() ? _('help-button.disable') : _('help-button.enable');
return this._translateService.instant(translation);
}
get buttonId() { get buttonId() {
return `help-mode-button${this.dialogButton ? '-dialog' : ''}`; return `help-mode-button${this.dialogButton ? '-dialog' : ''}`;
} }
get currentComponentRect() {
return this._elementRef.nativeElement.getBoundingClientRect();
}
@HostListener('window:resize', ['$event'])
onResize() {
if (this.helpModeService.isHelpModeActive()) this.#applyActiveButtonStyles();
}
ngOnInit() { ngOnInit() {
if (this.dialogButton) { if (this.dialogButton) {
const defaultButton = document.getElementById('help-mode-button') as HTMLElement; const defaultButton = document.getElementById('help-mode-button') as HTMLElement;
@ -57,39 +30,42 @@ export class HelpButtonComponent implements OnInit, OnDestroy {
} }
} }
ngAfterViewInit() {
const currentComponent = this._elementRef.nativeElement;
this.helpModeButton = currentComponent.querySelector('.help-mode-slide-toggle');
if (this.helpModeButton) {
setTimeout(() => {
const currentComponentRect = currentComponent.getBoundingClientRect();
this.helpModeButton.style.setProperty('position', 'absolute');
this.helpModeButton.style.setProperty('top', `${currentComponentRect.top}px`);
this.helpModeButton.style.setProperty('left', `${currentComponentRect.left}px`);
document.body.appendChild(this.helpModeButton);
}, 500);
}
}
ngOnDestroy() { ngOnDestroy() {
document.body.removeChild(this.helpModeButton);
if (this.dialogButton) { if (this.dialogButton) {
const defaultButton = document.getElementById('help-mode-button') as HTMLElement; const defaultButton = document.getElementById('help-mode-button') as HTMLElement;
defaultButton.style.removeProperty('z-index'); defaultButton.style.removeProperty('z-index');
if (!this.helpModeService.isHelpModeActive()) {
const helpButtonElement = document.querySelectorAll('iqser-help-button')[this.dialogButton ? 1 : 0];
if (helpButtonElement.contains(this.helpModeButton().nativeElement))
helpButtonElement?.removeChild(this.helpModeButton().nativeElement);
}
} }
} }
toggleHelpMode(): void { toggleHelpMode(): void {
if (this.helpModeService.isHelpModeActive()) { if (this.helpModeService.isHelpModeActive) {
this.helpModeService.deactivateHelpMode(); this.helpModeService.deactivateHelpMode();
return; return;
} }
this.helpModeService.activateHelpMode(this.dialogButton); this.helpModeService.activateHelpMode(this.dialogButton);
} }
#applyActiveButtonStyles() { @HostListener('window:resize', ['$event'])
this.helpModeButton().nativeElement.style.setProperty('position', 'absolute'); onResize() {
this.helpModeButton().nativeElement.style.setProperty('top', `${this.currentComponentRect.top}px`); const currentComponent = this._elementRef.nativeElement;
this.helpModeButton().nativeElement.style.setProperty('left', `${this.currentComponentRect.left}px`); const currentComponentRect = currentComponent.getBoundingClientRect();
document.body.appendChild(this.helpModeButton().nativeElement); this.helpModeButton?.style.setProperty('top', `${currentComponentRect.top}px`);
} this.helpModeButton?.style.setProperty('left', `${currentComponentRect.left}px`);
#applyInactiveButtonStyles() {
this.helpModeButton().nativeElement.style.setProperty('position', 'relative');
this.helpModeButton().nativeElement.style.setProperty('top', 'unset');
this.helpModeButton().nativeElement.style.setProperty('left', 'unset');
document.body.removeChild(this.helpModeButton().nativeElement);
document.querySelectorAll('iqser-help-button')[this.dialogButton ? 1 : 0]?.appendChild(this.helpModeButton().nativeElement);
} }
} }

View File

@ -12,6 +12,7 @@ const DEFAULT_CDK_OVERLAY_CONTAINER_ZINDEX = '800';
templateUrl: './help-mode-dialog.component.html', templateUrl: './help-mode-dialog.component.html',
styleUrls: ['./help-mode-dialog.component.scss'], styleUrls: ['./help-mode-dialog.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [MatCheckbox, CircleButtonComponent, TranslateModule], imports: [MatCheckbox, CircleButtonComponent, TranslateModule],
}) })
export class HelpModeDialogComponent implements OnInit, OnDestroy { export class HelpModeDialogComponent implements OnInit, OnDestroy {

View File

@ -2,8 +2,8 @@ import { Inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject, firstValueFrom } from 'rxjs'; import { BehaviorSubject, firstValueFrom } from 'rxjs';
import { getConfig } from '../services'; import { getConfig } from '../services/iqser-config.service';
import { IqserUserPreferenceService } from '../services'; import { IqserUserPreferenceService } from '../services/iqser-user-preference.service';
import { HelpModeDialogComponent } from './help-mode-dialog/help-mode-dialog.component'; import { HelpModeDialogComponent } from './help-mode-dialog/help-mode-dialog.component';
import { HELP_MODE_KEYS, MANUAL_BASE_URL } from './tokens'; import { HELP_MODE_KEYS, MANUAL_BASE_URL } from './tokens';
import { HelpModeKey } from './types'; import { HelpModeKey } from './types';
@ -20,7 +20,6 @@ import {
ScrollableParentViews, ScrollableParentViews,
WEB_VIEWER_ELEMENTS, WEB_VIEWER_ELEMENTS,
} from './utils/constants'; } from './utils/constants';
import { toSignal } from '@angular/core/rxjs-interop';
export interface Helper { export interface Helper {
readonly element: HTMLElement; readonly element: HTMLElement;
@ -40,7 +39,6 @@ export class HelpModeService {
#helpers: Record<string, Helper> = {}; #helpers: Record<string, Helper> = {};
#dialogMode = false; #dialogMode = false;
readonly isHelpModeActive$ = this.#isHelpModeActive$.asObservable(); readonly isHelpModeActive$ = this.#isHelpModeActive$.asObservable();
readonly isHelpModeActive = toSignal(this.isHelpModeActive$, { initialValue: false });
readonly helpModeDialogIsOpened$ = this.#helpModeDialogIsOpened$.asObservable(); readonly helpModeDialogIsOpened$ = this.#helpModeDialogIsOpened$.asObservable();
constructor( constructor(
@ -54,6 +52,10 @@ export class HelpModeService {
this.#renderer = this._rendererFactory.createRenderer(null, null); this.#renderer = this._rendererFactory.createRenderer(null, null);
} }
get isHelpModeActive(): boolean {
return this.#isHelpModeActive$.getValue();
}
get helpModeDialogIsOpened(): boolean { get helpModeDialogIsOpened(): boolean {
return this.#helpModeDialogIsOpened$.getValue(); return this.#helpModeDialogIsOpened$.getValue();
} }
@ -76,7 +78,7 @@ export class HelpModeService {
} }
activateHelpMode(dialogMode: boolean = false): void { activateHelpMode(dialogMode: boolean = false): void {
if (!this.isHelpModeActive()) { if (!this.isHelpModeActive) {
document.body.style.setProperty('overflow', 'unset'); document.body.style.setProperty('overflow', 'unset');
this.#isHelpModeActive$.next(true); this.#isHelpModeActive$.next(true);
this.openHelpModeDialog(); this.openHelpModeDialog();
@ -90,7 +92,7 @@ export class HelpModeService {
} }
deactivateHelpMode(): void { deactivateHelpMode(): void {
if (this.isHelpModeActive()) { if (this.isHelpModeActive) {
document.body.style.removeProperty('overflow'); document.body.style.removeProperty('overflow');
this.#isHelpModeActive$.next(false); this.#isHelpModeActive$.next(false);
this.#disableHelperElements(); this.#disableHelperElements();
@ -242,7 +244,6 @@ export class HelpModeService {
const iframe: HTMLIFrameElement = document.getElementById(PDF_TRON_IFRAME_ID) as HTMLIFrameElement; const iframe: HTMLIFrameElement = document.getElementById(PDF_TRON_IFRAME_ID) as HTMLIFrameElement;
const iframeRect = iframe.getBoundingClientRect(); const iframeRect = iframe.getBoundingClientRect();
dimensions.y += iframeRect.top; dimensions.y += iframeRect.top;
dimensions.x += iframeRect.left;
} }
helper.helperElement.style.cssText = ` helper.helperElement.style.cssText = `

View File

@ -3,7 +3,7 @@ import { HelpModeService } from '../help-mode.service';
import { IqserEventTarget } from '../../utils'; import { IqserEventTarget } from '../../utils';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { CircleButtonComponent, CircleButtonTypes } from '../../buttons'; import { CircleButtonComponent, CircleButtonTypes } from '../../buttons';
import { AsyncPipe } from '@angular/common'; import { AsyncPipe, NgIf } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@Component({ @Component({
@ -11,7 +11,8 @@ import { TranslateModule } from '@ngx-translate/core';
templateUrl: './help-mode.component.html', templateUrl: './help-mode.component.html',
styleUrls: ['./help-mode.component.scss'], styleUrls: ['./help-mode.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [AsyncPipe, TranslateModule, CircleButtonComponent], standalone: true,
imports: [AsyncPipe, TranslateModule, NgIf, CircleButtonComponent],
}) })
export class HelpModeComponent { export class HelpModeComponent {
readonly circleButtonTypes = CircleButtonTypes; readonly circleButtonTypes = CircleButtonTypes;
@ -23,7 +24,7 @@ export class HelpModeComponent {
@HostListener('document:keydown.escape', ['$event']) @HostListener('document:keydown.escape', ['$event'])
onEscKeydownHandler(event: KeyboardEvent): void { onEscKeydownHandler(event: KeyboardEvent): void {
if (!this.helpModeService.helpModeDialogIsOpened && this.helpModeService.isHelpModeActive()) { if (!this.helpModeService.helpModeDialogIsOpened && this.helpModeService.isHelpModeActive) {
event?.stopPropagation(); event?.stopPropagation();
this.helpModeService.deactivateHelpMode(); this.helpModeService.deactivateHelpMode();
} }
@ -32,7 +33,7 @@ export class HelpModeComponent {
@HostListener('document:keydown.h', ['$event']) @HostListener('document:keydown.h', ['$event'])
onHKeydownHandler(event: KeyboardEvent): void { onHKeydownHandler(event: KeyboardEvent): void {
const node = (event.target as IqserEventTarget).localName; const node = (event.target as IqserEventTarget).localName;
if (!this.helpModeService.isHelpModeActive() && node !== 'input' && node !== 'textarea') { if (!this.helpModeService.isHelpModeActive && node !== 'input' && node !== 'textarea') {
const dialogMode = !!this._dialog.openDialogs.length; const dialogMode = !!this._dialog.openDialogs.length;
this.helpModeService.activateHelpMode(dialogMode); this.helpModeService.activateHelpMode(dialogMode);
} }
@ -40,14 +41,14 @@ export class HelpModeComponent {
@HostListener('click') @HostListener('click')
onClick(): void { onClick(): void {
if (this.helpModeService.isHelpModeActive()) { if (this.helpModeService.isHelpModeActive) {
this.helpModeService.highlightHelperElements(); this.helpModeService.highlightHelperElements();
} }
} }
@HostListener('window:resize') @HostListener('window:resize')
onResize() { onResize() {
if (this.helpModeService.isHelpModeActive()) { if (this.helpModeService.isHelpModeActive) {
this.helpModeService.updateHelperElements(); this.helpModeService.updateHelperElements();
} }
} }

View File

@ -9,7 +9,7 @@ export const PDF_TRON_IFRAME_ID = 'webviewer-1';
export const WEB_VIEWER_ELEMENTS = [ export const WEB_VIEWER_ELEMENTS = [
{ {
querySelector: '.HeaderItems', querySelector: '.HeaderItems',
documentKey: 'document_viewer_features', documentKey: 'pdf_features',
}, },
]; ];
@ -18,7 +18,6 @@ export const ScrollableParentViews = {
ANNOTATIONS_LIST: 'ANNOTATIONS_LIST', ANNOTATIONS_LIST: 'ANNOTATIONS_LIST',
SCM_EDIT_DIALOG: 'SCM_EDIT_DIALOG', SCM_EDIT_DIALOG: 'SCM_EDIT_DIALOG',
WORKFLOW_VIEW: 'WORKFLOW_VIEW', WORKFLOW_VIEW: 'WORKFLOW_VIEW',
COMPONENTS_VIEW: 'COMPONENTS_VIEW',
} as const; } as const;
export const SCROLLABLE_PARENT_VIEWS_IDS = { export const SCROLLABLE_PARENT_VIEWS_IDS = {
@ -26,7 +25,6 @@ export const SCROLLABLE_PARENT_VIEWS_IDS = {
ANNOTATIONS_LIST: 'annotations-list', ANNOTATIONS_LIST: 'annotations-list',
SCM_EDIT_DIALOG: 'scm-edit', SCM_EDIT_DIALOG: 'scm-edit',
WORKFLOW_VIEW: 'workflow-view', WORKFLOW_VIEW: 'workflow-view',
COMPONENTS_VIEW: 'components-view',
} as const; } as const;
export type ScrollableParentView = keyof typeof ScrollableParentViews; export type ScrollableParentView = keyof typeof ScrollableParentViews;

View File

@ -1,29 +1,19 @@
interface AdditionalField { interface ExtraOption {
label: string; label: string;
description?: string; checked: boolean;
}
interface AdditionalCheck extends AdditionalField {
checked?: boolean;
hidden?: boolean; hidden?: boolean;
disabled?: boolean; disabled?: boolean;
} description?: string;
interface AdditionalInput extends AdditionalField {
value: string;
placeholder?: string;
errorCode?: string;
} }
export interface DetailsRadioOption<I> { export interface DetailsRadioOption<I> {
id?: string; id?: string;
label: string; label: string;
description: string; description: string;
descriptionParams?: Record<string, string | number>; descriptionParams?: Record<string, string>;
icon?: string; icon?: string;
value: I; value: I;
disabled?: boolean; disabled?: boolean;
tooltip?: string; tooltip?: string;
additionalCheck?: AdditionalCheck; extraOption?: ExtraOption;
additionalInput?: AdditionalInput;
} }

View File

@ -1,70 +1,41 @@
<div [class.row]="displayInRow()" class="iqser-input-group"> <div [class.row]="displayInRow" class="iqser-input-group">
@for (option of options(); track option) { @for (option of options; track option) {
<div <div
(click)="toggleOption(option)" (click)="toggleOption(option)"
[class.active]="isSelected(option)" [class.active]="option.value === value?.value"
[class.disabled]="option.disabled" [class.disabled]="option.disabled"
[id]="groupId(option)" [id]="groupId(option)"
[matTooltipPosition]="'above'" [matTooltipPosition]="'above'"
[matTooltip]="option.tooltip || '' | translate" [matTooltip]="option.tooltip || '' | translate"
[ngClass]="{ 'mb-8': !displayInRow(), 'mr-8': displayInRow() }" [ngClass]="{ 'mb-8': !displayInRow, 'mr-8': displayInRow }"
class="option pointer" class="option pointer"
> >
@if (option.icon) { @if (option.icon) {
<div class="icon-option"> <div class="icon-option">
<mat-icon [svgIcon]="option.icon" class="icon"></mat-icon> <mat-icon [svgIcon]="option.icon" class="icon"></mat-icon>
<div class="text"> <div class="text">
<label class="details-radio-label pointer">{{ <label class="details-radio-label pointer">{{ option.label | translate: option.descriptionParams }}</label>
option.label | translate: option.descriptionParams | replaceNbsp
}}</label>
<span class="hint">{{ option.description | translate: option.descriptionParams | replaceNbsp }}</span> <span class="hint">{{ option.description | translate: option.descriptionParams | replaceNbsp }}</span>
@if (option.extraOption && !option.extraOption.hidden && isSelected(option)) {
@if (isSelected(option)) { <div class="iqser-input-group">
@if (option.additionalCheck && !option.additionalCheck.hidden) { <mat-checkbox
<div class="iqser-input-group w-450"> (change)="emitExtraOption()"
<mat-checkbox [(ngModel)]="option.extraOption.checked"
(change)="emitExtraOption()" [checked]="option.extraOption.checked"
[(ngModel)]="option.additionalCheck.checked" [disabled]="!!option.extraOption.disabled"
[checked]="option.additionalCheck.checked" color="primary"
[disabled]="!!option.additionalCheck.disabled" >
color="primary" {{ option.extraOption.label | translate }}
> </mat-checkbox>
{{ option.additionalCheck.label | translate | replaceNbsp }} @if (option.extraOption.description) {
</mat-checkbox> <span
[innerHTML]="option.extraOption.description | translate"
@if (option.additionalCheck.description) { class="hint extra-option-description"
<span ></span>
[innerHTML]="option.additionalCheck.description | translate" }
class="hint additional-check-description" </div>
></span>
}
</div>
}
@if (option.additionalInput) {
<div class="iqser-input-group w-full additional-input">
<span class="label"> {{ option.additionalInput.label | translate }} </span>
<div class="flex-column">
<input
[(ngModel)]="option.additionalInput.value"
[ngClass]="{ error: additionalInputTouched && hasError(option.additionalInput.errorCode) }"
[placeholder]="
option.additionalInput.placeholder ? (option.additionalInput.placeholder | translate) : ''
"
(blur)="additionalInputTouched = true"
(focus)="additionalInputTouched = false"
(keydown)="emitExtraOption()"
/>
@if (option.additionalInput.description) {
<span class="hint" [innerHTML]="option.additionalInput.description | translate"></span>
}
</div>
</div>
}
} }
</div> </div>
@if (isSelected(option)) { @if (isSelected(option)) {
<mat-icon class="checked" svgIcon="iqser:radio-selected"></mat-icon> <mat-icon class="checked" svgIcon="iqser:radio-selected"></mat-icon>
} }
@ -72,11 +43,9 @@
} @else { } @else {
<div class="flex-align-items-center mb-8"> <div class="flex-align-items-center mb-8">
<iqser-round-checkbox [active]="isSelected(option)" class="mr-6"></iqser-round-checkbox> <iqser-round-checkbox [active]="isSelected(option)" class="mr-6"></iqser-round-checkbox>
<label class="details-radio-label pointer">{{ option.label | translate }}</label>
<label class="details-radio-label pointer">{{ option.label | translate | replaceNbsp }}</label>
</div> </div>
<span class="hint">{{ option.description | translate }}</span>
<span class="hint">{{ option.description | translate | replaceNbsp }}</span>
} }
</div> </div>
} }

View File

@ -43,44 +43,10 @@ label {
} }
} }
.additional-check-description { .extra-option-description {
margin-left: 23px; margin-left: 23px;
opacity: 0.49; opacity: 0.49;
} }
.additional-input {
display: flex;
flex-direction: row;
gap: 10px;
span {
margin-top: 8px;
font-size: 12px;
}
div {
.error {
border-color: var(--iqser-red-1);
}
display: flex;
span {
font-size: 10px;
margin-top: 4px;
}
}
.flex-column {
flex: 1;
input {
width: 232px;
min-height: 30px;
height: 30px;
}
}
}
} }
.row { .row {

View File

@ -1,5 +1,5 @@
import { NgClass } from '@angular/common'; import { NgClass } from '@angular/common';
import { booleanAttribute, Component, input, output } from '@angular/core'; import { booleanAttribute, Component, EventEmitter, Input, Output } from '@angular/core';
import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
@ -14,6 +14,7 @@ import { DetailsRadioOption } from './details-radio-option';
selector: 'iqser-details-radio', selector: 'iqser-details-radio',
templateUrl: './details-radio.component.html', templateUrl: './details-radio.component.html',
styleUrls: ['./details-radio.component.scss'], styleUrls: ['./details-radio.component.scss'],
standalone: true,
providers: [ providers: [
{ {
provide: NG_VALUE_ACCESSOR, provide: NG_VALUE_ACCESSOR,
@ -39,12 +40,12 @@ import { DetailsRadioOption } from './details-radio-option';
], ],
}) })
export class DetailsRadioComponent<I> extends FormFieldComponent<DetailsRadioOption<I>> { export class DetailsRadioComponent<I> extends FormFieldComponent<DetailsRadioOption<I>> {
readonly options = input.required<DetailsRadioOption<I>[]>(); @Input({ required: true }) options: DetailsRadioOption<I>[] = [];
readonly displayInRow = input(false, { transform: booleanAttribute }); @Input({ transform: booleanAttribute }) displayInRow = false;
readonly extraOptionChanged = output<DetailsRadioOption<I>>();
additionalInputTouched = false;
toggleOption(option: DetailsRadioOption<I>) { @Output() readonly extraOptionChanged: EventEmitter<DetailsRadioOption<I>> = new EventEmitter();
toggleOption(option: DetailsRadioOption<I>): void {
if (option.value !== this._value?.value && !option.disabled) { if (option.value !== this._value?.value && !option.disabled) {
this.markAsTouched(); this.markAsTouched();
const currentlyChecked = this.value?.value === option.value; const currentlyChecked = this.value?.value === option.value;
@ -53,20 +54,15 @@ export class DetailsRadioComponent<I> extends FormFieldComponent<DetailsRadioOpt
} }
} }
groupId(option: DetailsRadioOption<I>) { groupId(option: DetailsRadioOption<I>): string {
return (option.id ?? option.label.replace('.', '-')) + '-checkbox-details-input'; return (option.id ?? option.label.replace('.', '-')) + '-checkbox-details-input';
} }
isSelected(option: DetailsRadioOption<I>) { isSelected(option: DetailsRadioOption<I>): boolean {
return option.value === this.value?.value; return option.value === this.value?.value;
} }
emitExtraOption() { emitExtraOption(): void {
if (!this.value) {
console.error('Extra option selected but the value is undefined');
return;
}
this.extraOptionChanged.emit(this.value); this.extraOptionChanged.emit(this.value);
} }
} }

View File

@ -1,46 +1,37 @@
<div [class.datepicker-wrapper]="isDate()" [ngClass]="classList()" class="iqser-input-group"> <div [class.datepicker-wrapper]="isDate" [ngClass]="classList" class="iqser-input-group">
@if (label()) { @if (label) {
<label> {{ label() }} </label> <label> {{ label }} </label>
} }
@if (isDate()) { @if (isDate) {
<input <input
(ngModelChange)="onChange($event)" (ngModelChange)="onChange($event)"
[(ngModel)]="input" [(ngModel)]="input"
[disabled]="disabled" [disabled]="disabled"
[id]="id()" [id]="id"
[matDatepicker]="picker" [matDatepicker]="picker"
[placeholder]="placeholder() || 'dd/mm/yy'" [placeholder]="placeholder || 'dd/mm/yy'"
iqserStopPropagation iqserStopPropagation
/> />
<mat-datepicker-toggle [for]="picker" matSuffix> <mat-datepicker-toggle [for]="picker" matSuffix>
<mat-icon matDatepickerToggleIcon svgIcon="iqser:calendar"></mat-icon> <mat-icon matDatepickerToggleIcon svgIcon="iqser:calendar"></mat-icon>
</mat-datepicker-toggle> </mat-datepicker-toggle>
<mat-datepicker #picker (closed)="onCloseDatepicker()" (opened)="onOpenDatepicker()"></mat-datepicker> <mat-datepicker #picker (closed)="onCloseDatepicker()" (opened)="onOpenDatepicker()"></mat-datepicker>
} }
@if (isText()) { @if (isText) {
<input <input
(ngModelChange)="onChange($event)" (ngModelChange)="onChange($event)"
[(ngModel)]="input" [(ngModel)]="input"
[disabled]="disabled" [disabled]="disabled"
[id]="id()" [id]="id"
[placeholder]="placeholder() || ''" [placeholder]="placeholder || ''"
iqserStopPropagation iqserStopPropagation
type="text" type="text"
/> />
} }
@if (isNumber()) { @if (isNumber) {
<input <input (ngModelChange)="onChange($event)" [(ngModel)]="input" [disabled]="disabled" [id]="id" iqserStopPropagation type="number" />
(ngModelChange)="onChange($event)"
[(ngModel)]="input"
[disabled]="disabled"
[id]="id()"
iqserStopPropagation
type="number"
/>
} }
</div> </div>

View File

@ -1,13 +1,13 @@
import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, input, model, output } from '@angular/core';
import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms'; import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms';
import { FormFieldComponent } from '../form-field/form-field-component.directive';
import { NgClass } from '@angular/common';
import { MatDatepickerModule } from '@angular/material/datepicker'; import { MatDatepickerModule } from '@angular/material/datepicker';
import { StopPropagationDirective } from '../../directives';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { StopPropagationDirective } from '../../directives';
import { FormFieldComponent } from '../form-field/form-field-component.directive';
export const InputTypes = { const InputTypes = {
DATE: 'DATE', DATE: 'DATE',
NUMBER: 'NUMBER', NUMBER: 'NUMBER',
TEXT: 'TEXT', TEXT: 'TEXT',
@ -23,6 +23,7 @@ type DynamicInput = number | string | Date;
templateUrl: './dynamic-input.component.html', templateUrl: './dynamic-input.component.html',
styleUrls: ['./dynamic-input.component.scss'], styleUrls: ['./dynamic-input.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
providers: [ providers: [
{ {
provide: NG_VALUE_ACCESSOR, provide: NG_VALUE_ACCESSOR,
@ -38,20 +39,28 @@ type DynamicInput = number | string | Date;
imports: [NgClass, FormsModule, MatDatepickerModule, StopPropagationDirective, MatIconModule, MatInputModule], imports: [NgClass, FormsModule, MatDatepickerModule, StopPropagationDirective, MatIconModule, MatInputModule],
}) })
export class DynamicInputComponent extends FormFieldComponent<DynamicInput> { export class DynamicInputComponent extends FormFieldComponent<DynamicInput> {
readonly label = input<string>(); @Input() label?: string;
readonly type = input.required<InputType>(); @Input({ required: true }) type!: InputType;
readonly placeholder = input<string>(); @Input() placeholder?: string;
readonly id = input<string>(); @Input() id?: string;
readonly classList = input(''); @Input() classList = '';
readonly input = model<DynamicInput>(); @Input() input!: DynamicInput;
readonly closedDatepicker = output<boolean>(); @Output() readonly closedDatepicker = new EventEmitter<boolean>();
readonly isDate = computed(() => this.type() === InputTypes.DATE); get isDate() {
readonly isNumber = computed(() => this.type() === InputTypes.NUMBER); return this.type === InputTypes.DATE;
readonly isText = computed(() => this.type() === InputTypes.TEXT); }
override writeValue(input: DynamicInput): void { get isNumber() {
this.input.set(input); return this.type === InputTypes.NUMBER;
}
get isText() {
return this.type === InputTypes.TEXT;
}
writeValue(input: DynamicInput): void {
this.input = input;
} }
onCloseDatepicker() { onCloseDatepicker() {

View File

@ -1,53 +1,48 @@
@if (!_editing()) { @if (!editing) {
@if (showPreview()) { @if (showPreview) {
<div>{{ value() }}</div> <div>
{{ value }}
</div>
} }
<div class="flex"> <div class="flex">
@if (canEdit()) { @if (canEdit) {
<iqser-circle-button <iqser-circle-button
(action)="editing = true" (action)="editing = true"
[tooltip]="editTooltip()" [tooltip]="editTooltip"
[type]="buttonsType()" [type]="buttonsType"
[attr.help-mode-key]="helpModeKey()" [attr.help-mode-key]="helpModeKey"
class="edit-button" class="edit-button"
icon="iqser:edit" icon="iqser:edit"
></iqser-circle-button> ></iqser-circle-button>
} }
<ng-content select="[slot=editing]"></ng-content> <ng-content select="[slot=editing]"></ng-content>
</div> </div>
} @else { }
@if (editing) {
<form (submit)="saveValue()"> <form (submit)="saveValue()">
<div [class]="'iqser-input-group ' + class()"> <div [class]="'iqser-input-group ' + class">
@if (!parentId()) { @if (!parentId) {
<input (ngModelChange)="newValue = $event" [ngModel]="value()" [placeholder]="placeholder()" name="name" /> <input (ngModelChange)="newValue = $event" [ngModel]="value" [placeholder]="placeholder" name="name" />
} @else { } @else {
<textarea <textarea
(ngModelChange)="newValue = $event" (ngModelChange)="newValue = $event"
[ngModel]="value()" [ngModel]="value"
[placeholder]="placeholder()" [placeholder]="placeholder"
[id]="id()" [id]="id"
name="name" name="name"
[style.width]="textArea.width + 'px'" [style.width]="this.textArea.width + 'px'"
[style.height]="textArea.height + 'px'" [style.height]="this.textArea.height + 'px'"
></textarea> ></textarea>
} }
</div> </div>
</form> </form>
<div class="flex"> <div class="flex">
<iqser-circle-button <iqser-circle-button (action)="saveValue()" [tooltip]="saveTooltip" [type]="buttonsType" icon="iqser:check"></iqser-circle-button>
(action)="saveValue()"
[tooltip]="saveTooltip()"
[type]="buttonsType()"
icon="iqser:check"
></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="editing = false" (action)="editing = false"
[tooltip]="cancelTooltip()" [tooltip]="cancelTooltip"
[type]="buttonsType()" [type]="buttonsType"
icon="iqser:close" icon="iqser:close"
></iqser-circle-button> ></iqser-circle-button>
</div> </div>

View File

@ -1,40 +1,43 @@
import { booleanAttribute, ChangeDetectionStrategy, Component, input, OnChanges, output, signal, SimpleChanges } from '@angular/core'; import { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { CircleButtonComponent } from '../../buttons/circle-button/circle-button.component'; import { CircleButtonComponent, CircleButtonType, CircleButtonTypes } from '../../buttons';
import { CircleButtonType, CircleButtonTypes } from '../../buttons/types/circle-button.type';
@Component({ @Component({
selector: 'iqser-editable-input', selector: 'iqser-editable-input [value]',
templateUrl: './editable-input.component.html', templateUrl: './editable-input.component.html',
styleUrls: ['./editable-input.component.scss'], styleUrls: ['./editable-input.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [CircleButtonComponent, FormsModule], imports: [CircleButtonComponent, FormsModule],
host: {
'[class.editing]': '_editing()',
},
}) })
export class EditableInputComponent implements OnChanges { export class EditableInputComponent implements OnChanges {
protected readonly _editing = signal(false); @Input() id?: string;
readonly id = input<string>(); @Input() parentId?: string;
readonly parentId = input<string>(); @Input() value!: string;
readonly value = input.required<string>(); @Input() editTooltip?: string;
readonly editTooltip = input(''); @Input() saveTooltip?: string;
readonly saveTooltip = input(''); @Input() cancelTooltip?: string;
readonly cancelTooltip = input(''); @Input() placeholder = '';
readonly placeholder = input(''); @Input() class?: string;
readonly class = input<string>(); @Input() showPreview = true;
readonly showPreview = input(true, { transform: booleanAttribute }); @Input() canEdit = true;
readonly canEdit = input(true, { transform: booleanAttribute }); @Input() buttonsType: CircleButtonType = CircleButtonTypes.default;
readonly buttonsType = input<CircleButtonType>(CircleButtonTypes.default); @Input() helpModeKey: string = '';
readonly helpModeKey = input(''); @Input() lastChild = false;
readonly lastChild = input(false, { transform: booleanAttribute }); @Output() readonly save = new EventEmitter<string>();
readonly save = output<string>();
textArea?: { width: number; height: number }; textArea?: { width: number; height: number };
newValue = ''; newValue = '';
private _editing = false;
@HostBinding('class.editing')
get editing(): boolean {
return this._editing;
}
set editing(value: boolean) { set editing(value: boolean) {
this._editing.set(value); this._editing = value;
this.newValue = this.value(); this.newValue = this.value;
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
@ -48,12 +51,12 @@ export class EditableInputComponent implements OnChanges {
setTextAreaSize() { setTextAreaSize() {
setTimeout(() => { setTimeout(() => {
const element = document.getElementById(this.id() as string) as HTMLElement; const element = document.getElementById(this.id as string) as HTMLElement;
const parentElement = document.getElementById(this.parentId() as string) as HTMLElement; const parentElement = document.getElementById(this.parentId as string) as HTMLElement;
const width = parentElement.offsetWidth - 98; const width = parentElement.offsetWidth - 98;
let height = (this.lastChild() ? parentElement.offsetHeight : element.offsetHeight) - 16; let height = (this.lastChild ? parentElement.offsetHeight : element.offsetHeight) - 16;
if (this.lastChild()) { if (this.lastChild) {
const lastChildIndex = Number(this.id()?.split('-')[2]); const lastChildIndex = Number(this.id?.split('-')[2]);
height = height - lastChildIndex * element.offsetHeight; height = height - lastChildIndex * element.offsetHeight;
} }
this.textArea = { width, height }; this.textArea = { width, height };

View File

@ -1,47 +1,19 @@
import { ChangeDetectorRef, Directive, inject, Injector, OnInit } from '@angular/core'; import { ChangeDetectorRef, Directive, inject } from '@angular/core';
import { import { ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms';
ControlValueAccessor,
FormControl,
FormControlDirective,
FormControlName,
FormGroupDirective,
NgControl,
ValidationErrors,
Validator,
} from '@angular/forms';
@Directive() @Directive()
export abstract class FormFieldComponent<I> implements ControlValueAccessor, Validator, OnInit { export abstract class FormFieldComponent<I> implements ControlValueAccessor, Validator {
touched = false; touched = false;
disabled = false; disabled = false;
protected readonly _changeRef = inject(ChangeDetectorRef); protected readonly _changeRef = inject(ChangeDetectorRef);
protected readonly _injector = inject(Injector);
protected _formControl: FormControl | undefined;
protected _value: I | undefined; protected _value: I | undefined;
get value(): I | undefined { get value(): I | undefined {
return this._value; return this._value;
} }
ngOnInit() {
const ngControl = this._injector.get(NgControl);
if (ngControl instanceof FormControlName) {
this._formControl = this._injector.get(FormGroupDirective).getControl(ngControl);
} else {
this._formControl = (ngControl as FormControlDirective).form as FormControl;
}
}
hasError(errorCode: string | undefined): boolean {
if (errorCode && this._formControl) {
return this._formControl.hasError(errorCode);
}
return false;
}
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
onChange = (value?: I) => {}; onChange = (value?: I) => {};

7
src/lib/inputs/index.ts Normal file
View File

@ -0,0 +1,7 @@
export * from './round-checkbox/round-checkbox.component';
export * from './editable-input/editable-input.component';
export * from './input-with-action/input-with-action.component';
export * from './details-radio/details-radio.component';
export * from './details-radio/details-radio-option';
export * from './form-field/form-field-component.directive';
export * from './dynamic-input/dynamic-input.component';

View File

@ -1,33 +1,34 @@
<form (submit)="executeAction()" [style.max-width]="_computedWidth()" [style.width]="_computedWidth()" class="iqser-input-group"> <form (submit)="executeAction()" [style.max-width]="computedWidth" [style.width]="computedWidth" class="iqser-input-group">
<input <input
(ngModelChange)="valueChange.emit($event)"
[(ngModel)]="value" [(ngModel)]="value"
[autocomplete]="autocomplete()" [autocomplete]="autocomplete"
[disabled]="disabled()" [disabled]="disabled"
[id]="inputId()" [id]="inputId"
[ngModelOptions]="{ standalone: true }" [ngModelOptions]="{ standalone: true }"
[placeholder]="placeholder()" [placeholder]="placeholder"
class="with-icon mt-0" class="with-icon mt-0"
type="text" type="text"
/> />
@if (hint()) { @if (hint) {
<span class="hint">{{ hint() }}</span> <span class="hint">{{ hint }}</span>
} }
@if (_isSearch() && !_hasContent()) { @if (isSearch && !hasContent) {
<mat-icon class="icon-right" svgIcon="iqser:search"></mat-icon> <mat-icon class="icon-right" svgIcon="iqser:search"></mat-icon>
} }
@if (_isSearch() && _hasContent()) { @if (isSearch && hasContent) {
<iqser-circle-button (action)="reset()" [buttonId]="inputId() + '-clear'" icon="iqser:close"></iqser-circle-button> <iqser-circle-button (action)="reset()" [buttonId]="inputId + '-clear'" icon="iqser:close"></iqser-circle-button>
} }
@if (icon(); as icon) { @if (!isSearch) {
<iqser-circle-button <iqser-circle-button
(action)="executeAction()" (action)="executeAction()"
[buttonId]="actionButtonId()" [buttonId]="actionButtonId"
[disabled]="!_hasContent()" [disabled]="!hasContent"
[icon]="icon" [icon]="icon!"
></iqser-circle-button> ></iqser-circle-button>
} }
</form> </form>

View File

@ -1,39 +1,54 @@
import { booleanAttribute, ChangeDetectionStrategy, Component, computed, input, model, output } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { randomString } from '../../utils';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { MatIconModule } from '@angular/material/icon';
import { CircleButtonComponent } from '../../buttons/circle-button/circle-button.component'; import { CircleButtonComponent } from '../../buttons';
import { randomString } from '../../utils/functions'; import { MatIconModule } from '@angular/material/icon';
@Component({ @Component({
selector: 'iqser-input-with-action', selector: 'iqser-input-with-action',
templateUrl: './input-with-action.component.html', templateUrl: './input-with-action.component.html',
styleUrls: ['./input-with-action.component.scss'], styleUrls: ['./input-with-action.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [FormsModule, MatIconModule, CircleButtonComponent], imports: [FormsModule, MatIconModule, CircleButtonComponent],
}) })
export class InputWithActionComponent { export class InputWithActionComponent {
readonly inputId = input(`${randomString() + '-search-input'}`); @Input() inputId = `${randomString() + '-search-input'}`;
readonly actionButtonId = input(`${randomString() + '-action-input'}`); @Input() actionButtonId = `${randomString() + '-action-input'}`;
readonly placeholder = input(''); @Input() placeholder = '';
readonly hint = input<string>(); @Input() hint?: string;
readonly width = input<number | 'full'>(250); @Input() width: number | 'full' = 250;
protected readonly _computedWidth = computed(() => (this.width() === 'full' ? '100%' : `${this.width()}px`)); @Input() icon?: string;
readonly icon = input<string>(); @Input() autocomplete: 'on' | 'off' = 'on';
protected readonly _isSearch = computed(() => !this.icon()); @Input() value = '';
readonly autocomplete = input<'on' | 'off'>('on'); @Input() disabled = false;
readonly value = model(''); @Output() readonly action = new EventEmitter<string>();
protected readonly _hasContent = computed(() => !!this.value()?.length); @Output() readonly valueChange = new EventEmitter<string>();
readonly disabled = input(false, { transform: booleanAttribute });
readonly action = output<string>();
reset() { get hasContent(): boolean {
this.value.set(''); return !!this.value?.length;
} }
executeAction() { get computedWidth(): string {
if (this._hasContent()) { return this.width === 'full' ? '100%' : `${this.width}px`;
this.action.emit(this.value()); }
get isSearch(): boolean {
return !this.icon;
}
constructor(private readonly _changeDetectorRef: ChangeDetectorRef) {}
reset(): void {
this.value = '';
this.valueChange.emit(this.value);
this._changeDetectorRef.markForCheck();
}
executeAction(): void {
if (this.hasContent) {
this.action.emit(this.value);
} }
} }
} }

View File

@ -1,16 +1,15 @@
<div <div
#wrapper #wrapper
[class.active]="active() && !indeterminate()" [class.active]="active && !indeterminate"
[class.inactive]="!active() && !indeterminate()" [class.inactive]="!active && !indeterminate"
[class.indeterminate]="indeterminate()" [class.indeterminate]="indeterminate"
[class.with-bg]="type() === 'with-bg'" [class.with-bg]="type === 'with-bg'"
class="wrapper" class="wrapper"
> >
@if (active() && !indeterminate()) { @if (active && !indeterminate) {
<mat-icon svgIcon="iqser:radio-selected"></mat-icon> <mat-icon svgIcon="iqser:radio-selected"></mat-icon>
} }
@if (indeterminate) {
@if (indeterminate()) {
<mat-icon svgIcon="iqser:radio-indeterminate"></mat-icon> <mat-icon svgIcon="iqser:radio-indeterminate"></mat-icon>
} }
</div> </div>

View File

@ -1,4 +1,4 @@
import { booleanAttribute, ChangeDetectionStrategy, Component, effect, ElementRef, input, numberAttribute, viewChild } from '@angular/core'; import { booleanAttribute, ChangeDetectionStrategy, Component, ElementRef, HostBinding, Input, OnInit, ViewChild } from '@angular/core';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
@Component({ @Component({
@ -6,19 +6,21 @@ import { MatIconModule } from '@angular/material/icon';
templateUrl: './round-checkbox.component.html', templateUrl: './round-checkbox.component.html',
styleUrls: ['./round-checkbox.component.scss'], styleUrls: ['./round-checkbox.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [MatIconModule], imports: [MatIconModule],
}) })
export class RoundCheckboxComponent { export class RoundCheckboxComponent implements OnInit {
protected readonly _wrapper = viewChild.required('wrapper', { read: ElementRef }); @Input() size = 20;
readonly size = input(20, { transform: numberAttribute }); @Input({ transform: booleanAttribute }) active = false;
readonly active = input(false, { transform: booleanAttribute }); @Input() indeterminate = false;
readonly indeterminate = input(false, { transform: booleanAttribute }); @Input() type: 'default' | 'with-bg' = 'default';
readonly type = input<'default' | 'with-bg'>('default'); @HostBinding('class.disabled')
readonly disabled = input(false, { transform: booleanAttribute }); @Input()
disabled = false;
constructor() { @ViewChild('wrapper', { static: true }) private readonly _wrapper!: ElementRef;
effect(() => {
(this._wrapper().nativeElement as HTMLElement).style.setProperty('--size', `${this.size()}px`); ngOnInit(): void {
}); (this._wrapper.nativeElement as HTMLElement).style.setProperty('--size', `${this.size}px`);
} }
} }

View File

@ -10,8 +10,7 @@ import { CircleButtonComponent, IconButtonComponent } from '../buttons';
import { HasScrollbarDirective, SyncWidthDirective } from '../directives'; import { HasScrollbarDirective, SyncWidthDirective } from '../directives';
import { EmptyStateComponent } from '../empty-state'; import { EmptyStateComponent } from '../empty-state';
import { IqserFiltersModule, PopupFilterComponent } from '../filtering'; import { IqserFiltersModule, PopupFilterComponent } from '../filtering';
import { InputWithActionComponent } from '../inputs/input-with-action/input-with-action.component'; import { InputWithActionComponent, RoundCheckboxComponent } from '../inputs';
import { RoundCheckboxComponent } from '../inputs/round-checkbox/round-checkbox.component';
import { SnakeCasePipe } from '../pipes/snake-case.pipe'; import { SnakeCasePipe } from '../pipes/snake-case.pipe';
import { PageHeaderComponent } from './page-header/page-header.component'; import { PageHeaderComponent } from './page-header/page-header.component';
import { ScrollButtonComponent } from './scroll-button/scroll-button.component'; import { ScrollButtonComponent } from './scroll-button/scroll-button.component';

View File

@ -1,10 +1,9 @@
import { BaseHeaderConfig } from './base-config.model'; import { BaseHeaderConfig } from './base-config.model';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { OverlappingElement } from '../../../help-mode';
export interface ActionConfig extends BaseHeaderConfig { export interface ActionConfig extends BaseHeaderConfig {
readonly action: ($event: MouseEvent) => void; readonly action: ($event: MouseEvent) => void;
readonly helpModeKey?: string; readonly helpModeKey?: string;
readonly disabled$?: Observable<boolean>; readonly disabled$?: Observable<boolean>;
readonly disabled?: boolean;
readonly disableStopPropagation?: boolean;
} }

View File

@ -3,5 +3,4 @@ import { ActionConfig } from './action-config.model';
export interface ButtonConfig extends ActionConfig { export interface ButtonConfig extends ActionConfig {
readonly type?: IconButtonType; readonly type?: IconButtonType;
readonly tooltip?: string;
} }

View File

@ -1,20 +1,20 @@
<div class="page-header"> <div class="page-header">
@if (pageLabel()) { @if (pageLabel) {
<div class="breadcrumb">{{ pageLabel() }}</div> <div class="breadcrumb">{{ pageLabel }}</div>
} }
@if (filters$ | async; as filters) { @if (filters$ | async; as filters) {
<div class="filters"> <div class="filters">
<ng-content select="[slot=beforeFilters]"></ng-content> <ng-content select="[slot=beforeFilters]"></ng-content>
@if (filters.length && searchPosition() !== searchPositions.beforeFilters) { @if (filters.length && searchPosition !== searchPositions.beforeFilters) {
<div class="text-muted" translate="filters.filter-by"></div> <div class="text-muted" translate="filters.filter-by"></div>
} }
@if (searchPosition() === searchPositions.beforeFilters) { @if (searchPosition === searchPositions.beforeFilters) {
<ng-container [ngTemplateOutlet]="searchBar"></ng-container> <ng-container [ngTemplateOutlet]="searchBar"></ng-container>
} }
@for (filter of filters; track trackByLabel($index, filter)) { @for (filter of filters; track trackByLabel($index, filter)) {
@if (!filter.hide) { @if (!filter.hide) {
<iqser-popup-filter [primaryFiltersSlug]="filter.slug" [attr.help-mode-key]="filterHelpModeKey()"></iqser-popup-filter> <iqser-popup-filter [primaryFiltersSlug]="filter.slug" [attr.help-mode-key]="filterHelpModeKey"></iqser-popup-filter>
} }
} }
@for (filter$ of filterService.singleFilters; track filter$) { @for (filter$ of filterService.singleFilters; track filter$) {
@ -22,13 +22,13 @@
<iqser-single-filter [filter]="filter"></iqser-single-filter> <iqser-single-filter [filter]="filter"></iqser-single-filter>
} }
} }
@if (searchPosition() === searchPositions.afterFilters) { @if (searchPosition === searchPositions.afterFilters) {
<ng-container [ngTemplateOutlet]="searchBar"></ng-container> <ng-container [ngTemplateOutlet]="searchBar"></ng-container>
} }
@if (!hideResetButton() && (showResetFilters$ | async) === true) { @if (!hideResetButton && (showResetFilters$ | async) === true) {
<div <div
(click)="resetFilters()" (click)="resetFilters()"
[attr.help-mode-key]="'filter_' + helpModeKey() + '_list'" [attr.help-mode-key]="'filter_' + helpModeKey + '_list'"
class="reset-filters" class="reset-filters"
translate="reset-filters" translate="reset-filters"
></div> ></div>
@ -36,13 +36,13 @@
</div> </div>
} }
@if (showCloseButton() || actionConfigs() || buttonConfigs() || viewModeSelection()) { @if (showCloseButton || actionConfigs || buttonConfigs || viewModeSelection) {
<div class="actions"> <div class="actions">
@if (searchPosition() === searchPositions.withActions) { @if (searchPosition === searchPositions.withActions) {
<ng-container [ngTemplateOutlet]="searchBar"></ng-container> <ng-container [ngTemplateOutlet]="searchBar"></ng-container>
} }
<ng-container [ngTemplateOutlet]="viewModeSelection()"></ng-container> <ng-container [ngTemplateOutlet]="viewModeSelection"></ng-container>
@for (config of buttonConfigs(); track trackByLabel($index, config)) { @for (config of buttonConfigs; track trackByLabel($index, config)) {
@if (!config.hide) { @if (!config.hide) {
<iqser-icon-button <iqser-icon-button
(action)="config.action($event)" (action)="config.action($event)"
@ -50,34 +50,30 @@
[icon]="config.icon" [icon]="config.icon"
[label]="config.label | translate" [label]="config.label | translate"
[type]="config.type" [type]="config.type"
[matTooltip]="(config.tooltip | translate) ?? ''"
[disabled]="config.disabled"
[attr.help-mode-key]="config.helpModeKey" [attr.help-mode-key]="config.helpModeKey"
matTooltipPosition="above"
></iqser-icon-button> ></iqser-icon-button>
} }
} }
<div class="actions"> <div class="actions">
@for (config of actionConfigs(); track trackByLabel($index, config)) { @for (config of actionConfigs; track trackByLabel($index, config)) {
@if (!config.hide) { @if (!config.hide) {
<iqser-circle-button <iqser-circle-button
(action)="config.action($event)" (action)="config.action($event)"
[buttonId]="config.id" [buttonId]="config.id"
[disabled]="config.disabled" [disabled]="config.disabled$ && (config.disabled$ | async)"
[icon]="config.icon" [icon]="config.icon"
[tooltip]="config.label | translate" [tooltip]="config.label"
[attr.help-mode-key]="config.helpModeKey" [attr.help-mode-key]="config.helpModeKey"
[iqserDisableStopPropagation]="config.disableStopPropagation"
></iqser-circle-button> ></iqser-circle-button>
} }
} }
<!-- Extra custom actions here --> <!-- Extra custom actions here -->
<ng-content select="[slot=right]"></ng-content> <ng-content select="[slot=right]"></ng-content>
@if (showCloseButton()) { @if (showCloseButton) {
<iqser-circle-button <iqser-circle-button
buttonId="close-view-btn" buttonId="close-view-btn"
(action)="closeAction.emit()" (action)="closeAction.emit()"
[class.ml-6]="actionConfigs()" [class.ml-6]="actionConfigs"
[icon]="'iqser:close'" [icon]="'iqser:close'"
[attr.help-mode-key]="'close_dossier'" [attr.help-mode-key]="'close_dossier'"
[tooltip]="'common.close' | translate" [tooltip]="'common.close' | translate"
@ -89,14 +85,14 @@
</div> </div>
<ng-template #searchBar> <ng-template #searchBar>
@if (searchPlaceholder() && searchService) { @if (searchPlaceholder && searchService) {
<iqser-input-with-action <iqser-input-with-action
[inputId]="searchInputId()" [inputId]="searchInputId"
(valueChange)="searchService.searchValue = $event" (valueChange)="searchService.searchValue = $event"
[class.mr-8]="searchPosition() === searchPositions.beforeFilters" [class.mr-8]="searchPosition === searchPositions.beforeFilters"
[placeholder]="searchPlaceholder()" [placeholder]="searchPlaceholder"
[value]="searchService.valueChanges$ | async" [value]="searchService.valueChanges$ | async"
[width]="searchWidth()" [width]="searchWidth"
></iqser-input-with-action> ></iqser-input-with-action>
} }
</ng-template> </ng-template>

View File

@ -1,28 +1,27 @@
import { AsyncPipe, NgTemplateOutlet } from '@angular/common'; import { AsyncPipe, NgTemplateOutlet } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, inject, input, output, TemplateRef } from '@angular/core'; import { ChangeDetectionStrategy, Component, EventEmitter, inject, Input, Output, TemplateRef } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { combineLatest, Observable, of } from 'rxjs'; import { combineLatest, Observable, of } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators'; import { distinctUntilChanged, map } from 'rxjs/operators';
import { CircleButtonComponent } from '../../buttons'; import { CircleButtonComponent } from '../../buttons/circle-button/circle-button.component';
import { IconButtonComponent } from '../../buttons'; import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
import { IconButtonTypes } from '../../buttons'; import { IconButtonTypes } from '../../buttons/types/icon-button.type';
import { FilterService } from '../../filtering'; import { FilterService } from '../../filtering/filter.service';
import { IqserFiltersModule } from '../../filtering'; import { IqserFiltersModule } from '../../filtering/filters.module';
import { PopupFilterComponent } from '../../filtering'; import { PopupFilterComponent } from '../../filtering/popup-filter/popup-filter.component';
import { InputWithActionComponent } from '../../inputs/input-with-action/input-with-action.component'; import { InputWithActionComponent } from '../../inputs/input-with-action/input-with-action.component';
import { SearchService } from '../../search'; import { SearchService } from '../../search/search.service';
import { filterEach } from '../../utils'; import { filterEach } from '../../utils/operators';
import { List } from '../../utils'; import { List } from '../../utils/types/iqser-types';
import { IListable } from '../models'; import { IListable } from '../models/listable';
import { ActionConfig, ButtonConfig, SearchPosition, SearchPositions } from './models'; import { ActionConfig, ButtonConfig, SearchPosition, SearchPositions } from './models';
import { MatTooltip } from '@angular/material/tooltip';
import { DisableStopPropagationDirective } from '../../directives';
@Component({ @Component({
selector: 'iqser-page-header', selector: 'iqser-page-header',
templateUrl: './page-header.component.html', templateUrl: './page-header.component.html',
styleUrls: ['./page-header.component.scss'], styleUrls: ['./page-header.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [ imports: [
AsyncPipe, AsyncPipe,
NgTemplateOutlet, NgTemplateOutlet,
@ -32,36 +31,33 @@ import { DisableStopPropagationDirective } from '../../directives';
CircleButtonComponent, CircleButtonComponent,
TranslateModule, TranslateModule,
InputWithActionComponent, InputWithActionComponent,
MatTooltip,
DisableStopPropagationDirective,
], ],
}) })
export class PageHeaderComponent<T extends IListable> { export class PageHeaderComponent<T extends IListable> {
readonly searchPositions = SearchPositions; readonly searchPositions = SearchPositions;
readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
@Input() pageLabel?: string;
@Input() searchInputId?: string;
@Input() showCloseButton = false;
@Input() hideResetButton = false;
@Input() actionConfigs?: List<ActionConfig>;
@Input() buttonConfigs?: List<ButtonConfig>;
@Input() viewModeSelection?: TemplateRef<unknown>;
@Input() searchPlaceholder?: string;
@Input() searchWidth?: number | 'full';
@Input() helpModeKey?: 'dossier' | 'document';
@Input() searchPosition: SearchPosition = SearchPositions.afterFilters;
@Output() readonly closeAction = new EventEmitter();
readonly filterService = inject(FilterService, { optional: true }); readonly filterService = inject(FilterService, { optional: true });
readonly searchService = inject<SearchService<T>>(SearchService<T>, { optional: true }); readonly searchService = inject<SearchService<T>>(SearchService<T>, { optional: true });
readonly pageLabel = input<string>();
readonly searchInputId = input<string>();
readonly showCloseButton = input(false);
readonly hideResetButton = input(false);
readonly actionConfigs = input<List<ActionConfig>>();
readonly buttonConfigs = input<List<ButtonConfig>>();
readonly viewModeSelection = input<TemplateRef<unknown>>();
readonly searchPlaceholder = input<string>();
readonly searchWidth = input<number | 'full'>();
readonly helpModeKey = input<'dossier' | 'document'>();
readonly searchPosition = input<SearchPosition>(SearchPositions.afterFilters);
readonly closeAction = output();
readonly filterHelpModeKey = computed(() =>
this.helpModeKey() ? (this.helpModeKey() === 'dossier' ? 'filter_dossier_list' : 'filter_documents') : '',
);
readonly filters$ = this.filterService?.filterGroups$.pipe(filterEach(f => !!f.icon)); readonly filters$ = this.filterService?.filterGroups$.pipe(filterEach(f => !!f.icon));
readonly showResetFilters$ = this.#showResetFilters$; readonly showResetFilters$ = this.#showResetFilters$;
get filterHelpModeKey() {
return this.helpModeKey ? (this.helpModeKey === 'dossier' ? 'filter_dossier_list' : 'filter_documents') : '';
}
get #showResetFilters$(): Observable<boolean> { get #showResetFilters$(): Observable<boolean> {
if (!this.filterService) { if (!this.filterService) {
return of(false); return of(false);

View File

@ -18,6 +18,7 @@ type ButtonType = keyof typeof ButtonTypes;
templateUrl: './scroll-button.component.html', templateUrl: './scroll-button.component.html',
styleUrls: ['./scroll-button.component.scss'], styleUrls: ['./scroll-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [AsyncPipe, MatIcon], imports: [AsyncPipe, MatIcon],
}) })
export class ScrollButtonComponent implements OnInit { export class ScrollButtonComponent implements OnInit {

View File

@ -52,7 +52,7 @@ export class ListingService<Class extends IListable<PrimaryKey>, PrimaryKey exte
get selected(): Class[] { get selected(): Class[] {
const selectedIds = this.selectedIds; const selectedIds = this.selectedIds;
return selectedIds.map(id => this._entitiesService.all.find(a => a.id === id)).filter(a => !!a); return this._entitiesService.all.filter(a => selectedIds.includes(a.id));
} }
get selectedIds(): PrimaryKey[] { get selectedIds(): PrimaryKey[] {

View File

@ -22,14 +22,14 @@
} }
} }
&:last-of-type > div {
padding: 0 13px 0 10px;
}
&:first-child > div { &:first-child > div {
padding: 0 24px; padding: 0 24px;
} }
&:last-of-type > div {
padding: 0 13px 0 10px;
}
.flex-end { .flex-end {
min-width: 58px; min-width: 58px;
} }

View File

@ -12,6 +12,7 @@ import { Id, IListable } from '../models';
templateUrl: './table-column-name.component.html', templateUrl: './table-column-name.component.html',
styleUrls: ['./table-column-name.component.scss'], styleUrls: ['./table-column-name.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [MatIcon, MatTooltip, TranslateModule, AsyncPipe, NgClass], imports: [MatIcon, MatTooltip, TranslateModule, AsyncPipe, NgClass],
}) })
export class TableColumnNameComponent<T extends IListable<PrimaryKey>, PrimaryKey extends Id = T['id']> { export class TableColumnNameComponent<T extends IListable<PrimaryKey>, PrimaryKey extends Id = T['id']> {

View File

@ -11,7 +11,7 @@
<!-- mouseenter and mouseleave triggers change detection event if itemMouse functions are undefined --> <!-- mouseenter and mouseleave triggers change detection event if itemMouse functions are undefined -->
<!-- this little hack below ensures that change detection won't be triggered if functions are undefined --> <!-- this little hack below ensures that change detection won't be triggered if functions are undefined -->
@if (itemMouseEnterFn || itemMouseLeaveFn) { @if (itemMouseEnterFn || itemMouseLeaveFn) {
<a <div
(mouseenter)="itemMouseEnterFn && itemMouseEnterFn(entity)" (mouseenter)="itemMouseEnterFn && itemMouseEnterFn(entity)"
(mouseleave)="itemMouseLeaveFn && itemMouseLeaveFn(entity)" (mouseleave)="itemMouseLeaveFn && itemMouseLeaveFn(entity)"
[class.help-mode-active]="helpModeService?.isHelpModeActive$ | async" [class.help-mode-active]="helpModeService?.isHelpModeActive$ | async"
@ -21,12 +21,12 @@
> >
<iqser-table-item <iqser-table-item
(click)="multiSelect(entity, $event)" (click)="multiSelect(entity, $event)"
[entity]="$any(entity)" [entity]="entity"
[selectionEnabled]="selectionEnabled" [selectionEnabled]="selectionEnabled"
></iqser-table-item> ></iqser-table-item>
</a> </div>
} @else { } @else {
<a <div
[class.help-mode-active]="helpModeService?.isHelpModeActive$ | async" [class.help-mode-active]="helpModeService?.isHelpModeActive$ | async"
[id]="rowIdPrefix + '-' + ((entity[namePropertyKey] | snakeCase) ?? entity.id)" [id]="rowIdPrefix + '-' + ((entity[namePropertyKey] | snakeCase) ?? entity.id)"
[ngClass]="getTableItemClasses(entity)" [ngClass]="getTableItemClasses(entity)"
@ -34,10 +34,10 @@
> >
<iqser-table-item <iqser-table-item
(click)="multiSelect(entity, $event)" (click)="multiSelect(entity, $event)"
[entity]="$any(entity)" [entity]="entity"
[selectionEnabled]="selectionEnabled" [selectionEnabled]="selectionEnabled"
></iqser-table-item> ></iqser-table-item>
</a> </div>
} }
</ng-container> </ng-container>
</cdk-virtual-scroll-viewport> </cdk-virtual-scroll-viewport>

View File

@ -2,7 +2,7 @@
:host cdk-virtual-scroll-viewport { :host cdk-virtual-scroll-viewport {
height: calc(100vh - 50px - 31px - var(--iqser-top-bar-height) - 50px); height: calc(100vh - 50px - 31px - var(--iqser-top-bar-height) - 50px);
overflow-y: auto !important; overflow-y: hidden !important;
background-color: var(--iqser-background); background-color: var(--iqser-background);
@include mixins.scroll-bar; @include mixins.scroll-bar;
@ -10,6 +10,10 @@
display: none; display: none;
} }
&.has-scrollbar:hover ::ng-deep.cdk-virtual-scroll-content-wrapper {
grid-template-columns: var(--gridTemplateColumnsHover);
}
::ng-deep.cdk-virtual-scroll-content-wrapper { ::ng-deep.cdk-virtual-scroll-content-wrapper {
grid-template-columns: var(--gridTemplateColumns); grid-template-columns: var(--gridTemplateColumns);
display: grid; display: grid;
@ -33,7 +37,6 @@
} }
&:hover, &:hover,
&:has(iqser-circle-button[aria-expanded='true']),
&.help-mode-active { &.help-mode-active {
.selection-column iqser-round-checkbox .wrapper { .selection-column iqser-round-checkbox .wrapper {
opacity: 1; opacity: 1;
@ -49,10 +52,6 @@
> * > div { > * > div {
background-color: var(--iqser-not-disabled-table-item); background-color: var(--iqser-not-disabled-table-item);
} }
.scrollbar-placeholder {
background-color: var(--iqser-side-nav);
}
} }
} }
} }
@ -65,6 +64,10 @@
right: 0; right: 0;
padding-right: 10px; padding-right: 10px;
} }
.scrollbar-placeholder {
display: none !important;
}
} }
} }
} }
@ -72,8 +75,3 @@
.display-contents { .display-contents {
display: contents; display: contents;
} }
a {
display: contents;
@include mixins.clear-a;
}

View File

@ -20,6 +20,7 @@ import { TableItemComponent } from './table-item/table-item.component';
selector: 'iqser-table-content', selector: 'iqser-table-content',
templateUrl: './table-content.component.html', templateUrl: './table-content.component.html',
styleUrls: ['./table-content.component.scss'], styleUrls: ['./table-content.component.scss'],
standalone: true,
imports: [ imports: [
CdkVirtualScrollViewport, CdkVirtualScrollViewport,
AsyncPipe, AsyncPipe,
@ -86,7 +87,7 @@ export class TableContentComponent<Class extends IListable<PrimaryKey>, PrimaryK
getTableItemClasses(entity: Class): Record<string, boolean> { getTableItemClasses(entity: Class): Record<string, boolean> {
const classes: Record<string, boolean> = { const classes: Record<string, boolean> = {
'table-item': true, 'table-item': true,
'cursor-default': !entity.routerLink, pointer: !!entity.routerLink && entity.routerLink.length > 0,
}; };
for (const key in this.tableItemClasses) { for (const key in this.tableItemClasses) {
if (Object.prototype.hasOwnProperty.call(this.tableItemClasses, key)) { if (Object.prototype.hasOwnProperty.call(this.tableItemClasses, key)) {

View File

@ -12,6 +12,7 @@ import { ListingService } from '../../services/listing.service';
templateUrl: './table-item.component.html', templateUrl: './table-item.component.html',
styleUrls: ['./table-item.component.scss'], styleUrls: ['./table-item.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [RoundCheckboxComponent, AsyncPipe, NgTemplateOutlet], imports: [RoundCheckboxComponent, AsyncPipe, NgTemplateOutlet],
}) })
export class TableItemComponent<T extends IListable> implements OnChanges { export class TableItemComponent<T extends IListable> implements OnChanges {
@ -33,7 +34,6 @@ export class TableItemComponent<T extends IListable> implements OnChanges {
toggleEntitySelected($event: MouseEvent, entity: T): void { toggleEntitySelected($event: MouseEvent, entity: T): void {
$event.stopPropagation(); $event.stopPropagation();
$event.preventDefault();
this.listingService.select(entity, $event.shiftKey); this.listingService.select(entity, $event.shiftKey);
} }
} }

View File

@ -1,5 +1,5 @@
<div [class.selection-enabled]="selectionEnabled" class="header-item"> <div [class.selection-enabled]="selectionEnabled" class="header-item">
<div class="header-title"> <div [attr.help-mode-key]="helpModeKey" class="header-title">
@if (selectionEnabled) { @if (selectionEnabled) {
<iqser-round-checkbox <iqser-round-checkbox
(click)="listingService.selectAll()" (click)="listingService.selectAll()"
@ -9,7 +9,7 @@
></iqser-round-checkbox> ></iqser-round-checkbox>
} }
<span [attr.help-mode-key]="helpModeKey" class="all-caps-label"> <span class="all-caps-label">
{{ tableHeaderLabel | translate: { length: totalSize || (listingService.displayedLength$ | async) } }} {{ tableHeaderLabel | translate: { length: totalSize || (listingService.displayedLength$ | async) } }}
@if (listingService.selectedLength$ | async; as selectedItems) { @if (listingService.selectedLength$ | async; as selectedItems) {
<span> ({{ 'table-header.selected-count' | translate: { count: selectedItems } }}) </span> <span> ({{ 'table-header.selected-count' | translate: { count: selectedItems } }}) </span>

View File

@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, Component, inject, Input, TemplateRef } from '
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { SyncWidthDirective } from '../../directives'; import { SyncWidthDirective } from '../../directives';
import { FilterService, IqserFiltersModule } from '../../filtering'; import { FilterService, IqserFiltersModule } from '../../filtering';
import { RoundCheckboxComponent } from '../../inputs/round-checkbox/round-checkbox.component'; import { RoundCheckboxComponent } from '../../inputs';
import { Id, IListable, ListingMode, ListingModes, TableColumnConfig } from '../models'; import { Id, IListable, ListingMode, ListingModes, TableColumnConfig } from '../models';
import { EntitiesService, ListingService } from '../services'; import { EntitiesService, ListingService } from '../services';
import { TableColumnNameComponent } from '../table-column-name/table-column-name.component'; import { TableColumnNameComponent } from '../table-column-name/table-column-name.component';
@ -13,6 +13,7 @@ import { TableColumnNameComponent } from '../table-column-name/table-column-name
templateUrl: './table-header.component.html', templateUrl: './table-header.component.html',
styleUrls: ['./table-header.component.scss'], styleUrls: ['./table-header.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [ imports: [
RoundCheckboxComponent, RoundCheckboxComponent,
AsyncPipe, AsyncPipe,

View File

@ -28,6 +28,7 @@ const SCROLLBAR_WIDTH = 11;
selector: 'iqser-table [tableColumnConfigs] [itemSize]', selector: 'iqser-table [tableColumnConfigs] [itemSize]',
templateUrl: './table.component.html', templateUrl: './table.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [TableHeaderComponent, NgTemplateOutlet, AsyncPipe, EmptyStateComponent, ScrollButtonComponent, TableContentComponent], imports: [TableHeaderComponent, NgTemplateOutlet, AsyncPipe, EmptyStateComponent, ScrollButtonComponent, TableContentComponent],
}) })
export class TableComponent<Class extends IListable<PrimaryKey>, PrimaryKey extends Id = Class['id']> implements OnChanges { export class TableComponent<Class extends IListable<PrimaryKey>, PrimaryKey extends Id = Class['id']> implements OnChanges {
@ -86,17 +87,18 @@ export class TableComponent<Class extends IListable<PrimaryKey>, PrimaryKey exte
} }
private _setColumnsWidth(element: HTMLElement) { private _setColumnsWidth(element: HTMLElement) {
let gridTemplateColumns = ''; let gridTemplateColumnsHover = '';
if (this.selectionEnabled) { if (this.selectionEnabled) {
gridTemplateColumns += '30px '; gridTemplateColumnsHover += '30px ';
} }
for (const config of this.tableColumnConfigs) { for (const config of this.tableColumnConfigs) {
gridTemplateColumns += `${config.width || '1fr'} `; gridTemplateColumnsHover += `${config.width || '1fr'} `;
} }
gridTemplateColumns += this.emptyColumnWidth || ''; gridTemplateColumnsHover += this.emptyColumnWidth || '';
gridTemplateColumns = `${gridTemplateColumns} ${SCROLLBAR_WIDTH}px`; const gridTemplateColumns = `${gridTemplateColumnsHover} ${SCROLLBAR_WIDTH}px`;
element.style.setProperty('--gridTemplateColumns', gridTemplateColumns); element.style.setProperty('--gridTemplateColumns', gridTemplateColumns);
element.style.setProperty('--gridTemplateColumnsHover', gridTemplateColumnsHover);
} }
private _setItemSize(element: HTMLElement) { private _setItemSize(element: HTMLElement) {

View File

@ -14,13 +14,11 @@ import {
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { combineLatest } from 'rxjs'; import { combineLatest } from 'rxjs';
import { filter, map, tap } from 'rxjs/operators'; import { filter, map, tap } from 'rxjs/operators';
import { CircleButtonComponent } from '../../../buttons/circle-button/circle-button.component'; import { CircleButtonComponent, CircleButtonTypes } from '../../../buttons';
import { CircleButtonTypes } from '../../../buttons/types/circle-button.type'; import { RoundCheckboxComponent } from '../../../inputs';
import { RoundCheckboxComponent } from '../../../inputs/round-checkbox/round-checkbox.component'; import { ContextComponent, Debounce } from '../../../utils';
import { ContextComponent } from '../../../utils/context.component'; import { IListable } from '../../models';
import { Debounce } from '../../../utils/decorators/debounce.decorator'; import { ListingService } from '../../services';
import { IListable } from '../../models/listable';
import { ListingService } from '../../services/listing.service';
import { WorkflowColumn } from '../models/workflow-column.model'; import { WorkflowColumn } from '../models/workflow-column.model';
interface ColumnHeaderContext { interface ColumnHeaderContext {
@ -36,6 +34,7 @@ interface ColumnHeaderContext {
templateUrl: './column-header.component.html', templateUrl: './column-header.component.html',
styleUrls: ['./column-header.component.scss'], styleUrls: ['./column-header.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [AsyncPipe, TranslateModule, RoundCheckboxComponent, NgTemplateOutlet, CircleButtonComponent], imports: [AsyncPipe, TranslateModule, RoundCheckboxComponent, NgTemplateOutlet, CircleButtonComponent],
}) })
export class ColumnHeaderComponent<T extends IListable, K extends string> extends ContextComponent<ColumnHeaderContext> implements OnInit { export class ColumnHeaderComponent<T extends IListable, K extends string> extends ContextComponent<ColumnHeaderContext> implements OnInit {

View File

@ -1,5 +1,5 @@
@use '../../../assets/styles/common-variables'; @import '../../../assets/styles/common-variables';
@use '../../../assets/styles/common-mixins' as mixins; @import '../../../assets/styles/common-mixins';
:host { :host {
display: flex; display: flex;
@ -67,7 +67,7 @@
.cdk-drop-list { .cdk-drop-list {
overflow-y: auto; overflow-y: auto;
@include mixins.no-scroll-bar; @include no-scroll-bar;
min-height: calc(100% - 36px); min-height: calc(100% - 36px);
&.multi-select-active { &.multi-select-active {
@ -135,5 +135,5 @@
cdk-virtual-scroll-viewport { cdk-virtual-scroll-viewport {
height: 100%; height: 100%;
@include mixins.no-scroll-bar; @include no-scroll-bar;
} }

View File

@ -50,6 +50,7 @@ interface WorkflowContext<T> {
templateUrl: './workflow.component.html', templateUrl: './workflow.component.html',
styleUrls: ['./workflow.component.scss'], styleUrls: ['./workflow.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [ imports: [
TableHeaderComponent, TableHeaderComponent,
AsyncPipe, AsyncPipe,

View File

@ -5,7 +5,6 @@ import { LoadingService } from '../loading.service';
selector: 'iqser-full-page-loading-indicator', selector: 'iqser-full-page-loading-indicator',
templateUrl: './full-page-loading-indicator.component.html', templateUrl: './full-page-loading-indicator.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
}) })
export class FullPageLoadingIndicatorComponent { export class FullPageLoadingIndicatorComponent {
constructor(readonly loadingService: LoadingService) {} constructor(readonly loadingService: LoadingService) {}

View File

@ -1,16 +1,15 @@
import { ChangeDetectionStrategy, Component, Input, OnInit, Optional } from '@angular/core'; import { ChangeDetectionStrategy, Component, Input, Optional, OnInit } from '@angular/core';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { FilterService, INestedFilter } from '../../filtering';
import { get, shareLast } from '../../utils';
import { ProgressBarConfigModel } from './progress-bar-config.model'; import { ProgressBarConfigModel } from './progress-bar-config.model';
import { FilterService, INestedFilter } from '../../filtering';
import { Observable, of } from 'rxjs';
import { get, shareLast } from '../../utils';
import { map } from 'rxjs/operators';
@Component({ @Component({
selector: 'iqser-progress-bar [config]', selector: 'iqser-progress-bar [config]',
templateUrl: './progress-bar.component.html', templateUrl: './progress-bar.component.html',
styleUrls: ['./progress-bar.component.scss'], styleUrls: ['./progress-bar.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
}) })
export class ProgressBarComponent implements OnInit { export class ProgressBarComponent implements OnInit {
@Input() config!: ProgressBarConfigModel; @Input() config!: ProgressBarConfigModel;

View File

@ -6,7 +6,6 @@ import { ILoadingConfig } from '../loading.service';
templateUrl: './progress-loading.component.html', templateUrl: './progress-loading.component.html',
styleUrls: ['./progress-loading.component.scss'], styleUrls: ['./progress-loading.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
}) })
export class ProgressLoadingComponent { export class ProgressLoadingComponent {
@Input() config!: ILoadingConfig; @Input() config!: ILoadingConfig;

View File

@ -7,6 +7,7 @@ import { PaginationSettings } from './pagination-settings';
selector: 'iqser-pagination', selector: 'iqser-pagination',
templateUrl: './pagination.component.html', templateUrl: './pagination.component.html',
styleUrls: ['./pagination.component.scss'], styleUrls: ['./pagination.component.scss'],
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [TranslateModule], imports: [TranslateModule],
}) })

View File

@ -6,6 +6,7 @@ import { assertTemplate, IqserPermissionsDirective } from './permissions.directi
@Directive({ @Directive({
selector: '[allow]', selector: '[allow]',
standalone: true,
}) })
export class IqserAllowDirective extends IqserPermissionsDirective implements OnDestroy, OnInit { export class IqserAllowDirective extends IqserPermissionsDirective implements OnDestroy, OnInit {
/** /**

View File

@ -6,6 +6,7 @@ import { assertTemplate, IqserPermissionsDirective } from './permissions.directi
@Directive({ @Directive({
selector: '[deny]', selector: '[deny]',
standalone: true,
}) })
export class IqserDenyDirective extends IqserPermissionsDirective implements OnDestroy, OnInit { export class IqserDenyDirective extends IqserPermissionsDirective implements OnDestroy, OnInit {
/** /**

View File

@ -29,7 +29,7 @@ export function isArray<T>(value: unknown): value is T[] {
} }
export function toArray(value?: string | List): List { export function toArray(value?: string | List): List {
return isString(value) ? [value] : (value ?? []); return isString(value) ? [value] : value ?? [];
} }
export function isRedirectWithParameters(object: any | IqserRedirectToNavigationParameters): object is IqserRedirectToNavigationParameters { export function isRedirectWithParameters(object: any | IqserRedirectToNavigationParameters): object is IqserRedirectToNavigationParameters {

View File

@ -3,6 +3,7 @@ import { capitalize } from '../utils';
@Pipe({ @Pipe({
name: 'capitalize', name: 'capitalize',
standalone: true,
}) })
export class CapitalizePipe implements PipeTransform { export class CapitalizePipe implements PipeTransform {
transform(value: string): string { transform(value: string): string {

View File

@ -3,6 +3,7 @@ import { humanizeCamelCase } from '../utils';
@Pipe({ @Pipe({
name: 'humanizeCamelCase', name: 'humanizeCamelCase',
standalone: true,
}) })
export class HumanizeCamelCasePipe implements PipeTransform { export class HumanizeCamelCasePipe implements PipeTransform {
transform(item: string): string { transform(item: string): string {

View File

@ -3,6 +3,7 @@ import { humanize } from '../utils';
@Pipe({ @Pipe({
name: 'humanize', name: 'humanize',
standalone: true,
}) })
export class HumanizePipe implements PipeTransform { export class HumanizePipe implements PipeTransform {
transform(item: string, lowercase = false): string { transform(item: string, lowercase = false): string {

Some files were not shown because too many files have changed in this diff Show More