Skip to content

Commit

Permalink
refactor: refine 'Config' interface in Typescript to adhere to 'custo…
Browse files Browse the repository at this point in the history
…m' config
  • Loading branch information
malkja committed May 30, 2024
1 parent e53b292 commit 013c634
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/components/header/PanelsToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const { t } = useI18n();
const toggles = ref([]);
const showDropdown = ref(false);
const panels = computed(() => configStore.config.panels ); //store.getters['config/config'].panels);
const panels = computed(() => configStore.config.panels );
const resetColor = computed(() => (toggles.value.filter(({ show }) => !show).length > 0 ? 'primary' : 'grey-7'));
watch(
Expand Down
118 changes: 82 additions & 36 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ declare global {
id: string
}

interface AnnotationViewMotifs extends View {
connector: {
id: number,
options: AnnotationViewOptions
}
}

interface AnnotationViewOptions {
types: AnnotationsOptionsTypes[]
}

interface AnnotationsOptionsTypes {
name: string,
index: string
}

interface AnnotationViewEditorial extends AnnotationViewMotifs {
default: true
}

type AnnotationViews = [AnnotationViewEditorial, AnnotationViewMotifs]

interface ActiveAnnotation {
[key: string]: Annotation
}
Expand Down Expand Up @@ -57,37 +79,12 @@ declare global {
accent: string
}

interface ConnectorViewPanel {
id: number,
options?: Option_1_ConnectorViewPanel | Option_2_ConnectorViewPanel | Option_3_ConnectorViewPanel
}

type Option_1_ConnectorViewPanel = {
collection: {
all: boolean,
},
manifest: {
all: boolean,
},
item: {
all: boolean,
},
}

type Option_2_ConnectorViewPanel = {
labels: Labels
}

type Option_3_ConnectorViewPanel = {
types: Array
}

interface Config {
container: string,
collection: string,
manifest: string,
item: string,
panels: Panel[],
panels: TidoPanels,
colors: Colors,
header: Header,
labels: Labels,
Expand All @@ -103,6 +100,20 @@ declare global {
integrity?: DataIntegrity
}

interface ContentView extends View {
connector: {
id: number,
options: {
"labels": Labels
}
}
}

type ContentsAndMetadataViews = [
ContentView,
MetadataView
]


type CssSelector = {
type: 'CssSelector',
Expand Down Expand Up @@ -135,6 +146,13 @@ declare global {
license: License
}

interface ImageView extends View {
connector: {
id: number
}
}


interface Item {
'@context': string,
textapi: string,
Expand Down Expand Up @@ -188,7 +206,13 @@ declare global {
metadata?: Metadata[]
}

interface MetaConfig {
interface MetadataView extends View {
connector: {
id: number,
options: MetadataViewConfigOptions
}
}
interface MetadataViewConfigOptions {
collection: {
all: boolean
},
Expand All @@ -210,12 +234,6 @@ declare global {
warning: string
}

interface Panel {
label: string,
toggle: boolean,
show: boolean,
views: ViewPanel[]
}

type RangeSelector = {
type: 'RangeSelector',
Expand Down Expand Up @@ -248,20 +266,48 @@ declare global {
type SequenceType = 'collection' | 'manifest' | 'item'
type SupportType = 'font' | 'css'


interface TextView extends View {
connector: TextViewConfigConnector
}

interface TextViewConfigConnector {
id: number,
options: {
type: string
}
}

type TidoPanels = [ {
label: string,
views: ContentsAndMetadataViews
},
{
label: string,
views: ImageView[]
},
{
label: string,
views: TextView[]
},
{
label: string,
views: AnnotationsViews
}
]

interface Title {
'@context': string,
title: string
type: TitleType
}
type TitleType = 'main' | 'sub';

interface ViewPanel {
interface View {
id: string,
label: string,
connector: ConnectorViewPanel,
default?: boolean
}

}

export {}

0 comments on commit 013c634

Please sign in to comment.