11<template >
2- 	<div  class =" vue-component object-tree"   :class =" {inline: size === 0 }"  >
3- 		<em  v-if =" size  === 0 " >{{ format( data) }}</ em >
4- 		<template  v-else-if =" Array . isArray ( data ) " >
2+ 	<div  class =" vue-component object-tree"   :class =" {inline: !isComplex }"  >
3+ 		<openeo-object-tree  v-if =" type  === 'array' && data.length === 1 "   : data= " data[0] "  / >
4+ 		<template  v-else-if =" type   ===   ' array '   &&   isComplex " >
55			<ol >
66				<li  v-for =" i in indicesShown"   :key =" i"  >
7- 					<openeo-object-tree  v-if =" isStructured(data[i])"   :data =" data[i]"  ></openeo-object-tree >
8- 					<a  v-else-if =" isUrl(data[i])"   :href =" data[i]"   target =" _blank"  >{{ data[i] }}</a >
9- 					<em  v-else-if =" format(data[i])"  >{{ format(data[i]) }}</em >
10- 					<template  v-else >{{ data[i] }}</template >
7+ 					<openeo-object-tree  :data =" data[i]"   />
118				</li >
129			</ol >
1310			<button  type =" button"   @click =" show"   v-if =" size !== indicesShown.length"  >Show all {{ data.length }} entries</button >
1411		</template >
15- 		<ul  v-else-if =" typeof data  === 'object'"  >
12+ 		<ul  v-else-if =" type  === 'object' && isComplex "  >
1613			<li  v-for =" (value, key) in data"   :key =" key"  >
17- 				<strong >{{ prettifyKey(key) }}</strong >: 
18- 				<openeo-object-tree  v-if =" isStructured(value)"   :data =" value"  ></openeo-object-tree >
19- 				<a  v-else-if =" isUrl(value)"   :href =" value"   target =" _blank"  >{{ value }}</a >
20- 				<em  v-else-if =" format(value)"  >{{ format(value) }}</em >
21- 				<template  v-else >{{ value }}</template >
14+ 				<strong >{{ prettifyKey(key) }}</strong >: <openeo-object-tree  :data =" value"   />
2215			</li >
2316		</ul >
24- 		<template  v-else >{{ data }}</template >
17+ 		<a  v-else-if =" type === 'url'"   :href =" data"   target =" _blank"  >{{ data }}</a >
18+ 		<template  v-else-if =" type  ===  ' number'   ||  type  ===  ' string' " >{{ data }}</template >
19+ 		<template  v-else-if =" type  ===  ' boolean' " >{{ format(data) }}</template >
20+ 		<em  v-else >{{ format(data) }}</em >
2521	</div >
2622</template >
2723
@@ -51,23 +47,48 @@ export default {
5147		}; 
5248	}, 
5349	computed:  { 
54- 		isSingleValue () { 
55- 			return  (Array .isArray (this .data ) &&  this .data .length  ===  1  &&  Utils .size (this .data [0 ]) ===  0 ); 
50+ 		type () { 
51+ 			if  (Array .isArray (this .data )) { 
52+ 				return  ' array'  ; 
53+ 			} 
54+ 			else  if  (this .data  ===  null ) { 
55+ 				return  ' null'  ; 
56+ 			} 
57+ 			else  if  (Utils .isUrl (this .data , false )) { 
58+ 				return  ' url'  ; 
59+ 			} 
60+ 			else  { 
61+ 				return  typeof  this .data ; 
62+ 			} 
63+ 		}, 
64+ 		isComplex () { 
65+ 			if  (this .type  ===  ' array'  ) { 
66+ 				return  this .data .length  >  1 ; 
67+ 			} 
68+ 			else  if  (this .type  ===  ' object'  ) { 
69+ 				return  Utils .size (this .data ) >  0 ; 
70+ 			} 
71+ 			else  { 
72+ 				return  false ; 
73+ 			} 
5674		}, 
5775		size () { 
58-              if  (typeof  this .data  ===  ' object'  ) {
76+ 			 if  (typeof  this .data  ===  ' object'  ) {
5977				return  Utils .size (this .data ); 
6078			} 
79+ 			else  if  (typeof  this .data  ===  ' string'   ||  typeof  this .data  ===  ' number'  ) { 
80+ 				return  1 ; //  A number or string 
81+ 			} 
6182			else  { 
62- 				return  1 ; //  One  scalar value 
83+ 				return  0 ; //  A  scalar value 
6384			} 
6485		}, 
6586		indicesShown () { 
6687			if  (! Array .isArray (this .data )) { 
6788				return  []; 
6889			} 
6990			let  arr =  this .data ; 
70- 			if  (! this .expand  &&  this .collapseAfter  !==  null  &&  this .size  >  this .collapseAfter ) { 
91+ 			if  (! this .expand  &&  this .collapseAfter  !==  null  &&  Utils .size (arr)  >  this .collapseAfter ) { 
7192				arr =  Array (this .collapseAfter ); 
7293			} 
7394			return  [... arr .keys ()]; 
@@ -76,16 +97,13 @@ export default {
7697	beforeCreate () { 
7798		Utils .enableHtmlProps (this ); 
7899	}, 
79-      methods:  {
100+ 	 methods:  {
80101		prettifyKey (key ) { 
81102			return  Utils .prettifyString (key); 
82103		}, 
83104		show () { 
84105			this .expand  =  true ; 
85106		}, 
86- 		isStructured (value ) { 
87- 			return  Utils .size (value) >  0 ; 
88- 		}, 
89107		format (value ) { 
90108			if  (value ===  null ) { 
91109				return  ' N/A'  ; 
@@ -106,12 +124,9 @@ export default {
106124				return  ' JavaScript Symbol'  ; 
107125			} 
108126
109- 			return  null ; 
110- 		}, 
111- 		isUrl (url ) { 
112- 			return  Utils .isUrl (url, false ); 
127+ 			return  value; 
113128		} 
114-      }
129+ 	 }
115130} 
116131 </script >
117132
0 commit comments