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`
${this.photoAlt}
-

${this.nameFirst} ${this.nameLast}

+

${this.nameFirst} ${this.nameLast}

${this.positionTitle} | ${this.department}

${this.contactPhone ? html`${this.svgIcon.phone} ${this.contactPhone} |`: html``}

${this.contactEmail ? html`${this.svgIcon.email} ${this.contactEmail} ${this.contactAppointmentUrl ? html`|`:html`|`}`: html``}

diff --git a/package.json b/package.json index bef3b3e..602af02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ucd-lib/theme", - "version": "0.0.1", + "version": "1.1.2", "description": "University branding, additional theme support, theme elements", "main": "index.js", "scripts": {