Skip to content

Commit 3b742b4

Browse files
committed
Merge commit '0d2b2e3fe84ce0208662eba60dd867d8b203ccd4' into production
2 parents 00c8a6b + 0d2b2e3 commit 3b742b4

18 files changed

Lines changed: 348 additions & 27 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Knowledge Commons Works is a collaborative tool for storing and sharing academic research. It is part of Knowledge Commons and is built on an instance of the InvenioRDM repository system.
44

5-
Version 0.3.2-beta5
5+
Version 0.3.3-beta6
66

77
## Copyright
88

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { Component } from "react";
2+
import { Button, Header, Icon, Segment } from "semantic-ui-react";
3+
import { withState } from "react-searchkit";
4+
import { i18next } from "@translations/invenio_communities/i18next";
5+
import PropTypes from "prop-types";
6+
7+
const MembersEmptyResultsComponent = ({
8+
resetQuery,
9+
extraContent = null,
10+
queryString,
11+
currentQueryState,
12+
currentResultsState,
13+
}) => {
14+
const isEmptyPageAfterSearch = currentQueryState.page < 0;
15+
const isEmptyPage =
16+
currentQueryState.page === 1 && currentResultsState.data.total === 0;
17+
18+
return (
19+
<Segment placeholder textAlign="center">
20+
<Header icon>
21+
<Icon name={isEmptyPage ? "users" : "search"} />
22+
{isEmptyPage && i18next.t("This collection has no public members.")}
23+
{isEmptyPageAfterSearch && i18next.t("No matching members found.")}
24+
</Header>
25+
{queryString && (
26+
<p>
27+
<em>
28+
{i18next.t("Current search")} "{queryString}"
29+
</em>
30+
</p>
31+
)}
32+
{isEmptyPageAfterSearch && (
33+
<Button primary onClick={() => resetQuery()}>
34+
{i18next.t("Clear query")}
35+
</Button>
36+
)}
37+
{extraContent}
38+
</Segment>
39+
);
40+
};
41+
42+
MembersEmptyResultsComponent.propTypes = {
43+
resetQuery: PropTypes.func.isRequired,
44+
queryString: PropTypes.string.isRequired,
45+
currentQueryState: PropTypes.object.isRequired,
46+
currentResultsState: PropTypes.object.isRequired,
47+
extraContent: PropTypes.node,
48+
};
49+
50+
const MembersEmptyResults = withState(MembersEmptyResultsComponent);
51+
52+
export { MembersEmptyResults };

assets/js/invenio_app_rdm/overridableRegistry/fields/CreatibutorsField.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { CreatibutorsFieldItem } from "./creatibutors_components/CreatibutorsFie
1818
import { CREATIBUTOR_TYPE } from "./types";
1919
import { FormUIStateContext } from "@js/invenio_modular_deposit_form/InnerDepositForm";
2020
import { i18next } from "@translations/invenio_rdm_records/i18next";
21+
import { getFamilyName, getGivenName } from "../../../kcworks/names";
2122

