diff --git a/src/common/defaultConfigs.js b/src/common/defaultConfigs.js
new file mode 100644
index 00000000..8cb31e50
--- /dev/null
+++ b/src/common/defaultConfigs.js
@@ -0,0 +1,394 @@
+export const CONCEPT_MAP_DEFAULT_CONFIG = {
+ name: "FHIR Default (ConceptMap)",
+ web_default: true,
+ is_default: false,
+ config: {
+ tabs: [
+ {
+ type: "codes",
+ label: "Codes",
+ page_size: 25,
+ default: true,
+ layout: "table",
+ },
+ { type: "versions", label: "Versions", page_size: 25, layout: "table" },
+ { type: "about", label: "About" },
+ ],
+ },
+};
+
+export const CODE_SYSTEM_DEFAULT_CONFIG = {
+ name: "FHIR Default (CodeSystem)",
+ web_default: true,
+ is_default: false,
+ config: {
+ tabs: [
+ {
+ type: "codes",
+ label: "Codes",
+ page_size: 25,
+ default: true,
+ layout: "table",
+ },
+ { type: "versions", label: "Versions", page_size: 25, layout: "table" },
+ { type: "about", label: "About" },
+ ],
+ },
+};
+
+export const VALUE_SET_DEFAULT_CONFIG = {
+ name: "FHIR Default (ValueSet)",
+ web_default: true,
+ is_default: false,
+ config: {
+ tabs: [
+ {
+ type: "codes",
+ label: "Codes",
+ page_size: 25,
+ default: true,
+ layout: "table",
+ },
+ { type: "versions", label: "Versions", page_size: 25, layout: "table" },
+ { type: "about", label: "About" },
+ ],
+ },
+};
+
+export const FHIR_DEFAULT_CONFIG = {
+ name: "FHIR Default",
+ web_default: true,
+ is_default: false,
+ config: {
+ tabs: [
+ { type: "CodeSystem", label: "Code Systems", default: true },
+ { type: "ValueSet", label: "Value Sets" },
+ { type: "ConceptMap", label: "Concept Maps" },
+ ],
+ },
+};
+
+const ORG_BACKGROUND_CONFIG = {
+ background: {
+ image: "",
+ backgroundColor: "",
+ },
+ forground: {
+ color: "",
+ titleColor: "",
+ descriptionColor: "",
+ title: "",
+ description: "",
+ },
+};
+
+export const ORG_DEFAULT_CONFIG = {
+ name: "OCL Default (Org)",
+ web_default: true,
+ is_default: false,
+ config: {
+ header: {
+ ...ORG_BACKGROUND_CONFIG,
+ attributes: [
+ {
+ label: "Company",
+ value: "company",
+ type: "text",
+ },
+ {
+ label: "Location",
+ value: "location",
+ type: "text",
+ },
+ {
+ label: "Website",
+ value: "website",
+ type: "url",
+ },
+ ],
+ height: null,
+ controls: true,
+ signatures: true,
+ logo: true,
+ shrink: false,
+ },
+ tabs: [
+ {
+ type: "sources",
+ label: "Sources",
+ page_size: 25,
+ default: true,
+ layout: "table",
+ color: "",
+ },
+ {
+ type: "collections",
+ label: "Collections",
+ page_size: 25,
+ layout: "table",
+ color: "",
+ },
+ {
+ type: "users",
+ label: "Members",
+ page_size: 25,
+ layout: "table",
+ color: "",
+ },
+ { type: "about", label: "About", color: "" },
+ ],
+ },
+};
+
+export const SOURCE_DEFAULT_CONFIG = {
+ name: "OCL Default (Source)",
+ web_default: true,
+ is_default: false,
+ config: {
+ header: {
+ shrink: false,
+ visibleAttributes: [
+ {
+ label: "Source Type",
+ value: "source_type",
+ type: "text",
+ },
+ {
+ label: "Supported Locales",
+ value: "supported_locales",
+ },
+ {
+ label: "Custom Validation Schema",
+ value: "custom_validation_schema",
+ type: "text",
+ },
+ ],
+ invisibleAttributes: [
+ {
+ label: "Canonical Url",
+ value: "canonical_url",
+ type: "url",
+ },
+ {
+ label: "Publisher",
+ value: "publisher",
+ type: "text",
+ },
+ {
+ label: "Purpose",
+ value: "purpose",
+ type: "text",
+ },
+ {
+ label: "Copyright",
+ value: "copyright",
+ type: "text",
+ },
+ {
+ label: "Content Type",
+ value: "content_type",
+ type: "text",
+ },
+ {
+ label: "Revision Date",
+ value: "revision_date",
+ type: "date",
+ },
+ {
+ label: "Revision Date",
+ value: "revision_date",
+ type: "date",
+ },
+ {
+ label: "Identifier",
+ value: "identifier",
+ type: "json",
+ },
+ {
+ label: "Contact",
+ value: "contact",
+ type: "json",
+ },
+ {
+ label: "Jurisdiction",
+ value: "jurisdiction",
+ type: "json",
+ },
+ {
+ label: "Meta",
+ value: "meta",
+ type: "json",
+ },
+ {
+ label: "Collection Reference",
+ value: "collection_reference",
+ type: "text",
+ },
+ {
+ label: "Hierarchy Meaning",
+ value: "hierarchy_meaning",
+ type: "text",
+ },
+ {
+ label: "Experimental",
+ value: "experimental",
+ type: "boolean",
+ },
+ {
+ label: "Case Sensitive",
+ value: "case_sensitive",
+ type: "boolean",
+ },
+ {
+ label: "Compositional",
+ value: "compositional",
+ type: "boolean",
+ },
+ {
+ label: "Version Needed",
+ value: "version_needed",
+ type: "boolean",
+ },
+ ],
+ },
+ tabs: [
+ {
+ type: "concepts",
+ label: "Concepts",
+ page_size: 25,
+ default: true,
+ layout: "table",
+ },
+ { type: "mappings", label: "Mappings", page_size: 25, layout: "table" },
+ { type: "versions", label: "Versions", page_size: 25, layout: "table" },
+ { type: "about", label: "About" },
+ ],
+ },
+};
+
+export const COLLECTION_DEFAULT_CONFIG = {
+ name: "OCL Default (Collection)",
+ web_default: true,
+ is_default: false,
+ config: {
+ header: {
+ shrink: false,
+ visibleAttributes: [
+ {
+ label: "Short Code",
+ value: "short_code",
+ type: "text",
+ },
+ {
+ label: "Name",
+ value: "name",
+ type: "text",
+ },
+ {
+ label: "Collection Type",
+ value: "collection_type",
+ type: "text",
+ },
+ {
+ label: "Custom Validation Schema",
+ value: "custom_validation_schema",
+ type: "text",
+ },
+ {
+ label: "Supported Locales",
+ value: "supported_locales",
+ },
+ ],
+ invisibleAttributes: [
+ {
+ label: "Canonical Url",
+ value: "canonical_url",
+ type: "url",
+ },
+ {
+ label: "Publisher",
+ value: "publisher",
+ type: "text",
+ },
+ {
+ label: "Purpose",
+ value: "purpose",
+ type: "text",
+ },
+ {
+ label: "Copyright",
+ value: "copyright",
+ type: "text",
+ },
+ {
+ label: "Preferred Source",
+ value: "preferred_source",
+ type: "text",
+ },
+ {
+ label: "Custom Resources Linked Source",
+ value: "custom_resources_linked_source",
+ type: "text",
+ },
+ {
+ label: "Revision Date",
+ value: "revision_date",
+ type: "date",
+ },
+ {
+ label: "Identifier",
+ value: "identifier",
+ type: "json",
+ },
+ {
+ label: "Contact",
+ value: "contact",
+ type: "json",
+ },
+ {
+ label: "Jurisdiction",
+ value: "jurisdiction",
+ type: "json",
+ },
+ {
+ label: "Meta",
+ value: "meta",
+ type: "json",
+ },
+ {
+ label: "Immutable",
+ value: "immutable",
+ type: "boolean",
+ },
+ {
+ label: "Locked Date",
+ value: "locked_date",
+ type: "date",
+ },
+ {
+ label: "Experimental",
+ value: "experimental",
+ type: "boolean",
+ },
+ ],
+ },
+ tabs: [
+ {
+ type: "concepts",
+ label: "Concepts",
+ page_size: 25,
+ default: true,
+ layout: "table",
+ },
+ { type: "mappings", label: "Mappings", page_size: 25, layout: "table" },
+ {
+ type: "references",
+ label: "References",
+ page_size: 25,
+ layout: "table",
+ },
+ { type: "versions", label: "Versions", page_size: 25, layout: "table" },
+ { type: "about", label: "About" },
+ ],
+ },
+};
diff --git a/src/components/collections/CollectionHome.jsx b/src/components/collections/CollectionHome.jsx
index 1c71eb81..5b13f440 100644
--- a/src/components/collections/CollectionHome.jsx
+++ b/src/components/collections/CollectionHome.jsx
@@ -7,22 +7,10 @@ import CollectionHomeTabs from './CollectionHomeTabs';
import NotFound from '../common/NotFound';
import AccessDenied from '../common/AccessDenied';
import PermissionDenied from '../common/PermissionDenied';
+import { COLLECTION_DEFAULT_CONFIG } from "../../common/defaultConfigs"
const TABS = ['details', 'concepts', 'mappings', 'references', 'versions', 'about']
-const DEFAULT_CONFIG = {
- name: 'OCL Default (Collection)',
- web_default: true,
- is_default: false,
- config: {
- tabs: [
- {type: "concepts", label: "Concepts", page_size: 25, "default": true, layout: 'table'},
- {type: "mappings", label: "Mappings", page_size: 25, layout: 'table'},
- {type: "references", label: "References", page_size: 25, layout: 'table'},
- {type: "versions", label: "Versions", page_size: 25, layout: 'table'},
- {type: "about", label: "About"},
- ]
- }
-}
+
class CollectionHome extends React.Component {
constructor(props) {
@@ -147,7 +135,7 @@ class CollectionHome extends React.Component {
this.setState({
isLoading: false,
collection: collection,
- selectedConfig: defaultCustomConfig || DEFAULT_CONFIG,
+ selectedConfig: defaultCustomConfig || COLLECTION_DEFAULT_CONFIG,
customConfigs: customConfigs,
}, () => {
if(isEmpty(this.state.versions))
@@ -226,11 +214,11 @@ class CollectionHome extends React.Component {
currentVersion={this.getCurrentVersion()}
aboutTab={showAboutTab}
onVersionUpdate={this.onVersionUpdate}
- customConfigs={[...customConfigs, DEFAULT_CONFIG]}
+ customConfigs={[...customConfigs, COLLECTION_DEFAULT_CONFIG]}
onConfigChange={this.onConfigChange}
selectedConfig={selectedConfig}
showConfigSelection={this.customConfigFeatureApplicable()}
- isOCLDefaultConfigSelected={isEqual(selectedConfig, DEFAULT_CONFIG)}
+ isOCLDefaultConfigSelected={isEqual(selectedConfig, COLLECTION_DEFAULT_CONFIG)}
isLoadingVersions={isLoadingVersions}
/>
diff --git a/src/components/collections/CollectionHomeHeader.jsx b/src/components/collections/CollectionHomeHeader.jsx
index 170618da..3a9fbaac 100644
--- a/src/components/collections/CollectionHomeHeader.jsx
+++ b/src/components/collections/CollectionHomeHeader.jsx
@@ -7,7 +7,7 @@ import {
Delete as DeleteIcon,
} from '@material-ui/icons';
import { Tooltip, Button, ButtonGroup, Collapse } from '@material-ui/core';
-import { keys, map, startCase, get } from 'lodash';
+import { filter, map, get } from 'lodash';
import { toFullAPIURL, copyURL, nonEmptyCount, currentUserHasAccess } from '../../common/utils';
import { GREEN } from '../../common/constants';
import APIService from '../../services/APIService';
@@ -31,34 +31,21 @@ import RetiredChip from '../common/RetiredChip';
import ProcessingChip from '../common/ProcessingChip';
import ConceptContainerDelete from '../common/ConceptContainerDelete';
import CollapsibleDivider from '../common/CollapsibleDivider';
+import { COLLECTION_DEFAULT_CONFIG } from '../../common/defaultConfigs';
+
+const DEFAULT_VISIBLE_ATTRIBUTES = COLLECTION_DEFAULT_CONFIG.config.header.visibleAttributes
+const DEFAULT_INVISIBLE_ATTRIBUTES = COLLECTION_DEFAULT_CONFIG.config.header.invisibleAttributes
-const HIDDEN_ATTRIBUTES = {
- canonical_url: 'url',
- publisher: 'text',
- purpose: 'text',
- copyright: 'text',
- preferred_source: 'text',
- custom_resources_linked_source: 'text',
- revision_date: 'date',
- identifier: 'json',
- contact: 'json',
- jurisdiction: 'json',
- meta: 'json',
- immutable: 'boolean',
- locked_date: 'date',
- experimental: 'boolean'
-}
const CollectionHomeHeader = ({
collection, isVersionedObject, versionedObjectURL, currentURL, config
}) => {
const downloadFileName = isVersionedObject ? `${collection.type}-${collection.short_code}` : `${collection.type}-${collection.short_code}-${collection.id}`;
const hasAccess = currentUserHasAccess();
- const [openHeader, setOpenHeader] = React.useState(!get(config, 'config.shrinkHeader', false));
+ const [openHeader, setOpenHeader] = React.useState(!get(config, 'config.header.shrink', false));
const [deleteDialog, setDeleteDialog] = React.useState(false);
const [logoURL, setLogoURL] = React.useState(collection.logo_url)
const [collectionForm, setCollectionForm] = React.useState(false);
const onIconClick = () => copyURL(toFullAPIURL(currentURL))
- const hasManyHiddenAttributes = nonEmptyCount(collection, keys(HIDDEN_ATTRIBUTES)) >= 4;
const onLogoUpload = (base64, name) => {
APIService.new().overrideURL(versionedObjectURL).appendToUrl('logo/')
.post({base64: base64, name: name})
@@ -67,10 +54,36 @@ const CollectionHomeHeader = ({
setLogoURL(get(response, 'data.logo_url', logoURL))
})
}
+ const getDefaultHiddenAttributes = () => {
+ return filter(DEFAULT_VISIBLE_ATTRIBUTES, (attr) => {
+ return !map(get(config, 'config.header.visibleAttributes'),(attr) => attr.value).includes(attr.value)
+ }
+ )
+ }
+ const getHiddenAttributes = () => {
+ if (get(config, 'config.header.invisibleAttributes') === 'object'){
+ return {...get(config, 'config.header.invisibleAttributes'), ...getDefaultHiddenAttributes()}
+ }
+ else if (get(config, 'config.header.invisibleAttributes')) {
+ return { DEFAULT_INVISIBLE_ATTRIBUTES, ...getDefaultHiddenAttributes() }
+ }
+ else return []
+ }
+ const getVisibleAttributes = ()=>{
+ if (get(config, 'config.header.visibleAttributes') === 'object'){
+ return get(config, 'config.header.visibleAttributes')
+ }
+ else if (get(config, 'config.header.visibleAttributes')) {
+ return DEFAULT_VISIBLE_ATTRIBUTES
+ }
+ else return []
+ }
+ const hasManyHiddenAttributes = nonEmptyCount(collection, map(getHiddenAttributes(),(attr) => attr.value)) >= 4;
+
React.useEffect(
- () => setOpenHeader(!get(config, 'config.shrinkHeader', false)),
- [get(config, 'config.shrinkHeader')]
+ () => setOpenHeader(!get(config, 'config.header.shrink', false)),
+ [get(config, 'config.header.shrink')]
)
const deleteCollection = () => {
@@ -163,28 +176,25 @@ const CollectionHomeHeader = ({
{collection.description}
}
-