Skip to content

Commit

Permalink
Merge remote-tracking branch 'alex/w2p-100839_created-themeable-brows…
Browse files Browse the repository at this point in the history
…e-by-component_contribute-7.2' into atmire-contributions-august_contribute-7.6

# Conflicts:
#	src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts
#	src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.html
#	src/app/shared/shared.module.ts
#	src/themes/custom/entry-components.ts
#	src/themes/custom/lazy-theme.module.ts
  • Loading branch information
alexandrevryghem committed Aug 16, 2023
2 parents 15ba395 + 6487b5e commit 1a17664
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
const lastItemRD = this.browseService.getFirstItemFor(definition, scope, SortDirection.DESC);
this.subs.push(
observableCombineLatest([firstItemRD, lastItemRD]).subscribe(([firstItem, lastItem]) => {
let lowerLimit = this.getLimit(firstItem, metadataKeys, this.appConfig.browseBy.defaultLowerLimit);
let upperLimit = this.getLimit(lastItem, metadataKeys, new Date().getUTCFullYear());
const options = [];
const oneYearBreak = Math.floor((upperLimit - this.appConfig.browseBy.oneYearLimit) / 5) * 5;
const fiveYearBreak = Math.floor((upperLimit - this.appConfig.browseBy.fiveYearLimit) / 10) * 10;
let lowerLimit: number = this.getLimit(firstItem, metadataKeys, this.appConfig.browseBy.defaultLowerLimit);
let upperLimit: number = this.getLimit(lastItem, metadataKeys, new Date().getUTCFullYear());
const options: number[] = [];
const oneYearBreak: number = Math.floor((upperLimit - this.appConfig.browseBy.oneYearLimit) / 5) * 5;
const fiveYearBreak: number = Math.floor((upperLimit - this.appConfig.browseBy.fiveYearLimit) / 10) * 10;
if (lowerLimit <= fiveYearBreak) {
lowerLimit -= 10;
} else if (lowerLimit <= oneYearBreak) {
lowerLimit -= 5;
} else {
lowerLimit -= 1;
}
let i = upperLimit;
let i: number = upperLimit;
while (i > lowerLimit) {
options.push(i);
if (i <= fiveYearBreak) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<section class="comcol-page-browse-section">
<div class="browse-by-metadata w-100">
<ds-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
<ds-themed-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
title="{{'browse.title' | translate:
{
collection: dsoNameService.getName((parent$ | async)?.payload),
Expand All @@ -48,7 +48,7 @@
[startsWithOptions]="startsWithOptions"
(prev)="goPrev()"
(next)="goNext()">
</ds-browse-by>
</ds-themed-browse-by>
<ds-themed-loading *ngIf="!startsWithOptions" message="{{'loading.browse-by-page' | translate}}"></ds-themed-loading>
</div>
</section>
Expand Down
2 changes: 2 additions & 0 deletions src/app/browse-by/browse-by.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ThemedBrowseByTaxonomyPageComponent } from './browse-by-taxonomy-page/t
import { SharedBrowseByModule } from '../shared/browse-by/shared-browse-by.module';
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
import { FormModule } from '../shared/form/form.module';
import { SharedModule } from '../shared/shared.module';

const ENTRY_COMPONENTS = [
// put only entry components that use custom decorator
Expand All @@ -35,6 +36,7 @@ const ENTRY_COMPONENTS = [
ComcolModule,
DsoPageModule,
FormModule,
SharedModule,
],
declarations: [
BrowseBySwitcherComponent,
Expand Down
13 changes: 9 additions & 4 deletions src/app/shared/browse-by/shared-browse-by.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { NgModule } from '@angular/core';
import { BrowseByComponent } from './browse-by.component';
import { ThemedBrowseByComponent } from './themed-browse-by.component';
import { CommonModule } from '@angular/common';
import { SharedModule } from '../shared.module';
import { ResultsBackButtonModule } from '../results-back-button/results-back-button.module';
import { BrowseByRoutingModule } from '../../browse-by/browse-by-routing.module';
import { AccessControlRoutingModule } from '../../access-control/access-control-routing.module';

const DECLARATIONS = [
BrowseByComponent,
ThemedBrowseByComponent,
];

@NgModule({
declarations: [
BrowseByComponent,
],
...DECLARATIONS,
],
imports: [
ResultsBackButtonModule,
BrowseByRoutingModule,
Expand All @@ -18,8 +24,7 @@ import { AccessControlRoutingModule } from '../../access-control/access-control-
SharedModule,
],
exports: [
BrowseByComponent,
SharedModule,
...DECLARATIONS,
]
})
export class SharedBrowseByModule { }
76 changes: 76 additions & 0 deletions src/app/shared/browse-by/themed-browse-by.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { ThemedComponent } from '../theme-support/themed.component';
import { BrowseByComponent } from './browse-by.component';
import { Observable } from 'rxjs';
import { RemoteData } from '../../core/data/remote-data';
import { PaginatedList } from '../../core/data/paginated-list.model';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
import { SortOptions, SortDirection } from '../../core/cache/models/sort-options.model';
import { StartsWithType } from '../starts-with/starts-with-decorator';

/**
* Themed wrapper for {@link BrowseByComponent}
*/
@Component({
selector: 'ds-themed-browse-by',
styleUrls: [],
templateUrl: '../theme-support/themed.component.html',
})
export class ThemedBrowseByComponent extends ThemedComponent<BrowseByComponent> {

@Input() title: string;

@Input() parentname: string;

@Input() objects$: Observable<RemoteData<PaginatedList<ListableObject>>>;

@Input() paginationConfig: PaginationComponentOptions;

@Input() sortConfig: SortOptions;

@Input() type: StartsWithType;

@Input() startsWithOptions: number[];

@Input() showPaginator: boolean;

@Input() hideGear: boolean;

@Output() prev: EventEmitter<boolean> = new EventEmitter();

@Output() next: EventEmitter<boolean> = new EventEmitter();

@Output() pageSizeChange: EventEmitter<number> = new EventEmitter();

@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter();

protected inAndOutputNames: (keyof BrowseByComponent & keyof this)[] = [
'title',
'parentname',
'objects$',
'paginationConfig',
'sortConfig',
'type',
'startsWithOptions',
'showPaginator',
'hideGear',
'prev',
'next',
'pageSizeChange',
'sortDirectionChange',
];

protected getComponentName(): string {
return 'BrowseByComponent';
}

protected importThemedComponent(themeName: string): Promise<any> {
return import(`../../../themes/${themeName}/app/shared/browse-by/browse-by.component.ts`);
}

protected importUnthemedComponent(): Promise<any> {
return import('./browse-by.component');
}

}
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions src/themes/custom/app/shared/browse-by/browse-by.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component } from '@angular/core';
import { fadeIn, fadeInOut } from '../../../../../app/shared/animations/fade';
import { BrowseByComponent as BaseComponent } from '../../../../../app/shared/browse-by/browse-by.component';

@Component({
selector: 'ds-browse-by',
// styleUrls: ['./browse-by.component.scss'],
styleUrls: ['../../../../../app/shared/browse-by/browse-by.component.scss'],
// templateUrl: './browse-by.component.html',
templateUrl: '../../../../../app/shared/browse-by/browse-by.component.html',
animations: [
fadeIn,
fadeInOut,
],
})
export class BrowseByComponent extends BaseComponent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from '@angular/core';
import { BrowseEntry } from '../../../../../../app/core/shared/browse-entry.model';
import { ViewMode } from '../../../../../../app/core/shared/view-mode.model';
import { listableObjectComponent } from '../../../../../../app/shared/object-collection/shared/listable-object/listable-object.decorator';
import { Context } from '../../../../../../app/core/shared/context.model';
import {
BrowseEntryListElementComponent as BaseComponent
} from '../../../../../../app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component';

@Component({
selector: 'ds-browse-entry-list-element',
// styleUrls: ['./browse-entry-list-element.component.scss'],
styleUrls: ['../../../../../../app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.scss'],
// templateUrl: './browse-entry-list-element.component.html',
templateUrl: '../../../../../../app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html',
})
@listableObjectComponent(BrowseEntry, ViewMode.ListElement, Context.Any, 'custom')
export class BrowseEntryListElementComponent extends BaseComponent {
}
2 changes: 2 additions & 0 deletions src/themes/custom/eager-theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
} from './app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component';
import { TopLevelCommunityListComponent } from './app/home-page/top-level-community-list/top-level-community-list.component';
import { LogInComponent } from './app/shared/log-in/log-in.component';
import { BrowseEntryListElementComponent } from './app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component';


/**
Expand All @@ -76,6 +77,7 @@ const ENTRY_COMPONENTS = [
PublicationSidebarSearchListElementComponent,
ItemSearchResultListElementComponent,
TopLevelCommunityListComponent,
BrowseEntryListElementComponent,
];

const DECLARATIONS = [
Expand Down
2 changes: 2 additions & 0 deletions src/themes/custom/lazy-theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ import { ItemStatusComponent } from './app/item-page/edit-item-page/item-status/
import { EditBitstreamPageComponent } from './app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component';
import { FormModule } from '../../app/shared/form/form.module';
import { RequestCopyModule } from 'src/app/request-copy/request-copy.module';
import { BrowseByComponent } from './app/shared/browse-by/browse-by.component';

const DECLARATIONS = [
FileSectionComponent,
Expand Down Expand Up @@ -239,6 +240,7 @@ const DECLARATIONS = [
SubmissionSectionUploadFileComponent,
ItemStatusComponent,
EditBitstreamPageComponent,
BrowseByComponent,
];

@NgModule({
Expand Down

0 comments on commit 1a17664

Please sign in to comment.