Revize fb120216
Přidáno uživatelem Fantič před více než 1 rok
src/components/item/ItemView.tsx | ||
---|---|---|
1 | 1 |
import { Center, Box, VStack, Button, HStack, Text, Image, ScrollView, View, Spacer, Card, Heading, Switch, Flex, ChevronLeftIcon, ChevronRightIcon, Divider, Pressable } from "native-base" |
2 | 2 |
import React, { useCallback, useEffect, useState } from "react" |
3 |
import { Item } from "../../types/item"
|
|
3 |
import { Certainty, Item, RelationshipType } from "../../types/item"
|
|
4 | 4 |
import { Note } from "../../types/note" |
5 | 5 |
import LoadingBox from "../loading/LoadingBox" |
6 | 6 |
import NotesListView from "../notes/NotesListView" |
... | ... | |
15 | 15 |
import { DrawerNavigationProp } from "@react-navigation/drawer" |
16 | 16 |
import { RootStackParamList } from "../../pages/Navigation" |
17 | 17 |
import { select } from "d3" |
18 |
import { CertaintyWithColors } from "../../stores/reducers/itemSlice" |
|
18 | 19 |
|
19 | 20 |
interface ItemDetailProps { |
20 | 21 |
item: Item, |
... | ... | |
86 | 87 |
{item.fullView && item.images && item.images.length > 0 && ( |
87 | 88 |
<VStack marginTop={5} alignItems="center" justifyContent="center" backgroundColor="#F5F4F1" borderRadius={10} borderColor="#F5F4F1" padding={2}> |
88 | 89 |
|
89 |
<Box marginTop={2.5} borderWidth={1} width={Dimensions.get('window').width - 110} alignItems="center" backgroundColor="red" borderTopRadius={10} > |
|
90 |
<Text marginBottom={2}>{"Resembling objects"} |
|
91 |
{selectedImage + 1 + "/" + item.images.length + item.images[selectedImage].cert + item.images[selectedImage].relationship_type} |
|
90 |
<Box style={{ backgroundColor: item.images[selectedImage].relationship_type != RelationshipType.IdentifiedArtwork ? "#B3B3B3" : CertaintyWithColors[item.images[selectedImage].cert ?? Certainty.Unknown].color }} |
|
91 |
marginTop={2.5} width={Dimensions.get('window').width - 110} alignItems="center" borderTopRadius={10} > |
|
92 |
<Text marginBottom={2}> |
|
93 |
|
|
94 |
{item.images[selectedImage].relationship_type == RelationshipType.Resembling && "Resembling object"} |
|
95 |
{item.images[selectedImage].relationship_type == RelationshipType.IdentifiedArtwork && "Identified artwork"} |
|
96 |
{item.images[selectedImage].relationship_type == RelationshipType.Related && "Related item"} |
|
97 |
|
|
98 |
{item.images[selectedImage].relationship_type == RelationshipType.IdentifiedArtwork && item.images[selectedImage].cert && item.images[selectedImage].cert != Certainty.Unknown && ` - ${item.images?.[selectedImage].cert}`} |
|
92 | 99 |
</Text> |
93 | 100 |
</Box> |
94 | 101 |
|
... | ... | |
126 | 133 |
<HStack> |
127 | 134 |
<Text marginTop={2.5}> |
128 | 135 |
<Text color="#654B07" italic fontWeight={"semibold"}>Author name: </Text> |
129 |
{item.authorName}
|
|
136 |
{item.images?.[selectedImage]?.author}
|
|
130 | 137 |
</Text> |
131 | 138 |
</HStack>} |
132 | 139 |
{item.title && |
133 | 140 |
<HStack> |
134 | 141 |
<Text marginTop={2.5}> |
135 | 142 |
<Text color="#654B07" italic fontWeight={"semibold"}>Title: </Text> |
136 |
{item.title} |
|
143 |
{item.images?.[selectedImage].title}
|
|
137 | 144 |
</Text> |
138 | 145 |
</HStack>} |
139 | 146 |
{item.institution && |
140 | 147 |
<HStack> |
141 | 148 |
<Text marginTop={2.5}> |
142 | 149 |
<Text color="#654B07" italic fontWeight={"semibold"}>Institution: </Text> |
143 |
{item.institution.name}, Inv. No. {item.institution.inventoryNumber}, {item.institution.city} {"(" + item.institution.country + ")"} |
|
150 |
{item.images?.[selectedImage].institution.name && `${item.images?.[selectedImage].institution.name}`} |
|
151 |
{item.images?.[selectedImage].institution.inventoryNumber && `, Inv. No. ${item.images?.[selectedImage].institution.inventoryNumber}`} |
|
152 |
{item.images?.[selectedImage].institution.city && `, ${item.images?.[selectedImage].institution.city}`} |
|
153 |
{item.images?.[selectedImage].institution.country && ` (${item.images?.[selectedImage].institution.country})`} |
|
144 | 154 |
</Text> |
145 | 155 |
</HStack>} |
146 | 156 |
{item.repository && |
147 | 157 |
<HStack> |
148 | 158 |
<Text marginTop={2.5}> |
149 | 159 |
<Text color="#654B07" italic fontWeight={"semibold"}>Repository: </Text> |
150 |
{item.repository} |
|
160 |
{item.images?.[selectedImage].repository}
|
|
151 | 161 |
</Text> |
152 | 162 |
</HStack>} |
153 |
{item.provenance && |
|
163 |
{item.images?.[selectedImage].provenance &&
|
|
154 | 164 |
<HStack> |
155 | 165 |
<Text marginTop={2.5}> |
156 | 166 |
<Text color="#654B07" italic fontWeight={"semibold"}>Provenance: </Text> |
157 |
{item.provenance} |
|
167 |
{item.images?.[selectedImage].provenance}
|
|
158 | 168 |
</Text> |
159 | 169 |
</HStack>} |
160 |
{item.description && |
|
170 |
{item.images?.[selectedImage].description &&
|
|
161 | 171 |
<HStack> |
162 | 172 |
<Text marginTop={2.5}> |
163 | 173 |
<Text color="#654B07" italic fontWeight={"semibold"}>Description: </Text> |
164 |
{item.description} |
|
174 |
{item.images?.[selectedImage].description}
|
|
165 | 175 |
</Text> |
166 | 176 |
</HStack>} |
167 | 177 |
</View>)} |
src/components/plan/CastlePlanView.tsx | ||
---|---|---|
292 | 292 |
> |
293 | 293 |
{/* control panel */} |
294 | 294 |
<Flex direction="row" alignItems="center" justify="flex-end" style={{ height: 50, width: 100, top: fullScreenMode ? 10 : 0, right: fullScreenMode ? 20 : 15, position: "absolute", zIndex: 5 }}> |
295 |
<Pressable padding={1.5} backgroundColor={"primary"} borderRadius={5} marginRight={selectedRoom ? 1 : -2} onPress={handleFullScreenPressed}>
|
|
295 |
<Pressable padding={1.5} backgroundColor={"#654B07"} borderRadius={5} marginRight={selectedRoom ? 1 : -2} onPress={handleFullScreenPressed}>
|
|
296 | 296 |
<FullscreenIcon color="white" /> |
297 | 297 |
</Pressable> |
298 | 298 |
{ |
299 | 299 |
selectedRoom && |
300 |
<Pressable padding={1.5} backgroundColor={"primary"} borderRadius={5} marginRight={-2} onPress={() => { zoomToRoom(selectedRoom) }}>
|
|
300 |
<Pressable padding={1.5} backgroundColor={"#654B07"} borderRadius={5} marginRight={-2} onPress={() => { zoomToRoom(selectedRoom) }}>
|
|
301 | 301 |
<ExitfullscreenIcon color="white" /> |
302 | 302 |
</Pressable> |
303 | 303 |
} |
src/pages/PlanViewPage.tsx | ||
---|---|---|
278 | 278 |
} |
279 | 279 |
|
280 | 280 |
}} |
281 |
backgroundColor={"primary"}
|
|
281 |
backgroundColor={"#654B07"}
|
|
282 | 282 |
variant="subtle" |
283 | 283 |
borderRadius={10} |
284 | 284 |
size={"sm"} |
src/stores/actions/itemThunks.ts | ||
---|---|---|
1 | 1 |
import { createAsyncThunk } from "@reduxjs/toolkit" |
2 | 2 |
import { getItemRequest } from "../../api/itemservice" |
3 | 3 |
import { getItemNotesRequest } from "../../api/notesservice" |
4 |
import { Certainty, Concordance, Item } from "../../types/item"; |
|
4 |
import { Certainty, Concordance, Item, ItemObject } from "../../types/item";
|
|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
export const getItem = createAsyncThunk( |
... | ... | |
16 | 16 |
if (response.status === 200 && response.data.object.length > 1) { |
17 | 17 |
// TODO IMAGES to array :-) |
18 | 18 |
const authorName = response.data?.object[1]?.name?.[0]?.getty_data?.display_name ?? undefined; |
19 |
const images : {imageUrl: string, title: string, relationship_type: string, cert: Certainty}[] = []
|
|
19 |
const images : ItemObject[] = []
|
|
20 | 20 |
for(let i = 1; i < response.data.object.length; i++){ |
21 |
images.push({imageUrl: response.data.object[i]?.images?.[0]?.file ?? "", title: response.data.object[i]?.images?.[0]?.text ?? "", relationship_type: response.data.object[i].relationship_type ?? "", cert: response.data.object[i].cert ?? Certainty.Unknown }) |
|
21 |
images.push({ |
|
22 |
imageUrl: response.data.object[i]?.images?.[0]?.file ?? undefined, |
|
23 |
title: response.data.object[i]?.images?.[0]?.text ?? undefined, |
|
24 |
relationship_type: response.data.object[i].relationship_type ?? undefined, |
|
25 |
cert: response.data.object[i].cert ?? Certainty.Unknown , |
|
26 |
|
|
27 |
author: response.data?.object[i]?.name?.[0]?.getty_data?.display_name ?? undefined, |
|
28 |
description: response.data?.object[i]?.physical_description ?? undefined, |
|
29 |
institution: { |
|
30 |
name: response.data?.object[i]?.institution ?? undefined, |
|
31 |
inventoryNumber: response.data?.object[i]?.id_number ?? undefined, |
|
32 |
country: response.data?.object[i]?.country ?? undefined, |
|
33 |
city: response.data?.object[i]?.city ?? undefined |
|
34 |
}, |
|
35 |
provenance: response.data?.object[i]?.provenance ?? undefined, |
|
36 |
repository: response.data?.object[i]?.repository ?? undefined |
|
37 |
}) |
|
22 | 38 |
} |
23 | 39 |
|
24 | 40 |
const institution = { |
src/stores/reducers/itemSlice.ts | ||
---|---|---|
4 | 4 |
|
5 | 5 |
// TODO set colors |
6 | 6 |
export const CertaintyWithColors: Record<Certainty, { certainty: Certainty; color: string }> = { |
7 |
same_as: { certainty: Certainty.SameAs, color: "light.300" },
|
|
8 |
high: { certainty: Certainty.High, color: "success.300" },
|
|
9 |
medium: { certainty: Certainty.Medium, color: "warning.300" },
|
|
10 |
low: { certainty: Certainty.Low, color: "danger.300" },
|
|
11 |
unknown : { certainty: Certainty.Unknown, color: "light.300"}
|
|
7 |
same_as: { certainty: Certainty.SameAs, color: "white" },
|
|
8 |
high: { certainty: Certainty.High, color: "#aedfb5" },
|
|
9 |
medium: { certainty: Certainty.Medium, color: "#ffd8b3" },
|
|
10 |
low: { certainty: Certainty.Low, color: "#faa" },
|
|
11 |
unknown : { certainty: Certainty.Unknown, color: "white"}
|
|
12 | 12 |
}; |
13 | 13 |
|
14 | 14 |
const initialState: ItemViewState = { |
src/types/item.ts | ||
---|---|---|
1 | 1 |
import { Note } from "./note" |
2 | 2 |
|
3 | 3 |
|
4 |
export type Item = { |
|
4 |
export type ItemObject = { |
|
5 |
imageUrl: string, |
|
6 |
relationship_type: RelationshipType, |
|
7 |
cert: Certainty, |
|
8 |
|
|
9 |
author: string, |
|
10 |
title: string, |
|
11 |
institution: { |
|
12 |
name: string, |
|
13 |
inventoryNumber: number, |
|
14 |
country: string, |
|
15 |
city: string |
|
16 |
}, |
|
17 |
provenance: string, |
|
18 |
description: string, |
|
19 |
repository: string, |
|
20 |
} |
|
21 |
|
|
22 |
export type Item = { |
|
5 | 23 |
id?: string |
6 | 24 |
|
7 | 25 |
concordances?: Concordance[] |
... | ... | |
11 | 29 |
inventoryItem?: string |
12 | 30 |
searchSubjects?: string[] |
13 | 31 |
|
14 |
fullView : boolean
|
|
32 |
fullView: boolean |
|
15 | 33 |
|
16 | 34 |
authorName?: string |
17 |
images?: {imageUrl : string, title : string, relationship_type: string, cert: Certainty}[]
|
|
35 |
images?: ItemObject[]
|
|
18 | 36 |
title?: string |
19 |
institution?: {
|
|
20 |
name :string,
|
|
37 |
institution?: { |
|
38 |
name: string,
|
|
21 | 39 |
inventoryNumber: number, |
22 | 40 |
country: string, |
23 | 41 |
city: string |
... | ... | |
26 | 44 |
provenance?: string |
27 | 45 |
description?: string |
28 | 46 |
|
29 |
room?: {id: number, original_description: string}
|
|
47 |
room?: { id: number, original_description: string }
|
|
30 | 48 |
|
31 | 49 |
prevItem?: string | boolean |
32 | 50 |
nextItem?: string | boolean |
33 | 51 |
} |
34 | 52 |
|
53 |
// TODO |
|
54 |
export enum RelationshipType { |
|
55 |
Resembling = "resembling", |
|
56 |
IdentifiedArtwork = "identification", |
|
57 |
Related = "related" |
|
58 |
} |
|
59 |
|
|
60 |
|
|
35 | 61 |
export type ItemViewState = { |
36 | 62 |
item: Item |
37 | 63 |
itemLoading: boolean |
Také k dispozici: Unified diff
re #10895: ItemView: ItemObjects switching, display color