Skip to content

Commit 0b09bfa

Browse files
committed
Merge branch 'release/5.2.0'
2 parents 3b7efa6 + 3e8f222 commit 0b09bfa

20 files changed

+117
-25
lines changed

projects/truly-ui/src/components/dialog/dialog-confirmation/confirmation-options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
export interface ConfirmationOptions {
2323
textOk?: string;
2424
textCancel?: string;
25+
message?: string;
2526
defaultOK?: boolean;
2627
draggable?: boolean;
2728
}

projects/truly-ui/src/components/dialog/dialog.service.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ export class DialogService {
7878
confirmation( message: string, callbackConfirmation: ConfirmCallback, options: ConfirmationOptions = {}, mdOptions?: ModalOptions ) {
7979
this.modalService.createModalDialog( TlDialogConfirmation, this.factoryResolver, mdOptions ).then((value: any) => {
8080
if ( value.mdResult === ModalResult.MRYES ) {
81-
callbackConfirmation.isYes(ModalResult.MRYES);
81+
if (callbackConfirmation.isYes) {
82+
callbackConfirmation.isYes(ModalResult.MRYES);
83+
}
8284
} else if (value.mdResult === ModalResult.MRNO) {
83-
callbackConfirmation.isNo(ModalResult.MRNO);
85+
if (callbackConfirmation.isNo) {
86+
callbackConfirmation.isNo(ModalResult.MRNO);
87+
}
8488
}
8589
});
8690
const optionsObj = Object.assign( options, { message: message } );

projects/truly-ui/src/components/lightbox/lightbox.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
SOFTWARE.
2121
*/
2222

23-
import {ChangeDetectorRef, Component, EventEmitter, HostListener, OnInit} from '@angular/core';
23+
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, HostListener, OnInit} from '@angular/core';
2424
import {ImageLightboxInterface} from './interfaces/image.interface';
2525
import {DomSanitizer} from '@angular/platform-browser';
2626

2727
@Component({
2828
selector: 'tl-lightbox',
2929
templateUrl: './lightbox.html',
3030
styleUrls: ['./lightbox.scss'],
31+
changeDetection: ChangeDetectionStrategy.OnPush
3132
})
3233
export class TlLightbox implements OnInit {
3334

projects/truly-ui/src/components/modal/services/modal.service.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ export class ModalService implements OnDestroy {
9494
}
9595

9696
createModal(component: Type<any>, factoryOrConfig: ComponentFactoryResolver,
97-
identifier: string = '', parentElement: ElementRef = null, mdOptions?: ModalOptions) {
97+
identifier: string = '', properties?: {}, parentElement: ElementRef = null, mdOptions?: ModalOptions) {
9898
this.view = this.containerModal.view;
9999
return new Promise((resolve) => {
100-
this.setComponentModal(component, factoryOrConfig, identifier, parentElement, mdOptions);
100+
this.setComponentModal(component, factoryOrConfig, identifier, parentElement, mdOptions, properties);
101101
this.handleCallbackModal(resolve);
102102
});
103103
}
@@ -157,6 +157,14 @@ export class ModalService implements OnDestroy {
157157
this.modalOptions = Object.assign(this.modalOptions[0], mdOptions);
158158
}
159159

160+
private setModalProperties(properties) {
161+
if (properties) {
162+
Object.keys(properties).forEach( (value, index) => {
163+
(this.componentInjected.instance)[value] = properties[value];
164+
});
165+
}
166+
}
167+
160168
private setComponentWrapperProperties(config, identifier, parentElement) {
161169
(<TlModal>this.component.instance).setOptions(this.modalOptions);
162170
(<TlModal>this.component.instance).setIdentifier(this.isConfigSmartForm(config) ? config['identifier'] : identifier);
@@ -193,7 +201,7 @@ export class ModalService implements OnDestroy {
193201

194202
private setComponentModal(component: Type<any>,
195203
config: SmartFormConfiguration | ComponentFactoryResolver,
196-
identifier?, parentElement?, mdOptions?: ModalOptions) {
204+
identifier?, parentElement?, mdOptions?: ModalOptions, properties?) {
197205

198206
const factory = this.isConfigSmartForm(config) ? config['factory'] : config;
199207
if (this.isSmartFormUpdateDeleteAction(config) && !this.validateDataFormUpdate(config)) {
@@ -209,6 +217,7 @@ export class ModalService implements OnDestroy {
209217
this.setInitialZIndex();
210218
this.setInjectedComponent(factory, component);
211219
this.setModalOptions(mdOptions);
220+
this.setModalProperties(properties);
212221
this.handleBackDrop(factory);
213222
this.setComponentWrapperProperties(config, identifier, parentElement);
214223
this.setInstanceComponent(config);

projects/truly-ui/src/components/thumbnail/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { FormsModule } from '@angular/forms';
55
import { TlThumbnail } from './thumbnail';
66
import { IconsModule } from '../icons/index';
77
import { LightboxModule } from '../lightbox/index';
8+
import {DialogModule} from '../dialog/index';
89

910
@NgModule({
1011
imports: [
1112
CommonModule,
1213
IconsModule,
1314
FormsModule,
14-
LightboxModule
15+
LightboxModule,
16+
DialogModule
1517
],
1618
declarations: [
1719
TlThumbnail

projects/truly-ui/src/components/thumbnail/thumbnail.html

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<img class="thumbnail-image" [class.circle-shape]="isCircle" alt="image" [src]="item.file || image">
2424
<div class="thumbnail-controls" *ngIf="!overlayTemplate">
2525
<tl-icon style="margin-right: 5px" (click)="onViewImage( image )" [lib]="'dx'">find</tl-icon>
26+
<tl-icon *ngIf="showDeleteButton" style="cursor: pointer" (click)="onDeleteThumb(item)" [lib]="'dx'">trash</tl-icon>
2627
</div>
2728
<div class="thumbnail-controls" *ngIf="overlayTemplate">
2829
<ng-container *ngTemplateOutlet="overlayTemplate; context: { $implicit: item || image }"></ng-container>
@@ -33,6 +34,7 @@
3334
<tl-icon style="margin-right: 5px" [lib]="'fa'" [style]="'fas'" [color]="'#ec7e7e'" [size]="'40px'">file-pdf</tl-icon>
3435
<div class="thumbnail-controls" *ngIf="!overlayTemplate">
3536
<tl-icon style="margin-right: 5px" (click)="onViewImage( image )" [lib]="'dx'">find</tl-icon>
37+
<tl-icon *ngIf="showDeleteButton" style="cursor: pointer" (click)="onDeleteThumb(item)" [lib]="'dx'">trash</tl-icon>
3638
</div>
3739
<div class="thumbnail-controls" *ngIf="overlayTemplate">
3840
<ng-container *ngTemplateOutlet="overlayTemplate; context: { $implicit: item || image }"></ng-container>

projects/truly-ui/src/components/thumbnail/thumbnail.ts

+27-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef} from '@angular/core';
2424
import { LightboxService } from '../lightbox/services/lightbox.service';
25-
import {ThumbnailService} from './thumbnail.service';
25+
import { ThumbnailService } from './thumbnail.service';
26+
import { DialogService } from '../dialog/dialog.service';
27+
import { ModalOptions } from '../modal/interfaces/modal-options';
2628

2729
@Component({
2830
selector: 'tl-thumbnail',
@@ -43,13 +45,27 @@ export class TlThumbnail implements OnInit, OnChanges {
4345

4446
@Input() size: { width: string, height: string } = { width: '80px', height: '80px' };
4547

48+
@Input() showDeleteButton = false;
49+
50+
@Input() confirmationDeleteMessage = 'Do you want to delete the Thumbnail?';
51+
52+
@Input() showConfirmationOnDelete = false;
53+
54+
@Input() modalDeleteOptions: ModalOptions;
55+
4656
@Input() overlayTemplate: TemplateRef<any>;
4757

4858
@Input() emptyTemplate: TemplateRef<any>;
4959

5060
@Output() clickThumbnail = new EventEmitter();
5161

52-
constructor(private lightboxService: LightboxService, private thumbnailService: ThumbnailService) {}
62+
@Output() clickDeleteThumbail = new EventEmitter();
63+
64+
constructor(
65+
private lightboxService: LightboxService,
66+
private thumbnailService: ThumbnailService,
67+
private dialogService: DialogService
68+
) {}
5369

5470
ngOnInit() {}
5571

@@ -72,4 +88,13 @@ export class TlThumbnail implements OnInit, OnChanges {
7288
this.lightboxService.create( this.data, image);
7389
}
7490

91+
onDeleteThumb(image) {
92+
if (this.showConfirmationOnDelete) {
93+
return this.dialogService.confirmation( this.confirmationDeleteMessage, ({
94+
isYes: () => this.clickDeleteThumbail.emit(image),
95+
}), {}, this.modalDeleteOptions);
96+
}
97+
this.clickDeleteThumbail.emit(image);
98+
}
99+
75100
}

projects/truly-ui/src/components/timeline/timeline.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export class TlTimeline implements OnInit, OnChanges {
4343

4444
@Input('data') data = [];
4545

46+
@Input() clearOnUpdateData = false;
47+
4648
@Input() align = 'left';
4749

4850
@Input() height = '400px';
@@ -88,7 +90,11 @@ export class TlTimeline implements OnInit, OnChanges {
8890
ngOnChanges(changes: SimpleChanges) {
8991
this.loadingMoreData = false;
9092
if ( this.data.length > 0 ) {
91-
this.buffer = this.buffer.concat(this.data);
93+
if ( this.clearOnUpdateData ) {
94+
this.buffer = this.data;
95+
} else {
96+
this.buffer = this.buffer.concat(this.data);
97+
}
9298
this.nothingFound = false;
9399
return this.loadingMoreData = false;
94100
}

projects/truly-ui/src/components/upload/upload.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ng-container *ngIf="imageList.length === 0 || showAsList; else imagesContainerTemplate">
66
<span><tl-icon class="icon" [lib]="'fa'" [style]="'fas'">inbox</tl-icon></span>
77
<p style="white-space: pre-line">{{ boxDescription }}</p>
8-
<input #inputMultiple type="file" style="display: none;" (change)="onChange($event)" multiple>
8+
<input #inputMultiple type="file" style="display: none;" (change)="onChange($event)" multiple [accept]="acceptFiles">
99
</ng-container>
1010

1111
<ng-template #imagesContainerTemplate>
@@ -33,7 +33,7 @@
3333
</div>
3434

3535
<ng-template #uploadboxTemplate let-item>
36-
<input #inputSingle type="file" style="display: none;" (change)="onChange($event)">
36+
<input #inputSingle type="file" style="display: none;" (change)="onChange($event)" [accept]="acceptFiles">
3737
<tl-thumbnail
3838
[shape]="'square'"
3939
[bordered]="!item"

projects/truly-ui/src/components/upload/upload.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export class TlUpload implements OnInit {
6464

6565
@Input() viewControl = true;
6666

67+
@Input() acceptFiles = 'image/*,application/pdf';
68+
6769
@ViewChild('inputMultiple', {static: false}) inputMultiple;
6870

6971
@ViewChild('inputSingle', {static: false}) inputSingle;
@@ -178,18 +180,33 @@ export class TlUpload implements OnInit {
178180

179181
onChange($event) {
180182
if ($event.target.files.length > 0) {
183+
const filesAccepet = this.filterFilesAccpet($event.target.files);
181184
if (this.type === 'dragndrop') {
182-
return this.readFiles($event.target.files);
185+
return this.readFiles(filesAccepet);
183186
}
184187
const reader = new FileReader();
185-
reader.readAsDataURL($event.target.files[0]);
188+
reader.readAsDataURL(filesAccepet[0]);
186189
reader.onload = (event) => {
187190
this.imageSrc = (<FileReader>event.target).result;
188191
this.uploadChange.emit(this.imageSrc);
189192
};
190193
}
191194
}
192195

196+
private filterFilesAccpet( files ) {
197+
const acceptFiles = [];
198+
for (let i = 0; i < files.length; i++) {
199+
const regexExpresison = this.acceptFiles
200+
.replace( /\*/g, '.\*' )
201+
.replace( /\,/g, '|' ) ;
202+
const isAccept = new RegExp( regexExpresison ).test( files[ i ].type );
203+
if ( isAccept ) {
204+
acceptFiles.push(files[i]);
205+
}
206+
}
207+
return acceptFiles;
208+
}
209+
193210
private getBase64MimeType(encoded) {
194211
let result = null;
195212

src/app/components/modal/modaldemo.component.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export class ModalDemoComponent {
3333
}
3434

3535
modal1() {
36-
this.modalService.createModal( NewModalComponent, this.compiler )
36+
this.modalService.createModal( NewModalComponent, this.compiler, 'MODAL-TESTE', {
37+
myTitle: 'My Modal Text Title',
38+
notPropertie: ''
39+
} )
3740
.then( ( modalResult ) => {
3841
console.log( modalResult );
3942
});

src/app/components/modal/newmodal/newModal.component.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from '@angular/core';
1+
import {Component, Input} from '@angular/core';
22
import { Modal } from '../../../../../projects/truly-ui/src/components/modal/interfaces/modal-options';
33

44
@Modal({
@@ -17,4 +17,6 @@ import { Modal } from '../../../../../projects/truly-ui/src/components/modal/int
1717
templateUrl: './newModal.html',
1818
styleUrls: [ './newModal.component.scss' ]
1919
} )
20-
export class NewModalComponent {}
20+
export class NewModalComponent {
21+
@Input() myTitle;
22+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div class="content" style="padding: 20px; font-family: Lato; line-height: 25px; ">
2-
<h3>My Modal Text</h3>
2+
<h3>{{myTitle}}</h3>
33
<p style="user-select: text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
44
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
55
type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
66
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
77
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
88
of
99
Lorem Ipsum.</p>
10-
<tl-button mdResult="MRCLOSE">Button Callback</tl-button>
10+
<tl-button mdResult="MRCLOSE" [text]="'Button Callback'"></tl-button>
1111
</div>
1212

src/app/components/thumbnail/thumbnaildemo.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<app-card>
1111
<div class="col-md-12">
1212
<h5>Basic Image</h5>
13-
<tl-thumbnail [data]="files"></tl-thumbnail>
13+
<tl-thumbnail [data]="files" [showDeleteButton]="true" (clickDeleteThumbail)="deleteThumb($event)" [showConfirmationOnDelete]="true"></tl-thumbnail>
1414
<br>
1515
<div class="spacer"></div>
1616
<textarea highlight-js [options]="{'tabReplace': ''}" [lang]="'html'">

src/app/components/thumbnail/thumbnaildemo.component.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ThumbnailDemoComponent {
4545
{
4646
index: 1,
4747
description: 'PDF 1',
48-
file: 'https://cdn.medicsolution.app/prontuario/anexos/09794f95-4baf-4726-ab7b-dd62369d1cf6',
48+
file: 'http://www.orimi.com/pdf-test.pdf',
4949
type: 'application/pdf'
5050
}
5151
];
@@ -54,5 +54,9 @@ export class ThumbnailDemoComponent {
5454
this.dataTableProperties = json.dataProperties;
5555
this.dataEvents = jsonEvts.dataEvents;
5656
}
57+
58+
deleteThumb(thumb) {
59+
console.log('DELETING...', thumb);
60+
}
5761
}
5862

src/app/components/timeline/infinitescroll/timelinedemo.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class TimelineDemoComponent {
7878
public dataAdvanced = [
7979
{
8080
title: 'Dr. Gregory House 1',
81-
date: 1537477718000,
81+
date: 1537477712000,
8282
text: 'Mauris vulputate dolor vel finibus sagittis.',
8383
duration: 15,
8484
category: [
@@ -816,6 +816,7 @@ export class TimelineDemoComponent {
816816
this.dataLazy = this.getDataFromService(0, this.take);
817817
}
818818

819+
819820
getDataFromService(skip, take) {
820821
return this.dataAdvanced.slice(skip, take);
821822
}

src/app/components/timeline/infinitescroll/timelinedemo.module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ShowcaseCardModule } from '../../../shared/components/showcase-card/sho
1111
import { ShowcaseTablePropertiesModule } from '../../../shared/components/showcase-table-properties/showcase-table-properties.module';
1212
import { ShowcaseTableEventsModule } from '../../../shared/components/showcase-table-events/showcase-table-events.module';
1313
import { ShowcaseHeaderModule } from '../../../shared/components/showcase-header/showcase-header.module';
14+
import {ButtonModule} from '../../../../../projects/truly-ui/src/components/button';
1415

1516
@NgModule({
1617
declarations: [
@@ -26,7 +27,8 @@ import { ShowcaseHeaderModule } from '../../../shared/components/showcase-header
2627
ShowcaseTablePropertiesModule,
2728
ShowcaseTableEventsModule,
2829
ShowcaseHeaderModule,
29-
ShowcaseHeaderModule
30+
ShowcaseHeaderModule,
31+
ButtonModule
3032
],
3133
exports: [
3234
TimelineDemoComponent

src/app/components/timeline/overview/timelinedemo.component.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<div class="row">
1212
<div class="col-md-6">
1313
<h6>Basic</h6>
14-
<tl-timeline [data]="dataBasic" [height]="'300px'" [keyTitle]="'title'" [keyText]="'text'"></tl-timeline>
14+
<tl-button [text]="'Change Item'" (click)="changItem()"></tl-button>
15+
<tl-timeline [data]="dataBasic" [clearOnUpdateData]="true" [height]="'300px'" [keyTitle]="'title'" [keyText]="'text'"></tl-timeline>
1516
<br>
1617
<textarea highlight-js [options]="{'tabReplace': ''}" [lang]="'html'">
1718
<tl-timeline [data]="dataBasic" [height]="'300px'" [keyTitle]="'title'" [keyText]="'text'"></tl-timeline>

src/app/components/timeline/overview/timelinedemo.component.ts

+10
Original file line numberDiff line numberDiff line change
@@ -832,5 +832,15 @@ export class TimelineDemoComponent {
832832
this.dataTableProperties = json.dataProperties;
833833
}
834834

835+
836+
changItem() {
837+
this.dataBasic = this.dataBasic.map( (data, index) => {
838+
if (data.title === 'Dr. Gregory House 1') {
839+
data.text = data.text + index;
840+
}
841+
return data;
842+
});
843+
}
844+
835845
}
836846

0 commit comments

Comments
 (0)