@c8y/tutorial 1019.6.11 → 1019.7.15
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/cumulocity.config.ts +21 -7
- package/package.json +6 -6
- package/src/__mocks/utils/common.ts +1 -4
- package/src/hooks/action/logout-action/logout-action.component.ts +6 -2
- package/src/modal/confirm-modal/confirm-modal-example.component.ts +43 -54
- package/src/modal/confirm-modal/delete-modal-example.component.ts +73 -0
- package/src/modal/ngx-modal/ngx-modal-example.component.ts +73 -21
- package/src/modal/ngx-modal/ngx-modal-example.module.ts +1 -1
- package/src/modal/ngx-modal/simple-modal-example.component.ts +45 -0
- package/src/modal/ngx-modal-accessibility/ngx-modal-accessibility-example.component.ts +47 -0
- package/src/modal/ngx-modal-accessibility/ngx-modal-accessibility-example.module.ts +24 -0
- package/src/modal/ngx-modal-accessibility/simple-modal-accessibility-example.component.ts +49 -0
- package/src/modal/ngx-modal-selectors/ngx-modal-selectors-example.component.ts +47 -0
- package/src/modal/ngx-modal-selectors/ngx-modal-selectors-example.module.ts +24 -0
- package/src/modal/ngx-modal-selectors/simple-modal-example-with-content-selectors.component.ts +72 -0
- package/src/modal/ngx-modal-sizes/large-modal-example.component.ts +45 -0
- package/src/modal/ngx-modal-sizes/medium-modal-example.component.ts +45 -0
- package/src/modal/ngx-modal-sizes/ngx-modal-sizes-example.component.ts +66 -0
- package/src/modal/ngx-modal-sizes/ngx-modal-sizes-example.module.ts +22 -0
- package/src/modal/ngx-modal-sizes/small-modal-example.component.ts +49 -0
- package/src/modal/simple-modal/modal-example.component.ts +0 -34
- package/src/modal/simple-modal/modal.example.module.ts +0 -21
package/cumulocity.config.ts
CHANGED
|
@@ -388,12 +388,6 @@ export default {
|
|
|
388
388
|
path: './src/properties-list/properties-list-example.module.ts',
|
|
389
389
|
description: 'An example of using properties list.'
|
|
390
390
|
},
|
|
391
|
-
{
|
|
392
|
-
name: 'Modal example',
|
|
393
|
-
module: 'ModalExampleModule',
|
|
394
|
-
path: './src/modal/simple-modal/modal.example.module.ts',
|
|
395
|
-
description: 'An example for using Modal.'
|
|
396
|
-
},
|
|
397
391
|
{
|
|
398
392
|
name: 'Confirm modal example',
|
|
399
393
|
module: 'ConfirmModalExampleModule',
|
|
@@ -412,6 +406,24 @@ export default {
|
|
|
412
406
|
path: './src/modal/ngx-modal/ngx-modal-example.module.ts',
|
|
413
407
|
description: 'An example for ngx modal.'
|
|
414
408
|
},
|
|
409
|
+
{
|
|
410
|
+
name: 'Example of ngx modal sizes',
|
|
411
|
+
module: 'NgxModalSizesExampleModule',
|
|
412
|
+
path: './src/modal/ngx-modal-sizes/ngx-modal-sizes-example.module.ts',
|
|
413
|
+
description: 'An example for ngx modal of different sizes.'
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
name: 'Example of ngx modal selectors',
|
|
417
|
+
module: 'NgxModalSelectorsExampleModule',
|
|
418
|
+
path: './src/modal/ngx-modal-selectors/ngx-modal-selectors-example.module.ts',
|
|
419
|
+
description: 'An example for ngx modal using ng-content selectors.'
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: 'Example of ngx modal accessibility',
|
|
423
|
+
module: 'NgxModalAccessibilityExampleModule',
|
|
424
|
+
path: './src/modal/ngx-modal-accessibility/ngx-modal-accessibility-example.module.ts',
|
|
425
|
+
description: 'An example for ngx modal accessibility.'
|
|
426
|
+
},
|
|
415
427
|
{
|
|
416
428
|
name: 'Example of realtime',
|
|
417
429
|
module: 'RealtimeTutorialModule',
|
|
@@ -586,6 +598,9 @@ export default {
|
|
|
586
598
|
'FormsTutorialModule',
|
|
587
599
|
'TextTranslationNgnonbindableModule',
|
|
588
600
|
'NgxModalExampleModule',
|
|
601
|
+
'NgxModalSizesExampleModule',
|
|
602
|
+
'NgxModalSelectorsExampleModule',
|
|
603
|
+
'NgxModalAccessibilityExampleModule',
|
|
589
604
|
'JsonSchemaExampleModule',
|
|
590
605
|
'IntroductionExampleModule',
|
|
591
606
|
'CustomElementExampleModule',
|
|
@@ -637,7 +652,6 @@ export default {
|
|
|
637
652
|
'AssetSelectorMillerExampleModule',
|
|
638
653
|
'AssetSelectorTreeExampleModule',
|
|
639
654
|
'DatapointSelectionExampleModule',
|
|
640
|
-
'ModalExampleModule',
|
|
641
655
|
'ConfirmModalExampleModule',
|
|
642
656
|
'TutorialVersionModule',
|
|
643
657
|
'PopConfirmExampleModule',
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c8y/tutorial",
|
|
3
|
-
"version": "1019.
|
|
3
|
+
"version": "1019.7.15",
|
|
4
4
|
"description": "This package is used to scaffold a tutorial for Cumulocity IoT Web SDK which explains a lot of concepts.",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@c8y/devkit": "1019.
|
|
7
|
-
"@c8y/style": "1019.
|
|
8
|
-
"@c8y/ngx-components": "1019.
|
|
9
|
-
"@c8y/client": "1019.
|
|
10
|
-
"@c8y/bootstrap": "1019.
|
|
6
|
+
"@c8y/devkit": "1019.7.15",
|
|
7
|
+
"@c8y/style": "1019.7.15",
|
|
8
|
+
"@c8y/ngx-components": "1019.7.15",
|
|
9
|
+
"@c8y/client": "1019.7.15",
|
|
10
|
+
"@c8y/bootstrap": "1019.7.15",
|
|
11
11
|
"@angular/cdk": "^16.2.11",
|
|
12
12
|
"ngx-bootstrap": "11.0.2",
|
|
13
13
|
"leaflet": "1.7.1",
|
|
@@ -12,8 +12,6 @@ import { from } from 'rxjs';
|
|
|
12
12
|
* @param urlPath - The URL path which will be used to determine if the request should be handled. If the request URL includes this path, a handler will be searched for.
|
|
13
13
|
* @param handlers - An object mapping HTTP methods to their respective handlers. These handlers are functions that accept a string argument (requestDescriptor), which is a combination of the request URL and any parameters or body, and return either a Promise or an object of `IFetchResponse` type.
|
|
14
14
|
*
|
|
15
|
-
* For example:
|
|
16
|
-
*
|
|
17
15
|
* ```typescript
|
|
18
16
|
* {
|
|
19
17
|
* POST: mockPOSTFunction,
|
|
@@ -25,7 +23,7 @@ import { from } from 'rxjs';
|
|
|
25
23
|
* If a handler is found for the HTTP method of the request, the handler function is called with the `requestDescriptor` as its argument.
|
|
26
24
|
* @returns An Observable which will either contain the response from the matched handler function or, if no handler is matched, the result of the `next.handle(req)` call.
|
|
27
25
|
*
|
|
28
|
-
*
|
|
26
|
+
*
|
|
29
27
|
* In the example below, all requests to inventory/managedObjects will pass through the interceptor.
|
|
30
28
|
*
|
|
31
29
|
* ```typescript
|
|
@@ -45,7 +43,6 @@ import { from } from 'rxjs';
|
|
|
45
43
|
* mockPUT(_requestDescriptor: string) {
|
|
46
44
|
* return null;
|
|
47
45
|
* }
|
|
48
|
-
* ...
|
|
49
46
|
* }
|
|
50
47
|
* ```
|
|
51
48
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component } from '@angular/core';
|
|
2
|
+
// eslint-disable-next-line
|
|
2
3
|
import { CoreModule, LoginService } from '@c8y/ngx-components';
|
|
3
4
|
|
|
4
5
|
@Component({
|
|
@@ -10,9 +11,12 @@ import { CoreModule, LoginService } from '@c8y/ngx-components';
|
|
|
10
11
|
imports: [CoreModule]
|
|
11
12
|
})
|
|
12
13
|
export class LogoutActionComponent {
|
|
13
|
-
|
|
14
|
+
// Uncomment to see the effect.
|
|
15
|
+
// constructor(private loginService: LoginService) {}
|
|
14
16
|
|
|
15
17
|
logout() {
|
|
16
|
-
|
|
18
|
+
console.log('Logout action triggered!');
|
|
19
|
+
// Uncomment to see the effect.
|
|
20
|
+
// this.loginService.logout();
|
|
17
21
|
}
|
|
18
22
|
}
|
|
@@ -1,69 +1,58 @@
|
|
|
1
|
-
import { Component
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
2
|
import {
|
|
3
|
-
ConfirmModalComponent,
|
|
4
3
|
CoreModule,
|
|
5
4
|
FormsModule,
|
|
6
|
-
|
|
5
|
+
gettext,
|
|
7
6
|
ModalModule,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
ModalService,
|
|
8
|
+
Status
|
|
10
9
|
} from '@c8y/ngx-components';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { BsModalService } from 'ngx-bootstrap/modal';
|
|
11
|
+
import { DeleteModalExampleComponent } from './delete-modal-example.component';
|
|
13
12
|
|
|
14
13
|
@Component({
|
|
15
|
-
selector: 'confirm-modal',
|
|
16
|
-
template: `<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<span></span>
|
|
30
|
-
<span class="text-break-word">
|
|
31
|
-
{{ 'Also delete all devices inside asset and its subassets' }}
|
|
32
|
-
</span>
|
|
33
|
-
</label>
|
|
34
|
-
</c8y-form-group>
|
|
35
|
-
</form>
|
|
36
|
-
</c8y-confirm-modal>`,
|
|
14
|
+
selector: 'tut-confirm-modal',
|
|
15
|
+
template: `<div class="p-t-24">
|
|
16
|
+
<c8y-title>Confirm modal example</c8y-title>
|
|
17
|
+
<div class="p-b-24 text-center">
|
|
18
|
+
<button class="btn btn-default" (click)="deleteConfigurationSnapshot()">
|
|
19
|
+
Confirm modal using <code>ModalService.confirm</code>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="p-b-24 text-center">
|
|
23
|
+
<button class="btn btn-default" (click)="deleteDevice()">
|
|
24
|
+
Confirm modal using <code>c8y-confirm-modal</code> component
|
|
25
|
+
</button>
|
|
26
|
+
</div>
|
|
27
|
+
</div>`,
|
|
37
28
|
standalone: true,
|
|
38
|
-
imports: [ModalModule, FormsModule, CoreModule]
|
|
29
|
+
imports: [ModalModule, FormsModule, CoreModule, DeleteModalExampleComponent]
|
|
39
30
|
})
|
|
40
31
|
export class ConfirmModalExampleComponent {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
config: DeleteModalCheckboxes = {
|
|
46
|
-
cascade: false
|
|
47
|
-
};
|
|
32
|
+
constructor(
|
|
33
|
+
private bsModalService: BsModalService,
|
|
34
|
+
private modalService: ModalService
|
|
35
|
+
) {}
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
await this.modalRef.result;
|
|
52
|
-
this.onClose();
|
|
53
|
-
} catch (error) {
|
|
54
|
-
this.onDismiss();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
onClose() {
|
|
59
|
-
console.log('You have clicked "Delete" button the modal!');
|
|
60
|
-
this.closeSubject.next(this.config);
|
|
61
|
-
console.log('cascade is true -> you checked the checkbox', this.config);
|
|
62
|
-
this.closeSubject.complete();
|
|
37
|
+
deleteDevice() {
|
|
38
|
+
this.bsModalService.show(DeleteModalExampleComponent);
|
|
63
39
|
}
|
|
64
40
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
async deleteConfigurationSnapshot() {
|
|
42
|
+
try {
|
|
43
|
+
await this.modalService.confirm(
|
|
44
|
+
'Delete configuration snapshot',
|
|
45
|
+
'You are about to delete the configuration snapshot DeviceA.',
|
|
46
|
+
Status.DANGER,
|
|
47
|
+
{
|
|
48
|
+
ok: gettext('Delete')
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
52
|
+
console.log('Delete clicked');
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
console.log('Cancel clicked');
|
|
56
|
+
}
|
|
68
57
|
}
|
|
69
58
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AfterViewInit, Component, EventEmitter, Output, ViewChild } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
ConfirmModalComponent,
|
|
4
|
+
CoreModule,
|
|
5
|
+
FormsModule,
|
|
6
|
+
ModalLabels,
|
|
7
|
+
ModalModule,
|
|
8
|
+
Status,
|
|
9
|
+
StatusType
|
|
10
|
+
} from '@c8y/ngx-components';
|
|
11
|
+
import { DeleteModalCheckboxes } from '@c8y/ngx-components/sub-assets';
|
|
12
|
+
import { Subject } from 'rxjs';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'tut-delete-modal',
|
|
16
|
+
template: ` <c8y-confirm-modal
|
|
17
|
+
[title]="'Delete device'"
|
|
18
|
+
[status]="status"
|
|
19
|
+
[labels]="labels"
|
|
20
|
+
#modalRef
|
|
21
|
+
>
|
|
22
|
+
<form>
|
|
23
|
+
<p class="text-wrap m-b-16">
|
|
24
|
+
{{ 'You are about to delete device. Do you want to proceed?' }}
|
|
25
|
+
</p>
|
|
26
|
+
<c8y-form-group class="m-b-0">
|
|
27
|
+
<label class="c8y-checkbox" title="{{ 'Delete devices' }}">
|
|
28
|
+
<input name="cascade" type="checkbox" [(ngModel)]="config.cascade" />
|
|
29
|
+
<span></span>
|
|
30
|
+
<span class="text-break-word">
|
|
31
|
+
{{ 'Also delete all devices inside asset and its subassets' }}
|
|
32
|
+
</span>
|
|
33
|
+
</label>
|
|
34
|
+
</c8y-form-group>
|
|
35
|
+
</form>
|
|
36
|
+
</c8y-confirm-modal>`,
|
|
37
|
+
standalone: true,
|
|
38
|
+
imports: [ModalModule, FormsModule, CoreModule]
|
|
39
|
+
})
|
|
40
|
+
export class DeleteModalExampleComponent implements AfterViewInit {
|
|
41
|
+
@ViewChild('modalRef', { static: false }) modalRef: ConfirmModalComponent;
|
|
42
|
+
labels: ModalLabels = { ok: 'Delete', cancel: 'Cancel' };
|
|
43
|
+
status: StatusType = Status.DANGER;
|
|
44
|
+
closeSubject: Subject<DeleteModalCheckboxes> = new Subject();
|
|
45
|
+
config: DeleteModalCheckboxes = {
|
|
46
|
+
cascade: false
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
@Output() hideModal = new EventEmitter();
|
|
50
|
+
|
|
51
|
+
async ngAfterViewInit() {
|
|
52
|
+
try {
|
|
53
|
+
await this.modalRef.result;
|
|
54
|
+
this.onClose();
|
|
55
|
+
} catch (error) {
|
|
56
|
+
this.onDismiss();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onClose() {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.log('You have clicked the "Delete" button!');
|
|
63
|
+
// eslint-disable-next-line no-console
|
|
64
|
+
console.log('Config value:', this.config);
|
|
65
|
+
this.hideModal.emit();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onDismiss() {
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.log('You have clicked "Cancel" button the modal!');
|
|
71
|
+
this.hideModal.emit();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,34 +1,86 @@
|
|
|
1
1
|
import { Component, TemplateRef } from '@angular/core';
|
|
2
2
|
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
|
|
3
|
+
import {
|
|
4
|
+
C8yTranslateModule,
|
|
5
|
+
FormsModule,
|
|
6
|
+
HeaderModule,
|
|
7
|
+
ModalLabels,
|
|
8
|
+
ModalModule,
|
|
9
|
+
CoreModule
|
|
10
|
+
} from '@c8y/ngx-components';
|
|
11
|
+
import { SimpleModalExampleComponent } from './simple-modal-example.component';
|
|
3
12
|
|
|
4
13
|
@Component({
|
|
5
|
-
selector: 'ngx-modal
|
|
6
|
-
template: `<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
selector: 'tut-ngx-modal',
|
|
15
|
+
template: `<div class="p-t-24">
|
|
16
|
+
<c8y-title>ngx-bootstrap modal example</c8y-title>
|
|
17
|
+
<div class="p-b-24 text-center">
|
|
18
|
+
<button class="btn btn-default" type="button" (click)="openTemplateModal(template)">
|
|
19
|
+
Modal with <code>TemplateRef</code>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="p-b-24 text-center">
|
|
23
|
+
<button class="btn btn-default" type="button" (click)="openC8yComponentModal()">
|
|
24
|
+
Modal with <code>c8y-modal</code>
|
|
25
|
+
</button>
|
|
26
|
+
</div>
|
|
10
27
|
<ng-template #template>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
<c8y-modal
|
|
29
|
+
title="Export documents"
|
|
30
|
+
(onClose)="onTemplateRefClose($event)"
|
|
31
|
+
(onDismiss)="onTemplateRefDismiss($event)"
|
|
32
|
+
[labels]="labels"
|
|
33
|
+
[disabled]="true"
|
|
34
|
+
>
|
|
35
|
+
<c8y-list-group>
|
|
36
|
+
<c8y-li *ngFor="let a of listArray; let index = index">
|
|
37
|
+
<c8y-li-checkbox></c8y-li-checkbox>
|
|
38
|
+
<c8y-li-icon icon="file"></c8y-li-icon>
|
|
39
|
+
Document {{ index + 1 }}
|
|
40
|
+
</c8y-li>
|
|
41
|
+
</c8y-list-group>
|
|
42
|
+
</c8y-modal>
|
|
43
|
+
</ng-template>
|
|
44
|
+
</div>`,
|
|
24
45
|
standalone: true,
|
|
25
|
-
imports: [
|
|
46
|
+
imports: [
|
|
47
|
+
SimpleModalExampleComponent,
|
|
48
|
+
HeaderModule,
|
|
49
|
+
C8yTranslateModule,
|
|
50
|
+
FormsModule,
|
|
51
|
+
ModalModule,
|
|
52
|
+
CoreModule
|
|
53
|
+
]
|
|
26
54
|
})
|
|
27
55
|
export class NgxModalExampleComponent {
|
|
28
56
|
modalRef?: BsModalRef;
|
|
57
|
+
labels: ModalLabels = { ok: 'Export', cancel: 'Cancel' };
|
|
58
|
+
listArray = new Array(12);
|
|
29
59
|
constructor(private modalService: BsModalService) {}
|
|
30
60
|
|
|
31
|
-
|
|
32
|
-
|
|
61
|
+
onTemplateRefDismiss(_) {
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.log('On "Cancel" clicked');
|
|
64
|
+
this.modalRef.hide();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onTemplateRefClose(_) {
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.log('On "Export" clicked');
|
|
70
|
+
this.modalRef.hide();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
openTemplateModal(template: TemplateRef<any>) {
|
|
75
|
+
this.modalRef = this.modalService.show(template, { ignoreBackdropClick: true });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
openC8yComponentModal(size: 'modal-sm' | 'modal-md' | 'modal-lg' = 'modal-md') {
|
|
79
|
+
this.modalService.show(SimpleModalExampleComponent, {
|
|
80
|
+
class: size,
|
|
81
|
+
ariaDescribedby: 'modal-body',
|
|
82
|
+
ariaLabelledBy: 'modal-title',
|
|
83
|
+
ignoreBackdropClick: true
|
|
84
|
+
}).content as SimpleModalExampleComponent;
|
|
33
85
|
}
|
|
34
86
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
CommonModule,
|
|
4
|
+
FormsModule,
|
|
5
|
+
HeaderModule,
|
|
6
|
+
ModalLabels,
|
|
7
|
+
ModalModule,
|
|
8
|
+
CoreModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'tut-simple-modal',
|
|
13
|
+
template: `
|
|
14
|
+
<c8y-modal
|
|
15
|
+
title="Export documents"
|
|
16
|
+
(onClose)="onClose($event)"
|
|
17
|
+
(onDismiss)="onDismiss($event)"
|
|
18
|
+
[labels]="labels"
|
|
19
|
+
[disabled]="true"
|
|
20
|
+
>
|
|
21
|
+
<c8y-list-group>
|
|
22
|
+
<c8y-li *ngFor="let a of listArray; let index = index">
|
|
23
|
+
<c8y-li-checkbox></c8y-li-checkbox>
|
|
24
|
+
<c8y-li-icon icon="file"></c8y-li-icon>
|
|
25
|
+
Document {{ index + 1 }}
|
|
26
|
+
</c8y-li>
|
|
27
|
+
</c8y-list-group>
|
|
28
|
+
</c8y-modal>
|
|
29
|
+
`,
|
|
30
|
+
standalone: true,
|
|
31
|
+
imports: [ModalModule, HeaderModule, CommonModule, FormsModule, CoreModule]
|
|
32
|
+
})
|
|
33
|
+
export class SimpleModalExampleComponent {
|
|
34
|
+
labels: ModalLabels = { ok: 'Export', cancel: 'Cancel' };
|
|
35
|
+
listArray = new Array(12);
|
|
36
|
+
onDismiss(_) {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log('On "Cancel" clicked');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onClose(_) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log('On "Export" clicked');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { BsModalService } from 'ngx-bootstrap/modal';
|
|
3
|
+
import {
|
|
4
|
+
C8yTranslateModule,
|
|
5
|
+
CoreModule,
|
|
6
|
+
FormsModule,
|
|
7
|
+
HeaderModule,
|
|
8
|
+
ModalModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
import { SimpleModalAccessibilityExampleComponent } from './simple-modal-accessibility-example.component';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'tut-ngx-modal-accessibility',
|
|
14
|
+
template: `<div>
|
|
15
|
+
<c8y-title>ngx-bootstrap modal example with custom ids</c8y-title>
|
|
16
|
+
<div class="p-t-24 p-b-24 text-center">
|
|
17
|
+
<button
|
|
18
|
+
class="btn btn-default m-8"
|
|
19
|
+
type="button"
|
|
20
|
+
(click)="openComponentModalWithContentSelectors()"
|
|
21
|
+
>
|
|
22
|
+
Create component modal with with ModalComponent and custom ids
|
|
23
|
+
</button>
|
|
24
|
+
</div>
|
|
25
|
+
</div>`,
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [
|
|
28
|
+
HeaderModule,
|
|
29
|
+
SimpleModalAccessibilityExampleComponent,
|
|
30
|
+
C8yTranslateModule,
|
|
31
|
+
FormsModule,
|
|
32
|
+
ModalModule,
|
|
33
|
+
CoreModule
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
export class NgxModalAccessibilityExampleComponent {
|
|
37
|
+
constructor(private modalService: BsModalService) {}
|
|
38
|
+
|
|
39
|
+
openComponentModalWithContentSelectors() {
|
|
40
|
+
this.modalService.show(SimpleModalAccessibilityExampleComponent, {
|
|
41
|
+
class: 'modal-sm',
|
|
42
|
+
ariaDescribedby: 'modal-body-custom',
|
|
43
|
+
ariaLabelledBy: 'modal-title-custom',
|
|
44
|
+
ignoreBackdropClick: true
|
|
45
|
+
}).content as SimpleModalAccessibilityExampleComponent;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@NgModule({
|
|
5
|
+
providers: [
|
|
6
|
+
hookRoute({
|
|
7
|
+
path: 'modal/ngx-modal-accessibility',
|
|
8
|
+
loadComponent: () =>
|
|
9
|
+
import('./ngx-modal-accessibility-example.component').then(
|
|
10
|
+
m => m.NgxModalAccessibilityExampleComponent
|
|
11
|
+
)
|
|
12
|
+
}),
|
|
13
|
+
hookNavigator(
|
|
14
|
+
new NavigatorNode({
|
|
15
|
+
label: 'Ngx modal accessibility',
|
|
16
|
+
path: '/modal/ngx-modal-accessibility',
|
|
17
|
+
icon: 'list-alt',
|
|
18
|
+
priority: 10,
|
|
19
|
+
parent: 'Modal'
|
|
20
|
+
})
|
|
21
|
+
)
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
export class NgxModalAccessibilityExampleModule {}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
CommonModule,
|
|
4
|
+
FormsModule,
|
|
5
|
+
HeaderModule,
|
|
6
|
+
ListGroupModule,
|
|
7
|
+
ModalLabels,
|
|
8
|
+
ModalModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'tut-simple-modal-with-selectors',
|
|
13
|
+
template: `
|
|
14
|
+
<c8y-modal
|
|
15
|
+
(onClose)="onClose($event)"
|
|
16
|
+
(onDismiss)="onDismiss($event)"
|
|
17
|
+
[labels]="labels"
|
|
18
|
+
[headerClasses]="'dialog-header'"
|
|
19
|
+
[disabled]="true"
|
|
20
|
+
>
|
|
21
|
+
<ng-container c8y-modal-title>
|
|
22
|
+
<span [c8yIcon]="'export'"></span>
|
|
23
|
+
<div class="modal-title" id="modal-title-custom">Export documents</div>
|
|
24
|
+
</ng-container>
|
|
25
|
+
<c8y-list-group id="modal-body-custom">
|
|
26
|
+
<c8y-li *ngFor="let a of listArray; let index = index">
|
|
27
|
+
<c8y-li-checkbox></c8y-li-checkbox>
|
|
28
|
+
<c8y-li-icon icon="file"></c8y-li-icon>
|
|
29
|
+
Document {{ index + 1 }}
|
|
30
|
+
</c8y-li>
|
|
31
|
+
</c8y-list-group>
|
|
32
|
+
</c8y-modal>
|
|
33
|
+
`,
|
|
34
|
+
standalone: true,
|
|
35
|
+
imports: [ModalModule, HeaderModule, CommonModule, FormsModule, ListGroupModule]
|
|
36
|
+
})
|
|
37
|
+
export class SimpleModalAccessibilityExampleComponent {
|
|
38
|
+
labels: ModalLabels = { ok: 'Export', cancel: 'Cancel' };
|
|
39
|
+
listArray = new Array(12);
|
|
40
|
+
onDismiss(_) {
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log('On "Cancel" clicked');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onClose(_) {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.log('On "Export" clicked');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { BsModalService } from 'ngx-bootstrap/modal';
|
|
3
|
+
import {
|
|
4
|
+
C8yTranslateModule,
|
|
5
|
+
CoreModule,
|
|
6
|
+
FormsModule,
|
|
7
|
+
HeaderModule,
|
|
8
|
+
ModalModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
import { SimpleModalExampleWithContentSelectorsComponent } from './simple-modal-example-with-content-selectors.component';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'tut-ngx-modal-selectors',
|
|
14
|
+
template: `<div>
|
|
15
|
+
<c8y-title>ngx-bootstrap modal example with ng-content selectors</c8y-title>
|
|
16
|
+
<div class="p-t-24 p-b-24 text-center">
|
|
17
|
+
<button
|
|
18
|
+
class="btn btn-default m-8"
|
|
19
|
+
type="button"
|
|
20
|
+
(click)="openComponentModalWithContentSelectors()"
|
|
21
|
+
>
|
|
22
|
+
Modal with <code>c8y-modal</code> and <code>ng-content</code> selectors
|
|
23
|
+
</button>
|
|
24
|
+
</div>
|
|
25
|
+
</div>`,
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [
|
|
28
|
+
HeaderModule,
|
|
29
|
+
SimpleModalExampleWithContentSelectorsComponent,
|
|
30
|
+
C8yTranslateModule,
|
|
31
|
+
FormsModule,
|
|
32
|
+
ModalModule,
|
|
33
|
+
CoreModule
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
export class NgxModalSelectorsExampleComponent {
|
|
37
|
+
constructor(private modalService: BsModalService) {}
|
|
38
|
+
|
|
39
|
+
openComponentModalWithContentSelectors() {
|
|
40
|
+
this.modalService.show(SimpleModalExampleWithContentSelectorsComponent, {
|
|
41
|
+
class: 'modal-sm',
|
|
42
|
+
ariaDescribedby: 'modal-body',
|
|
43
|
+
ariaLabelledBy: 'modal-title',
|
|
44
|
+
ignoreBackdropClick: true
|
|
45
|
+
}).content as SimpleModalExampleWithContentSelectorsComponent;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@NgModule({
|
|
5
|
+
providers: [
|
|
6
|
+
hookRoute({
|
|
7
|
+
path: 'modal/ngx-modal-selectors',
|
|
8
|
+
loadComponent: () =>
|
|
9
|
+
import('./ngx-modal-selectors-example.component').then(
|
|
10
|
+
m => m.NgxModalSelectorsExampleComponent
|
|
11
|
+
)
|
|
12
|
+
}),
|
|
13
|
+
hookNavigator(
|
|
14
|
+
new NavigatorNode({
|
|
15
|
+
label: 'Ngx modal selectors',
|
|
16
|
+
path: '/modal/ngx-modal-selectors',
|
|
17
|
+
icon: 'list-alt',
|
|
18
|
+
priority: 10,
|
|
19
|
+
parent: 'Modal'
|
|
20
|
+
})
|
|
21
|
+
)
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
export class NgxModalSelectorsExampleModule {}
|
package/src/modal/ngx-modal-selectors/simple-modal-example-with-content-selectors.component.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Component, ViewChild } from '@angular/core';
|
|
2
|
+
import { CommonModule, FormsModule, HeaderModule, ModalModule } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'tut-simple-modal-with-selectors',
|
|
6
|
+
template: `
|
|
7
|
+
<c8y-modal
|
|
8
|
+
title="Create smart group"
|
|
9
|
+
[headerClasses]="'dialog-header'"
|
|
10
|
+
[customFooter]="true"
|
|
11
|
+
#modal
|
|
12
|
+
>
|
|
13
|
+
<ng-container c8y-modal-title>
|
|
14
|
+
<span [c8yIcon]="'c8y-group-smart'"></span>
|
|
15
|
+
</ng-container>
|
|
16
|
+
|
|
17
|
+
<form class="p-24" #createSmartGroup="ngForm" c8y-modal-body>
|
|
18
|
+
<c8y-form-group>
|
|
19
|
+
<label for="name" translate> Smart group name </label>
|
|
20
|
+
<input
|
|
21
|
+
class="form-control"
|
|
22
|
+
id="name"
|
|
23
|
+
placeholder="{{ 'e.g. My smart group' }}"
|
|
24
|
+
name="name"
|
|
25
|
+
type="text"
|
|
26
|
+
autocomplete="off"
|
|
27
|
+
required
|
|
28
|
+
[(ngModel)]="smartGroup.name"
|
|
29
|
+
/>
|
|
30
|
+
</c8y-form-group>
|
|
31
|
+
</form>
|
|
32
|
+
|
|
33
|
+
<div class="modal-footer" c8y-modal-footer-custom>
|
|
34
|
+
<button class="btn btn-default" (click)="onCustomFooterCancel()">
|
|
35
|
+
{{ 'Cancel' }}
|
|
36
|
+
</button>
|
|
37
|
+
<button
|
|
38
|
+
class="btn btn-primary"
|
|
39
|
+
(click)="onCustomFooterContinue()"
|
|
40
|
+
[disabled]="createSmartGroup.form.invalid || pending"
|
|
41
|
+
[ngClass]="{ 'btn-pending': pending }"
|
|
42
|
+
>
|
|
43
|
+
{{ 'Continue' }}
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
</c8y-modal>
|
|
47
|
+
`,
|
|
48
|
+
standalone: true,
|
|
49
|
+
imports: [ModalModule, HeaderModule, CommonModule, FormsModule]
|
|
50
|
+
})
|
|
51
|
+
export class SimpleModalExampleWithContentSelectorsComponent {
|
|
52
|
+
smartGroup = {
|
|
53
|
+
name: ''
|
|
54
|
+
};
|
|
55
|
+
pending = false;
|
|
56
|
+
|
|
57
|
+
@ViewChild('modal', { static: false }) private modal;
|
|
58
|
+
|
|
59
|
+
onCustomFooterCancel(): void {
|
|
60
|
+
console.log('On custom footer Cancel');
|
|
61
|
+
this.modal._dismiss();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onCustomFooterContinue(): void {
|
|
65
|
+
this.pending = true;
|
|
66
|
+
console.log('On custom footer Continue');
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
this.modal._dismiss();
|
|
69
|
+
this.pending = false;
|
|
70
|
+
}, 1000);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
CommonModule,
|
|
4
|
+
FormsModule,
|
|
5
|
+
HeaderModule,
|
|
6
|
+
ModalLabels,
|
|
7
|
+
ModalModule,
|
|
8
|
+
CoreModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'tut-simple-modal',
|
|
13
|
+
template: `
|
|
14
|
+
<c8y-modal
|
|
15
|
+
title="Export documents"
|
|
16
|
+
(onClose)="onClose($event)"
|
|
17
|
+
(onDismiss)="onDismiss($event)"
|
|
18
|
+
[labels]="labels"
|
|
19
|
+
[disabled]="true"
|
|
20
|
+
>
|
|
21
|
+
<c8y-list-group>
|
|
22
|
+
<c8y-li *ngFor="let a of listArray; let index = index">
|
|
23
|
+
<c8y-li-checkbox></c8y-li-checkbox>
|
|
24
|
+
<c8y-li-icon icon="file"></c8y-li-icon>
|
|
25
|
+
Document {{ index + 1 }}
|
|
26
|
+
</c8y-li>
|
|
27
|
+
</c8y-list-group>
|
|
28
|
+
</c8y-modal>
|
|
29
|
+
`,
|
|
30
|
+
standalone: true,
|
|
31
|
+
imports: [ModalModule, HeaderModule, CommonModule, FormsModule, CoreModule]
|
|
32
|
+
})
|
|
33
|
+
export class LargeModalExampleComponent {
|
|
34
|
+
labels: ModalLabels = { ok: 'Export', cancel: 'Cancel' };
|
|
35
|
+
listArray = new Array(12);
|
|
36
|
+
onDismiss(_) {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log('On "Cancel" clicked');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onClose(_) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log('On "Export" clicked');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
CommonModule,
|
|
4
|
+
FormsModule,
|
|
5
|
+
HeaderModule,
|
|
6
|
+
ModalLabels,
|
|
7
|
+
ModalModule,
|
|
8
|
+
CoreModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'tut-simple-modal',
|
|
13
|
+
template: `
|
|
14
|
+
<c8y-modal
|
|
15
|
+
title="Export documents"
|
|
16
|
+
(onClose)="onClose($event)"
|
|
17
|
+
(onDismiss)="onDismiss($event)"
|
|
18
|
+
[labels]="labels"
|
|
19
|
+
[disabled]="true"
|
|
20
|
+
>
|
|
21
|
+
<c8y-list-group>
|
|
22
|
+
<c8y-li *ngFor="let a of listArray; let index = index">
|
|
23
|
+
<c8y-li-checkbox></c8y-li-checkbox>
|
|
24
|
+
<c8y-li-icon icon="file"></c8y-li-icon>
|
|
25
|
+
Document {{ index + 1 }}
|
|
26
|
+
</c8y-li>
|
|
27
|
+
</c8y-list-group>
|
|
28
|
+
</c8y-modal>
|
|
29
|
+
`,
|
|
30
|
+
standalone: true,
|
|
31
|
+
imports: [ModalModule, HeaderModule, CommonModule, FormsModule, CoreModule]
|
|
32
|
+
})
|
|
33
|
+
export class MediumModalExampleComponent {
|
|
34
|
+
labels: ModalLabels = { ok: 'Export', cancel: 'Cancel' };
|
|
35
|
+
listArray = new Array(12);
|
|
36
|
+
onDismiss(_) {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log('On "Cancel" clicked');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onClose(_) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log('On "Export" clicked');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { BsModalService } from 'ngx-bootstrap/modal';
|
|
3
|
+
import {
|
|
4
|
+
C8yTranslateModule,
|
|
5
|
+
CoreModule,
|
|
6
|
+
FormsModule,
|
|
7
|
+
HeaderModule,
|
|
8
|
+
ModalModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
import { SmallModalExampleComponent } from './small-modal-example.component';
|
|
11
|
+
import { MediumModalExampleComponent } from './medium-modal-example.component';
|
|
12
|
+
import { LargeModalExampleComponent } from './large-modal-example.component';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'tut-ngx-modal-sizes',
|
|
16
|
+
template: `<div>
|
|
17
|
+
<c8y-title>ngx-bootstrap modal sizes example</c8y-title>
|
|
18
|
+
<div class="p-t-24 p-b-24 text-center">
|
|
19
|
+
<button class="btn btn-default m-8" type="button" (click)="openModalSm()">
|
|
20
|
+
Modal with size <code>modal-sm</code>
|
|
21
|
+
</button>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="p-b-24 text-center">
|
|
24
|
+
<button class="btn btn-default m-8" type="button" (click)="openModalMd()">
|
|
25
|
+
Modal with size <code>modal-md</code>
|
|
26
|
+
</button>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="p-b-24 text-center">
|
|
29
|
+
<button class="btn btn-default m-8" type="button" (click)="openModalLg()">
|
|
30
|
+
Modal with size <code>modal-lg</code>
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
</div>`,
|
|
34
|
+
standalone: true,
|
|
35
|
+
imports: [HeaderModule, C8yTranslateModule, FormsModule, ModalModule, CoreModule]
|
|
36
|
+
})
|
|
37
|
+
export class NgxModalSizesExampleComponent {
|
|
38
|
+
constructor(private modalService: BsModalService) {}
|
|
39
|
+
|
|
40
|
+
openModalSm() {
|
|
41
|
+
this.modalService.show(SmallModalExampleComponent, {
|
|
42
|
+
class: 'modal-sm',
|
|
43
|
+
ariaDescribedby: 'modal-body',
|
|
44
|
+
ariaLabelledBy: 'modal-title',
|
|
45
|
+
ignoreBackdropClick: true
|
|
46
|
+
}).content as SmallModalExampleComponent;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
openModalMd() {
|
|
50
|
+
this.modalService.show(MediumModalExampleComponent, {
|
|
51
|
+
class: 'modal-md',
|
|
52
|
+
ariaDescribedby: 'modal-body',
|
|
53
|
+
ariaLabelledBy: 'modal-title',
|
|
54
|
+
ignoreBackdropClick: true
|
|
55
|
+
}).content as MediumModalExampleComponent;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
openModalLg() {
|
|
59
|
+
this.modalService.show(LargeModalExampleComponent, {
|
|
60
|
+
class: 'modal-lg',
|
|
61
|
+
ariaDescribedby: 'modal-body',
|
|
62
|
+
ariaLabelledBy: 'modal-title',
|
|
63
|
+
ignoreBackdropClick: true
|
|
64
|
+
}).content as LargeModalExampleComponent;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
3
|
+
|
|
4
|
+
@NgModule({
|
|
5
|
+
providers: [
|
|
6
|
+
hookRoute({
|
|
7
|
+
path: 'modal/ngx-modal-sizes',
|
|
8
|
+
loadComponent: () =>
|
|
9
|
+
import('./ngx-modal-sizes-example.component').then(m => m.NgxModalSizesExampleComponent)
|
|
10
|
+
}),
|
|
11
|
+
hookNavigator(
|
|
12
|
+
new NavigatorNode({
|
|
13
|
+
label: 'Ngx modal sizes',
|
|
14
|
+
path: '/modal/ngx-modal-sizes',
|
|
15
|
+
icon: 'list-alt',
|
|
16
|
+
priority: 20,
|
|
17
|
+
parent: 'Modal'
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
]
|
|
21
|
+
})
|
|
22
|
+
export class NgxModalSizesExampleModule {}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
CommonModule,
|
|
4
|
+
FormsModule,
|
|
5
|
+
HeaderModule,
|
|
6
|
+
ModalLabels,
|
|
7
|
+
ModalModule,
|
|
8
|
+
CoreModule
|
|
9
|
+
} from '@c8y/ngx-components';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'tut-simple-modal',
|
|
13
|
+
template: `
|
|
14
|
+
<c8y-modal
|
|
15
|
+
title="Export documents"
|
|
16
|
+
(onClose)="onClose($event)"
|
|
17
|
+
(onDismiss)="onDismiss($event)"
|
|
18
|
+
[labels]="labels"
|
|
19
|
+
[headerClasses]="'dialog-header'"
|
|
20
|
+
[disabled]="true"
|
|
21
|
+
>
|
|
22
|
+
<ng-container c8y-modal-title>
|
|
23
|
+
<span [c8yIcon]="'export'"></span>
|
|
24
|
+
</ng-container>
|
|
25
|
+
<c8y-list-group>
|
|
26
|
+
<c8y-li *ngFor="let a of listArray; let index = index">
|
|
27
|
+
<c8y-li-checkbox></c8y-li-checkbox>
|
|
28
|
+
<c8y-li-icon icon="file"></c8y-li-icon>
|
|
29
|
+
Document {{ index + 1 }}
|
|
30
|
+
</c8y-li>
|
|
31
|
+
</c8y-list-group>
|
|
32
|
+
</c8y-modal>
|
|
33
|
+
`,
|
|
34
|
+
standalone: true,
|
|
35
|
+
imports: [ModalModule, HeaderModule, CommonModule, FormsModule, CoreModule]
|
|
36
|
+
})
|
|
37
|
+
export class SmallModalExampleComponent {
|
|
38
|
+
labels: ModalLabels = { ok: 'Export', cancel: 'Cancel' };
|
|
39
|
+
listArray = new Array(12);
|
|
40
|
+
onDismiss(_) {
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log('On "Cancel" clicked');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onClose(_) {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.log('On "Export" clicked');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { ModalLabels, ModalModule } from '@c8y/ngx-components';
|
|
3
|
-
import { Subject } from 'rxjs';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'modal-example',
|
|
7
|
-
template: `
|
|
8
|
-
<c8y-modal
|
|
9
|
-
title="CustomTitle"
|
|
10
|
-
(onClose)="onClose($event)"
|
|
11
|
-
(onDismiss)="onDismiss($event)"
|
|
12
|
-
[labels]="labels"
|
|
13
|
-
[disabled]="true"
|
|
14
|
-
>
|
|
15
|
-
<!--! will disable ok button -->
|
|
16
|
-
<span>I am body of modal</span>
|
|
17
|
-
<span>For simple string use body="string"</span>
|
|
18
|
-
</c8y-modal>
|
|
19
|
-
`,
|
|
20
|
-
standalone: true,
|
|
21
|
-
imports: [ModalModule]
|
|
22
|
-
})
|
|
23
|
-
export class ModalExampleComponent {
|
|
24
|
-
closeSubject: Subject<boolean> = new Subject();
|
|
25
|
-
labels: ModalLabels = { ok: 'customOK', cancel: 'customCancel' };
|
|
26
|
-
|
|
27
|
-
onDismiss(event) {
|
|
28
|
-
this.closeSubject.next(!event);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
onClose(event) {
|
|
32
|
-
this.closeSubject.next(event);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { NavigatorNode, hookNavigator, hookRoute } from '@c8y/ngx-components';
|
|
3
|
-
|
|
4
|
-
@NgModule({
|
|
5
|
-
providers: [
|
|
6
|
-
hookRoute({
|
|
7
|
-
path: 'modal/simple-modal',
|
|
8
|
-
loadComponent: () => import('./modal-example.component').then(m => m.ModalExampleComponent)
|
|
9
|
-
}),
|
|
10
|
-
hookNavigator(
|
|
11
|
-
new NavigatorNode({
|
|
12
|
-
label: 'Simple Modal',
|
|
13
|
-
path: '/modal/simple-modal',
|
|
14
|
-
icon: 'list-alt',
|
|
15
|
-
priority: 2,
|
|
16
|
-
parent: 'Modal'
|
|
17
|
-
})
|
|
18
|
-
)
|
|
19
|
-
]
|
|
20
|
-
})
|
|
21
|
-
export class ModalExampleModule {}
|