From 7d2990d08bb8e80449f9319f5b1d30f5fb7ae207 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 12 Apr 2022 14:36:31 +0300 Subject: [PATCH] [Library | new-theme]: orcid.module.ts: Removed IconsService | orcid-work.component.ts: Updated icons (remove -> delete & preview -> visibility) & grouped tooltips wherever possible (background css not ready) & Removed unused css & Updated orcid buttons for landing page & [Bug fix] Update how "isLoggedIn" is calculated (userManagementService.getUserInfo() instead of Session). --- orcid/orcid-work.component.ts | 105 ++++++++++++++++------------------ orcid/orcid.module.ts | 6 +- 2 files changed, 51 insertions(+), 60 deletions(-) diff --git a/orcid/orcid-work.component.ts b/orcid/orcid-work.component.ts index 05454dbb..425b53fb 100644 --- a/orcid/orcid-work.component.ts +++ b/orcid/orcid-work.component.ts @@ -9,32 +9,19 @@ import {Session} from "../login/utils/helper.class"; import {LoginErrorCodes} from "../login/utils/guardHelper.class"; import {ExternalIDV3_0, WorkV3_0} from "./orcidWork"; import {EnvProperties} from "../utils/properties/env-properties"; +import {UserManagementService} from "../services/user-management.service"; declare var UIkit: any; @Component({ styles: [ - '.add-orcid-button { background-color: #a6ce39; color: #fff; border: 1px solid #a6ce39; } ' + - '.add-orcid-button:hover { background-color: #b6d65c; border-color: #b6d65c; } ' + - '.delete-orcid-button { background-color: #fff; color: #ff3d33; border: 1px solid #ff3d33 }' + - '.delete-orcid-button:hover { color: #ff0d00; border-color: #ff0d00; } ' + - ' a:not(:hover) .orcid-color { color: #a6ce39; }' + - - '.loading-action-button { width: 36px; height: 36px; }' + - - '.orcid-button { background-color: #fff; border: 1px solid #a6ce39; } ' + - '.orcid-button:hover { background-color: #e0f0d5; } ' + - - 'a.orcid_icon_opacity:hover > .uk-icon { opacity: 0.8; } ' + '.loading-action-button { width: 36px; height: 36px; }' ], selector: 'orcid-work', template: ` Add to  - + ORCID  orcid{{" "}} @@ -51,17 +38,14 @@ declare var UIkit: any; - + Delete from  - + ORCID  {{" "}} @@ -72,44 +56,29 @@ declare var UIkit: any; - - add orcid + [class]="(showLoading ? 'uk-disabled' : '') + (!isLoggedIn || !pids ? 'uk-disabled uk-text-muted' : '')"> + + add orcid - - - - - - + [class]="(showLoading ? 'uk-disabled' : '') + (!isLoggedIn || !pids ? 'uk-disabled uk-text-muted' : '')"> + - - - - - @@ -152,7 +121,7 @@ declare var UIkit: any; : 'View this work from your ORCID record'"> - + View ORCID work @@ -172,7 +141,7 @@ declare var UIkit: any; + [attr.uk-tooltip]="tooltipAdd"> @@ -182,10 +151,10 @@ declare var UIkit: any; + [attr.uk-tooltip]="tooltipDelete"> - + Delete from ORCID @@ -352,7 +321,7 @@ export class OrcidWorkComponent { public orcidWorks: any[] = []; public window: any; - public isLoggedIn: boolean = Session.isLoggedIn(); + public isLoggedIn: boolean = false; public currentAction: string = ""; @@ -361,7 +330,8 @@ export class OrcidWorkComponent { constructor(private route: ActivatedRoute, private _router: Router, private orcidService: OrcidService, - private resultLandingService: ResultLandingService) { + private resultLandingService: ResultLandingService, + private userManagementService: UserManagementService) { if(typeof document !== 'undefined') { this.tokenUrl = properties.orcidTokenURL + "client_id="+properties.orcidClientId @@ -373,9 +343,18 @@ export class OrcidWorkComponent { } ngOnInit() { - if(!this.givenPutCode && this.isLoggedIn) { - this.getPutCode(); - } + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { + if (user) { + this.isLoggedIn = true; + if(!this.givenPutCode) { + this.getPutCode(); + } + } else { + this.isLoggedIn = false; + } + }, error => { + this.isLoggedIn = false; + })); } ngOnDestroy() { @@ -790,4 +769,20 @@ export class OrcidWorkComponent { } this.showLoading = false; } + + get tooltipAdd() { + return "Add this work to your ORCID record" + ((properties.environment == "beta") ? ". The action will affect your real ORCID iD." : ""); + } + + get tooltipDelete() { + return "Delete this work from your ORCID record" + ((properties.environment == "beta") ? ". The action will affect your real ORCID iD." : ""); + } + + get tooltipNoPid() { + return "Only resources with a PID (persistent identifier) like DOI, handle, PMID can be added or deleted from your ORCID record"; + } + + get tooltipNoLoggedInUser() { + return "Only logged in users can add or delete a work from their ORCID record"; + } } diff --git a/orcid/orcid.module.ts b/orcid/orcid.module.ts index 7231b5dc..06f1ad47 100644 --- a/orcid/orcid.module.ts +++ b/orcid/orcid.module.ts @@ -13,8 +13,6 @@ import {ResultLandingService} from '../landingPages/result/resultLanding.service import {LoadingModule} from '../utils/loading/loading.module'; import {ResultLandingUtilsModule} from '../landingPages/landing-utils/resultLandingUtils.module'; import {IconsModule} from '../utils/icons/icons.module'; -import {IconsService} from '../utils/icons/icons.service'; -import {add, preview, refresh, remove} from '../utils/icons/icons'; @NgModule({ imports: [ @@ -37,7 +35,5 @@ import {add, preview, refresh, remove} from '../utils/icons/icons'; export class OrcidModule{ - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([add, remove, preview, refresh]); - } + constructor() {} }