Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spelkey-ucd committed May 10, 2024
1 parent 4b4d03f commit 29f1ced
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 69 deletions.
19 changes: 10 additions & 9 deletions ucdlib-directory/src/editor/lib/plugins/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const Edit = () => {
const hidePronouns = meta.hide_pronouns ? true : false;
const hideLibraries = meta.hide_libraries ? true : false;
const hideDirectoryTags = meta.hide_tags ? true : false;
const hideExpertiseAreas = meta.hide_expertise_areas ? true : false;
const hideBio = meta.hide_bio ? true : false;
const hideExpertiseAreas = meta.hide_expertise_areas ? true : false;
const hideBio = meta.hide_bio ? true : false;
const pastEmployee = meta.pastEmployee | false;
const { editPost } = useDispatch( 'core/editor', [ hidePronouns, hideLibraries, hideDirectoryTags, hideExpertiseAreas, hideBio, pastEmployee ] );

Expand All @@ -27,35 +27,36 @@ const Edit = () => {
<${Fragment}>
${(isPerson) && html`
<${PluginDocumentSettingPanel}
name=${name}
className=${name}
icon=${html`<ucdlib-icon style=${{marginLeft: '8px', width: '18px', minWidth: '18px'}} icon="ucd-public:fa-user-gear"></ucdlib-icon>`}
title="Profile Settings">
<${ToggleControl}
<${ToggleControl}
label="No Longer Employed at Library"
checked=${pastEmployee}
onChange=${() => editPost({meta: { pastEmployee: !pastEmployee}})}
/>
<${ToggleControl}
<${ToggleControl}
label="Hide Pronouns"
checked=${hidePronouns}
onChange=${() => editPost({meta: { hide_pronouns: !hidePronouns}})}
/>
<${ToggleControl}
<${ToggleControl}
label="Hide Library Locations"
checked=${hideLibraries}
onChange=${() => editPost({meta: { hide_libraries: !hideLibraries}})}
/>
<${ToggleControl}
<${ToggleControl}
label="Hide Bio"
checked=${hideBio}
onChange=${() => editPost({meta: { hide_bio: !hideBio}})}
/>
<${ToggleControl}
<${ToggleControl}
label="Hide Directory Tags"
checked=${hideDirectoryTags}
onChange=${() => editPost({meta: { hide_tags: !hideDirectoryTags}})}
/>
<${ToggleControl}
<${ToggleControl}
label="Hide Areas of Expertise"
checked=${hideExpertiseAreas}
onChange=${() => editPost({meta: { hide_expertise_areas: !hideExpertiseAreas}})}
Expand All @@ -68,4 +69,4 @@ const Edit = () => {
}

const settings = {render: Edit};
export default { name, settings };
export default { name, settings };
21 changes: 11 additions & 10 deletions ucdlib-directory/src/editor/lib/plugins/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Edit = () => {
return html`
<${PluginDocumentSettingPanel}
name=${name}
className=${name}
icon=${html`<ucdlib-icon style=${{marginLeft: '8px', width: '12px', minWidth: '12px'}} icon="ucd-public:fa-user"></ucdlib-icon>`}
title="User Account">
Expand All @@ -38,37 +39,37 @@ const Edit = () => {
` : html`
<${BaseControl} help=${helpText.noAccount} />
`}
<${TextControl}
label="WP Account ID"
value=${userId}
<${TextControl}
label="WP Account ID"
value=${userId}
onChange=${(wp_user_id) => editPost({meta: {wp_user_id}})}/>
${hasUserAccount ? html`
<div>
<${TextControl}
<${TextControl}
disabled=${true}
label="Kerberos"
value=${user && user.username ? user.username : ''}
/>
<${TextControl}
<${TextControl}
disabled=${true}
label="UC Path ID"
value=${user && user.meta && user.meta['ucd-cas_ucpath-id'] ? user.meta['ucd-cas_ucpath-id'] : ''}
/>
<${TextControl}
<${TextControl}
disabled=${true}
label="IAM ID"
value=${user && user.meta && user.meta['ucd-cas_iam-id'] ? user.meta['ucd-cas_ucpath-id'] : ''}
/>
</div>
` : html`
<${TextControl}
label="Kerberos"
value=${kerberos}
<${TextControl}
label="Kerberos"
value=${kerberos}
onChange=${(username) => editPost({meta: {username}})}/>
`}
</${PluginDocumentSettingPanel}>
`
}

const settings = {render: Edit};
export default { name, settings };
export default { name, settings };
21 changes: 11 additions & 10 deletions ucdlib-locations/src/editor/lib/plugins/core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Fragment } from "@wordpress/element";
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { useDispatch } from "@wordpress/data";
import {
import {
ToggleControl,
SelectControl,
TextControl } from '@wordpress/components';
Expand Down Expand Up @@ -64,6 +64,7 @@ const Edit = () => {
<${Fragment}>
${isLocation && html`
<${PluginDocumentSettingPanel}
name=${name}
className=${name}
icon=${html`<ucdlib-icon style=${{marginLeft: '8px', width: '15px', minWidth: '15px'}} icon="ucd-public:fa-building-circle-exclamation"></ucdlib-icon>`}
title="This Location">
Expand All @@ -80,54 +81,54 @@ const Edit = () => {
}
</style>
<div style=${{marginBottom: '15px'}}>
<${TextControl}
<${TextControl}
value=${labelShort}
label="Short Label"
onChange=${label_short => editPost({meta: {label_short}})}
help="Less than 15 characters or so..."
/>
<${TextControl}
<${TextControl}
value=${address}
label="Address to Display"
onChange=${display_address => editPost({meta: {display_address}})}
/>
<${TextControl}
<${TextControl}
value=${roomNumber}
label="Room Number"
onChange=${room_number => editPost({meta: {room_number}})}
/>
</div>
<div style=${{marginBottom: '15px'}}>
<${ToggleControl}
<${ToggleControl}
label="Show Alert Notification"
checked=${hasAlert}
onChange=${ () => editPost({meta: {has_alert: !hasAlert}})}
help="Displayed on hours and visit pages."
/>
${hasAlert && html`
<${TextControl}
<${TextControl}
label="Notification"
value=${alertText}
onChange=${alert_text => editPost({meta: {alert_text}})}
/>
`}
</div>
<div>
<${ToggleControl}
<${ToggleControl}
label="Custom Location Page"
checked=${hasRedirect}
onChange=${ () => editPost({meta: {has_redirect: !hasRedirect}})}
help="Any requests to this page will be redirected to a custom url"
/>
${hasRedirect && html`
<${LinkControl}
<${LinkControl}
settings=${[]}
value=${redirect}
onRemove=${() => onRedirectChange()}
onChange=${v => onRedirectChange(v)}/>
`}
</div>
<${SelectControl}
<${SelectControl}
options=${parentOptions}
value=${locationParent}
label="Parent Location"
Expand All @@ -141,4 +142,4 @@ const Edit = () => {
}

const settings = {render: Edit};
export default { name, settings };
export default { name, settings };
33 changes: 17 additions & 16 deletions ucdlib-locations/src/editor/lib/plugins/hours.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Fragment } from "@wordpress/element";
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { useDispatch } from "@wordpress/data";
import {
import {
ToggleControl,
TextareaControl,
TextControl } from '@wordpress/components';
Expand Down Expand Up @@ -45,62 +45,63 @@ const Edit = () => {
<${Fragment}>
${isLocation && html`
<${PluginDocumentSettingPanel}
name=${name}
className=${name}
icon=${html`<ucdlib-icon style=${{marginLeft: '8px', width: '15px', minWidth: '15px'}} icon="ucd-public:fa-clock"></ucdlib-icon>`}
title="Hours and Occupancy">
<${ToggleControl}
<${ToggleControl}
label="Display Operating Hours"
checked=${hasOperatingHours}
onChange=${() => editPost({meta: { has_operating_hours: !hasOperatingHours}})}
/>
${hasOperatingHours && html`
<div>
<${TextControl}
<${TextControl}
label="Libcal ID"
value=${libcalId}
onChange=${libcal_id => editPost({meta: {libcal_id}})}
help="Can be found here: https://ucdavis.libcal.com/admin/hours"
/>
<${TextControl}
<${TextControl}
label="Today's Hours Prefix Label"
value=${openPrefix}
onChange=${open_prefix => editPost({meta: {open_prefix}})}
help="Displays before open hours on any Today's Hours widget."
/>
</div>
`}
<${ToggleControl}
<${ToggleControl}
label="Display Description in Hours page"
checked=${hasDescriptonDisplay}
onChange=${() => editPost({meta: { hasDescriptonDisplay: !hasDescriptonDisplay}})}
/>
${hasDescriptonDisplay && html`
<div>
<${TextControl}
<${TextControl}
label="Description (html allowed)"
value=${descriptionDisplay.linkUrl}
onChange=${linkUrl => editPost({meta: {descriptionDisplay: {...descriptionDisplay, linkUrl}}})}
/>
</div>
`}
<${ToggleControl}
<${ToggleControl}
label="Hide Hours on Hours page"
checked=${hideHours}
onChange=${() => editPost({meta: { hideHours: !hideHours}})}
/>
<${ToggleControl}
<${ToggleControl}
label="Has Appointments"
checked=${hasAppointments}
onChange=${() => editPost({meta: { has_appointments: !hasAppointments}})}
/>
${hasAppointments && html`
<div>
<${TextControl}
<${TextControl}
label="Link Text"
value=${appointments.linkText}
onChange=${linkText => editPost({meta: {appointments: {...appointments, linkText}}})}
/>
<${TextControl}
<${TextControl}
label="Link Url"
value=${appointments.linkUrl}
onChange=${linkUrl => editPost({meta: {appointments: {...appointments, linkUrl}}})}
Expand All @@ -109,34 +110,34 @@ const Edit = () => {
`}
${!hasOperatingHours && html`
<div>
<${ToggleControl}
<${ToggleControl}
label="Display Placeholder Message"
checked=${hasPlaceholder}
onChange=${() => editPost({meta: { has_hours_placeholder: !hasPlaceholder}})}
help="Will display custom text instead of location hours on hours page."
/>
${hasPlaceholder && html`
<${TextareaControl}
<${TextareaControl}
label="Placeholder Text"
value=${placeholderText}
onChange=${hours_placeholder => editPost({meta: {hours_placeholder}})}
/>
`}
</div>
`}
<${ToggleControl}
<${ToggleControl}
label="Display Current Occupancy"
checked=${hasOccupancy}
onChange=${() => editPost({meta: { has_occupancy: !hasOccupancy}})}
/>
${hasOccupancy && html`
<div>
<${TextControl}
<${TextControl}
label="Max Capacity"
value=${occupancy.capacity}
onChange=${capacity => editPost({meta: {occupancy: {...occupancy, capacity}}})}
/>
<${TextControl}
<${TextControl}
label="Safespace Id"
value=${occupancy.safespaceId}
onChange=${safespaceId => editPost({meta: {occupancy: {...occupancy, safespaceId}}})}
Expand All @@ -151,4 +152,4 @@ const Edit = () => {
}

const settings = {render: Edit};
export default { name, settings };
export default { name, settings };
21 changes: 11 additions & 10 deletions ucdlib-migration/src/editor/lib/plugins/post-meta.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useState, useEffect } from "@wordpress/element";
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { useDispatch, useSelect } from "@wordpress/data";
import {
SelectControl,
PanelRow,
BaseControl,
Button,
import {
SelectControl,
PanelRow,
BaseControl,
Button,
Modal } from '@wordpress/components';
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs, getPath } from '@wordpress/url';
Expand Down Expand Up @@ -48,17 +48,17 @@ const Edit = () => {
target: permaPath,
status: 'enabled',
action: 'url'
},
},
per_page: 200,
orderby: "last_count",
direction: 'desc'
});
apiFetch( {path} ).then(
apiFetch( {path} ).then(
( r ) => {
setRedirects(r.items.filter(redirect => {
return redirect.action_data.url == `/${permaPath}` || redirect.action_data.url == permalink;
}));
},
},
(error) => {
console.warn('Unable to retrieve redirect list.')
})
Expand All @@ -74,10 +74,11 @@ const Edit = () => {

return html`
<${PluginDocumentSettingPanel}
name=${name}
className=${name}
title="Migration">
<${PanelRow}>
<${SelectControl}
<${SelectControl}
label="Content Status"
value=${pageMeta.migration_status}
options=${statusOptions}
Expand Down Expand Up @@ -123,4 +124,4 @@ const Edit = () => {
}

const settings = {render: Edit};
export default { name, settings };
export default { name, settings };
Loading

0 comments on commit 29f1ced

Please sign in to comment.