openaire-library/utils/modal/alert.ts

163 lines
4.6 KiB
TypeScript
Raw Normal View History

import {Component, ViewEncapsulation, ElementRef, EventEmitter, Output, Input, ViewChild} from '@angular/core';
import {properties} from "../../../../environments/environment";
declare var UIkit: any;
@Component({
selector: 'modal-alert',
template: `
<div #element class="uk-modal" [class.uk-modal-container]="large" [id]="id" uk-modal>
<div class="uk-modal-dialog uk-modal-body uk-animation-fast uk-margin-medium-bottom uk-text-left"
[ngClass]="classBody">
<div [ngClass]="classTitle" class="uk-modal-title" [hidden]=!alertHeader>
<button class="uk-close uk-icon uk-modal-close-default uk-float-right" (click)='cancel()'>
<icon name="close" ratio="1.5"></icon>
</button>
[Library & common-assets | new-theme]: Updates for redesign. 1. availableOn.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external icon to links and updated accessright icons. 2. citation.class.ts: Added fileFormatOptions: Option[] to use it in input options. 3. citeThis.component.ts: Updated select inputs using "input" from InputComponent | Updated copy to clipboard button to link. 4. citeThis.module.ts: Import InputModule. 5. fos.component.ts: Updated class of title to "uk-text-light-grey". 6. fundedBy.component.ts: Updated class of title to "uk-text-light-grey" and updated links with uk-text-emphasis class. 7. landing-header.component.ts: Increase authorsLimit to 7 | Changed class of "under curation" to uk-text-primary (used to be custom class). 8. metrics.component.ts: Updated in clickOutside event. parsingFunctions.class.ts: Updated open, closed and unknown with icon names instead of paths to svgs (download accessright icons). 9. relatedTo.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external for links. 10. resultLandingUtils.module.ts: Inport AlertModalModule (to open modal). 11. sdg.component.ts: Updated class of titlte to "uk-text-light-grey". 12. showIdentifiers.component.ts: Added view more functionality. 13. showPublisher.component.ts: Updated custon-external class. 14. resultLanding.module.ts: registerIcon link. 15. resultLanding.component.html: Updated css for result landing and commented annotations (b2note). 16. orcid-work.component.ts: Updated orcid action button for landing page. 17. orcid.module.ts: registerIcons orcid_add and orcid_bin. 18. customOptions.class.ts: [Bug fix] [By Kostis] registryOptions() was not returning properly httpHeaders. 19. showAuthors.component.ts: Updated css 20. icons.ts: Export svgs orcid_add, orcid_bin, link. 21. alert.ts: Removed margin from title. 22. result-preview.component.html: Title of results set to <h2> and uk-h6 and when links to uk-link-heading | accessRightIcon for hostedBy_collectedFrom. 23. result-preview.module.ts: Imported IconsModule. 24. landing-utils.css: Updates in landing css & css of landing-action-button & added backdrop filter missing rules. 25. utils.css: Updated class orcid-clipboard-wrapper and renamed to clipboad-wrapper | Update class .custom-external to set in content with code instead of name and updated not to underline it on hover 26. library.css: Added class .default-dropdown with max-width: 500px;
2022-04-16 09:47:30 +02:00
<h5 class="uk-margin-remove">{{alertTitle}}</h5>
</div>
<div class="uk-margin">
<div *ngIf="message" [hidden]=!alertMessage [innerHTML]="message | safeHtml"></div>
<ng-content></ng-content>
</div>
<div class="uk-grid uk-flex uk-flex-middle">
<label *ngIf="choice" class="uk-width-1-2">
<input type="checkbox" [(ngModel)]="select">
<span class="uk-margin-small-left">Don't show this message again</span>
</label>
<div [ngClass]="(choice)?'uk-width-1-2':'uk-width-1-1'">
<div *ngIf="alertFooter" class="uk-flex-right uk-grid uk-grid-small" uk-grid>
<span *ngIf="okButton" [class.uk-flex-last]="!okButtonLeft">
<button class="uk-button uk-button-primary" [disabled]="okDisabled"
[class.uk-disabled]="okDisabled" (click)="ok()">{{okButtonText}}</button>
</span>
<span *ngIf="cancelButton">
<button class="uk-button uk-button-default uk-margin-small-left"
(click)="cancel()">{{cancelButtonText}}</button>
</span>
</div>
</div>
</div>
</div>
</div>
`,
encapsulation: ViewEncapsulation.None,
})
/**
* API to an open alert window.
*/
export class AlertModal {
@Input() id: string = "modal";
@Input() classTitle: string = "";
@Input() classBody: string = "";
@Input() large: boolean = false;
/**
* Caption for the title.
*/
public alertTitle: string;
/**
* Describes if the alert contains Ok Button.
* The default Ok button will close the alert and emit the callback.
* Defaults to true.
*/
public okButton: boolean = true;
/**
* Caption for the OK button.
* Default: Ok
*/
public okButtonText: string = 'OK';
/**
* Describes if the alert contains cancel Button.
* The default Cancelbutton will close the alert.
* Defaults to true.
*/
public cancelButton: boolean = true;
/**
* Caption for the Cancel button.
* Default: Cancel
*/
public cancelButtonText: string = 'Cancel';
/**
* if the alertMessage is true it will show the contentString inside alert body.
*/
public alertMessage: boolean = true;
/**
* Some message/content can be set in message which will be shown in alert body.
*/
public message: string;
/**
* if the value is true alert footer will be visible or else it will be hidden.
*/
public alertFooter: boolean = true;
/**
* shows alert header if the value is true.
*/
public alertHeader: boolean = true;
/**
* if the value is true ok button align on the left, else on the right
*/
public okButtonLeft: boolean = true;
/**
* if the value is true ok button is disabled
*/
@Input()
public okDisabled: boolean = false;
/**
* If the value is true, a checkbox option will be appeared on the right side of footer
*/
@Input()
public choice: boolean = false;
/**
* if the value is true then on ok clicked, modal will stay open.
*/
public stayOpen: boolean = false;
/**
* Value will be emitted if @choice is true
*/
public select: boolean = true;
/**
* Emitted when a ok button was clicked
* or when Ok method is called.
*/
@Output() public alertOutput: EventEmitter<any> = new EventEmitter();
@ViewChild('element') element: ElementRef;
constructor() {
}
/**
* Opens a alert window creating backdrop.
*/
open() {
UIkit.modal(this.element.nativeElement).show();
}
/**
* ok method closes the modal and emits modalOutput.
*/
ok() {
if (!this.stayOpen) {
this.cancel();
}
if (!this.choice) {
this.alertOutput.emit(true);
} else {
this.alertOutput.emit({
value: true,
choice: this.select
});
}
}
/**
* cancel method closes the modal.
*/
cancel() {
UIkit.modal(this.element.nativeElement).hide();
}
}