@js-smart/ng-kit 20.6.0 → 20.6.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.js +18 -0
- package/karma.conf.js +35 -0
- package/ng-package.json +11 -0
- package/package.json +2 -13
- package/src/assets/app-buttons.css +33 -0
- package/src/assets/app-mat-snack-bar.css +89 -0
- package/src/assets/app-variables.css +10 -0
- package/src/assets/general.scss +77 -0
- package/src/assets/styles.scss +5 -0
- package/src/lib/components/alert/alert.component.html +12 -0
- package/src/lib/components/alert/alert.component.scss +5 -0
- package/src/lib/components/alert/alert.component.ts +105 -0
- package/src/lib/components/autocomplete/autocomplete.component.html +42 -0
- package/src/lib/components/autocomplete/autocomplete.component.ts +207 -0
- package/src/lib/components/buttons/base-button/base-button.component.html +0 -0
- package/src/lib/components/buttons/base-button/base-button.component.ts +86 -0
- package/src/lib/components/buttons/base-button/base-button.directive.ts +87 -0
- package/src/lib/components/buttons/bs-link-button/bs-link-button.component.ts +37 -0
- package/src/lib/components/buttons/bs-link-button/bs-link-button.directive.ts +28 -0
- package/src/lib/components/buttons/close-button/close-button.directive.ts +12 -0
- package/src/lib/components/buttons/delete-button/delete-button.component.ts +42 -0
- package/src/lib/components/buttons/delete-button/delete-button.directive.ts +15 -0
- package/src/lib/components/buttons/edit-bs-button/edit-bs-button.component.ts +39 -0
- package/src/lib/components/buttons/edit-bs-button/edit-bs-button.directive.ts +37 -0
- package/src/lib/components/buttons/edit-button/edit-button.component.ts +37 -0
- package/src/lib/components/buttons/edit-button/edit-button.directive.ts +15 -0
- package/src/lib/components/buttons/edit-svg-icon-button/edit-svg-icon-button.component.ts +37 -0
- package/src/lib/components/buttons/edit-svg-icon-button/edit-svg-icon-button.directive.ts +39 -0
- package/src/lib/components/buttons/excel-export-button/excel-export-button.component.ts +23 -0
- package/src/lib/components/buttons/excel-export-button/excel-export-button.directive.ts +23 -0
- package/src/lib/components/buttons/manage-button/manage-button.component.ts +35 -0
- package/src/lib/components/buttons/manage-button/manage-button.directive.ts +15 -0
- package/src/lib/components/buttons/pdf-export-button/pdf-export-button.component.ts +20 -0
- package/src/lib/components/buttons/pdf-export-button/pdf-export-button.directive.ts +22 -0
- package/src/lib/components/buttons/primary-button/primary-button.component.ts +43 -0
- package/src/lib/components/buttons/primary-button/primary-button.directive.ts +16 -0
- package/src/lib/components/buttons/save-primary-button/save-primary-button.component.ts +43 -0
- package/src/lib/components/buttons/save-primary-button/save-primary-button.directive.ts +16 -0
- package/src/lib/components/buttons/search-button/search-button.component.ts +41 -0
- package/src/lib/components/buttons/success-button/success-button.component.ts +41 -0
- package/src/lib/components/buttons/success-button/success-button.directive.ts +15 -0
- package/src/lib/components/buttons/view-button/view-button.component.ts +32 -0
- package/src/lib/components/buttons/view-button/view-button.directive.ts +14 -0
- package/src/lib/components/buttons/view-primary-button/view-primary-button.component.ts +37 -0
- package/src/lib/components/buttons/view-primary-button/view-primary-button.directive.ts +15 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +56 -0
- package/src/lib/components/ngx-spinner/ngx-spinner.component.css +169 -0
- package/src/lib/components/ngx-spinner/ngx-spinner.component.html +24 -0
- package/src/lib/components/ngx-spinner/ngx-spinner.component.spec.ts +186 -0
- package/src/lib/components/ngx-spinner/ngx-spinner.component.ts +199 -0
- package/src/lib/components/ngx-spinner/ngx-spinner.enum.ts +45 -0
- package/src/lib/components/ngx-spinner/ngx-spinner.service.ts +66 -0
- package/src/lib/components/ngx-spinner/safe-html.pipe.ts +17 -0
- package/src/lib/components/snack-bar/error-snack-bar/error-snack-bar.component.ts +36 -0
- package/src/lib/components/snack-bar/success-snack-bar/success-snack-bar.component.ts +35 -0
- package/src/lib/components/spinner/spinner.component.html +11 -0
- package/src/lib/components/spinner/spinner.component.scss +18 -0
- package/src/lib/components/spinner/spinner.component.ts +31 -0
- package/src/lib/directives/ngx-print/ngx-print.directive.ts +281 -0
- package/src/lib/directives/ngx-print/print-options.ts +16 -0
- package/src/lib/directives/prevent-multiple-clicks/prevent-multiple-clicks.directive.spec.ts +99 -0
- package/src/lib/directives/prevent-multiple-clicks/prevent-multiple-clicks.directive.ts +36 -0
- package/src/lib/services/mat-snack-bar.service.ts +102 -0
- package/src/lib/store/entity-store.spec.ts +128 -0
- package/src/lib/store/entity-store.ts +88 -0
- package/src/lib/store/store.spec.ts +47 -0
- package/src/lib/store/store.ts +44 -0
- package/src/lib/svg-icons/edit-solid-svg/edit-solid-svg.component.ts +20 -0
- package/src/lib/types/id-type.ts +3 -0
- package/src/lib/types/progress-state.ts +7 -0
- package/src/lib/util/progress-util.ts +84 -0
- package/src/public-api.ts +64 -0
- package/test.ts +11 -0
- package/tsconfig.lib.json +12 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +10 -0
- package/fesm2022/js-smart-ng-kit.mjs +0 -2440
- package/fesm2022/js-smart-ng-kit.mjs.map +0 -1
- package/index.d.ts +0 -1095
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Component, input, output } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
standalone: true,
|
|
5
|
+
template: ``,
|
|
6
|
+
})
|
|
7
|
+
export class BaseButtonComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Is search in progress and loading the data
|
|
10
|
+
*/
|
|
11
|
+
loading = input(false, { transform: (value: boolean | undefined) => value ?? false });
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Is button disabled
|
|
15
|
+
*/
|
|
16
|
+
disabled = input<boolean>(false);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Type of the button. Following values are supported. See BootStrap docs for more information
|
|
20
|
+
* <pre>
|
|
21
|
+
* 1. button
|
|
22
|
+
* 2. submit
|
|
23
|
+
* </pre>
|
|
24
|
+
*/
|
|
25
|
+
type = input('button');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* If set, shows when action in Progress
|
|
29
|
+
*/
|
|
30
|
+
loadingLabel = input('Saving...');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* If set, shows when Delete is not in progress
|
|
34
|
+
*/
|
|
35
|
+
label = input('Save');
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* If set, shows the icon. Otherwise, shows delete icon
|
|
39
|
+
*/
|
|
40
|
+
icon = input('save');
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* If set, shows material icon otherwise hides the icons
|
|
44
|
+
*/
|
|
45
|
+
showIcon = input(true);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* If set, sets the style of the button
|
|
49
|
+
*/
|
|
50
|
+
style = input<any | null | undefined>();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* If set, sets the class of the button
|
|
54
|
+
*/
|
|
55
|
+
classes = input('btn');
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If set, sets the data-cy attribute for the button
|
|
59
|
+
*/
|
|
60
|
+
dataCy = input('save-button');
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Output event when button is clicked
|
|
64
|
+
*/
|
|
65
|
+
onClick = output<MouseEvent>();
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Output event when button is focused
|
|
69
|
+
*/
|
|
70
|
+
onFocus = output<FocusEvent>();
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Output event when button is blurred
|
|
74
|
+
*/
|
|
75
|
+
onBlur = output<FocusEvent>();
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Output event when key is pressed
|
|
79
|
+
*/
|
|
80
|
+
onKeyDown = output<KeyboardEvent>();
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Output event when key is up
|
|
84
|
+
*/
|
|
85
|
+
onKeyUp = output<KeyboardEvent>();
|
|
86
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Directive, DOCUMENT, effect, ElementRef, inject, input, OnInit, signal } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive()
|
|
4
|
+
export abstract class BaseButtonDirective implements OnInit {
|
|
5
|
+
icon = input<string>('');
|
|
6
|
+
loadingLabel = input<string>('Loading...');
|
|
7
|
+
loading = input<boolean>(false);
|
|
8
|
+
elementRef = inject(ElementRef);
|
|
9
|
+
document = inject(DOCUMENT);
|
|
10
|
+
|
|
11
|
+
protected originalText = signal('');
|
|
12
|
+
protected iconSpan = signal<HTMLElement | null>(null);
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this.elementRef.nativeElement.classList.add('btn');
|
|
16
|
+
|
|
17
|
+
effect(() => {
|
|
18
|
+
this.updateContent();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ngOnInit(): void {
|
|
23
|
+
// Capture original text before creating icon
|
|
24
|
+
this.originalText.set(this.elementRef.nativeElement.textContent?.trim() || 'Button');
|
|
25
|
+
|
|
26
|
+
// Create icon after capturing text
|
|
27
|
+
this.createIcon();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create icon element if icon name is provided
|
|
32
|
+
*/
|
|
33
|
+
protected createIcon(): void {
|
|
34
|
+
if (this.icon()) {
|
|
35
|
+
const iconElement = this.document.createElement('mat-icon');
|
|
36
|
+
iconElement.classList.add('mat-icon', 'material-icons', 'pe-2');
|
|
37
|
+
iconElement.textContent = this.icon();
|
|
38
|
+
this.iconSpan.set(iconElement);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Update content of the button
|
|
44
|
+
*/
|
|
45
|
+
protected updateContent(): void {
|
|
46
|
+
const element = this.elementRef.nativeElement;
|
|
47
|
+
element.innerHTML = '';
|
|
48
|
+
|
|
49
|
+
if (this.loading()) {
|
|
50
|
+
this.showLoadingState(element);
|
|
51
|
+
} else {
|
|
52
|
+
this.showNormalState(element);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Show loading state. Add spinner and loadingLabel text
|
|
58
|
+
*/
|
|
59
|
+
protected showLoadingState(element: HTMLElement): void {
|
|
60
|
+
// Create a new span element
|
|
61
|
+
const newSpan = this.document.createElement('span');
|
|
62
|
+
|
|
63
|
+
// Set its text content
|
|
64
|
+
newSpan.classList.add('spinner-border', 'spinner-border-sm', 'me-2');
|
|
65
|
+
newSpan.setAttribute('role', 'status');
|
|
66
|
+
|
|
67
|
+
// Append the new element to the host element
|
|
68
|
+
element.appendChild(newSpan);
|
|
69
|
+
element.appendChild(this.document.createTextNode(this.loadingLabel()));
|
|
70
|
+
element.setAttribute('disabled', 'true');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Show normal state. Add icon and original text
|
|
75
|
+
*/
|
|
76
|
+
protected showNormalState(element: HTMLElement): void {
|
|
77
|
+
// Add icon and original text
|
|
78
|
+
const iconElement = this.iconSpan();
|
|
79
|
+
if (iconElement) {
|
|
80
|
+
element.appendChild(iconElement);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Append text node instead of setting textContent (which overwrites the icon)
|
|
84
|
+
element.appendChild(this.document.createTextNode(this.originalText()));
|
|
85
|
+
element.removeAttribute('disabled');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
import { MatIcon } from '@angular/material/icon';
|
|
3
|
+
import { MatAnchor } from '@angular/material/button';
|
|
4
|
+
import { BaseButtonComponent } from '../base-button/base-button.component';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'bs-link-button',
|
|
8
|
+
imports: [MatIcon, MatAnchor],
|
|
9
|
+
template: `
|
|
10
|
+
<a
|
|
11
|
+
type="{{ type() }}"
|
|
12
|
+
class="{{ classes() }}"
|
|
13
|
+
(click)="onClick.emit($event)"
|
|
14
|
+
(focus)="onFocus.emit($event)"
|
|
15
|
+
(blur)="onBlur.emit($event)"
|
|
16
|
+
(keydown)="onKeyDown.emit($event)"
|
|
17
|
+
(keyup)="onKeyUp.emit($event)"
|
|
18
|
+
[disabled]="disabled()"
|
|
19
|
+
[type]="type()"
|
|
20
|
+
[style]="style()"
|
|
21
|
+
[attr.data-cy]="'bs-link-button'"
|
|
22
|
+
mat-button>
|
|
23
|
+
<mat-icon>{{ icon() }}</mat-icon>
|
|
24
|
+
{{ label() }}
|
|
25
|
+
</a>
|
|
26
|
+
`,
|
|
27
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
28
|
+
})
|
|
29
|
+
export class BsLinkButtonComponent extends BaseButtonComponent {
|
|
30
|
+
override label = input('Edit');
|
|
31
|
+
override icon = input('search');
|
|
32
|
+
override classes = input('btn text-primary');
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Directive, DOCUMENT, effect, ElementRef, inject, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[bsLinkButton]',
|
|
5
|
+
})
|
|
6
|
+
export class BsLinkButtonDirective {
|
|
7
|
+
icon = input<string>('search');
|
|
8
|
+
elementRef = inject(ElementRef);
|
|
9
|
+
document = inject(DOCUMENT);
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
this.elementRef.nativeElement.classList.add('btn', 'text-primary');
|
|
13
|
+
|
|
14
|
+
effect(() => {
|
|
15
|
+
this.updateContent();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private updateContent(): void {
|
|
20
|
+
// if icon present, add material-icons class and set text content
|
|
21
|
+
if (this.icon()) {
|
|
22
|
+
const iconSpan = this.document.createElement('span');
|
|
23
|
+
iconSpan.classList.add('material-icons', 'pe-2');
|
|
24
|
+
iconSpan.textContent = this.icon();
|
|
25
|
+
this.elementRef.nativeElement.appendChild(iconSpan);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Directive, ElementRef, inject } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[closeButton]',
|
|
5
|
+
})
|
|
6
|
+
export class CloseButtonDirective {
|
|
7
|
+
elementRef = inject(ElementRef);
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this.elementRef.nativeElement.classList.add('secondary-button');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
3
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
+
import { BaseButtonComponent } from '../base-button/base-button.component';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'delete-button',
|
|
8
|
+
imports: [MatButtonModule, MatIconModule],
|
|
9
|
+
template: `
|
|
10
|
+
<button
|
|
11
|
+
mat-raised-button
|
|
12
|
+
class="btn {{ classes() }}"
|
|
13
|
+
(click)="onClick.emit($event)"
|
|
14
|
+
(focus)="onFocus.emit($event)"
|
|
15
|
+
(blur)="onBlur.emit($event)"
|
|
16
|
+
(keydown)="onKeyDown.emit($event)"
|
|
17
|
+
(keyup)="onKeyUp.emit($event)"
|
|
18
|
+
[disabled]="disabled() || loading()"
|
|
19
|
+
[type]="type()"
|
|
20
|
+
[style]="style()"
|
|
21
|
+
[attr.data-cy]="'delete-button'">
|
|
22
|
+
@if (loading()) {
|
|
23
|
+
<span aria-hidden="true" class="spinner-border spinner-border-sm" role="status"></span>
|
|
24
|
+
}
|
|
25
|
+
@if (!loading()) {
|
|
26
|
+
<mat-icon>{{ icon() }}</mat-icon>
|
|
27
|
+
}
|
|
28
|
+
{{ loading() ? loadingLabel() : label() }}
|
|
29
|
+
</button>
|
|
30
|
+
`,
|
|
31
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
32
|
+
})
|
|
33
|
+
export class DeleteButtonComponent extends BaseButtonComponent {
|
|
34
|
+
override loadingLabel = input('Deleting...');
|
|
35
|
+
override label = input('Delete');
|
|
36
|
+
override icon = input('delete');
|
|
37
|
+
override classes = input('delete-button');
|
|
38
|
+
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Directive, input } from '@angular/core';
|
|
2
|
+
import { BaseButtonDirective } from '../base-button/base-button.directive';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[deleteButton]',
|
|
6
|
+
})
|
|
7
|
+
export class DeleteButtonDirective extends BaseButtonDirective {
|
|
8
|
+
override icon = input<string>('delete');
|
|
9
|
+
override loadingLabel = input<string>('Deleting...');
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.elementRef.nativeElement.classList.add('delete-button');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
5
|
+
import { EditSolidSvgComponent } from '../../../svg-icons/edit-solid-svg/edit-solid-svg.component';
|
|
6
|
+
import { BaseButtonComponent } from '../base-button/base-button.component';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'edit-bs-button',
|
|
10
|
+
imports: [MatButtonModule, MatIconModule, EditSolidSvgComponent],
|
|
11
|
+
template: `
|
|
12
|
+
<button
|
|
13
|
+
color="primary"
|
|
14
|
+
type="{{ type() }}"
|
|
15
|
+
class="{{ classes() }}"
|
|
16
|
+
(click)="onClick.emit($event)"
|
|
17
|
+
(focus)="onFocus.emit($event)"
|
|
18
|
+
(blur)="onBlur.emit($event)"
|
|
19
|
+
(keydown)="onKeyDown.emit($event)"
|
|
20
|
+
(keyup)="onKeyUp.emit($event)"
|
|
21
|
+
[disabled]="disabled()"
|
|
22
|
+
[type]="type()"
|
|
23
|
+
[style]="style()"
|
|
24
|
+
[attr.data-cy]="'edit-bs-button'"
|
|
25
|
+
mat-button>
|
|
26
|
+
<edit-solid-svg></edit-solid-svg>
|
|
27
|
+
{{ label() }}
|
|
28
|
+
</button>
|
|
29
|
+
`,
|
|
30
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
31
|
+
})
|
|
32
|
+
export class EditBsButtonComponent extends BaseButtonComponent {
|
|
33
|
+
override label = input('Edit');
|
|
34
|
+
override classes = input('text-primary');
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ComponentRef, Directive, DOCUMENT, ElementRef, inject, OnInit, signal, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { EditSolidSvgComponent } from '../../../svg-icons/edit-solid-svg/edit-solid-svg.component';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[editBsButton]',
|
|
6
|
+
})
|
|
7
|
+
export class EditBsButtonDirective implements OnInit {
|
|
8
|
+
elementRef = inject(ElementRef);
|
|
9
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
10
|
+
document = inject(DOCUMENT);
|
|
11
|
+
protected originalText = signal('');
|
|
12
|
+
protected iconComponentRef = signal<ComponentRef<EditSolidSvgComponent> | null>(null);
|
|
13
|
+
|
|
14
|
+
ngOnInit(): void {
|
|
15
|
+
// Add the btn class first
|
|
16
|
+
this.elementRef.nativeElement.classList.add('btn', 'text-primary');
|
|
17
|
+
|
|
18
|
+
// Capture original text before creating icon
|
|
19
|
+
this.originalText.set(this.elementRef.nativeElement.textContent?.trim() || 'Edit');
|
|
20
|
+
|
|
21
|
+
// Update content to show icon and text
|
|
22
|
+
this.updateContent();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private updateContent(): void {
|
|
26
|
+
// Create the EditSolidSvgComponent properly using Angular's component system
|
|
27
|
+
const componentRef = this.viewContainerRef.createComponent(EditSolidSvgComponent);
|
|
28
|
+
this.iconComponentRef.set(componentRef);
|
|
29
|
+
|
|
30
|
+
// Clear the original content and append the icon component
|
|
31
|
+
this.elementRef.nativeElement.textContent = '';
|
|
32
|
+
this.elementRef.nativeElement.appendChild(componentRef.location.nativeElement);
|
|
33
|
+
|
|
34
|
+
// Add text after the icon
|
|
35
|
+
this.elementRef.nativeElement.appendChild(this.document.createTextNode(' ' + this.originalText()));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { MatIcon } from '@angular/material/icon';
|
|
4
|
+
import { MatButton } from '@angular/material/button';
|
|
5
|
+
import { BaseButtonComponent } from '../base-button/base-button.component';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'edit-button',
|
|
9
|
+
imports: [MatButton, MatIcon],
|
|
10
|
+
template: `
|
|
11
|
+
<button
|
|
12
|
+
class="{{ classes() }}"
|
|
13
|
+
(click)="onClick.emit($event)"
|
|
14
|
+
(focus)="onFocus.emit($event)"
|
|
15
|
+
(blur)="onBlur.emit($event)"
|
|
16
|
+
(keydown)="onKeyDown.emit($event)"
|
|
17
|
+
(keyup)="onKeyUp.emit($event)"
|
|
18
|
+
[disabled]="disabled()"
|
|
19
|
+
[type]="type()"
|
|
20
|
+
[style]="style()"
|
|
21
|
+
[attr.data-cy]="'edit-button'"
|
|
22
|
+
mat-raised-button>
|
|
23
|
+
<mat-icon>{{ icon() }}</mat-icon>
|
|
24
|
+
{{ label() }}
|
|
25
|
+
</button>
|
|
26
|
+
`,
|
|
27
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
28
|
+
})
|
|
29
|
+
export class EditButtonComponent extends BaseButtonComponent {
|
|
30
|
+
override label = input('Edit');
|
|
31
|
+
override icon = input('edit');
|
|
32
|
+
override classes = input('primary-button');
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Directive, input } from '@angular/core';
|
|
2
|
+
import { BaseButtonDirective } from '../base-button/base-button.directive';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[editButton]',
|
|
6
|
+
})
|
|
7
|
+
export class EditButtonDirective extends BaseButtonDirective {
|
|
8
|
+
override icon = input<string>('edit');
|
|
9
|
+
override loadingLabel = input<string>('Editing...');
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.elementRef.nativeElement.classList.add('primary-button');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
import { MatButton } from '@angular/material/button';
|
|
3
|
+
import { EditSolidSvgComponent } from '../../../svg-icons/edit-solid-svg/edit-solid-svg.component';
|
|
4
|
+
import { BaseButtonComponent } from '../base-button/base-button.component';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'edit-svg-icon-button',
|
|
8
|
+
imports: [MatButton, EditSolidSvgComponent],
|
|
9
|
+
template: `
|
|
10
|
+
<button
|
|
11
|
+
type="{{ type() }}"
|
|
12
|
+
class="{{ classes() }}"
|
|
13
|
+
(click)="onClick.emit($event)"
|
|
14
|
+
(focus)="onFocus.emit($event)"
|
|
15
|
+
(blur)="onBlur.emit($event)"
|
|
16
|
+
(keydown)="onKeyDown.emit($event)"
|
|
17
|
+
(keyup)="onKeyUp.emit($event)"
|
|
18
|
+
[disabled]="disabled()"
|
|
19
|
+
[type]="type()"
|
|
20
|
+
[style]="style()"
|
|
21
|
+
[attr.data-cy]="'edit-svg-icon-button'"
|
|
22
|
+
mat-raised-button>
|
|
23
|
+
<edit-solid-svg></edit-solid-svg>
|
|
24
|
+
{{ label() }}
|
|
25
|
+
</button>
|
|
26
|
+
`,
|
|
27
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
28
|
+
})
|
|
29
|
+
export class EditSvgIconButtonComponent extends BaseButtonComponent {
|
|
30
|
+
override label = input('Edit');
|
|
31
|
+
override icon = input('edit');
|
|
32
|
+
override classes = input('primary-button');
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComponentRef, Directive, DOCUMENT, ElementRef, inject, OnInit, signal, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { EditSolidSvgComponent } from '../../../svg-icons/edit-solid-svg/edit-solid-svg.component';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[editSvgIconButton]',
|
|
6
|
+
})
|
|
7
|
+
export class EditSvgIconButtonDirective implements OnInit {
|
|
8
|
+
elementRef = inject(ElementRef);
|
|
9
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
10
|
+
document = inject(DOCUMENT);
|
|
11
|
+
|
|
12
|
+
protected originalText = signal('');
|
|
13
|
+
protected iconComponentRef = signal<ComponentRef<EditSolidSvgComponent> | null>(null);
|
|
14
|
+
|
|
15
|
+
ngOnInit(): void {
|
|
16
|
+
// Add Material Design button classes
|
|
17
|
+
this.elementRef.nativeElement.classList.add('mat-raised-button', 'primary-button');
|
|
18
|
+
|
|
19
|
+
// Capture original text before creating icon
|
|
20
|
+
this.originalText.set(this.elementRef.nativeElement.textContent?.trim() || 'Edit');
|
|
21
|
+
|
|
22
|
+
// Set data-cy attribute for testing
|
|
23
|
+
this.elementRef.nativeElement.setAttribute('data-cy', 'edit-svg-icon-button');
|
|
24
|
+
|
|
25
|
+
// Update content to show icon and text
|
|
26
|
+
this.updateContent();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private updateContent(): void {
|
|
30
|
+
// Create the EditSolidSvgComponent properly using Angular's component system
|
|
31
|
+
const componentRef = this.viewContainerRef.createComponent(EditSolidSvgComponent);
|
|
32
|
+
this.iconComponentRef.set(componentRef);
|
|
33
|
+
|
|
34
|
+
// Clear the original content and append the icon component
|
|
35
|
+
this.elementRef.nativeElement.textContent = '';
|
|
36
|
+
this.elementRef.nativeElement.appendChild(componentRef.location.nativeElement);
|
|
37
|
+
this.elementRef.nativeElement.appendChild(this.document.createTextNode(' ' + this.originalText()));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'excel-export-button',
|
|
7
|
+
imports: [MatButtonModule],
|
|
8
|
+
template: ` <button class="excel-export-button" mat-raised-button type="button" data-cy="excel-export-button">Excel</button> `,
|
|
9
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
10
|
+
styles: [
|
|
11
|
+
`
|
|
12
|
+
.excel-export-button {
|
|
13
|
+
margin-left: 20px !important;
|
|
14
|
+
margin-right: 20px !important;
|
|
15
|
+
width: 100px;
|
|
16
|
+
color: white !important;
|
|
17
|
+
background-color: darkgreen !important;
|
|
18
|
+
border-radius: 24px !important;
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
],
|
|
22
|
+
})
|
|
23
|
+
export class ExcelExportButtonComponent {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Directive } from '@angular/core';
|
|
2
|
+
import { BaseButtonDirective } from '../base-button/base-button.directive';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[excelExportButton]',
|
|
6
|
+
})
|
|
7
|
+
export class ExcelExportButtonDirective extends BaseButtonDirective {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
const styles = [
|
|
11
|
+
{ property: 'margin-left', value: '20px' },
|
|
12
|
+
{ property: 'margin-right', value: '20px' },
|
|
13
|
+
{ property: 'width', value: '100px' },
|
|
14
|
+
{ property: 'color', value: 'white' },
|
|
15
|
+
{ property: 'background-color', value: 'darkgreen' },
|
|
16
|
+
{ property: 'border-radius', value: '24px' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
styles.forEach((style) => {
|
|
20
|
+
this.elementRef.nativeElement.style[style.property] = style.value;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { MatButton } from '@angular/material/button';
|
|
4
|
+
import { MatIcon } from '@angular/material/icon';
|
|
5
|
+
import { BaseButtonComponent } from '../base-button/base-button.component';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'manage-button',
|
|
9
|
+
imports: [MatButton, MatIcon],
|
|
10
|
+
template: `
|
|
11
|
+
<button
|
|
12
|
+
mat-raised-button
|
|
13
|
+
class="{{ classes() }}"
|
|
14
|
+
(click)="onClick.emit($event)"
|
|
15
|
+
(focus)="onFocus.emit($event)"
|
|
16
|
+
(blur)="onBlur.emit($event)"
|
|
17
|
+
[disabled]="disabled()"
|
|
18
|
+
[type]="type()"
|
|
19
|
+
[style]="style()"
|
|
20
|
+
[attr.data-cy]="'manage-button'">
|
|
21
|
+
<mat-icon>{{ icon() }}</mat-icon>
|
|
22
|
+
{{ label() }}
|
|
23
|
+
</button>
|
|
24
|
+
`,
|
|
25
|
+
styleUrls: ['../../../../assets/app-buttons.css'],
|
|
26
|
+
})
|
|
27
|
+
export class ManageButtonComponent extends BaseButtonComponent {
|
|
28
|
+
override label = input('Manage');
|
|
29
|
+
override icon = input('settings');
|
|
30
|
+
override classes = input('mr-3 btn btn-secondary secondary-button');
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Directive, input } from '@angular/core';
|
|
2
|
+
import { BaseButtonDirective } from '../base-button/base-button.directive';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[manageButton]',
|
|
6
|
+
})
|
|
7
|
+
export class ManageButtonDirective extends BaseButtonDirective {
|
|
8
|
+
override icon = input<string>('settings');
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.elementRef.nativeElement.classList.add('mr-3');
|
|
13
|
+
this.elementRef.nativeElement.classList.add('secondary-button');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'pdf-export-button',
|
|
6
|
+
imports: [MatButtonModule],
|
|
7
|
+
template: ` <button class="pdf-export-button" mat-raised-button type="button" data-cy="pdf-export-button">PDF</button> `,
|
|
8
|
+
styles: [
|
|
9
|
+
`
|
|
10
|
+
.pdf-export-button {
|
|
11
|
+
margin-left: 20px !important;
|
|
12
|
+
width: 100px;
|
|
13
|
+
color: white !important;
|
|
14
|
+
background-color: #a3071b !important;
|
|
15
|
+
border-radius: 24px !important;
|
|
16
|
+
}
|
|
17
|
+
`,
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
export class PdfExportButtonComponent {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Directive } from '@angular/core';
|
|
2
|
+
import { BaseButtonDirective } from '../base-button/base-button.directive';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[pdfExportButton]',
|
|
6
|
+
})
|
|
7
|
+
export class PdfExportButtonDirective extends BaseButtonDirective {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
const styles = [
|
|
11
|
+
{ property: 'margin-left', value: '20px' },
|
|
12
|
+
{ property: 'width', value: '100px' },
|
|
13
|
+
{ property: 'color', value: 'white' },
|
|
14
|
+
{ property: 'background-color', value: '#a3071b' },
|
|
15
|
+
{ property: 'border-radius', value: '24px' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
styles.forEach((style) => {
|
|
19
|
+
this.elementRef.nativeElement.style[style.property] = style.value;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|