@@ -530,7 +530,30 @@ <h5 class="card-title"><a :href="documentation['@id']">{{ documentation.name }}<
530
530
< h2 > Libraries</ h2 >
531
531
532
532
< div class ="row ">
533
- < div class ="col-md-4 " v-for ="library in libraries ">
533
+ < div class ="col-md-4 ">
534
+ < div class ="form-group ">
535
+ < label for ="librariesSort "> Sort</ label >
536
+ < select class ="form-control " id ="librariesSort " v-model ="librariesSort " @change ="updateLibraries ">
537
+ < option value =""> </ option >
538
+ < option value ="asc "> A-Z</ option >
539
+ < option value ="desc "> Z-A</ option >
540
+ </ select >
541
+ </ div >
542
+ </ div >
543
+
544
+ < div class ="col-md-4 ">
545
+ < div class ="form-group ">
546
+ < label for ="librariesFilter "> Interface</ label >
547
+ < select class ="form-control " id ="librariesFilter " v-model ="librariesFilter " @change ="updateLibraries ">
548
+ < option value =""> </ option >
549
+ < option v-for ="interface of interfaces " :value ="interface "> {{ interface }}</ option >
550
+ </ select >
551
+ </ div >
552
+ </ div >
553
+ </ div >
554
+
555
+ < div class ="row ">
556
+ < div class ="col-md-4 " v-for ="library in libraryList ">
534
557
< div class ="card ">
535
558
< div class ="card-body ">
536
559
< h5 class ="card-title "> < a :href ="library['@id'] "> {{ library.name }}</ a > </ h5 >
@@ -547,22 +570,49 @@ <h5 class="card-title"><a :href="library['@id']">{{ library.name }}</a></h5>
547
570
</ div >
548
571
549
572
< script >
573
+ let libraryList = [ ]
574
+ let librariesSort = ''
575
+ let librariesFilter = ''
576
+
550
577
const content = JSON . parse ( document . getElementById ( 'content' ) . innerText )
551
578
552
579
const { specifications, documentations, libraries } = content . breadcrumb . reduce ( ( list , item ) => {
553
- list [ item [ '@id' ] . substr ( 1 ) ] = item . breadcrumb
580
+ list [ item [ '@id' ] . slice ( 1 ) ] = item . breadcrumb
554
581
555
582
return list
556
583
} , { } )
557
584
558
- new Vue ( {
585
+ const interfaces = [ ...new Set ( libraries . flatMap ( library => library . implements ) ) ] . sort ( )
586
+
587
+ const app = new Vue ( {
559
588
el : '#app' ,
560
589
data : {
561
590
specifications,
562
591
documentations,
563
- libraries
592
+ libraries,
593
+ libraryList
564
594
}
565
595
} )
596
+
597
+ function updateLibraries ( ) {
598
+ libraryList = libraries . slice ( )
599
+
600
+ if ( librariesFilter ) {
601
+ libraryList = libraryList . filter ( library => library . implements . includes ( librariesFilter ) )
602
+ }
603
+
604
+ if ( librariesSort === 'asc' ) {
605
+ libraryList = libraryList . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
606
+ }
607
+
608
+ if ( librariesSort === 'desc' ) {
609
+ libraryList = libraryList . sort ( ( a , b ) => b . name . localeCompare ( a . name ) )
610
+ }
611
+
612
+ app . libraryList = libraryList
613
+ }
614
+
615
+ updateLibraries ( )
566
616
</ script >
567
617
</ body >
568
618
</ html >
0 commit comments