File tree Expand file tree Collapse file tree 6 files changed +378
-20
lines changed
CollectionAssociationForm
ManageCollectionAssociation
pages/CollectionAssociationFormPage Expand file tree Collapse file tree 6 files changed +378
-20
lines changed Original file line number Diff line number Diff line change @@ -306,18 +306,18 @@ const CollectionAssociationForm = ({ metadata }) => {
306306 // Creates an action cell based on the current concept type
307307 const buildActionsCell = useCallback ( ( cellData , rowData ) => {
308308 let disabled = false
309- let checked = null
309+ let checked = false
310310
311311 const { conceptId : collectionConceptId } = rowData
312- const { associationDetails } = fetchedDraft
313- const { collections } = associationDetails || { }
312+ const { collections = { } } = fetchedDraft
313+ const { items } = collections
314314
315315 // Checks if collection is already associated to the record.
316- if ( collections ) {
317- const associatedCollection = collections . filter (
316+ if ( items ) {
317+ const associatedCollection = items . find (
318318 ( item ) => item . conceptId === collectionConceptId
319319 )
320- if ( associatedCollection [ 0 ] ?. conceptId === collectionConceptId ) {
320+ if ( associatedCollection ) {
321321 disabled = true
322322 checked = true
323323 }
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ export const mockTool = {
165165 version : '1.2.0'
166166 } ,
167167 name : 'Collection Association Mock Test' ,
168+ pageTitle : 'Collection Association Mock Test' ,
168169 organizations : [
169170 {
170171 roles : [
@@ -180,6 +181,15 @@ export const mockTool = {
180181 quality : null ,
181182 revisionId : '1' ,
182183 revisionDate : '2024-03-21T15:01:58.533Z' ,
184+ revisions : {
185+ count : 1 ,
186+ items : {
187+ conceptId : 'T1200000098-MMT_2' ,
188+ revisionDate : '2024-03-21T15:01:58.533Z' ,
189+ revisionId : '1' ,
190+ userId : 'user1'
191+ }
192+ } ,
183193 relatedUrls : null ,
184194 searchAction : null ,
185195 supportedBrowsers : null ,
Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ const ManageCollectionAssociation = () => {
217217 } )
218218
219219 // Handle refresh, calls getMetadata to get the list of association
220- // TODO: See if we can get rid of this refresh button.
220+ // TODO: MMT-4089 See if we can get rid of this refresh button.
221221 const handleRefreshPage = ( ) => {
222222 refetch ( )
223223 }
Original file line number Diff line number Diff line change 11import { gql } from '@apollo/client'
22
33export const GET_CITATION = gql `
4- query GetCitation ($params: CitationInput) {
4+ query GetCitation ($params: CitationInput, $collectionsParams: CollectionsInput ) {
55 citation (params: $params) {
66 abstract
77 citationMetadata
8+ collections (params: $collectionsParams) {
9+ count
10+ items {
11+ conceptId
12+ provider
13+ shortName
14+ title
15+ version
16+ }
17+ }
818 conceptId
919 identifier
1020 identifierType
21+ name,
1122 pageTitle: name
1223 nativeId
1324 providerId
Original file line number Diff line number Diff line change @@ -82,17 +82,33 @@ const CollectionAssociationFormPageHeader = () => {
8282 * <CollectionAssociationFormPage />
8383 * )
8484 */
85- const CollectionAssociationFormPage = ( ) => (
86- < Page
87- pageType = "secondary"
88- header = { < CollectionAssociationFormPageHeader /> }
89- >
90- < ErrorBoundary >
91- < Suspense fallback = "Loading..." >
92- < CollectionAssociationForm />
93- </ Suspense >
94- </ ErrorBoundary >
95- </ Page >
96- )
85+ const CollectionAssociationFormPage = ( ) => {
86+ const { conceptId } = useParams ( )
87+
88+ const derivedConceptType = getConceptTypeByConceptId ( conceptId )
89+
90+ const { data } = useSuspenseQuery ( conceptTypeQueries [ derivedConceptType ] , {
91+ variables : {
92+ params : {
93+ conceptId
94+ }
95+ }
96+ } )
97+
98+ const { [ camelCase ( derivedConceptType ) ] : concept } = data
99+
100+ return (
101+ < Page
102+ pageType = "secondary"
103+ header = { < CollectionAssociationFormPageHeader /> }
104+ >
105+ < ErrorBoundary >
106+ < Suspense fallback = "Loading..." >
107+ < CollectionAssociationForm metadata = { concept } />
108+ </ Suspense >
109+ </ ErrorBoundary >
110+ </ Page >
111+ )
112+ }
97113
98114export default CollectionAssociationFormPage
You can’t perform that action at this time.
0 commit comments