[develop | DONE | FIXED]: orcid-work.component.ts: [Bug fix] Show tooltip when button is disabled & When in beta environment, do not call query to get put codes, always disable buttons and show tooltip about not available feature on beta.
This commit is contained in:
parent
6c9c477c24
commit
56faf6f6a4
|
@ -22,88 +22,54 @@ declare var UIkit: any;
|
|||
template: `
|
||||
<ng-container *ngIf="pageType == 'landing' || pageType == 'search'">
|
||||
<span *ngIf="!putCodes || putCodes.length == 0"
|
||||
(click)="currentAction='add'; saveWorkPreparation();"
|
||||
[class.uk-disabled]="showLoading || !isLoggedIn || (!pids && (!identifiers || identifiers.size == 0))"
|
||||
[class.clickable]="!showLoading && isLoggedIn && (pids || (identifiers && identifiers.size > 0))"
|
||||
[ngClass]="isMobile && pageType == 'landing' ? ' uk-width-1-1' : ''"
|
||||
[attr.uk-tooltip]="isMobile? 'cls: uk-invisible' : 'pos: bottom; cls: uk-active uk-text-small uk-padding-small'"
|
||||
[title]="((!pids && (!identifiers || identifiers.size == 0)) || !isLoggedIn) ? ((!pids && (!identifiers || identifiers.size == 0)) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipAdd">
|
||||
<a class="uk-flex uk-flex-middle uk-button-link"
|
||||
[ngClass]="isMobile && !(pageType == 'landing') ? 'uk-margin-left' : ''"
|
||||
[class.uk-text-bolder]="!(isMobile && pageType == 'landing')"
|
||||
[class.uk-text-muted]="showLoading || !isLoggedIn || (!pids && (!identifiers || identifiers.size == 0))"
|
||||
(mouseover)="hoverEvent($event)" (mouseout)="hoverEvent($event)">
|
||||
<icon *ngIf="!showLoading" [class.text-orcid]="!showLoading && isLoggedIn && (pids || identifiers?.size > 0)"
|
||||
[class.uk-text-muted]="showLoading || !isLoggedIn || (!pids && (!identifiers || identifiers.size == 0))"
|
||||
name="orcid_add" [ratio]="(isMobile && pageType == 'search') ? 0.7 : 1" visuallyHidden="add"></icon>
|
||||
<span *ngIf="showLoading" class="uk-icon"><loading
|
||||
[top_margin]="false" [size]="'small'"></loading></span>
|
||||
<span [ngClass]="(isMobile && pageType == 'landing') ? 'uk-margin-small-left' : 'uk-margin-xsmall-left'">Claim</span>
|
||||
</a>
|
||||
<div *ngIf="isMobile && pageType == 'landing'" class="uk-margin-xsmall-top uk-padding uk-padding-remove-vertical uk-text-meta uk-text-xsmall"
|
||||
[innerHTML]="((!pids && (!identifiers || identifiers.size == 0)) || !isLoggedIn) ? ((!pids && (!identifiers || identifiers.size == 0)) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipAdd"></div>
|
||||
[ngClass]="isMobile && pageType == 'landing' ? ' uk-width-1-1' : ''"
|
||||
[attr.uk-tooltip]="isMobile? 'cls: uk-invisible' : 'pos: bottom; cls: uk-active uk-text-small uk-padding-small'"
|
||||
[title]="(noPids || !isLoggedIn) ? ((noPids) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipAdd">
|
||||
<span (click)="currentAction='add'; saveWorkPreparation();"
|
||||
[class.uk-disabled]="isDisabled"
|
||||
[class.clickable]="!isDisabled">
|
||||
<a class="uk-flex uk-flex-middle uk-button-link"
|
||||
[ngClass]="isMobile && !(pageType == 'landing') ? 'uk-margin-left' : ''"
|
||||
[class.uk-text-bolder]="!(isMobile && pageType == 'landing')"
|
||||
[class.uk-text-muted]="isDisabled">
|
||||
<icon *ngIf="!showLoading" [class.text-orcid]="properties.environment != 'beta' && !showLoading && isLoggedIn && (pids || identifiers?.size > 0)"
|
||||
[class.uk-text-muted]="isDisabled"
|
||||
name="orcid_add" [ratio]="(isMobile && pageType == 'search') ? 0.7 : 1" visuallyHidden="add"></icon>
|
||||
<span *ngIf="showLoading" class="uk-icon"><loading
|
||||
[top_margin]="false" [size]="'small'"></loading></span>
|
||||
<span [ngClass]="(isMobile && pageType == 'landing') ? 'uk-margin-small-left' : 'uk-margin-xsmall-left'">Claim</span>
|
||||
</a>
|
||||
<div *ngIf="isMobile && pageType == 'landing'" class="uk-margin-xsmall-top uk-padding uk-padding-remove-vertical uk-text-meta uk-text-xsmall"
|
||||
[innerHTML]="(noPids || !isLoggedIn) ? ((noPids) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipAdd"></div>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span *ngIf="putCodes && putCodes.length > 0"
|
||||
(click)="currentAction='delete'; deleteWorks();"
|
||||
[class.uk-disabled]="showLoading || !isLoggedIn || (!pids && (!identifiers || identifiers.size == 0))"
|
||||
[class.clickable]="!showLoading && isLoggedIn && (pids || (identifiers && identifiers.size > 0))"
|
||||
[ngClass]="isMobile && pageType == 'landing' ? ' uk-width-1-1' : ''"
|
||||
<span *ngIf="putCodes && putCodes.length > 0" [ngClass]="isMobile && pageType == 'landing' ? ' uk-width-1-1' : ''"
|
||||
[attr.uk-tooltip]="isMobile? 'cls: uk-invisible' : 'pos: bottom; cls: uk-active uk-text-small uk-padding-small'"
|
||||
[title]="((!pids && (!identifiers || identifiers.size == 0)) || !isLoggedIn) ? ((!pids && (!identifiers || identifiers.size == 0)) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipDelete">
|
||||
<a class="uk-flex uk-flex-middle uk-button-link"
|
||||
[ngClass]="isMobile && !(pageType == 'landing') ? 'uk-margin-left' : ''"
|
||||
[class.uk-text-bolder]="!(isMobile && pageType == 'landing')"
|
||||
[class.uk-text-muted]="showLoading || !isLoggedIn || (!pids && (!identifiers || identifiers.size == 0))"
|
||||
(mouseover)="hoverEvent($event, 'delete')" (mouseout)="hoverEvent($event, 'delete')">
|
||||
<icon *ngIf="!showLoading" [class.text-orcid]="!showLoading && isLoggedIn && (pids || identifiers?.size > 0)"
|
||||
[class.uk-text-muted]="showLoading || !isLoggedIn || (!pids && (!identifiers || identifiers.size == 0))"
|
||||
name="orcid_bin" [ratio]="(isMobile && pageType == 'search') ? 0.7 : 1" visuallyHidden="delete"></icon>
|
||||
<span *ngIf="showLoading" class="uk-icon"><loading
|
||||
[top_margin]="false" [size]="'small'"></loading></span>
|
||||
<span [ngClass]="(isMobile && pageType == 'landing') ? 'uk-margin-small-left' : 'uk-margin-xsmall-left'">Remove</span>
|
||||
</a>
|
||||
<div *ngIf="isMobile && pageType == 'landing'" class="uk-margin-xsmall-top uk-padding uk-padding-remove-vertical uk-text-meta uk-text-xsmall"
|
||||
[innerHTML]="((!pids && (!identifiers || identifiers.size == 0)) || !isLoggedIn) ? ((!pids && (!identifiers || identifiers.size == 0)) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipDelete"></div>
|
||||
[title]="(noPids || !isLoggedIn) ? ((noPids) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipDelete">
|
||||
<span (click)="currentAction='delete'; deleteWorks();"
|
||||
[class.uk-disabled]="isDisabled"
|
||||
[class.clickable]="!isDisabled">
|
||||
<a class="uk-flex uk-flex-middle uk-button-link"
|
||||
[ngClass]="isMobile && !(pageType == 'landing') ? 'uk-margin-left' : ''"
|
||||
[class.uk-text-bolder]="!(isMobile && pageType == 'landing')"
|
||||
[class.uk-text-muted]="isDisabled">
|
||||
<icon *ngIf="!showLoading" [class.text-orcid]="!showLoading && isLoggedIn && (pids || identifiers?.size > 0)"
|
||||
[class.uk-text-muted]="isDisabled"
|
||||
name="orcid_bin" [ratio]="(isMobile && pageType == 'search') ? 0.7 : 1" visuallyHidden="delete"></icon>
|
||||
<span *ngIf="showLoading" class="uk-icon"><loading
|
||||
[top_margin]="false" [size]="'small'"></loading></span>
|
||||
<span [ngClass]="(isMobile && pageType == 'landing') ? 'uk-margin-small-left' : 'uk-margin-xsmall-left'">Remove</span>
|
||||
</a>
|
||||
<div *ngIf="isMobile && pageType == 'landing'" class="uk-margin-xsmall-top uk-padding uk-padding-remove-vertical uk-text-meta uk-text-xsmall"
|
||||
[innerHTML]="(noPids || !isLoggedIn) ? ((noPids) ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipDelete"></div>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<!-- Old 'remove' code -->
|
||||
<!-- <span *ngIf="putCodes && putCodes.length > 0"
|
||||
[attr.uk-tooltip]="'pos: bottom; cls: uk-active uk-text-small uk-padding-small'"
|
||||
[title]="(!pids || !isLoggedIn) ? (!pids ? tooltipNoPid : tooltipNoLoggedInUser) : tooltipDelete">
|
||||
<a *ngIf="!showLoading" (click)="currentAction='delete'; deleteWorks();"
|
||||
class="uk-icon-button uk-icon landing-action-button landing-action-button-orcid"
|
||||
[class.uk-disabled]="showLoading || !isLoggedIn || !pids"
|
||||
(mouseover)="hoverEvent($event, 'delete')" (mouseout)="hoverEvent($event, 'delete')">
|
||||
<icon *ngIf="!hoverDelete" name="orcid_bin" ratio="1.1" visuallyHidden="delete"></icon>
|
||||
<icon *ngIf="hoverDelete" name="delete_outline" class="uk-text-danger" visuallyHidden="delete"></icon>
|
||||
</a>
|
||||
<span *ngIf="showLoading" class="uk-icon icon-button uk-icon-button-small"><loading
|
||||
[top_margin]="false" [size]="'small'"></loading></span>
|
||||
</span> -->
|
||||
</ng-container>
|
||||
|
||||
<modal-alert *ngIf="!isMobile" #grantModal [overflowBody]=false (alertOutput)="openGrantWindow()">
|
||||
<div>
|
||||
<div>{{requestGrantMessage}}</div>
|
||||
|
||||
<!-- <div class="uk-margin-medium-top uk-align-right">-->
|
||||
<!-- <button (click)="closeGrantModal()" type="submit"-->
|
||||
<!-- class="uk-button uk-padding-small uk-padding-remove-vertical uk-button-default">-->
|
||||
<!-- <span>Cancel</span>-->
|
||||
<!-- </button>-->
|
||||
|
||||
<!-- <button (click)="openGrantWindow()" type="submit"-->
|
||||
<!-- class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left uk-button-primary">-->
|
||||
<!-- <span>Grant OpenAIRE</span>-->
|
||||
<!-- </button>-->
|
||||
|
||||
<!--<!– <button (click)="openGrantWindow()" type="submit"–>-->
|
||||
<!--<!– class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left orcid-button">–>-->
|
||||
<!--<!– <img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="">{{" "}}–>-->
|
||||
<!--<!– <span>Create or Connect your ORCID iD</span>–>-->
|
||||
<!--<!– </button>–>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</modal-alert>
|
||||
|
||||
|
@ -292,18 +258,6 @@ declare var UIkit: any;
|
|||
instead.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="uk-margin-medium-top uk-align-right">-->
|
||||
<!-- <button (click)="closePropagationModal()" type="submit"-->
|
||||
<!-- class="uk-button uk-padding-small uk-padding-remove-vertical uk-button-default">-->
|
||||
<!-- <span>Cancel</span>-->
|
||||
<!-- </button>-->
|
||||
|
||||
<!-- <button (click)="confirmedPropagation()" type="submit"-->
|
||||
<!-- class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left uk-button-primary">-->
|
||||
<!-- <span>Continue</span>-->
|
||||
<!-- </button>-->
|
||||
<!-- </div>-->
|
||||
</modal-alert>
|
||||
|
||||
<fs-modal #propagationFsModal classTitle="uk-tile-default uk-border-bottom">
|
||||
|
@ -369,9 +323,6 @@ export class OrcidWorkComponent {
|
|||
public hasConsent: boolean = false;
|
||||
public currentAction: string = "";
|
||||
|
||||
public hoverAdd: boolean = false;
|
||||
public hoverDelete: boolean = false;
|
||||
|
||||
public properties: EnvProperties = properties;
|
||||
public openaireEntities = OpenaireEntities;
|
||||
|
||||
|
@ -391,24 +342,26 @@ export class OrcidWorkComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
if (user) {
|
||||
this.isLoggedIn = true;
|
||||
if (!this.givenPutCode) {
|
||||
this.getPutCode();
|
||||
if(this.properties.environment != 'beta') {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
if (user) {
|
||||
this.isLoggedIn = true;
|
||||
if (!this.givenPutCode) {
|
||||
this.getPutCode();
|
||||
}
|
||||
} else {
|
||||
this.isLoggedIn = false;
|
||||
}
|
||||
} else {
|
||||
}, error => {
|
||||
this.isLoggedIn = false;
|
||||
}));
|
||||
if (properties.dashboard == 'irish') {
|
||||
this.subscriptions.push(this._userProfileService.getUserProfile().subscribe(userProfile => {
|
||||
this.hasConsent = userProfile.consent;
|
||||
}, error => {
|
||||
this.hasConsent = false;
|
||||
}));
|
||||
}
|
||||
}, error => {
|
||||
this.isLoggedIn = false;
|
||||
}));
|
||||
if(properties.dashboard == 'irish'){
|
||||
this.subscriptions.push(this._userProfileService.getUserProfile().subscribe(userProfile => {
|
||||
this.hasConsent = userProfile.consent;
|
||||
}, error =>{
|
||||
this.hasConsent = false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -894,13 +847,18 @@ export class OrcidWorkComponent {
|
|||
}
|
||||
this.showLoading = false;
|
||||
}
|
||||
|
||||
|
||||
get tooltipBETA() {
|
||||
// return "Login to the production environment to add works to your <span class=\"text-orcid\">ORCID</span> record";
|
||||
return "Add or delete a work from your <span class=\"text-orcid\">ORCID</span> record. This feature is not available on BETA.";
|
||||
}
|
||||
|
||||
get tooltipAdd() {
|
||||
return "Add this work to your <span class=\"text-orcid\">ORCID</span> record" + ((properties.environment == "beta") ? ". The action will affect your real ORCID iD." : "");
|
||||
return (properties.environment == "beta") ? this.tooltipBETA : ("Add this work to your <span class=\"text-orcid\">ORCID</span> record" + ((properties.environment == "test") ? ". The action will affect your real ORCID iD." : ""));
|
||||
}
|
||||
|
||||
get tooltipDelete() {
|
||||
return "Delete this work from your <span class=\"text-orcid\">ORCID</span> record" + ((properties.environment == "beta") ? ". The action will affect your real ORCID iD." : "");
|
||||
return "Delete this work from your <span class=\"text-orcid\">ORCID</span> record" + ((properties.environment == "test") ? ". The action will affect your real ORCID iD." : "");
|
||||
}
|
||||
|
||||
get tooltipNoPid() {
|
||||
|
@ -908,16 +866,14 @@ export class OrcidWorkComponent {
|
|||
}
|
||||
|
||||
get tooltipNoLoggedInUser() {
|
||||
return "Add or delete a work from your <span class=\"text-orcid\">ORCID</span> record. Please log in first."
|
||||
return (properties.environment == "beta") ? this.tooltipBETA : "Add or delete a work from your <span class=\"text-orcid\">ORCID</span> record. Please log in first."
|
||||
}
|
||||
|
||||
hoverEvent($event, action: string = "add") {
|
||||
if (action == "add") {
|
||||
this.hoverAdd = $event.type == "mouseover";
|
||||
this.hoverDelete = false;
|
||||
} else if (action == "delete") {
|
||||
this.hoverDelete = $event.type == "mouseover";
|
||||
this.hoverAdd = false;
|
||||
}
|
||||
|
||||
get isDisabled() {
|
||||
return (this.properties.environment == 'beta' || this.showLoading || !this.isLoggedIn || (!this.pids && (!this.identifiers || this.identifiers.size == 0)));
|
||||
}
|
||||
|
||||
get noPids() {
|
||||
return (!this.pids && (!this.identifiers || this.identifiers.size == 0));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue