Skip to content

Commit fafe572

Browse files
authored
Merge pull request #173 from UCDavisLibrary/stage
v4.0.0
2 parents a17d1b9 + c5e3a3e commit fafe572

File tree

24 files changed

+8182
-593
lines changed

24 files changed

+8182
-593
lines changed

ucdlib-assets/src/public/package-lock.json

Lines changed: 129 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ucdlib-assets/src/public/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@ucd-lib/plugin-locations-public": "file:../../../ucdlib-locations/src/public",
1818
"@ucd-lib/plugin-search-public": "file:../../../ucdlib-search/src/public",
1919
"@ucd-lib/plugin-special-public": "file:../../../ucdlib-special/src/public",
20-
"@ucd-lib/theme-sass": "^5.0.16",
20+
"@ucd-lib/theme-sass": "^6.0.1",
2121
"jquery": "^3.6.1",
2222
"normalize-scss": "^7.0.1",
2323
"slick-carousel": "^1.8.1"

ucdlib-directory/includes/api-filters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function epcb_service_filters($request){
3333
$slug = $this->config['taxSlugs']['service-type'];
3434
$terms = Timber::get_terms([
3535
'taxonomy' => $slug,
36-
'orderby' => 'name',
36+
'orderby' => 'term_order',
3737
'order' => 'ASC',
3838
]);
3939
$out[$slug] = array_map(function($t) {

ucdlib-directory/includes/block-transformations.php

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ public static function getEsResults($attrs){
141141
$query['query']['bool']['filter'] = $filterContext;
142142
$results = $client->search( $query );
143143

144+
if ( $results['hits']['total']['value'] == 0 ) return $attrs;
145+
144146
// display params
145147
$hideDepartments = array_key_exists('hideDepartments', $attrs) && $attrs['hideDepartments'] != 'false';
146-
$orderby = $attrs['orderby'] == 'name' ? 'name' : 'department';
147-
if ( $results['hits']['total']['value'] == 0 ) return $attrs;
148+
$orderby = self::directoryOrderby($attrs['orderby']);
148149

149150
// get timber people objects
150151
$personQuery = [
@@ -153,41 +154,57 @@ public static function getEsResults($attrs){
153154
'post__in' => array_map(function($x){return $x['_id'];}, $results['hits']['hits']),
154155
'post_type' => 'person',
155156
'meta_key' => 'name_last',
156-
'orderby' => $orderby == 'department' ? 'menu_order meta_value' : 'meta_value',
157+
'orderby' => $orderby['query'],
157158
'order' => 'ASC'
158159
];
159160
$people = Timber::get_posts($personQuery);
160161

161162
if ( $hideDepartments ){
162163
$attrs['people'] = $people;
163-
} else if ( $orderby == 'name' ) {
164-
$attrs['people'] = $people;
165-
} else {
164+
} else if ( $orderby['attr'] == 'department' ) {
166165
$attrs['departments'] = self::assignPeopleToDepartments($people);
166+
} else {
167+
$attrs['people'] = $people;
167168
}
168-
169+
169170

170171
return $attrs;
171172
}
172173

173174
// converts directory url query args to attributes
174175
public static function queryArgsToAttributes($attrs){
175176
$attrs['orderby'] = get_query_var('orderby', '');
176-
$attrs['qRaw'] = get_query_var('q', '');
177+
$attrs['qRaw'] = get_query_var('q', '');
177178
$attrs['q'] = UCDLibPluginDirectoryUtils::explodeQueryVar('q', false, ' ');
178179
$attrs['library'] = UCDLibPluginDirectoryUtils::explodeQueryVar('library');
179180
$attrs['department'] = UCDLibPluginDirectoryUtils::explodeQueryVar('department');
180181
$attrs['directoryTag'] = UCDLibPluginDirectoryUtils::explodeQueryVar('directory-tag');
181182
return $attrs;
182183
}
183184

185+
public static function directoryOrderby($orderby){
186+
$out = [
187+
'attr' => 'department',
188+
'query' => 'menu_order meta_value'
189+
];
190+
if ( $orderby == 'name' ) {
191+
$out['attr'] = 'name';
192+
$out['query'] = 'meta_value';
193+
} else if ( $orderby == 'rand' ) {
194+
$out['attr'] = 'rand';
195+
$out['query'] = 'rand';
196+
}
197+
198+
return $out;
199+
}
200+
184201
public static function setDefaultQueryAttributes( $attrs ){
185202
if ( !array_key_exists('orderby', $attrs) ) $attrs['orderby'] = 'department';
186203
$vars = ['q', 'library', 'department', 'directoryTag'];
187204
foreach ($vars as $var) {
188205
if ( !array_key_exists($var, $attrs) ) $attrs[$var] = [];
189206
}
190-
207+
191208
return $attrs;
192209
}
193210

@@ -222,13 +239,8 @@ public static function getDirectoryResults( $attrs=[] ){
222239
]
223240
];
224241

225-
// set order of results
226-
$orderby = $attrs['orderby'] == 'name' ? 'name' : 'department';
227-
if ( $orderby == 'department' ){
228-
$personQuery['orderby'] = 'menu_order meta_value';
229-
} else {
230-
$personQuery['orderby'] = 'meta_value';
231-
}
242+
$orderby = self::directoryOrderby($attrs['orderby']);
243+
$personQuery['orderby'] = $orderby['query'];
232244

233245
// keyword search. needs to search both name and areas of expertise taxonomy
234246
$kwQueryVar = array_filter($attrs['q'], function($x){return $x;});
@@ -301,10 +313,10 @@ public static function getDirectoryResults( $attrs=[] ){
301313

302314
if ( $hideDepartments ){
303315
$attrs['people'] = $people;
304-
} else if ( $orderby == 'name' ) {
305-
$attrs['people'] = $people;
306-
} else {
316+
} else if ( $orderby['attr'] == 'department' ) {
307317
$attrs['departments'] = self::assignPeopleToDepartments($people);
318+
} else {
319+
$attrs['people'] = $people;
308320
}
309321
return $attrs;
310322
}
@@ -346,4 +358,4 @@ public static function widgetIcons( $attrs ){
346358
return $attrs;
347359
}
348360
}
349-
?>
361+
?>

ucdlib-directory/src/editor/lib/plugins/profile.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const Edit = () => {
1717
const hidePronouns = meta.hide_pronouns ? true : false;
1818
const hideLibraries = meta.hide_libraries ? true : false;
1919
const hideDirectoryTags = meta.hide_tags ? true : false;
20-
const hideExpertiseAreas = meta.hide_expertise_areas ? true : false;
21-
const hideBio = meta.hide_bio ? true : false;
20+
const hideExpertiseAreas = meta.hide_expertise_areas ? true : false;
21+
const hideBio = meta.hide_bio ? true : false;
2222
const pastEmployee = meta.pastEmployee | false;
2323
const { editPost } = useDispatch( 'core/editor', [ hidePronouns, hideLibraries, hideDirectoryTags, hideExpertiseAreas, hideBio, pastEmployee ] );
2424

@@ -27,35 +27,36 @@ const Edit = () => {
2727
<${Fragment}>
2828
${(isPerson) && html`
2929
<${PluginDocumentSettingPanel}
30+
name=${name}
3031
className=${name}
3132
icon=${html`<ucdlib-icon style=${{marginLeft: '8px', width: '18px', minWidth: '18px'}} icon="ucd-public:fa-user-gear"></ucdlib-icon>`}
3233
title="Profile Settings">
33-
<${ToggleControl}
34+
<${ToggleControl}
3435
label="No Longer Employed at Library"
3536
checked=${pastEmployee}
3637
onChange=${() => editPost({meta: { pastEmployee: !pastEmployee}})}
3738
/>
38-
<${ToggleControl}
39+
<${ToggleControl}
3940
label="Hide Pronouns"
4041
checked=${hidePronouns}
4142
onChange=${() => editPost({meta: { hide_pronouns: !hidePronouns}})}
4243
/>
43-
<${ToggleControl}
44+
<${ToggleControl}
4445
label="Hide Library Locations"
4546
checked=${hideLibraries}
4647
onChange=${() => editPost({meta: { hide_libraries: !hideLibraries}})}
4748
/>
48-
<${ToggleControl}
49+
<${ToggleControl}
4950
label="Hide Bio"
5051
checked=${hideBio}
5152
onChange=${() => editPost({meta: { hide_bio: !hideBio}})}
5253
/>
53-
<${ToggleControl}
54+
<${ToggleControl}
5455
label="Hide Directory Tags"
5556
checked=${hideDirectoryTags}
5657
onChange=${() => editPost({meta: { hide_tags: !hideDirectoryTags}})}
5758
/>
58-
<${ToggleControl}
59+
<${ToggleControl}
5960
label="Hide Areas of Expertise"
6061
checked=${hideExpertiseAreas}
6162
onChange=${() => editPost({meta: { hide_expertise_areas: !hideExpertiseAreas}})}
@@ -68,4 +69,4 @@ const Edit = () => {
6869
}
6970

7071
const settings = {render: Edit};
71-
export default { name, settings };
72+
export default { name, settings };

ucdlib-directory/src/editor/lib/plugins/user.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Edit = () => {
3030
return html`
3131
3232
<${PluginDocumentSettingPanel}
33+
name=${name}
3334
className=${name}
3435
icon=${html`<ucdlib-icon style=${{marginLeft: '8px', width: '12px', minWidth: '12px'}} icon="ucd-public:fa-user"></ucdlib-icon>`}
3536
title="User Account">
@@ -38,37 +39,37 @@ const Edit = () => {
3839
` : html`
3940
<${BaseControl} help=${helpText.noAccount} />
4041
`}
41-
<${TextControl}
42-
label="WP Account ID"
43-
value=${userId}
42+
<${TextControl}
43+
label="WP Account ID"
44+
value=${userId}
4445
onChange=${(wp_user_id) => editPost({meta: {wp_user_id}})}/>
4546
${hasUserAccount ? html`
4647
<div>
47-
<${TextControl}
48+
<${TextControl}
4849
disabled=${true}
4950
label="Kerberos"
5051
value=${user && user.username ? user.username : ''}
5152
/>
52-
<${TextControl}
53+
<${TextControl}
5354
disabled=${true}
5455
label="UC Path ID"
5556
value=${user && user.meta && user.meta['ucd-cas_ucpath-id'] ? user.meta['ucd-cas_ucpath-id'] : ''}
5657
/>
57-
<${TextControl}
58+
<${TextControl}
5859
disabled=${true}
5960
label="IAM ID"
6061
value=${user && user.meta && user.meta['ucd-cas_iam-id'] ? user.meta['ucd-cas_ucpath-id'] : ''}
6162
/>
6263
</div>
6364
` : html`
64-
<${TextControl}
65-
label="Kerberos"
66-
value=${kerberos}
65+
<${TextControl}
66+
label="Kerberos"
67+
value=${kerberos}
6768
onChange=${(username) => editPost({meta: {username}})}/>
6869
`}
6970
</${PluginDocumentSettingPanel}>
7071
`
7172
}
7273

7374
const settings = {render: Edit};
74-
export default { name, settings };
75+
export default { name, settings };

0 commit comments

Comments
 (0)