Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

150 list and grid feedback #202

Merged
merged 49 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d2135ab
#150 Initial grid/list view implementation
jonas-atmire Oct 26, 2017
a65dd80
#150 SortOptions config fixing
jonas-atmire Oct 31, 2017
1acd8a9
#150 Pre grid/list decorator generalisation commit
jonas-atmire Oct 31, 2017
6a4500b
#150 Intermediate commit
jonas-atmire Oct 31, 2017
0032a73
#150 Intermediate commit
jonas-atmire Nov 2, 2017
7d982ad
#150 Intermediate commit
jonas-atmire Nov 2, 2017
7273539
#150 Safety-commit before moving to "shared" package
jonas-atmire Nov 3, 2017
7adfa5b
#150 Moved list,grid and object-collection to shared package
jonas-atmire Nov 3, 2017
2aa8bdf
150 Backup commit
jonas-atmire Nov 6, 2017
1a2c74d
#150 Grid element testing
jonas-atmire Nov 6, 2017
78cbc48
#150 Removal of inherited css + restyling using bootstrap classes
jonas-atmire Nov 13, 2017
aabc683
Additional IDE generated files ignored
jonas-atmire Nov 14, 2017
9957711
#150 Removal of iml file + small margin between pagination and grid
jonas-atmire Nov 15, 2017
cb15939
#150 Merge fixes
jonas-atmire Nov 15, 2017
9a16812
#150 Generalised AbstractListableElementComponent instead of grid/lis…
jonas-atmire Nov 17, 2017
806b7bc
150 Separate maps per viewMode
jonas-atmire Nov 21, 2017
1ac9bc0
#150 Rollback to previous state (not part of this issue)
jonas-atmire Nov 21, 2017
17dec3d
#150 Avoid first "null" download for initial content
jonas-atmire Nov 22, 2017
02e6c89
#150 Fixing rebase errors
jonas-atmire Nov 30, 2017
a704157
#150 Initial grid/list view implementation
jonas-atmire Oct 26, 2017
17f839f
#150 SortOptions config fixing
jonas-atmire Oct 31, 2017
c5bfbea
#150 Pre grid/list decorator generalisation commit
jonas-atmire Oct 31, 2017
491d40c
#150 Intermediate commit
jonas-atmire Oct 31, 2017
e7e129f
#150 Intermediate commit
jonas-atmire Nov 2, 2017
67356ef
#150 Intermediate commit
jonas-atmire Nov 2, 2017
cc4aaa4
#150 Safety-commit before moving to "shared" package
jonas-atmire Nov 3, 2017
520b7f3
#150 Moved list,grid and object-collection to shared package
jonas-atmire Nov 3, 2017
0421806
150 Backup commit
jonas-atmire Nov 6, 2017
68dd411
#150 Grid element testing
jonas-atmire Nov 6, 2017
7ae8950
#150 Removal of inherited css + restyling using bootstrap classes
jonas-atmire Nov 13, 2017
9be1d59
Additional IDE generated files ignored
jonas-atmire Nov 14, 2017
ee099e2
#150 Removal of iml file + small margin between pagination and grid
jonas-atmire Nov 15, 2017
d1b225b
#150 Merge fixes
jonas-atmire Nov 15, 2017
db0db81
#150 Generalised AbstractListableElementComponent instead of grid/lis…
jonas-atmire Nov 17, 2017
d045b67
150 Separate maps per viewMode
jonas-atmire Nov 21, 2017
e331f7e
#150 Rollback to previous state (not part of this issue)
jonas-atmire Nov 21, 2017
27ae938
#150 Avoid first "null" download for initial content
jonas-atmire Nov 22, 2017
b86905a
#150 Fixing rebase errors
jonas-atmire Nov 30, 2017
78ba105
Merge remote-tracking branch 'origin/150-List-and-grid-feedback' into…
jonas-atmire Dec 1, 2017
9b81210
#150 Fixing path to use relative import
jonas-atmire Dec 1, 2017
1f873ac
#150 TSLint error fixing
jonas-atmire Dec 1, 2017
5061cee
#150 Payload compatibility fix
jonas-atmire Dec 1, 2017
23afe33
Merge remote-tracking branch 'community/master' into 150-List-and-gri…
jonas-atmire Dec 7, 2017
8270587
#150 Mive object-list.component test to correct package + delete empt…
jonas-atmire Dec 7, 2017
4a56bd0
#150 Feedback fixes
jonas-atmire Dec 19, 2017
df31790
#150 Remove incorrectly referencing searchOptions
jonas-atmire Dec 20, 2017
0e4c93b
#150 Separate pageSizeOptions for list and grid
jonas-atmire Dec 20, 2017
c89e343
#150 Get component's pageSizeOptions
jonas-atmire Dec 21, 2017
bbd6dcd
#150 alligning statements....
jonas-atmire Jan 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ npm-debug.log
/coverage/

