@internetarchive/collection-browser 1.9.1-alpha.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/collection-browser.d.ts +3 -1
- package/dist/src/collection-browser.js +26 -14
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/models.d.ts +1 -0
- package/dist/src/models.js +13 -0
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +7 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.js +21 -4
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +1 -1
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +1 -5
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js +19 -0
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +1 -0
- package/dist/test/mocks/mock-search-responses.js +42 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -1
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +29 -14
- package/src/models.ts +13 -0
- package/src/sort-filter-bar/sort-filter-bar.ts +22 -4
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +1 -1
- package/src/tiles/grid/tile-stats.ts +1 -1
- package/src/tiles/tile-dispatcher.ts +1 -5
- package/test/collection-browser.test.ts +25 -0
- package/test/mocks/mock-search-responses.ts +46 -0
- package/test/mocks/mock-search-service.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-search-responses.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-responses.ts"],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E;gBACnB,eAAe,EAAE;oBACf,SAAS,EAAE,aAAa;iBACzB;aACF;SACF;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,CAAC;SACd;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oCAAoC,GAG7C,GAAG,EAAE,CAAC,CAAC;IACT,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,gBAAgB,EAAE;gBAChB,UAAU,EAAE,sBAAsB;gBAClC,IAAI,EAAE,EAAE;aACT;YACD,eAAe,EAAE;gBACf,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,oBAAoB,EAAE;wBACpB,UAAU,EAAE,sBAAsB;wBAClC,IAAI,EAAE,CAAC,gBAAgB,EAAE,YAAY,CAAC;qBACvC;iBACF;aACF;SACF;QACD,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,OAAO,EAAE;gBACP,IAAI,OAAO,CAAC;oBACV,MAAM,EAAE;wBACN,UAAU,EAAE,KAAK;wBACjB,KAAK,EAAE,KAAK;qBACb;iBACF,CAAC;aACH;YACD,mBAAmB,EAAE;gBACnB,eAAe,EAAE;oBACf,SAAS,EAAE,YAAY;iBACxB;aACF;SACF;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,CAAC;SACd;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAG3B,GAAG,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,IAAI,kBAAkB,CAAC,sBAAsB,CAAC,YAAY,EAAE,KAAK,EAAE;QACxE,OAAO,EAAE,KAAK;KACf,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAG/B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport {\n Aggregation,\n ItemHit,\n SearchResponse,\n SearchServiceError,\n TextHit,\n} from '@internetarchive/search-service';\nimport { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';\n\nexport const getMockSuccessSingleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithYearHistogramAggs: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'years',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'years',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n subject: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 3,\n },\n ],\n }),\n year_histogram: new Aggregation({\n buckets: [1, 2, 3, 3, 2, 1],\n first_bucket_key: 1950,\n last_bucket_key: 2000,\n interval: 10,\n number_buckets: 6,\n }),\n },\n results: [],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'loggedin',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'loggedin',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'bar'],\n title: 'foo',\n mediatype: 'data',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'no-preview',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'no-preview',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInAndNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstTitleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstTitle: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstCreatorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstCreator: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionTitles: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n collectionTitles: {\n foo: 'Foo Collection',\n bar: 'Bar Collection',\n baz: 'Baz Collection',\n boop: 'Boop Collection',\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionAggregations: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 0,\n returnedCount: 0,\n results: [],\n aggregations: {\n collection: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 10,\n },\n {\n key: 'bar',\n doc_count: 10,\n },\n ],\n }),\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessSingleResultWithSort: (\n resultsSpy: Function\n) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n get results() {\n resultsSpy();\n return [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ];\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultipleResults: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultiLineDescription: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n description: ['line1', 'line2'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessExtraQuotedHref: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new TextHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n __href__: '/details/foo?q=%22%22quoted+query%22%22',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithDefaultSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'default-sort',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'default-sort',\n sort: ['titleSorter', 'identifier'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n 'sort-by': 'titleSorter',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithConciseDefaultSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'default-sort-concise',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'default-sort-concise',\n sort: ['addeddate:desc', 'identifier'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n 'sort-by': '-addeddate',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockErrorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n error: new SearchServiceError(SearchServiceErrorType.networkError, 'foo', {\n message: 'bar',\n }),\n});\n\nexport const getMockMalformedResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({});\n"]}
|
|
1
|
+
{"version":3,"file":"mock-search-responses.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-responses.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,OAAO,EAEP,kBAAkB,EAClB,OAAO,GACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AAEvG,MAAM,CAAC,MAAM,0BAA0B,GAGnC,GAAG,EAAE,CAAC,CAAC;IACT,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,gBAAgB,EAAE;gBAChB,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,EAAE,EAAE;aACT;YACD,eAAe,EAAE;gBACf,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,oBAAoB,EAAE;wBACpB,UAAU,EAAE,gBAAgB;wBAC5B,IAAI,EAAE,EAAE;qBACT;iBACF;aACF;SACF;QACD,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,OAAO,EAAE;gBACP,IAAI,OAAO,CAAC;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AM,sBAAsB,GAG/B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport {\n Aggregation,\n ItemHit,\n SearchResponse,\n SearchServiceError,\n TextHit,\n} from '@internetarchive/search-service';\nimport { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';\n\nexport const getMockSuccessSingleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithYearHistogramAggs: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'years',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'years',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n subject: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 3,\n },\n ],\n }),\n year_histogram: new Aggregation({\n buckets: [1, 2, 3, 3, 2, 1],\n first_bucket_key: 1950,\n last_bucket_key: 2000,\n interval: 10,\n number_buckets: 6,\n }),\n },\n results: [],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'loggedin',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'loggedin',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'bar'],\n title: 'foo',\n mediatype: 'data',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'no-preview',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'no-preview',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInAndNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstTitleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstTitle: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstCreatorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstCreator: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionTitles: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n collectionTitles: {\n foo: 'Foo Collection',\n bar: 'Bar Collection',\n baz: 'Baz Collection',\n boop: 'Boop Collection',\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionAggregations: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 0,\n returnedCount: 0,\n results: [],\n aggregations: {\n collection: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 10,\n },\n {\n key: 'bar',\n doc_count: 10,\n },\n ],\n }),\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessSingleResultWithSort: (\n resultsSpy: Function\n) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n get results() {\n resultsSpy();\n return [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ];\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultipleResults: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultiLineDescription: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n description: ['line1', 'line2'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessExtraQuotedHref: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new TextHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n __href__: '/details/foo?q=%22%22quoted+query%22%22',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithDefaultSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'default-sort',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'default-sort',\n sort: ['titleSorter', 'identifier'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n 'sort-by': 'titleSorter',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithConciseDefaultSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'default-sort-concise',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'default-sort-concise',\n sort: ['addeddate:desc', 'identifier'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n 'sort-by': '-addeddate',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithDefaultFavSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'fav-sort',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'fav-sort',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n identifier: 'fav-foo',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockErrorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n error: new SearchServiceError(SearchServiceErrorType.networkError, 'foo', {\n message: 'bar',\n }),\n});\n\nexport const getMockMalformedResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({});\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMockSuccessSingleResult, getMockSuccessMultipleResults, getMockSuccessSingleResultWithSort, getMockSuccessLoggedInResult, getMockSuccessNoPreviewResult, getMockSuccessLoggedInAndNoPreviewResult, getMockSuccessWithYearHistogramAggs, getMockSuccessMultiLineDescription, getMockSuccessFirstTitleResult, getMockSuccessFirstCreatorResult, getMockErrorResult, getMockMalformedResult, getMockSuccessWithCollectionTitles, getMockSuccessWithCollectionAggregations, getMockSuccessExtraQuotedHref, getMockSuccessWithDefaultSort, getMockSuccessWithConciseDefaultSort, } from './mock-search-responses';
|
|
1
|
+
import { getMockSuccessSingleResult, getMockSuccessMultipleResults, getMockSuccessSingleResultWithSort, getMockSuccessLoggedInResult, getMockSuccessNoPreviewResult, getMockSuccessLoggedInAndNoPreviewResult, getMockSuccessWithYearHistogramAggs, getMockSuccessMultiLineDescription, getMockSuccessFirstTitleResult, getMockSuccessFirstCreatorResult, getMockErrorResult, getMockMalformedResult, getMockSuccessWithCollectionTitles, getMockSuccessWithCollectionAggregations, getMockSuccessExtraQuotedHref, getMockSuccessWithDefaultSort, getMockSuccessWithConciseDefaultSort, getMockSuccessWithDefaultFavSort, } from './mock-search-responses';
|
|
2
2
|
const responses = {
|
|
3
3
|
'single-result': getMockSuccessSingleResult,
|
|
4
4
|
years: getMockSuccessWithYearHistogramAggs,
|
|
@@ -13,6 +13,7 @@ const responses = {
|
|
|
13
13
|
'extra-quoted-href': getMockSuccessExtraQuotedHref,
|
|
14
14
|
'default-sort': getMockSuccessWithDefaultSort,
|
|
15
15
|
'default-sort-concise': getMockSuccessWithConciseDefaultSort,
|
|
16
|
+
'fav-sort': getMockSuccessWithDefaultFavSort,
|
|
16
17
|
error: getMockErrorResult,
|
|
17
18
|
malformed: getMockMalformedResult,
|
|
18
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-search-service.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-service.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,EAC7B,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,kBAAkB,EAClB,sBAAsB,EACtB,kCAAkC,EAClC,wCAAwC,EACxC,6BAA6B,EAC7B,6BAA6B,EAC7B,oCAAoC,
|
|
1
|
+
{"version":3,"file":"mock-search-service.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-service.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,EAC7B,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,kBAAkB,EAClB,sBAAsB,EACtB,kCAAkC,EAClC,wCAAwC,EACxC,6BAA6B,EAC7B,6BAA6B,EAC7B,oCAAoC,EACpC,gCAAgC,GACjC,MAAM,yBAAyB,CAAC;AAEjC,MAAM,SAAS,GAGX;IACF,eAAe,EAAE,0BAA0B;IAC3C,KAAK,EAAE,mCAAmC;IAC1C,wBAAwB,EAAE,kCAAkC;IAC5D,QAAQ,EAAE,4BAA4B;IACtC,YAAY,EAAE,6BAA6B;IAC3C,qBAAqB,EAAE,wCAAwC;IAC/D,aAAa,EAAE,8BAA8B;IAC7C,eAAe,EAAE,gCAAgC;IACjD,mBAAmB,EAAE,kCAAkC;IACvD,yBAAyB,EAAE,wCAAwC;IACnE,mBAAmB,EAAE,6BAA6B;IAClD,cAAc,EAAE,6BAA6B;IAC7C,sBAAsB,EAAE,oCAAoC;IAC5D,UAAU,EAAE,gCAAgC;IAC5C,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,sBAAsB;CAClC,CAAC;AAEF,MAAM,OAAO,iBAAiB;IAW5B,YAAY,EACV,aAAa,GAAG,KAAK,EACrB,kBAAkB,GAAG,CAAC,EACtB,UAAU,GAAG,GAAG,EAAE,GAAE,CAAC,GACtB,GAAG,EAAE;QACJ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,MAAM,CACV,MAAoB,EACpB,UAAsB;;QAEtB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,iCAAiC;YACjC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;gBACtB,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,WAAW,GACf,MAAA,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;QAClE,MAAM,QAAQ,GACZ,MAAA,SAAS,CAAC,WAAW,CAAC,mCAAI,6BAA6B,CAAC;QAC1D,IAAI,MAAM,GAAG,QAAQ,EAAE,CAAC;QAExB,uCAAuC;QACvC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,KAAK,WAAW,EAAE;YAC3C,MAAM,GAAG,kCAAkC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC9D;QAED,uCAAuC;QACvC,IAAI,MAAM,CAAC,OAAO,EAAE;YACjB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAwB,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;SACnE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport type {\n SearchParams,\n SearchResponse,\n SearchServiceInterface,\n SearchServiceError,\n SearchType,\n} from '@internetarchive/search-service';\nimport {\n getMockSuccessSingleResult,\n getMockSuccessMultipleResults,\n getMockSuccessSingleResultWithSort,\n getMockSuccessLoggedInResult,\n getMockSuccessNoPreviewResult,\n getMockSuccessLoggedInAndNoPreviewResult,\n getMockSuccessWithYearHistogramAggs,\n getMockSuccessMultiLineDescription,\n getMockSuccessFirstTitleResult,\n getMockSuccessFirstCreatorResult,\n getMockErrorResult,\n getMockMalformedResult,\n getMockSuccessWithCollectionTitles,\n getMockSuccessWithCollectionAggregations,\n getMockSuccessExtraQuotedHref,\n getMockSuccessWithDefaultSort,\n getMockSuccessWithConciseDefaultSort,\n getMockSuccessWithDefaultFavSort,\n} from './mock-search-responses';\n\nconst responses: Record<\n string,\n () => Result<SearchResponse, SearchServiceError>\n> = {\n 'single-result': getMockSuccessSingleResult,\n years: getMockSuccessWithYearHistogramAggs,\n 'multi-line-description': getMockSuccessMultiLineDescription,\n loggedin: getMockSuccessLoggedInResult,\n 'no-preview': getMockSuccessNoPreviewResult,\n 'loggedin-no-preview': getMockSuccessLoggedInAndNoPreviewResult,\n 'first-title': getMockSuccessFirstTitleResult,\n 'first-creator': getMockSuccessFirstCreatorResult,\n 'collection-titles': getMockSuccessWithCollectionTitles,\n 'collection-aggregations': getMockSuccessWithCollectionAggregations,\n 'extra-quoted-href': getMockSuccessExtraQuotedHref,\n 'default-sort': getMockSuccessWithDefaultSort,\n 'default-sort-concise': getMockSuccessWithConciseDefaultSort,\n 'fav-sort': getMockSuccessWithDefaultFavSort,\n error: getMockErrorResult,\n malformed: getMockMalformedResult,\n};\n\nexport class MockSearchService implements SearchServiceInterface {\n searchParams?: SearchParams;\n\n searchType?: SearchType;\n\n asyncResponse: boolean;\n\n asyncResponseDelay: number;\n\n resultsSpy: Function;\n\n constructor({\n asyncResponse = false,\n asyncResponseDelay = 0,\n resultsSpy = () => {},\n } = {}) {\n this.asyncResponse = asyncResponse;\n this.asyncResponseDelay = asyncResponseDelay;\n this.resultsSpy = resultsSpy;\n }\n\n async search(\n params: SearchParams,\n searchType: SearchType\n ): Promise<Result<SearchResponse, SearchServiceError>> {\n this.searchParams = params;\n this.searchType = searchType;\n\n if (this.asyncResponse) {\n // Add an artificial 1-tick delay\n await new Promise(res => {\n setTimeout(res, this.asyncResponseDelay);\n });\n }\n\n const responseKey =\n (this.searchParams.query || this.searchParams.pageTarget) ?? '';\n const resultFn: () => Result<SearchResponse, SearchServiceError> =\n responses[responseKey] ?? getMockSuccessMultipleResults;\n let result = resultFn();\n\n // with-sort query has special handling\n if (this.searchParams.query === 'with-sort') {\n result = getMockSuccessSingleResultWithSort(this.resultsSpy);\n }\n\n // Apply any uid param from the request\n if (result.success) {\n (result.success.request.clientParameters as any).uid = params.uid;\n }\n\n return result;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -564,6 +564,7 @@ export class CollectionBrowser
|
|
|
564
564
|
.selectedSort=${this.selectedSort}
|
|
565
565
|
.sortDirection=${this.sortDirection}
|
|
566
566
|
.showRelevance=${this.isRelevanceSortAvailable}
|
|
567
|
+
.showDateFavorited=${this.withinCollection?.startsWith('fav-')}
|
|
567
568
|
.displayMode=${this.displayMode}
|
|
568
569
|
.selectedTitleFilter=${this.selectedTitleFilter}
|
|
569
570
|
.selectedCreatorFilter=${this.selectedCreatorFilter}
|
|
@@ -947,6 +948,10 @@ export class CollectionBrowser
|
|
|
947
948
|
);
|
|
948
949
|
}
|
|
949
950
|
|
|
951
|
+
if (changed.has('withinCollection')) {
|
|
952
|
+
this.clearFilters({ sort: true });
|
|
953
|
+
}
|
|
954
|
+
|
|
950
955
|
if (
|
|
951
956
|
changed.has('baseQuery') ||
|
|
952
957
|
changed.has('searchType') ||
|
|
@@ -1841,7 +1846,9 @@ export class CollectionBrowser
|
|
|
1841
1846
|
/**
|
|
1842
1847
|
* Applies any default sort option for the current collection, by checking
|
|
1843
1848
|
* for one in the collection's metadata. If none is found, defaults to sorting
|
|
1844
|
-
* descending by
|
|
1849
|
+
* descending by:
|
|
1850
|
+
* - Date Favorited for fav-* collections
|
|
1851
|
+
* - Weekly views for all other collections
|
|
1845
1852
|
*/
|
|
1846
1853
|
private applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo) {
|
|
1847
1854
|
if (this.baseQuery) {
|
|
@@ -1852,11 +1859,22 @@ export class CollectionBrowser
|
|
|
1852
1859
|
return;
|
|
1853
1860
|
}
|
|
1854
1861
|
|
|
1855
|
-
|
|
1856
|
-
|
|
1862
|
+
// Favorite collections sort on Date Favorited by default.
|
|
1863
|
+
// Other collections fall back to sorting on weekly views.
|
|
1864
|
+
const baseDefaultSort: string =
|
|
1865
|
+
collectionInfo?.public_metadata?.identifier?.startsWith('fav-')
|
|
1866
|
+
? '-favoritedate'
|
|
1867
|
+
: '-week';
|
|
1868
|
+
|
|
1869
|
+
// The collection metadata may override the default sorting with something else
|
|
1870
|
+
const metadataSort: string | undefined =
|
|
1871
|
+
collectionInfo?.public_metadata?.['sort-by'];
|
|
1872
|
+
|
|
1873
|
+
// Prefer the metadata-specified sort if one exists
|
|
1874
|
+
const defaultSortToApply = metadataSort ?? baseDefaultSort;
|
|
1857
1875
|
|
|
1858
1876
|
// Account for both -field and field:dir formats
|
|
1859
|
-
let [field, dir] =
|
|
1877
|
+
let [field, dir] = defaultSortToApply.split(':');
|
|
1860
1878
|
if (field.startsWith('-')) {
|
|
1861
1879
|
field = field.slice(1);
|
|
1862
1880
|
dir = 'desc';
|
|
@@ -2194,7 +2212,7 @@ export class CollectionBrowser
|
|
|
2194
2212
|
padding-left: 1rem;
|
|
2195
2213
|
padding-right: 1rem;
|
|
2196
2214
|
margin-top: var(--rightColumnMarginTop, 0);
|
|
2197
|
-
background:
|
|
2215
|
+
background: #fff;
|
|
2198
2216
|
}
|
|
2199
2217
|
|
|
2200
2218
|
.mobile #right-column {
|
|
@@ -2256,15 +2274,12 @@ export class CollectionBrowser
|
|
|
2256
2274
|
}
|
|
2257
2275
|
|
|
2258
2276
|
#facets-bottom-fade {
|
|
2259
|
-
background:
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
#f5f5f7 80%,
|
|
2266
|
-
#f5f5f7 100%
|
|
2267
|
-
)
|
|
2277
|
+
background: linear-gradient(
|
|
2278
|
+
to bottom,
|
|
2279
|
+
#f5f5f700 0%,
|
|
2280
|
+
#f5f5f7c0 50%,
|
|
2281
|
+
#f5f5f7 80%,
|
|
2282
|
+
#f5f5f7 100%
|
|
2268
2283
|
);
|
|
2269
2284
|
position: fixed;
|
|
2270
2285
|
bottom: 0;
|
package/src/models.ts
CHANGED
|
@@ -65,6 +65,7 @@ export enum SortField {
|
|
|
65
65
|
'datearchived' = 'datearchived',
|
|
66
66
|
'datereviewed' = 'datereviewed',
|
|
67
67
|
'dateadded' = 'dateadded',
|
|
68
|
+
'datefavorited' = 'datefavorited',
|
|
68
69
|
'creator' = 'creator',
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -127,6 +128,7 @@ export const SORT_OPTIONS: Record<SortField, SortOption> = {
|
|
|
127
128
|
// For collection pages _without a query_, the default is usually weekly views, but this can be
|
|
128
129
|
// overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the
|
|
129
130
|
// default is again relevance sort.
|
|
131
|
+
// For fav-* collections only, the default is instead sorting by date favorited.
|
|
130
132
|
[SortField.default]: {
|
|
131
133
|
field: SortField.default,
|
|
132
134
|
defaultSortDirection: null,
|
|
@@ -241,6 +243,17 @@ export const SORT_OPTIONS: Record<SortField, SortOption> = {
|
|
|
241
243
|
displayName: 'Date added',
|
|
242
244
|
urlNames: ['addeddate'],
|
|
243
245
|
},
|
|
246
|
+
[SortField.datefavorited]: {
|
|
247
|
+
field: SortField.datefavorited,
|
|
248
|
+
defaultSortDirection: 'desc',
|
|
249
|
+
canSetDirection: false,
|
|
250
|
+
shownInSortBar: true, // But only when viewing fav-* collections
|
|
251
|
+
shownInURL: false,
|
|
252
|
+
handledBySearchService: false,
|
|
253
|
+
searchServiceKey: 'favoritedate',
|
|
254
|
+
displayName: 'Date favorited',
|
|
255
|
+
urlNames: ['favoritedate'],
|
|
256
|
+
},
|
|
244
257
|
[SortField.creator]: {
|
|
245
258
|
field: SortField.creator,
|
|
246
259
|
defaultSortDirection: 'asc',
|
|
@@ -65,6 +65,9 @@ export class SortFilterBar
|
|
|
65
65
|
/** Whether to show the Relevance sort option (default `true`) */
|
|
66
66
|
@property({ type: Boolean }) showRelevance: boolean = true;
|
|
67
67
|
|
|
68
|
+
/** Whether to show the Date Favorited sort option instead of Date Published/Archived/Reviewed (default `false`) */
|
|
69
|
+
@property({ type: Boolean }) showDateFavorited: boolean = false;
|
|
70
|
+
|
|
68
71
|
/** Maps of result counts for letters on the alphabet bar, for each letter filter type */
|
|
69
72
|
@property({ type: Object }) prefixFilterCountMap?: Record<
|
|
70
73
|
PrefixFilterType,
|
|
@@ -356,7 +359,10 @@ export class SortFilterBar
|
|
|
356
359
|
private get mobileSortSelectorTemplate() {
|
|
357
360
|
const displayedOptions = Object.values(SORT_OPTIONS)
|
|
358
361
|
.filter(opt => opt.shownInSortBar)
|
|
359
|
-
.filter(opt => this.showRelevance || opt.field !== SortField.relevance)
|
|
362
|
+
.filter(opt => this.showRelevance || opt.field !== SortField.relevance)
|
|
363
|
+
.filter(
|
|
364
|
+
opt => this.showDateFavorited || opt.field !== SortField.datefavorited
|
|
365
|
+
);
|
|
360
366
|
|
|
361
367
|
return html`
|
|
362
368
|
<div
|
|
@@ -536,6 +542,9 @@ export class SortFilterBar
|
|
|
536
542
|
id: 'date-dropdown',
|
|
537
543
|
selected: this.dateOptionSelected,
|
|
538
544
|
dropdownOptions: [
|
|
545
|
+
...(this.showDateFavorited
|
|
546
|
+
? [this.getDropdownOption(SortField.datefavorited)]
|
|
547
|
+
: []),
|
|
539
548
|
this.getDropdownOption(SortField.date),
|
|
540
549
|
this.getDropdownOption(SortField.datearchived),
|
|
541
550
|
this.getDropdownOption(SortField.datereviewed),
|
|
@@ -552,7 +561,7 @@ export class SortFilterBar
|
|
|
552
561
|
if (!this.dateDropdown.open && !this.dateOptionSelected) {
|
|
553
562
|
e.stopPropagation();
|
|
554
563
|
this.clearAlphaBarFilters();
|
|
555
|
-
this.setSelectedSort(
|
|
564
|
+
this.setSelectedSort(this.defaultDateSortField);
|
|
556
565
|
}
|
|
557
566
|
},
|
|
558
567
|
});
|
|
@@ -729,6 +738,7 @@ export class SortFilterBar
|
|
|
729
738
|
*/
|
|
730
739
|
private get dateOptionSelected(): boolean {
|
|
731
740
|
const dateSortFields: SortField[] = [
|
|
741
|
+
SortField.datefavorited,
|
|
732
742
|
SortField.datearchived,
|
|
733
743
|
SortField.date,
|
|
734
744
|
SortField.datereviewed,
|
|
@@ -755,6 +765,14 @@ export class SortFilterBar
|
|
|
755
765
|
return viewSortFields.includes(this.finalizedSortField);
|
|
756
766
|
}
|
|
757
767
|
|
|
768
|
+
/**
|
|
769
|
+
* The default field for the date sort dropdown.
|
|
770
|
+
* This is Date Favorited when that option is available, or Date Published otherwise.
|
|
771
|
+
*/
|
|
772
|
+
private get defaultDateSortField(): SortField {
|
|
773
|
+
return this.showDateFavorited ? SortField.datefavorited : SortField.date;
|
|
774
|
+
}
|
|
775
|
+
|
|
758
776
|
/**
|
|
759
777
|
* The display name of the current date field
|
|
760
778
|
*
|
|
@@ -764,7 +782,7 @@ export class SortFilterBar
|
|
|
764
782
|
* @memberof SortFilterBar
|
|
765
783
|
*/
|
|
766
784
|
private get dateSortField(): string {
|
|
767
|
-
const defaultDateSort = SORT_OPTIONS[
|
|
785
|
+
const defaultDateSort = SORT_OPTIONS[this.defaultDateSortField];
|
|
768
786
|
const currentDateSort = this.dateOptionSelected
|
|
769
787
|
? SORT_OPTIONS[this.finalizedSortField] ?? defaultDateSort
|
|
770
788
|
: defaultDateSort;
|
|
@@ -1008,7 +1026,7 @@ export class SortFilterBar
|
|
|
1008
1026
|
background: none;
|
|
1009
1027
|
font-family: inherit;
|
|
1010
1028
|
font-size: inherit;
|
|
1011
|
-
color:
|
|
1029
|
+
color: #333;
|
|
1012
1030
|
line-height: 2;
|
|
1013
1031
|
cursor: pointer;
|
|
1014
1032
|
appearance: none;
|
|
@@ -331,11 +331,7 @@ export class TileDispatcher
|
|
|
331
331
|
|
|
332
332
|
item-tile {
|
|
333
333
|
--tileBorderColor: #dddddd;
|
|
334
|
-
--
|
|
335
|
-
--imageBlockBackgroundColor: var(
|
|
336
|
-
--ia-theme-primary-background-color,
|
|
337
|
-
#f1f1f4
|
|
338
|
-
);
|
|
334
|
+
--imageBlockBackgroundColor: #f1f1f4;
|
|
339
335
|
}
|
|
340
336
|
|
|
341
337
|
#container {
|
|
@@ -1065,6 +1065,31 @@ describe('Collection Browser', () => {
|
|
|
1065
1065
|
expect(sortBar.sortDirection).to.be.null;
|
|
1066
1066
|
});
|
|
1067
1067
|
|
|
1068
|
+
it('uses date favorited sort as default when targeting fav- collection', async () => {
|
|
1069
|
+
const searchService = new MockSearchService();
|
|
1070
|
+
const el = await fixture<CollectionBrowser>(
|
|
1071
|
+
html`<collection-browser
|
|
1072
|
+
.searchService=${searchService}
|
|
1073
|
+
.baseNavigationUrl=${''}
|
|
1074
|
+
></collection-browser>`
|
|
1075
|
+
);
|
|
1076
|
+
|
|
1077
|
+
el.withinCollection = 'fav-sort';
|
|
1078
|
+
await el.updateComplete;
|
|
1079
|
+
await el.initialSearchComplete;
|
|
1080
|
+
await el.updateComplete;
|
|
1081
|
+
await aTimeout(50);
|
|
1082
|
+
|
|
1083
|
+
const sortBar = el.shadowRoot?.querySelector(
|
|
1084
|
+
'sort-filter-bar'
|
|
1085
|
+
) as SortFilterBar;
|
|
1086
|
+
expect(sortBar).to.exist;
|
|
1087
|
+
expect(sortBar.defaultSortField).to.equal(SortField.datefavorited);
|
|
1088
|
+
expect(sortBar.defaultSortDirection).to.equal('desc');
|
|
1089
|
+
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
1090
|
+
expect(sortBar.sortDirection).to.be.null;
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1068
1093
|
it('scrolls to page', async () => {
|
|
1069
1094
|
const searchService = new MockSearchService();
|
|
1070
1095
|
const el = await fixture<CollectionBrowser>(
|
|
@@ -682,6 +682,52 @@ export const getMockSuccessWithConciseDefaultSort: () => Result<
|
|
|
682
682
|
},
|
|
683
683
|
});
|
|
684
684
|
|
|
685
|
+
export const getMockSuccessWithDefaultFavSort: () => Result<
|
|
686
|
+
SearchResponse,
|
|
687
|
+
SearchServiceError
|
|
688
|
+
> = () => ({
|
|
689
|
+
success: {
|
|
690
|
+
request: {
|
|
691
|
+
kind: 'hits',
|
|
692
|
+
clientParameters: {
|
|
693
|
+
user_query: 'fav-sort',
|
|
694
|
+
sort: [],
|
|
695
|
+
},
|
|
696
|
+
backendRequests: {
|
|
697
|
+
primary: {
|
|
698
|
+
kind: 'hits',
|
|
699
|
+
finalized_parameters: {
|
|
700
|
+
user_query: 'fav-sort',
|
|
701
|
+
sort: [],
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
rawResponse: {},
|
|
707
|
+
response: {
|
|
708
|
+
totalResults: 1,
|
|
709
|
+
returnedCount: 1,
|
|
710
|
+
results: [
|
|
711
|
+
new ItemHit({
|
|
712
|
+
fields: {
|
|
713
|
+
identifier: 'foo',
|
|
714
|
+
title: 'Foo',
|
|
715
|
+
},
|
|
716
|
+
}),
|
|
717
|
+
],
|
|
718
|
+
collectionExtraInfo: {
|
|
719
|
+
public_metadata: {
|
|
720
|
+
identifier: 'fav-foo',
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
},
|
|
724
|
+
responseHeader: {
|
|
725
|
+
succeeded: true,
|
|
726
|
+
query_time: 0,
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
|
|
685
731
|
export const getMockErrorResult: () => Result<
|
|
686
732
|
SearchResponse,
|
|
687
733
|
SearchServiceError
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
getMockSuccessExtraQuotedHref,
|
|
25
25
|
getMockSuccessWithDefaultSort,
|
|
26
26
|
getMockSuccessWithConciseDefaultSort,
|
|
27
|
+
getMockSuccessWithDefaultFavSort,
|
|
27
28
|
} from './mock-search-responses';
|
|
28
29
|
|
|
29
30
|
const responses: Record<
|
|
@@ -43,6 +44,7 @@ const responses: Record<
|
|
|
43
44
|
'extra-quoted-href': getMockSuccessExtraQuotedHref,
|
|
44
45
|
'default-sort': getMockSuccessWithDefaultSort,
|
|
45
46
|
'default-sort-concise': getMockSuccessWithConciseDefaultSort,
|
|
47
|
+
'fav-sort': getMockSuccessWithDefaultFavSort,
|
|
46
48
|
error: getMockErrorResult,
|
|
47
49
|
malformed: getMockMalformedResult,
|
|
48
50
|
};
|