2223
/**
2324
* Sort a list of string values (options).
@@ -114,11 +115,15 @@ const makeSelfCreatibutor = (currentUserprofile) => {
114115

115116
let myNameParts = {};
116117
if (
117-
!!currentUserprofile?.name_parts &&
118-
currentUserprofile?.name_parts !== ""
118+
!!currentUserprofile?.name_parts_local &&
119+
currentUserprofile?.name_parts_local !== ""
119120
) {
121+
myNameParts = JSON.parse(currentUserprofile.name_parts_local);
122+
} else if (!!currentUserprofile?.name_parts && currentUserprofile?.name_parts !== "") {
120123
myNameParts = JSON.parse(currentUserprofile.name_parts);
121124
}
125+
const part1 = [myNameParts?.given, myNameParts?.first, myNameParts?.middle, myNameParts?.nickname].filter(Boolean).join(" ");
126+
const part2 = [myNameParts?.family_prefix, myNameParts?.family_prefix_fixed, myNameParts?.spousal, myNameParts?.parental, myNameParts?.family, myNameParts?.last, ].filter(Boolean).join(" ");
122127

123128
let myIdentifiers = undefined;
124129
const rawIdentifiers = Object.fromEntries(
@@ -136,8 +141,14 @@ const makeSelfCreatibutor = (currentUserprofile) => {
136141

137142
let selfCreatibutor = {
138143
person_or_org: {
139-
family_name: myNameParts?.last || currentUserprofile?.full_name || "",
140-
given_name: myNameParts?.first || "",
144+
family_name:
145+
getFamilyName(myNameParts) ||
146+
currentUserprofile?.full_name ||
147+
"",
148+
given_name:
149+
getGivenName(myNameParts) ||
150+
myNameParts?.first ||
151+
"",
141152
name: currentUserprofile?.full_name || "",
142153
type: "personal",
143154
identifiers: myIdentifiers?.length > 0 ? myIdentifiers : [],

assets/js/invenio_app_rdm/overridableRegistry/mapping.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { InvitationResultItemWithConfig } from "./collections/invitations/Invita
2424
import { LicenseField } from "./fields/LicenseField";
2525
import { LogoUploader } from "./collections/settings/profile/LogoUploader";
2626
import { ManagerMembersResultItemWithConfig } from "./collections/members/manager_view/ManagerMembersResultItem";
27+
import { MembersEmptyResults } from "./collections/members/components/MembersEmptyResults";
2728
import { MembersSearchBarElement } from "./collections/members/components/MembersSearchBarElement";
2829
import { MetadataOnlyToggle } from "./fields/MetadataOnlyToggle";
2930
import Pagination from "./search/Pagination";
@@ -120,12 +121,15 @@ export const overriddenComponents = {
120121
"InvenioCommunities.RequestSearch.ResultsList.item": RequestsResultsItemTemplateWithCommunity,
121122
"InvenioCommunities.RequestSearch.SearchApp.layout": CommunityRequestsSearchLayoutWithApp,
122123
"InvenioCommunities.InvitationsSearch.ResultsList.item": InvitationResultItemWithConfig,
124+
"InvenioCommunities.ManagerSearch.EmptyResults.element": MembersEmptyResults,
123125
"InvenioCommunities.ManagerSearch.ResultsList.item": ManagerMembersResultItemWithConfig,
124126
"InvenioCommunities.ManagerSearch.SearchBar.element": MembersSearchBarElement,
125127
"InvenioCommunities.MemberSearch.ResultsList.item": ManagerMembersResultItemWithConfig,
128+
"InvenioCommunities.MemberSearch.EmptyResults.element": MembersEmptyResults,
126129
"InvenioCommunities.MemberSearch.SearchBar.element": MembersSearchBarElement,
127130
"InvenioCommunities.PublicSearch.ResultsList.item": PublicMembersResultsItemWithCommunity,
128131
"InvenioCommunities.PublicSearch.SearchBar.element": MembersSearchBarElement,
132+
"InvenioCommunities.PublicSearch.EmptyResults.element": MembersEmptyResults,
129133
"InvenioModularDetailPage.MobileActionMenu.container": MobileActionMenu,
130134
// "InvenioAppRdm.Deposit.ResourceTypeField.container": ResourceTypeField
131135
// InvenioCommunities.Search.SearchApp.layout: CommunityRecordsSearchAppLayout,

assets/less/site/collections/grid.overrides

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,21 @@
4848
.row:first-child {
4949
padding-bottom: 0;
5050
}
51-
.row:nth-child(2) {
51+
.row:not(:first-child) {
5252
padding-top: 0;
53+
padding-bottom: 0;
54+
a {
55+
display: inline-block;
56+
margin-left: 1rem;
57+
width: 1.5rem;
58+
height: 1.5rem;
59+
background-color: @white;
60+
padding-left: 1.5px;
61+
padding-bottom: 2px;
62+
}
63+
}
64+
.row:last-child {
65+
padding-bottom: 1rem;
5366
}
5467
}
5568
}

invenio.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5744,6 +5744,7 @@ class CustomUserProfileSchema(Schema):
57445744
full_name = fields.String()
57455745
affiliations = fields.String()
57465746
name_parts = fields.String()
5747+
name_parts_local = fields.String()
57475748
identifier_email = fields.String()
57485749
identifier_orcid = fields.String()
57495750
identifier_kc_username = fields.String()

site/CHANGES.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33

44
# Changes
55

6+
## 0.3.3-beta6 (2024-12-18)
7+
8+
- Names
9+
- Added the infrastructure to customize the division of users' names into parts so that it can be divided as desired when, e.g., the user's name is being auto-filled in the name fields of the upload form. This involves
10+
- a new "name_parts_local" field to the user profile schema. This field contains the user's name parts if they have been modified within the KCWorks system. This is sometimes necessary when the user data synced from the remote user data service does not divide the user's name correctly.
11+
- a cli command to update the user's name parts.
12+
- a new "names" js module that contains functions to get the user's full name, full name in inverted order, family name, and given name from the user's name parts.
13+
- updates to the CreatibutorsField component to use the new "names" js module and the customized name parts if they are present in a user's profile.
14+
- Detail page
15+
- Added missing aria-label properties for accessibility
16+
- Collections
17+
- Fixed wording of empty results message for collection members search
18+
- Previously, the empty results message used "community" instead of "collection".
19+
- Tweaks to layout of collection detail page header
20+
- Remote user data service
21+
- Fixed bug where user profile data was not being updated because comparison with initial data was not being made correctly. This means that, among other things, ORCID ids will now be added correctly when the user chooses "add self" on the upload form.
22+
623
## 0.3.2-beta5 (2024-12-11)
724

825
- Added Bluesky sharing option to detail page

site/kcworks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
"""KCWorks customizations to InvenioRDM."""
2020

21-
__version__ = "0.3.2-beta5"
21+
__version__ = "0.3.3-beta6"

site/kcworks/assets/semantic-ui/js/collections/communityRecordsSearch/CommunityRecordsSearchAppLayout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const CommunityRecordsSearchAppLayout = ({ config, appName }) => {
3434
aria-label={i18next.t("Filter results")}
3535
/>
3636
</Grid.Column>
37-
<Grid.Column mobile={10} tablet={8} computer={8}>
37+
<Grid.Column mobile={10} tablet={6} computer={4}>
3838
<Sort
3939
values={config.sortOptions}
4040
label={(cmp) => (
@@ -45,7 +45,7 @@ export const CommunityRecordsSearchAppLayout = ({ config, appName }) => {
4545
)}
4646
/>
4747
</Grid.Column>
48-
<Grid.Column width={4} tablet={7} computer={4} mobile={4} textAlign="right">
48+
<Grid.Column width={4} tablet={7} computer={8} mobile={6} textAlign="right">
4949
<Count
5050
label={(cmp) => (
5151
<Trans key="communityRecordsSearch" count={cmp}>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function getFullName(nameParts) {
2+
let fullName = [
3+
getGivenName(nameParts),
4+
nameParts?.family_prefix,
5+
getFamilyName(nameParts),
6+
]
7+
.filter(Boolean)
8+
.join(" ");
9+
if (nameParts?.suffix) {
10+
fullName += ", " + nameParts?.suffix;
11+
}
12+
return fullName;
13+
}
14+
15+
function getFullNameInverted(nameParts) {
16+
const beforeComma = [
17+
getFamilyName(nameParts),
18+
]
19+
const afterComma = [
20+
getGivenName(nameParts),
21+
nameParts?.family_prefix,
22+
]
23+
.filter(Boolean)
24+
.join(" ");
25+
let fullNameInverted = `${beforeComma}, ${afterComma}`;
26+
if (nameParts?.suffix) {
27+
fullNameInverted += ", " + nameParts?.suffix;
28+
}
29+
return fullNameInverted;
30+
}
31+
32+
function getFamilyName(nameParts) {
33+
return [
34+
nameParts?.family_prefix_fixed,
35+
nameParts?.parental,
36+
nameParts?.spousal,
37+
nameParts?.family,
38+
nameParts?.last,
39+
]
40+
.filter(Boolean)
41+
.join(" ");
42+
}
43+
44+
function getGivenName(nameParts) {
45+
return [
46+
nameParts?.given,
47+
nameParts?.first,
48+
nameParts?.middle,
49+
nameParts?.nickname,
50+
]
51+
.filter(Boolean)
52+
.join(" ");
53+
}
54+
55+
export { getFullName, getFullNameInverted, getFamilyName, getGivenName };

0 commit comments

Comments
 (0)