.idea
*.iml
*.ngfactory.ts
*.css.shim.ts
*.scss.shim.ts
Expand Down
4 changes: 2 additions & 2 deletions src/app/+collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
<ng-container *ngVar="(itemRDObs | async) as itemRD">
<div *ngIf="itemRD?.hasSucceeded" @fadeIn>
<h2>{{'collection.page.browse.recent.head' | translate}}</h2>
<ds-object-list
<ds-viewable-collection
[config]="paginationConfig"
[sortConfig]="sortConfig"
[objects]="itemRD"
[hideGear]="false"
(paginationChange)="onPaginationChange($event)">
</ds-object-list>
</ds-viewable-collection>
</div>
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.recent-submissions' | translate}}"></ds-error>
<ds-loading *ngIf="!itemRD || itemRD.isLoading" message="{{'loading.recent-submissions' | translate}}"></ds-loading>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<ng-container *ngVar="(communitiesRDObs | async) as communitiesRD">
<div *ngIf="communitiesRD?.hasSucceeded" @fadeInOut>
<h2>{{'home.top-level-communities.head' | translate}}</h2>
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
<ds-object-list
[config]="config"
[sortConfig]="sortConfig"
[objects]="communitiesRD"
[hideGear]="true"
(paginationChange)="updatePage($event)">
</ds-object-list>
</div>
<ds-error *ngIf="communitiesRD?.hasFailed" message="{{'error.top-level-communites' | translate}}"></ds-error>
<ds-loading *ngIf="communitiesRD?.isLoading" message="{{'loading.top-level-communities' | translate}}"></ds-loading>
</ng-container>
<div *ngIf="communitiesRD?.hasSucceeded " @fadeInOut>
<h2>{{'home.top-level-communities.head' | translate}}</h2>
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
<ds-viewable-collection
[config]="config"
[sortConfig]="sortConfig"
[objects]="communitiesRD"
(paginationChange)="updatePage($event)">
</ds-viewable-collection>
</div>
<ds-error *ngIf="communitiesRD?.hasFailed " message="{{'error.top-level-communites' | translate}}"></ds-error>
<ds-loading *ngIf="communitiesRD?.isLoading " message="{{'loading.top-level-communities' | translate}}"></ds-loading></ng-container>
2 changes: 1 addition & 1 deletion src/app/+search-page/search-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</button>
</div>
<ds-search-results [searchResults]="resultsRDObs | async"
[searchConfig]="searchOptions"></ds-search-results>
[searchConfig]="searchOptions" [sortConfig]="sortConfig"></ds-search-results>
</div>
</div>
</div>
Expand Down
32 changes: 29 additions & 3 deletions src/app/+search-page/search-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { RemoteData } from '../core/data/remote-data';
import { Community } from '../core/shared/community.model';
import { DSpaceObject } from '../core/shared/dspace-object.model';
import { isNotEmpty } from '../shared/empty.util';
import { SearchOptions } from './search-options.model';
import { SearchOptions,ViewMode } from './search-options.model';
import { SearchResult } from './search-result.model';
import { SearchService } from './search-service/search.service';
import { pushInOut } from '../shared/animations/push';
import { HostWindowService } from '../shared/host-window.service';
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { SortOptions } from '../core/cache/models/sort-options.model';

