@@ -88,7 +88,7 @@ import classNames from "classnames";
8888import * as Popover from "@radix-ui/react-popover" ;
8989
9090// import { PublicationInfoLibWithRadix, PublicationInfoLibWithRadixContent, PublicationInfoLibWithRadixTrigger } from "../dialog/publicationInfos/PublicationInfo";
91- import { useSearchParams } from "react-router-dom" ;
91+ import { useLocation , useNavigate , useSearchParams } from "react-router-dom" ;
9292// import * as FilterIcon from "readium-desktop/renderer/assets/icons/filter-icon.svg";
9393// import * as DeleteFilter from "readium-desktop/renderer/assets/icons/deleteFilter-icon.svg";
9494import { MySelectProps , Select } from "readium-desktop/renderer/common/components/Select" ;
@@ -397,6 +397,20 @@ const CellGlobalFilter: React.FC<ITableCellProps_GlobalFilter> = (props) => {
397397 // className={classNames(classThemeExample)}
398398 // className={classNames(classStyleExample)}
399399
400+ const navigate = useNavigate ( ) ;
401+ const location = useLocation ( ) ;
402+ const queryParams = new URLSearchParams ( location . search ) ;
403+ const searchPubTitle = queryParams . get ( "searchPubTitle" ) || undefined ;
404+ const searchPubHash = queryParams . get ( "searchPubHash" ) || undefined ;
405+
406+ React . useEffect ( ( ) => {
407+ const val = searchPubHash ? `id:${ searchPubHash } ` : ( searchPubTitle || "" ) ;
408+ if ( val && props . focusInputRef ?. current && props . focusInputRef . current . value !== val ) {
409+ props . focusInputRef . current . value = val ;
410+ onInputChange ( val ) ;
411+ }
412+ } , [ searchPubHash , searchPubTitle , onInputChange , props . focusInputRef , props . focusInputRef ?. current ?. value ] ) ;
413+
400414 return (
401415 < div className = { classNames ( stylesInput . form_group , stylesInput . form_group_allPubSearch ) } >
402416 < label
@@ -422,24 +436,35 @@ const CellGlobalFilter: React.FC<ITableCellProps_GlobalFilter> = (props) => {
422436
423437 onChange = { ( e ) => {
424438 // setValue(e.target.value);
439+ const val = ( e . target . value || "" ) . trim ( ) ;
440+ if ( queryParams . has ( "searchPubTitle" ) || queryParams . has ( "searchPubHash" ) ) {
441+ // navigate(location.pathname + (val ? `?focus=search&searchPubTitle=${encodeURIComponent(val)}` : ""), {
442+ // state: location.state,
443+ // replace: true,
444+ // });
445+ navigate ( location . pathname , {
446+ state : location . state ,
447+ replace : true ,
448+ } ) ;
449+ }
425450 if ( ! props . accessibilitySupportEnabled ) {
426- onInputChange ( ( e . target . value || "" ) . trim ( ) || undefined ) ;
451+ onInputChange ( val ) ;
427452 }
428453 } }
429454 onKeyUp = { ( e ) => {
455+ const val = ( props . focusInputRef ?. current ?. value || "" ) . trim ( ) ;
430456 if ( props . accessibilitySupportEnabled && e . key === "Enter" ) {
431457 props . setShowColumnFilters ( true ) ;
432- props . setGlobalFilter ( // value
433- ( props . focusInputRef ?. current ?. value || "" ) . trim ( ) || undefined ) ;
458+ props . setGlobalFilter ( val ) ;
434459 }
435460 } }
436461 placeholder = { `${ props . __ ( "header.searchTitle" ) } ` }
437462 />
438463 { props . accessibilitySupportEnabled ? < button
439464 onClick = { ( ) => {
465+ const val = ( props . focusInputRef ?. current ?. value || "" ) . trim ( ) ;
440466 props . setShowColumnFilters ( true ) ;
441- props . setGlobalFilter ( // value
442- ( props . focusInputRef ?. current ?. value || "" ) . trim ( ) || undefined ) ;
467+ props . setGlobalFilter ( val ) ;
443468 } }
444469 > { `${ props . __ ( "header.searchPlaceholder" ) } ` } </ button > : < > </ > }
445470 </ div >
@@ -1362,6 +1387,8 @@ interface IColumns {
13621387 // colIdentifier: string;
13631388 // colPublicationType: string;
13641389 // colProgression: string;
1390+
1391+ col_pubHash : string ;
13651392}
13661393
13671394// https://gist.github.com/ggascoigne/646e14c9d54258e40588a13aabf0102d
@@ -1657,6 +1684,8 @@ export const TableView: React.FC<ITableCellProps_TableView & ITableCellProps_Com
16571684 // colProgression: "Progression",
16581685 // colIdentifier: identifier,
16591686 // colPublicationType: publicationType,
1687+
1688+ col_pubHash : "id:" + publicationView . publicationHash ,
16601689 } ;
16611690 return cols ;
16621691 } ) ;
@@ -1905,6 +1934,12 @@ export const TableView: React.FC<ITableCellProps_TableView & ITableCellProps_Com
19051934 // accessor: "colPublicationType",
19061935 // sortType: sortFunction,
19071936 // },
1937+
1938+ {
1939+ Header : "Publication Hash" ,
1940+ accessor : "col_pubHash" ,
1941+ sortType : sortFunction ,
1942+ } ,
19081943 ] ;
19091944 return arr ;
19101945 } , [ __ ] ) ;
@@ -1970,7 +2005,7 @@ export const TableView: React.FC<ITableCellProps_TableView & ITableCellProps_Com
19702005 const initialState : UsePaginationState < IColumns > & TableState < IColumns > = {
19712006 pageSize : PAGESIZE , // displayType === DisplayType.List ? 20 : 10;
19722007 pageIndex : 0 ,
1973- hiddenColumns : displayType === DisplayType . Grid ? [ "colLanguages" , "colPublishers" , "colPublishedDate" , "colLCP" , "colDuration" , "colDescription" , "col_a11y_accessibilitySummary" ] : [ ] ,
2008+ hiddenColumns : displayType === DisplayType . Grid ? [ "colLanguages" , "colPublishers" , "colPublishedDate" , "colLCP" , "colDuration" , "colDescription" , "col_a11y_accessibilitySummary" , "col_pubHash" ] : [ "col_pubHash" ] ,
19742009 } ;
19752010 const opts :
19762011 TableOptions < IColumns > &
0 commit comments