@@ -530,7 +530,30 @@ <h5 class="card-title"><a :href="documentation['@id']">{{ documentation.name }}<
530530 < h2 > Libraries</ h2 >
531531
532532 < 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 ">
534557 < div class ="card ">
535558 < div class ="card-body ">
536559 < 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>
547570 </ div >
548571
549572 < script >
573+ let libraryList = [ ]
574+ let librariesSort = ''
575+ let librariesFilter = ''
576+
550577 const content = JSON . parse ( document . getElementById ( 'content' ) . innerText )
551578
552579 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
554581
555582 return list
556583 } , { } )
557584
558- new Vue ( {
585+ const interfaces = [ ...new Set ( libraries . flatMap ( library => library . implements ) ) ] . sort ( )
586+
587+ const app = new Vue ( {
559588 el : '#app' ,
560589 data : {
561590 specifications,
562591 documentations,
563- libraries
592+ libraries,
593+ libraryList
564594 }
565595 } )
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 ( )
566616 </ script >
567617</ body >
568618</ html >
0 commit comments