Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,18 @@ const CollectionAssociationForm = ({ metadata }) => {
// Creates an action cell based on the current concept type
const buildActionsCell = useCallback((cellData, rowData) => {
let disabled = false
let checked = null
let checked = false

const { conceptId: collectionConceptId } = rowData
const { associationDetails } = fetchedDraft
const { collections } = associationDetails || {}
const { collections = {} } = fetchedDraft
const { items } = collections

// Checks if collection is already associated to the record.
if (collections) {
const associatedCollection = collections.filter(
if (items) {
const associatedCollection = items.find(
(item) => item.conceptId === collectionConceptId
)
if (associatedCollection[0]?.conceptId === collectionConceptId) {
if (associatedCollection) {
disabled = true
checked = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const mockTool = {
version: '1.2.0'
},
name: 'Collection Association Mock Test',
pageTitle: 'Collection Association Mock Test',
organizations: [
{
roles: [
Expand All @@ -180,6 +181,15 @@ export const mockTool = {
quality: null,
revisionId: '1',
revisionDate: '2024-03-21T15:01:58.533Z',
revisions: {
count: 1,
items: {
conceptId: 'T1200000098-MMT_2',
revisionDate: '2024-03-21T15:01:58.533Z',
revisionId: '1',
userId: 'user1'
}
},
relatedUrls: null,
searchAction: null,
supportedBrowsers: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const ManageCollectionAssociation = () => {
})

// Handle refresh, calls getMetadata to get the list of association
// TODO: See if we can get rid of this refresh button.
// TODO: MMT-4089 See if we can get rid of this refresh button.
const handleRefreshPage = () => {
refetch()
}
Expand Down
13 changes: 12 additions & 1 deletion static/src/js/operations/queries/getCitation.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { gql } from '@apollo/client'

export const GET_CITATION = gql`
query GetCitation ($params: CitationInput) {
query GetCitation ($params: CitationInput, $collectionsParams: CollectionsInput) {
citation (params: $params) {
abstract
citationMetadata
collections (params: $collectionsParams) {
count
items {
conceptId
provider
shortName
title
version
}
}
conceptId
identifier
identifierType
name,
pageTitle: name
nativeId
providerId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,33 @@ const CollectionAssociationFormPageHeader = () => {
* <CollectionAssociationFormPage />
* )
*/
const CollectionAssociationFormPage = () => (
<Page
pageType="secondary"
header={<CollectionAssociationFormPageHeader />}
>
<ErrorBoundary>
<Suspense fallback="Loading...">
<CollectionAssociationForm />
</Suspense>
</ErrorBoundary>
</Page>
)
const CollectionAssociationFormPage = () => {
const { conceptId } = useParams()

const derivedConceptType = getConceptTypeByConceptId(conceptId)

const { data } = useSuspenseQuery(conceptTypeQueries[derivedConceptType], {
variables: {
params: {
conceptId
}
}
})

const { [camelCase(derivedConceptType)]: concept } = data

return (
<Page
pageType="secondary"
header={<CollectionAssociationFormPageHeader />}
>
<ErrorBoundary>
<Suspense fallback="Loading...">
<CollectionAssociationForm metadata={concept} />
</Suspense>
</ErrorBoundary>
</Page>
)
}

export default CollectionAssociationFormPage
Loading