/**
* This component renders a simple item page.
Expand All @@ -36,6 +38,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {
resultsRDObs: Observable<RemoteData<Array<SearchResult<DSpaceObject>>>>;
currentParams = {};
searchOptions: SearchOptions;
sortConfig: SortOptions;
scopeListRDObs: Observable<RemoteData<Community[]>>;
isMobileView: Observable<boolean>;

Expand All @@ -51,6 +54,13 @@ export class SearchPageComponent implements OnInit, OnDestroy {
);
this.scopeListRDObs = communityService.findAll();
// Initial pagination config
const pagination: PaginationComponentOptions = new PaginationComponentOptions();
pagination.id = 'search-results-pagination';
pagination.currentPage = 1;
pagination.pageSize = 10;

const sort: SortOptions = new SortOptions();
this.sortConfig = sort;
this.searchOptions = this.service.searchOptions;
}

Expand All @@ -63,16 +73,31 @@ export class SearchPageComponent implements OnInit, OnDestroy {
this.query = params.query || '';
this.scope = params.scope;
const page = +params.page || this.searchOptions.pagination.currentPage;
const pageSize = +params.pageSize || this.searchOptions.pagination.pageSize;
let pageSize = +params.pageSize || this.searchOptions.pagination.pageSize;
let pageSizeOptions: number[] = [5, 10, 20, 40, 60, 80, 100];

if (isNotEmpty(params.view) && params.view === ViewMode.Grid) {
pageSizeOptions = [12, 24, 36, 48 , 50, 62, 74, 84];
if (pageSizeOptions.indexOf(pageSize) === -1) {
pageSize = 12;
}
}
if (isNotEmpty(params.view) && params.view === ViewMode.List) {
if (pageSizeOptions.indexOf(pageSize) === -1) {
pageSize = 10;
}
}

const sortDirection = +params.sortDirection || this.searchOptions.sort.direction;
const pagination = Object.assign({},
this.searchOptions.pagination,
{ currentPage: page, pageSize: pageSize }
{ currentPage: page, pageSize: pageSize, pageSizeOptions: pageSizeOptions}
);
const sort = Object.assign({},
this.searchOptions.sort,
{ direction: sortDirection, field: params.sortField }
);

this.updateSearchResults({
pagination: pagination,
sort: sort
Expand All @@ -88,6 +113,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {

private updateSearchResults(searchOptions) {
this.resultsRDObs = this.service.search(this.query, this.scope, searchOptions);
this.searchOptions = searchOptions;
}

ngOnDestroy() {
Expand Down
21 changes: 16 additions & 5 deletions src/app/+search-page/search-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { SharedModule } from '../shared/shared.module';
import { SearchPageRoutingModule } from './search-page-routing.module';
import { SearchPageComponent } from './search-page.component';
import { SearchResultsComponent } from './search-results/search-results.component';
import { ItemSearchResultListElementComponent } from '../object-list/search-result-list-element/item-search-result/item-search-result-list-element.component';
import { CollectionSearchResultListElementComponent } from '../object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component';
import { CommunitySearchResultListElementComponent } from '../object-list/search-result-list-element/community-search-result/community-search-result-list-element.component';
import { ItemSearchResultListElementComponent } from '../shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component';
import { CollectionSearchResultListElementComponent } from '../shared/object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component';
import { CommunitySearchResultListElementComponent } from '../shared/object-list/search-result-list-element/community-search-result/community-search-result-list-element.component';
import { ItemSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component';
import { CommunitySearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component'
import { CollectionSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component';
import { SearchService } from './search-service/search.service';
import { SearchSidebarComponent } from './search-sidebar/search-sidebar.component';
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
Expand Down Expand Up @@ -37,6 +40,10 @@ const effects = [
ItemSearchResultListElementComponent,
CollectionSearchResultListElementComponent,
CommunitySearchResultListElementComponent,
ItemSearchResultGridElementComponent,
CollectionSearchResultGridElementComponent,
CommunitySearchResultGridElementComponent,
CommunitySearchResultListElementComponent,
SearchFiltersComponent,
SearchFilterComponent,
SearchFacetFilterComponent
Expand All @@ -49,7 +56,11 @@ const effects = [
entryComponents: [
ItemSearchResultListElementComponent,
CollectionSearchResultListElementComponent,
CommunitySearchResultListElementComponent
CommunitySearchResultListElementComponent,
ItemSearchResultGridElementComponent,
CollectionSearchResultGridElementComponent,
CommunitySearchResultGridElementComponent,
]
})
export class SearchPageModule { }
export class SearchPageModule {
}
2 changes: 1 addition & 1 deletion src/app/+search-page/search-result.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DSpaceObject } from '../core/shared/dspace-object.model';
import { Metadatum } from '../core/shared/metadatum.model';
import { ListableObject } from '../object-list/listable-object/listable-object.model';
import { ListableObject } from '../shared/object-collection/shared/listable-object.model';

export class SearchResult<T extends DSpaceObject> implements ListableObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div *ngIf="searchResults?.hasSucceeded" @fadeIn>
<h2 *ngIf="searchResults?.payload ?.length > 0">{{ 'search.results.head' | translate }}</h2>
<ds-object-list
<ds-viewable-collection
[config]="searchConfig.pagination"
[sortConfig]="searchConfig.sort"
[objects]="searchResults"
[hideGear]="true">
</ds-object-list></div>
</ds-viewable-collection></div>
<ds-loading *ngIf="searchResults?.isLoading" message="{{'loading.search-results' | translate}}"></ds-loading>
<ds-error *ngIf="searchResults?.hasFailed" message="{{'error.search-results' | translate}}"></ds-error>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Component, Input } from '@angular/core';
import { RemoteData } from '../../core/data/remote-data';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
import { SearchOptions } from '../search-options.model';
import { SearchOptions, ViewMode } from '../search-options.model';
import { SortOptions } from '../../core/cache/models/sort-options.model';
import { SearchResult } from '../search-result.model';

/**
Expand All @@ -21,4 +22,6 @@ import { SearchResult } from '../search-result.model';
export class SearchResultsComponent {
@Input() searchResults: RemoteData<Array<SearchResult<DSpaceObject>>>;
@Input() searchConfig: SearchOptions;
@Input() sortConfig: SortOptions;
@Input() viewMode: ViewMode;
}
4 changes: 2 additions & 2 deletions src/app/+search-page/search-service/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { SearchOptions } from '../search-options.model';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { Metadatum } from '../../core/shared/metadatum.model';
import { Item } from '../../core/shared/item.model';
import { ItemSearchResult } from '../../object-list/search-result-list-element/item-search-result/item-search-result.model';
import { SearchFilterConfig } from './search-filter-config.model';
import { FilterType } from './filter-type.model';
import { FacetValue } from './facet-value.model';
import { ItemSearchResult } from '../../shared/object-collection/shared/item-search-result.model';
import { ViewMode } from '../../+search-page/search-options.model';
import { Router, NavigationExtras, ActivatedRoute } from '@angular/router';
import { RouteService } from '../../shared/route.service';
Expand Down Expand Up @@ -100,7 +100,7 @@ export class SearchService implements OnDestroy {
}

search(query: string, scopeId?: string, searchOptions?: SearchOptions): Observable<RemoteData<Array<SearchResult<DSpaceObject>>>> {
this.searchOptions = this.searchOptions;
this.searchOptions = searchOptions;
let self = `https://dspace7.4science.it/dspace-spring-rest/api/search?query=${query}`;
if (hasValue(scopeId)) {
self += `&scope=${scopeId}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h5>{{ 'search.sidebar.settings.sort-by' | translate}}</h5>
<h5>{{ 'search.sidebar.settings.rpp' | translate}}</h5>

<select class="form-control" (change)="reloadRPP($event)">
<option *ngFor="let item of searchOptions.pagination.pageSizeOptions" [value]="item"
<option *ngFor="let item of pageSizeOptions" [value]="item"
[selected]="item === searchOptions.pagination.pageSize ? 'selected': null">
{{item}}
</option>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { SearchService } from '../search-service/search.service';
import { SearchOptions } from '../search-options.model';
import { SearchOptions, ViewMode } from '../search-options.model';
import { SortDirection } from '../../core/cache/models/sort-options.model';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';

Expand All @@ -20,6 +20,9 @@ export class SearchSettingsComponent implements OnInit {
* Number of items per page.
*/
public pageSize;
@Input() public pageSizeOptions;
public listPageSizeOptions: number[] = [5, 10, 20, 40, 60, 80, 100];
public gridPageSizeOptions: number[] = [12, 24, 36, 48 , 50, 62, 74, 84];

