From a6002e57f4302c2c1d3b0e78160ee67823254f24 Mon Sep 17 00:00:00 2001
From: sbagg <42234329+sbagg@users.noreply.github.com>
Date: Tue, 30 Aug 2022 12:13:52 -0700
Subject: [PATCH] issue#73 changes (#74)
* issue#73 changes
* person page change
* Updated theme version to 1.1.2
---
.../pages/page-ucdlib-author-profile.tpl.js | 10 ++---
elements/package.json | 2 +-
.../ucdlib-author-profile.js | 41 ++++++++++---------
.../ucdlib-author-profile.tpl.js | 2 +-
package.json | 2 +-
5 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/brand-app/pages/page-ucdlib-author-profile.tpl.js b/brand-app/pages/page-ucdlib-author-profile.tpl.js
index 466943f..694c74a 100644
--- a/brand-app/pages/page-ucdlib-author-profile.tpl.js
+++ b/brand-app/pages/page-ucdlib-author-profile.tpl.js
@@ -22,7 +22,7 @@ export function render() {
Use the email
attribute to query an employee:
${this.sampleList.map(email => this.examplePanel(
html`
-
+
`)
)}
@@ -44,17 +44,17 @@ export function render() {
-
-
+
+
`)}
Changing the Data Source
By default, this element queries data from https://library.ucdavis.edu
.
- However, the domain
attribute can be used to query a subdomain of the site instead:
+ However, the host
attribute can be used to query a subdomain of the site instead:
${this.examplePanel(html`
-
+
`)}
`;}
diff --git a/elements/package.json b/elements/package.json
index 8baee87..1ea0a84 100644
--- a/elements/package.json
+++ b/elements/package.json
@@ -1,6 +1,6 @@
{
"name": "@ucd-lib/theme-elements",
- "version": "1.1.1",
+ "version": "1.1.2",
"description": "Custom elements for the UCD brand theme",
"main": "index.js",
"scripts": {
diff --git a/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.js b/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.js
index 80918d1..87734b2 100644
--- a/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.js
+++ b/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.js
@@ -6,9 +6,9 @@ import {TaskController} from '../../utils/controllers/task.js';
* @class AuthorProfile
* @description This author profile hydrates with the website wordpress api and goes into a profile block.
* @property {String} email - Email to reference person
- * @property {String} domain - Specify the domain to choose from
+ * @property {String} host - Specify the host to choose from
*
- *
*/
export default class UcdlibAuthorProfile extends LitElement {
static get properties() {
@@ -16,20 +16,21 @@ export default class UcdlibAuthorProfile extends LitElement {
results : {type: Object, attribute:false},
email : {type: String},
id: {type: Number},
- nameLast: {type: String},
- nameFirst: {type: String},
+ nameLast: {type: String, attribute: 'name-last'},
+ nameFirst: {type: String, attribute: 'name-first'},
link: {type: String},
- contactWebsite: {type: String},
- contactEmail: {type: String},
- contactPhone: {type: String},
- contactWebsiteLabel: {type: String},
- contactEmailLabel: {type: String},
- contactPhoneLabel: {type: String},
- contactAppointmentUrl: {type: String},
- positionTitle: {type: String},
+ contactWebsite: {type: String, attribute: 'contact-website'},
+ contactEmail: {type: String, attribute: 'contact-email'},
+ contactPhone: {type: String, attribute: 'contact-phone'},
+ contactWebsiteLabel: {type: String, attribute: 'contact-website-label'},
+ contactEmailLabel: {type: String, attribute: 'contact-email-label'},
+ contactPhoneLabel: {type: String, attribute: 'contact-phone-label'},
+ contactAppointmentUrl: {type: String, attribute: 'contact-appointment-url'},
+ positionTitle: {type: String, attribute: 'position-title'},
photo: {type: Object},
department: {type: String},
- domain: {type: String},
+ host: {type: String},
+ apiPath: {type: String, attribute: 'api-path'},
sidebar: {type: Boolean}
};
}
@@ -46,7 +47,9 @@ export default class UcdlibAuthorProfile extends LitElement {
this.ERROR = false;
this.results = {};
this.email = '';
- this.domain = '';
+ this.host = window.location.origin;
+ this.apiPath = '/wp-json/ucdlib-directory/person/';
+
this.errorMessage = 'This is not an email.';
@@ -77,13 +80,13 @@ export default class UcdlibAuthorProfile extends LitElement {
/**
* @method updated
*
- * @description request user data when email or domain changes
+ * @description request user data when email or host changes
*
* @param {Object} props
*
*/
updated(props){
- if( props.has('email') || props.has('domain') ){
+ if( props.has('email') || props.has('host') || props.has('apiPath')){
if( !this.email ) return;
this.eController = new TaskController(this, this._requestUrl());
}
@@ -194,11 +197,9 @@ export default class UcdlibAuthorProfile extends LitElement {
let email =this.email;
let validate = this.validationLink(email);
if(!validate) console.error(email);
- let url;
- url = "https://library.ucdavis.edu/wp-json/ucdlib-directory/person/" + String(email);
- if (this.domain != "")
- url = "https://" + this.domain + ".library.ucdavis.edu/wp-json/ucdlib-directory/person/" + String(email);
+ let url = (this.host || window.location.origin) + this.apiPath + String(email);
+
this.requestUpdate();
return url;
diff --git a/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.tpl.js b/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.tpl.js
index d438fb5..cebda26 100644
--- a/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.tpl.js
+++ b/elements/ucdlib/ucdlib-author-profile/ucdlib-author-profile.tpl.js
@@ -166,7 +166,7 @@ ${this.eController ? html`