1
1
import { CardDetail } from "@interfaces/card.ts" ;
2
- import { ImasparqlResponse } from "@interfaces/imasparql.ts" ;
2
+ import { Binding , ImasparqlResponse } from "@interfaces/imasparql.ts" ;
3
3
4
4
/**
5
- * クラス名をラベルに変換
6
- * @param c クラス名
5
+ * ラベルを取得
6
+ * @param b データ
7
7
* @returns ラベル
8
8
*/
9
- function toLabel ( c : string ) : string {
9
+ function getLabel ( b : Binding ) : string {
10
+ if ( b . label ) {
11
+ return b . label . value ;
12
+ }
13
+
10
14
const altLabels = new Map ( [
11
15
[ "MusicAlbum" , "アルバム" ] ,
12
16
[ "MusicRelease" , "CD" ] ,
13
17
[ "MusicComposition" , "作詞・作曲家" ] ,
14
18
[ "MusicRecording" , "楽曲" ] ,
15
19
] ) ;
16
20
17
- return altLabels . get ( c ) || "Unknown " ;
21
+ return altLabels . get ( b . class . value ) || "不明なデータ " ;
18
22
}
19
23
20
24
/**
@@ -25,6 +29,25 @@ function toLabel(c: string): string {
25
29
function getIcon ( c : string ) : string {
26
30
const icons = new Map ( [
27
31
[ "CallName" , "messages" ] ,
32
+ [ "ScriptText" , "message-circle" ] ,
33
+ [ "Unit" , "users" ] ,
34
+ [ "SetlistNumber" , "playlist" ] ,
35
+ [ "Clothes" , "hanger" ] ,
36
+ [ "CinderellaRankingResult" , "trophy" ] ,
37
+ [ "Introduction" , "id" ] ,
38
+ [ "Idol" , "user" ] ,
39
+ [ "Communication" , "book-2" ] ,
40
+ [ "Live" , "device-speaker" ] ,
41
+ [ "Event" , "calendar-event" ] ,
42
+ [ "Staff" , "briefcase" ] ,
43
+ [ "Idol_1st" , "history" ] ,
44
+ [ "Facility" , "building-community" ] ,
45
+ [ "MusicRecording" , "music" ] ,
46
+ [ "Production" , "building" ] ,
47
+ [ "CinderellaVoiceIdolAudition" , "microphone-2" ] ,
48
+ [ "MusicComposition" , "writing" ] ,
49
+ [ "MusicAlbum" , "disc" ] ,
50
+ [ "MusicRelease" , "disc" ] ,
28
51
] ) ;
29
52
30
53
return icons . get ( c ) || "error-404" ;
@@ -38,13 +61,11 @@ function getIcon(c: string): string {
38
61
export function createCardDetails ( json : ImasparqlResponse ) : CardDetail [ ] {
39
62
console . log ( json ) ;
40
63
41
- const cards = json . results . bindings . map ( ( e ) : CardDetail => {
42
- return {
43
- title : e . label ?. value || toLabel ( e . class . value ) ,
44
- count : e . count . value ,
45
- icon : getIcon ( e . class . value ) ,
46
- } ;
47
- } ) ;
64
+ const cards = json . results . bindings . map ( ( e ) : CardDetail => ( {
65
+ title : getLabel ( e ) ,
66
+ count : e . count . value ,
67
+ icon : getIcon ( e . class . value ) ,
68
+ } ) ) ;
48
69
49
70
return cards ;
50
71
}
0 commit comments