Skip to content

Commit

Permalink
Merge branch 'release/5.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
abalad committed Feb 22, 2021
2 parents 3b7efa6 + 3e8f222 commit 0b09bfa
Show file tree
Hide file tree
Showing 20 changed files with 117 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
export interface ConfirmationOptions {
textOk?: string;
textCancel?: string;
message?: string;
defaultOK?: boolean;
draggable?: boolean;
}
8 changes: 6 additions & 2 deletions projects/truly-ui/src/components/dialog/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ export class DialogService {
confirmation( message: string, callbackConfirmation: ConfirmCallback, options: ConfirmationOptions = {}, mdOptions?: ModalOptions ) {
this.modalService.createModalDialog( TlDialogConfirmation, this.factoryResolver, mdOptions ).then((value: any) => {
if ( value.mdResult === ModalResult.MRYES ) {
callbackConfirmation.isYes(ModalResult.MRYES);
if (callbackConfirmation.isYes) {
callbackConfirmation.isYes(ModalResult.MRYES);
}
} else if (value.mdResult === ModalResult.MRNO) {
callbackConfirmation.isNo(ModalResult.MRNO);
if (callbackConfirmation.isNo) {
callbackConfirmation.isNo(ModalResult.MRNO);
}
}
});
const optionsObj = Object.assign( options, { message: message } );
Expand Down
3 changes: 2 additions & 1 deletion projects/truly-ui/src/components/lightbox/lightbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
SOFTWARE.
*/

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

@Component({
selector: 'tl-lightbox',
templateUrl: './lightbox.html',
styleUrls: ['./lightbox.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TlLightbox implements OnInit {

Expand Down
15 changes: 12 additions & 3 deletions projects/truly-ui/src/components/modal/services/modal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export class ModalService implements OnDestroy {
}

createModal(component: Type<any>, factoryOrConfig: ComponentFactoryResolver,
identifier: string = '', parentElement: ElementRef = null, mdOptions?: ModalOptions) {
identifier: string = '', properties?: {}, parentElement: ElementRef = null, mdOptions?: ModalOptions) {
this.view = this.containerModal.view;
return new Promise((resolve) => {
this.setComponentModal(component, factoryOrConfig, identifier, parentElement, mdOptions);
this.setComponentModal(component, factoryOrConfig, identifier, parentElement, mdOptions, properties);
this.handleCallbackModal(resolve);
});
}
Expand Down Expand Up @@ -157,6 +157,14 @@ export class ModalService implements OnDestroy {
this.modalOptions = Object.assign(this.modalOptions[0], mdOptions);
}

private setModalProperties(properties) {
if (properties) {
Object.keys(properties).forEach( (value, index) => {
(this.componentInjected.instance)[value] = properties[value];
});
}
}

private setComponentWrapperProperties(config, identifier, parentElement) {
(<TlModal>this.component.instance).setOptions(this.modalOptions);
(<TlModal>this.component.instance).setIdentifier(this.isConfigSmartForm(config) ? config['identifier'] : identifier);
Expand Down Expand Up @@ -193,7 +201,7 @@ export class ModalService implements OnDestroy {

private setComponentModal(component: Type<any>,
config: SmartFormConfiguration | ComponentFactoryResolver,
identifier?, parentElement?, mdOptions?: ModalOptions) {
identifier?, parentElement?, mdOptions?: ModalOptions, properties?) {

const factory = this.isConfigSmartForm(config) ? config['factory'] : config;
if (this.isSmartFormUpdateDeleteAction(config) && !this.validateDataFormUpdate(config)) {
Expand All @@ -209,6 +217,7 @@ export class ModalService implements OnDestroy {
this.setInitialZIndex();
this.setInjectedComponent(factory, component);
this.setModalOptions(mdOptions);
this.setModalProperties(properties);
this.handleBackDrop(factory);
this.setComponentWrapperProperties(config, identifier, parentElement);
this.setInstanceComponent(config);
Expand Down
4 changes: 3 additions & 1 deletion projects/truly-ui/src/components/thumbnail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { FormsModule } from '@angular/forms';
import { TlThumbnail } from './thumbnail';
import { IconsModule } from '../icons/index';
import { LightboxModule } from '../lightbox/index';
import {DialogModule} from '../dialog/index';

@NgModule({
imports: [
CommonModule,
IconsModule,
FormsModule,
LightboxModule
LightboxModule,
DialogModule
],
declarations: [
TlThumbnail
Expand Down
2 changes: 2 additions & 0 deletions projects/truly-ui/src/components/thumbnail/thumbnail.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<img class="thumbnail-image" [class.circle-shape]="isCircle" alt="image" [src]="item.file || image">
<div class="thumbnail-controls" *ngIf="!overlayTemplate">
<tl-icon style="margin-right: 5px" (click)="onViewImage( image )" [lib]="'dx'">find</tl-icon>
<tl-icon *ngIf="showDeleteButton" style="cursor: pointer" (click)="onDeleteThumb(item)" [lib]="'dx'">trash</tl-icon>
</div>
<div class="thumbnail-controls" *ngIf="overlayTemplate">
<ng-container *ngTemplateOutlet="overlayTemplate; context: { $implicit: item || image }"></ng-container>
Expand All @@ -33,6 +34,7 @@
<tl-icon style="margin-right: 5px" [lib]="'fa'" [style]="'fas'" [color]="'#ec7e7e'" [size]="'40px'">file-pdf</tl-icon>
<div class="thumbnail-controls" *ngIf="!overlayTemplate">
<tl-icon style="margin-right: 5px" (click)="onViewImage( image )" [lib]="'dx'">find</tl-icon>
<tl-icon *ngIf="showDeleteButton" style="cursor: pointer" (click)="onDeleteThumb(item)" [lib]="'dx'">trash</tl-icon>
</div>
<div class="thumbnail-controls" *ngIf="overlayTemplate">
<ng-container *ngTemplateOutlet="overlayTemplate; context: { $implicit: item || image }"></ng-container>
Expand Down
29 changes: 27 additions & 2 deletions projects/truly-ui/src/components/thumbnail/thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

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

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

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

@Input() showDeleteButton = false;

@Input() confirmationDeleteMessage = 'Do you want to delete the Thumbnail?';

@Input() showConfirmationOnDelete = false;

@Input() modalDeleteOptions: ModalOptions;

@Input() overlayTemplate: TemplateRef<any>;

@Input() emptyTemplate: TemplateRef<any>;

@Output() clickThumbnail = new EventEmitter();

constructor(private lightboxService: LightboxService, private thumbnailService: ThumbnailService) {}
@Output() clickDeleteThumbail = new EventEmitter();

constructor(
private lightboxService: LightboxService,
private thumbnailService: ThumbnailService,
private dialogService: DialogService
) {}

ngOnInit() {}

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

onDeleteThumb(image) {
if (this.showConfirmationOnDelete) {
return this.dialogService.confirmation( this.confirmationDeleteMessage, ({
isYes: () => this.clickDeleteThumbail.emit(image),
}), {}, this.modalDeleteOptions);
}
this.clickDeleteThumbail.emit(image);
}

}
8 changes: 7 additions & 1 deletion projects/truly-ui/src/components/timeline/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class TlTimeline implements OnInit, OnChanges {

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

@Input() clearOnUpdateData = false;

@Input() align = 'left';

@Input() height = '400px';
Expand Down Expand Up @@ -88,7 +90,11 @@ export class TlTimeline implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges) {
this.loadingMoreData = false;
if ( this.data.length > 0 ) {
this.buffer = this.buffer.concat(this.data);
if ( this.clearOnUpdateData ) {
this.buffer = this.data;
} else {
this.buffer = this.buffer.concat(this.data);
}
this.nothingFound = false;
return this.loadingMoreData = false;
}
Expand Down
4 changes: 2 additions & 2 deletions projects/truly-ui/src/components/upload/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ng-container *ngIf="imageList.length === 0 || showAsList; else imagesContainerTemplate">
<span><tl-icon class="icon" [lib]="'fa'" [style]="'fas'">inbox</tl-icon></span>
<p style="white-space: pre-line">{{ boxDescription }}</p>
<input #inputMultiple type="file" style="display: none;" (change)="onChange($event)" multiple>
<input #inputMultiple type="file" style="display: none;" (change)="onChange($event)" multiple [accept]="acceptFiles">
</ng-container>

<ng-template #imagesContainerTemplate>
Expand Down Expand Up @@ -33,7 +33,7 @@
</div>

<ng-template #uploadboxTemplate let-item>
<input #inputSingle type="file" style="display: none;" (change)="onChange($event)">
<input #inputSingle type="file" style="display: none;" (change)="onChange($event)" [accept]="acceptFiles">
<tl-thumbnail
[shape]="'square'"
[bordered]="!item"
Expand Down
21 changes: 19 additions & 2 deletions projects/truly-ui/src/components/upload/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class TlUpload implements OnInit {

@Input() viewControl = true;

@Input() acceptFiles = 'image/*,application/pdf';

@ViewChild('inputMultiple', {static: false}) inputMultiple;

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

onChange($event) {
if ($event.target.files.length > 0) {
const filesAccepet = this.filterFilesAccpet($event.target.files);
if (this.type === 'dragndrop') {
return this.readFiles($event.target.files);
return this.readFiles(filesAccepet);
}
const reader = new FileReader();
reader.readAsDataURL($event.target.files[0]);
reader.readAsDataURL(filesAccepet[0]);
reader.onload = (event) => {
this.imageSrc = (<FileReader>event.target).result;
this.uploadChange.emit(this.imageSrc);
};
}
}

private filterFilesAccpet( files ) {
const acceptFiles = [];
for (let i = 0; i < files.length; i++) {
const regexExpresison = this.acceptFiles
.replace( /\*/g, '.\*' )
.replace( /\,/g, '|' ) ;
const isAccept = new RegExp( regexExpresison ).test( files[ i ].type );
if ( isAccept ) {
acceptFiles.push(files[i]);
}
}
return acceptFiles;
}

private getBase64MimeType(encoded) {
let result = null;

Expand Down
5 changes: 4 additions & 1 deletion src/app/components/modal/modaldemo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export class ModalDemoComponent {
}

modal1() {
this.modalService.createModal( NewModalComponent, this.compiler )
this.modalService.createModal( NewModalComponent, this.compiler, 'MODAL-TESTE', {
myTitle: 'My Modal Text Title',
notPropertie: ''
} )
.then( ( modalResult ) => {
console.log( modalResult );
});
Expand Down
6 changes: 4 additions & 2 deletions src/app/components/modal/newmodal/newModal.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import {Component, Input} from '@angular/core';
import { Modal } from '../../../../../projects/truly-ui/src/components/modal/interfaces/modal-options';

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

2 changes: 1 addition & 1 deletion src/app/components/thumbnail/thumbnaildemo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<app-card>
<div class="col-md-12">
<h5>Basic Image</h5>
<tl-thumbnail [data]="files"></tl-thumbnail>
<tl-thumbnail [data]="files" [showDeleteButton]="true" (clickDeleteThumbail)="deleteThumb($event)" [showConfirmationOnDelete]="true"></tl-thumbnail>
<br>
<div class="spacer"></div>
<textarea highlight-js [options]="{'tabReplace': ''}" [lang]="'html'">
Expand Down
6 changes: 5 additions & 1 deletion src/app/components/thumbnail/thumbnaildemo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ThumbnailDemoComponent {
{
index: 1,
description: 'PDF 1',
file: 'https://cdn.medicsolution.app/prontuario/anexos/09794f95-4baf-4726-ab7b-dd62369d1cf6',
file: 'http://www.orimi.com/pdf-test.pdf',
type: 'application/pdf'
}
];
Expand All @@ -54,5 +54,9 @@ export class ThumbnailDemoComponent {
this.dataTableProperties = json.dataProperties;
this.dataEvents = jsonEvts.dataEvents;
}

deleteThumb(thumb) {
console.log('DELETING...', thumb);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class TimelineDemoComponent {
public dataAdvanced = [
{
title: 'Dr. Gregory House 1',
date: 1537477718000,
date: 1537477712000,
text: 'Mauris vulputate dolor vel finibus sagittis.',
duration: 15,
category: [
Expand Down Expand Up @@ -816,6 +816,7 @@ export class TimelineDemoComponent {
this.dataLazy = this.getDataFromService(0, this.take);
}


getDataFromService(skip, take) {
return this.dataAdvanced.slice(skip, take);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ShowcaseCardModule } from '../../../shared/components/showcase-card/sho
import { ShowcaseTablePropertiesModule } from '../../../shared/components/showcase-table-properties/showcase-table-properties.module';
import { ShowcaseTableEventsModule } from '../../../shared/components/showcase-table-events/showcase-table-events.module';
import { ShowcaseHeaderModule } from '../../../shared/components/showcase-header/showcase-header.module';
import {ButtonModule} from '../../../../../projects/truly-ui/src/components/button';

@NgModule({
declarations: [
Expand All @@ -26,7 +27,8 @@ import { ShowcaseHeaderModule } from '../../../shared/components/showcase-header
ShowcaseTablePropertiesModule,
ShowcaseTableEventsModule,
ShowcaseHeaderModule,
ShowcaseHeaderModule
ShowcaseHeaderModule,
ButtonModule
],
exports: [
TimelineDemoComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<div class="row">
<div class="col-md-6">
<h6>Basic</h6>
<tl-timeline [data]="dataBasic" [height]="'300px'" [keyTitle]="'title'" [keyText]="'text'"></tl-timeline>
<tl-button [text]="'Change Item'" (click)="changItem()"></tl-button>
<tl-timeline [data]="dataBasic" [clearOnUpdateData]="true" [height]="'300px'" [keyTitle]="'title'" [keyText]="'text'"></tl-timeline>
<br>
<textarea highlight-js [options]="{'tabReplace': ''}" [lang]="'html'">
<tl-timeline [data]="dataBasic" [height]="'300px'" [keyTitle]="'title'" [keyText]="'text'"></tl-timeline>
Expand Down
10 changes: 10 additions & 0 deletions src/app/components/timeline/overview/timelinedemo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,5 +832,15 @@ export class TimelineDemoComponent {
this.dataTableProperties = json.dataProperties;
}


changItem() {
this.dataBasic = this.dataBasic.map( (data, index) => {
if (data.title === 'Dr. Gregory House 1') {
data.text = data.text + index;
}
return data;
});
}

}

Loading

0 comments on commit 0b09bfa

Please sign in to comment.