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KAAkCjB,UAL9CgB,OAAU,CACPc,SAAU,mCACVC,SCNW,+/BDSFd,2CEARhB,wFAAiB,KAClB+B,sBACAzC,8BAMS0C,EAAoB,cAASC,sCACtCvB,WAAwB,IAExBF,MAAM0B,EAAe1C,EAAiB,GAClCE,KAAKS,MAAMC,OAAOR,iBAA6BD,MAAK,OAAK,IAAIE,UAAUJ,IACnE,QAAI,MACA,MAAM,IAAIc,MAAM,+CAGpBb,KAAKS,MAAMQ,SAASf,4BAAsC,CAACuC,SAAU1C,EAAKgC,KAAMjB,QAAO4B,SAAQC,OAAO,aAAI3B,YAIlH4B,kBACI,OAAO,aAAI5B,OAGfJ,kBACI,MAAO,cAGXG,mBAAmByB,GACf,OAAQA,EAAKK,WACJvC,EAAkB+B,UACnB,OAAOhB,SAENf,EAAkBwC,WACnB,OAAOxB,YAGP,MAAM,IAAIT,MAAM,oCAAoC2B,EAAKK,0BA9B5DP,KAAoBjC,UAHhCe,OAAW,CACR2B,WAAY,UAEHT","names":["s","constructor","l","m","this","pipe","a","subscribe","h","o","r","call","fetchPage","store","select","b","getDatasourceId","Error","query","getComponentByItem","e","dispatch","datasourceId","searchResults","f","y","t","setData","data","ngOnInit","title","highlights","subTitle","routerLink","book","uuid","chapter","document","dpsId","selector","template","Paragraph","d","c","u","bookUuid","offset","limit","getItemsPerPage","type","Assignment","providedIn"],"sources":["./src/app/core/search/contract/abstract-search-datasource.service.ts","./src/app/features/books/components/search-result-assignment/search-result-assignment.component.ts","./src/app/features/books/components/search-result-assignment/search-result-assignment.component.html","./src/app/features/books/components/search-result-document/search-result-document.component.ts","./src/app/features/books/components/search-result-document/search-result-document.component.html","./src/app/features/books/datasource/book-search.datasource.ts"],"sourcesContent":["import {ActionsSubject, Store} from '@ngrx/store';\nimport {ofType} from '@ngrx/effects';\nimport {SearchActions} from '@store/search';\nimport {Injectable, Type} from '@angular/core';\nimport {SearchResultsInterface} from '@core/search/component/search/search.component';\nimport {take} from 'rxjs/operators';\nimport {SearchSelectors} from '@store/search/search.selectors';\nimport {SearchResultInterface} from '@shared/interfaces/search.interface';\nimport {AbstractSearchResultComponent} from '@core/search/contract/search-component.contract';\nimport {SearchResultComponent} from '@core/search/component/result/search-result.component';\n\n@Injectable()\nexport abstract class AbstractSearchDatasource {\n maxDisplayedPages: number = 10;\n\n minDisplayedPages: number = 3;\n\n abstract query(query: string, offset: number): void;\n\n abstract getDatasourceId(): string;\n\n abstract getItemsPerPage(): number;\n\n constructor(protected store: Store, actionsSubject: ActionsSubject) {\n actionsSubject.pipe(ofType(SearchActions.fetchResultsSuccess)).subscribe(results => this.#handleFetchResultsSuccess(results));\n }\n\n /**\n * This method is connected to the paginator that passes page numbers\n */\n fetchPage(page: number): void {\n this.store.select(SearchSelectors.selectResultsByDataSourceId(this.getDatasourceId())).pipe(take(1)).subscribe(results => {\n if (undefined === results) {\n throw new Error(`Unable to fetch next page, current result is undefined for datasource \"${this.getDatasourceId()}\"`);\n }\n\n this.query(results.query, page - 1);\n });\n }\n\n getComponentByItem(item: ItemType): Type {\n return SearchResultComponent;\n }\n\n /**\n * Put results in state in case we load the results from another route\n */\n #handleFetchResultsSuccess(searchResults: SearchResultsInterface): void {\n this.store.dispatch(SearchActions.setSearchResults({datasourceId: this.getDatasourceId(), searchResults}));\n }\n}\n","import {SearchResultProgressInterface} from '@shared/interfaces/search.interface';\nimport {AbstractSearchResultComponent} from '@core/search/contract/search-component.contract';\nimport {Component, OnInit} from '@angular/core';\n\n@Component({\n selector: 'app-books-search-assignment-result',\n templateUrl: './search-result-assignment.component.html',\n styleUrls: ['./search-result-assignment.component.scss'],\n})\nexport class BooksSearchAssignmentResultComponent extends AbstractSearchResultComponent implements OnInit {\n public data!: SearchResultProgressInterface;\n\n public title!: string;\n\n public subTitle!: string;\n\n public routerLink!: string[];\n\n public setData(data: SearchResultProgressInterface): void {\n this.data = data;\n }\n\n public ngOnInit(): void {\n this.title = this.data.highlights.title;\n this.subTitle = this.data.highlights.subTitle;\n this.routerLink = ['/books', this.data.book.uuid, 'chapters', this.data.chapter.uuid, 'documents', this.data.document.dpsId];\n }\n}\n","export default \"\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n \\n \\n
\\n
\\n
\\n \\n
\\n
\\n
\\n\";","import {SearchResultProgressInterface} from '@shared/interfaces/search.interface';\nimport {AbstractSearchResultComponent} from '@core/search/contract/search-component.contract';\nimport {Component, OnInit} from '@angular/core';\n\n@Component({\n selector: 'app-books-search-document-result',\n templateUrl: './search-result-document.component.html',\n styleUrls: ['./search-result-document.component.scss'],\n})\nexport class BooksSearchDocumentResultComponent extends AbstractSearchResultComponent implements OnInit {\n public data!: SearchResultProgressInterface;\n\n public title!: string;\n\n public subTitle!: string;\n\n public routerLink!: string[];\n\n public setData(data: SearchResultProgressInterface): void {\n this.data = data;\n }\n\n public ngOnInit(): void {\n this.title = this.data.highlights.title;\n this.subTitle = this.data.highlights.subTitle;\n this.routerLink = ['/books', this.data.book.uuid, 'chapters', this.data.chapter.uuid, 'documents', this.data.document.dpsId];\n }\n}\n","export default \"\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n \\n \\n
\\n
\\n
\\n \\n
\\n
\\n
\\n\";","import {Injectable, Type} from '@angular/core';\nimport {AbstractSearchDatasource} from '@core/search/contract/abstract-search-datasource.service';\nimport {LibraryActions, LibrarySelectors} from '@store/library';\nimport {BooksSearchDocumentResultComponent} from '@feature/books/components/search-result-document/search-result-document.component';\nimport {AbstractSearchResultComponent} from '@core/search/contract/search-component.contract';\nimport {SearchTypedResultInterface} from '@shared/interfaces/search.interface';\nimport {BooksSearchAssignmentResultComponent} from '@feature/books/components/search-result-assignment/search-result-assignment.component';\nimport {take} from 'rxjs/operators';\n\nenum BookItemTypesEnum {\n Paragraph = 'paragraph',\n Assignment = 'assignment',\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class BookSearchDatasource extends AbstractSearchDatasource {\n #itemsPerPage: number = 10;\n\n query(query: string, offset: number = 0): void {\n this.store.select(LibrarySelectors.selectBook).pipe(take(1)).subscribe(book => {\n if (undefined === book) {\n throw new Error('Unable to execute search, book is undefined');\n }\n\n this.store.dispatch(LibraryActions.fetchBookSearchResults({bookUuid: book.uuid, query, offset, limit: this.#itemsPerPage}));\n });\n }\n\n getItemsPerPage(): number {\n return this.#itemsPerPage;\n }\n\n getDatasourceId(): string {\n return 'book-search';\n }\n\n getComponentByItem(item: SearchTypedResultInterface): Type {\n switch (item.type) {\n case BookItemTypesEnum.Paragraph:\n return BooksSearchDocumentResultComponent;\n\n case BookItemTypesEnum.Assignment:\n return BooksSearchAssignmentResultComponent;\n\n default:\n throw new Error(`Unsupported search result type: \"${item.type}\"`);\n }\n }\n}\n"],"sourceRoot":"webpack:///","file":"526.e928354b336a6071a211.js"}