private sub;
private scope: string;
Expand All @@ -36,6 +39,7 @@ export class SearchSettingsComponent implements OnInit {
ngOnInit(): void {
this.searchOptions = this.service.searchOptions;
this.pageSize = this.searchOptions.pagination.pageSize;
this.pageSizeOptions = this.searchOptions.pagination.pageSizeOptions;
this.sub = this.route
.queryParams
.subscribe((params) => {
Expand All @@ -45,6 +49,11 @@ export class SearchSettingsComponent implements OnInit {
this.page = +params.page || this.searchOptions.pagination.currentPage;
this.pageSize = +params.pageSize || this.searchOptions.pagination.pageSize;
this.direction = +params.sortDirection || this.searchOptions.sort.direction;
if (params.view === ViewMode.Grid) {
this.pageSizeOptions = this.gridPageSizeOptions;
} else {
this.pageSizeOptions = this.listPageSizeOptions;
}
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/app/core/data/browse-response-parsing.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BrowseResponseParsingService } from './browse-response-parsing.service'
import { BrowseEndpointRequest } from './request.models';
import { BrowseSuccessResponse, ErrorResponse } from '../cache/response-cache.models';
import { BrowseDefinition } from '../shared/browse-definition.model';
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';

describe('BrowseResponseParsingService', () => {
let service: BrowseResponseParsingService;
Expand Down Expand Up @@ -48,7 +49,7 @@ describe('BrowseResponseParsingService', () => {
_links: { self: { href: 'https://rest.api/discover/browses' } },
page: { size: 20, totalElements: 2, totalPages: 1, number: 0 }
}, statusCode: '200'
};
} as DSpaceRESTV2Response;

const invalidResponse1 = {
payload: {
Expand All @@ -71,22 +72,21 @@ describe('BrowseResponseParsingService', () => {
_links: { self: { href: 'https://rest.api/discover/browses' } },
page: { size: 20, totalElements: 2, totalPages: 1, number: 0 }
}, statusCode: '200'
};
} as DSpaceRESTV2Response;

const invalidResponse2 = {
payload: {
browses: [{}, {}],
_links: { self: { href: 'https://rest.api/discover/browses' } },
page: { size: 20, totalElements: 2, totalPages: 1, number: 0 }
}, statusCode: '200'
};
} as DSpaceRESTV2Response ;

const invalidResponse3 = {
payload: {
_links: { self: { href: 'https://rest.api/discover/browses' } },
page: { size: 20, totalElements: 2, totalPages: 1, number: 0 }
}, statusCode: '500'
};
} as DSpaceRESTV2Response;

const definitions = [
Object.assign(new BrowseDefinition(), {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/dspace-object.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isEmpty, isNotEmpty } from '../../shared/empty.util';
import { CacheableObject } from '../cache/object-cache.reducer';
import { RemoteData } from '../data/remote-data';
import { ResourceType } from './resource-type';
import { ListableObject } from '../../object-list/listable-object/listable-object.model';
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
import { Observable } from 'rxjs/Observable';

/**
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.