Skip to content

Commit

Permalink
Merge branch CST-5249_suggestion of https://github.com/4Science/DSpace
Browse files Browse the repository at this point in the history
…into CST-11299
  • Loading branch information
frabacche committed Aug 22, 2023
1 parent f31d4d5 commit 9b556fd
Show file tree
Hide file tree
Showing 27 changed files with 193 additions and 62 deletions.
1 change: 1 addition & 0 deletions src/app/core/cache/builders/remote-data-build.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export class RemoteDataBuildService {
} else {
// in case the elements of the paginated list were already filled in, because they're UnCacheableObjects
paginatedList.page = paginatedList.page
.filter((obj: any) => obj != null)
.map((obj: any) => this.plainObjectToInstance<T>(obj))
.map((obj: any) =>
this.linkService.resolveLinks(obj, ...pageLink.linksToFollow)
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ import { FlatBrowseDefinition } from './shared/flat-browse-definition.model';
import { ValueListBrowseDefinition } from './shared/value-list-browse-definition.model';
import { NonHierarchicalBrowseDefinition } from './shared/non-hierarchical-browse-definition';
import { BulkAccessConditionOptions } from './config/models/bulk-access-condition-options.model';
import { SuggestionTarget } from './suggestion-notifications/reciter-suggestions/models/suggestion-target.model';
import { SuggestionSource } from './suggestion-notifications/reciter-suggestions/models/suggestion-source.model';

/**
* When not in production, endpoint responses can be mocked for testing purposes
Expand Down Expand Up @@ -386,7 +388,9 @@ export const models =
IdentifierData,
Subscription,
ItemRequest,
BulkAccessConditionOptions
BulkAccessConditionOptions,
SuggestionTarget,
SuggestionSource
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
import { ResourceType } from '../../../shared/resource-type';

/**
* The resource type for the Suggestion Target object
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const SUGGESTION_TARGET = new ResourceType('suggestiontarget');

/**
* The resource type for the Suggestion Source object
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const SUGGESTION_SOURCE = new ResourceType('suggestionsource');

/**
* The resource type for the Suggestion object
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ResourceType } from '../../../shared/resource-type';

/**
* The resource type for the Suggestion Source object
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const SUGGESTION_SOURCE = new ResourceType('suggestionsource');
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { autoserialize, deserialize } from 'cerialize';

import { SUGGESTION_SOURCE } from './suggestion-objects.resource-type';
import { SUGGESTION_SOURCE } from './suggestion-source-object.resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { ResourceType } from '../../../shared/resource-type';
import { HALLink } from '../../../shared/hal-link.model';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ResourceType } from '../../../shared/resource-type';

/**
* The resource type for the Suggestion Target object
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const SUGGESTION_TARGET = new ResourceType('suggestiontarget');
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { autoserialize, deserialize } from 'cerialize';


import { CacheableObject } from '../../../cache/cacheable-object.model';
import { SUGGESTION_TARGET } from './suggestion-objects.resource-type';
import { SUGGESTION_TARGET } from './suggestion-target-object.resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { ResourceType } from '../../../shared/resource-type';
import { HALLink } from '../../../shared/hal-link.model';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { dataService } from '../../../data/base/data-service.decorator';
import { SUGGESTION_SOURCE } from '../models/suggestion-objects.resource-type';
import { SUGGESTION_SOURCE } from '../models/suggestion-source-object.resource-type';
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { SuggestionSource } from '../models/suggestion-source.model';
import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ export class SuggestionsDataService {
...linksToFollow: FollowLinkConfig<SuggestionTarget>[]
): Observable<RemoteData<PaginatedList<SuggestionTarget>>> {
options.searchParams = [new RequestParam('target', userId)];

return this.suggestionTargetsDataService.getTargetsByUser(this.searchFindByTargetMethod, options, ...linksToFollow);
//return this.suggestionTargetsDataService.getTargetsByUser(this.searchFindByTargetMethod, options, ...linksToFollow);
return this.suggestionTargetsDataService.getTargetsByUser(userId, options, ...linksToFollow);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { dataService } from '../../../data/base/data-service.decorator';
import { SUGGESTION_TARGET } from '../models/suggestion-objects.resource-type';

import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
import { SuggestionTarget } from '../models/suggestion-target.model';
import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data';
Expand All @@ -20,6 +20,7 @@ import { Observable } from 'rxjs/internal/Observable';
import { RequestParam } from '../../../cache/models/request-param.model';
import { SearchData, SearchDataImpl } from '../../../data/base/search-data';
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
import { SUGGESTION_TARGET } from '../models/suggestion-target-object.resource-type';

@Injectable()
@dataService(SUGGESTION_TARGET)
Expand Down
1 change: 1 addition & 0 deletions src/app/home-page/home-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
<ds-themed-top-level-community-list></ds-themed-top-level-community-list>
<ds-recent-item-list *ngIf="recentSubmissionspageSize>0"></ds-recent-item-list>
</div>
<ds-suggestions-popup></ds-suggestions-popup>
18 changes: 10 additions & 8 deletions src/app/home-page/home-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { RecentItemListComponent } from './recent-item-list/recent-item-list.com
import { JournalEntitiesModule } from '../entity-groups/journal-entities/journal-entities.module';
import { ResearchEntitiesModule } from '../entity-groups/research-entities/research-entities.module';
import { ThemedTopLevelCommunityListComponent } from './top-level-community-list/themed-top-level-community-list.component';
import { SuggestionNotificationsModule } from '../suggestion-notifications/suggestion-notifications.module';

const DECLARATIONS = [
HomePageComponent,
Expand All @@ -25,14 +26,15 @@ const DECLARATIONS = [
];

@NgModule({
imports: [
CommonModule,
SharedModule.withEntryComponents(),
JournalEntitiesModule.withEntryComponents(),
ResearchEntitiesModule.withEntryComponents(),
HomePageRoutingModule,
StatisticsModule.forRoot()
],
imports: [
CommonModule,
SharedModule.withEntryComponents(),
JournalEntitiesModule.withEntryComponents(),
ResearchEntitiesModule.withEntryComponents(),
HomePageRoutingModule,
StatisticsModule.forRoot(),
SuggestionNotificationsModule
],
declarations: [
...DECLARATIONS,
],
Expand Down
12 changes: 12 additions & 0 deletions src/app/menu.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
import {
ExportBatchSelectorComponent
} from './shared/dso-selector/modal-wrappers/export-batch-selector/export-batch-selector.component';
import { NOTIFICATIONS_RECITER_SUGGESTION_PATH } from './admin/admin-notifications/admin-notifications-routing-paths';

/**
* Creates all of the app's menus
Expand Down Expand Up @@ -555,6 +556,17 @@ export class MenuResolver implements Resolve<boolean> {
link: '/admin/notifications/quality-assurance'
} as LinkMenuItemModel,
},
{
id: 'notifications_reciter',
parentID: 'notifications',
active: false,
visible: authorized,
model: {
type: MenuItemType.LINK,
text: 'menu.section.notifications_reciter',
link: '/admin/notifications/' + NOTIFICATIONS_RECITER_SUGGESTION_PATH
} as LinkMenuItemModel,
},
/* Admin Search */
{
id: 'admin_search',
Expand Down
1 change: 1 addition & 0 deletions src/app/my-dspace-page/my-dspace-page.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="container">
<ds-my-dspace-new-submission *dsShowOnlyForRole="[roleTypeEnum.Submitter]"></ds-my-dspace-new-submission>
<ds-suggestions-notification></ds-suggestions-notification>
</div>

<ds-themed-search *ngIf="configuration && context"
Expand Down
18 changes: 10 additions & 8 deletions src/app/my-dspace-page/my-dspace-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MyDSpaceNewExternalDropdownComponent } from './my-dspace-new-submission
import { ThemedMyDSpacePageComponent } from './themed-my-dspace-page.component';
import { SearchModule } from '../shared/search/search.module';
import { UploadModule } from '../shared/upload/upload.module';
import { SuggestionNotificationsModule } from '../suggestion-notifications/suggestion-notifications.module';

const DECLARATIONS = [
MyDSpacePageComponent,
Expand All @@ -26,14 +27,15 @@ const DECLARATIONS = [
];

@NgModule({
imports: [
CommonModule,
SharedModule,
SearchModule,
MyDspacePageRoutingModule,
MyDspaceSearchModule.withEntryComponents(),
UploadModule,
],
imports: [
CommonModule,
SharedModule,
SearchModule,
MyDspacePageRoutingModule,
MyDspaceSearchModule.withEntryComponents(),
UploadModule,
SuggestionNotificationsModule,
],
declarations: DECLARATIONS,
providers: [
MyDSpaceGuard,
Expand Down
1 change: 1 addition & 0 deletions src/app/profile-page/profile-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h3 class="mb-4">{{'profile.head' | translate}}</h3>
<div class="mb-4">
<ds-profile-page-researcher-form [user]="user" ></ds-profile-page-researcher-form>
</div>
<ds-suggestions-notification></ds-suggestions-notification>
</div>
</div>
</ng-container>
Expand Down
16 changes: 9 additions & 7 deletions src/app/profile-page/profile-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import { ThemedProfilePageComponent } from './themed-profile-page.component';
import { FormModule } from '../shared/form/form.module';
import { UiSwitchModule } from 'ngx-ui-switch';
import { ProfileClaimItemModalComponent } from './profile-claim-item-modal/profile-claim-item-modal.component';
import { SuggestionNotificationsModule } from '../suggestion-notifications/suggestion-notifications.module';


@NgModule({
imports: [
ProfilePageRoutingModule,
CommonModule,
SharedModule,
FormModule,
UiSwitchModule
],
imports: [
ProfilePageRoutingModule,
CommonModule,
SharedModule,
FormModule,
UiSwitchModule,
SuggestionNotificationsModule
],
exports: [
ProfilePageComponent,
ThemedProfilePageComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { RemoteData } from '../../../core/data/remote-data';
Expand Down Expand Up @@ -29,6 +29,11 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit {
*/
@Input() dsoRD: RemoteData<DSpaceObject>;

/**
* Representing if component should emit value of selected entries or navigate
*/
@Input() emitOnly = false;

/**
* Optional header to display above the selection list
* Supports i18n keys
Expand All @@ -50,6 +55,11 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit {
*/
action: SelectorActionType;

/**
* Event emitted when a DSO entry is selected if emitOnly is set to true
*/
@Output() select: EventEmitter<DSpaceObject> = new EventEmitter<DSpaceObject>();

/**
* Default DSO ordering
*/
Expand Down Expand Up @@ -93,7 +103,11 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit {
*/
selectObject(dso: DSpaceObject) {
this.close();
this.navigate(dso);
if (this.emitOnly) {
this.select.emit(dso);
} else {
this.navigate(dso);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function reciterSuggestionTargetStateSelector(): MemoizedSelector<Suggest
/**
* Returns the Reciter Suggestion Targets list.
* @function reciterSuggestionTargetObjectSelector
* @return {OpenaireReciterSuggestionTarget[]}
* @return {SuggestionTarget[]}
*/
export function reciterSuggestionTargetObjectSelector(): MemoizedSelector<SuggestionNotificationsState, SuggestionTarget[]> {
return subStateSelector<SuggestionNotificationsState, SuggestionTarget[]>(reciterSuggestionTargetStateSelector(), 'targets');
Expand All @@ -47,7 +47,7 @@ export const isReciterSuggestionTargetLoadedSelector = createSelector(_getRecite
* @function isDeduplicationSetsProcessingSelector
* @return {boolean}
*/
export const isreciterSuggestionTargetProcessingSelector = createSelector(_getReciterSuggestionTargetState,
export const isReciterSuggestionTargetProcessingSelector = createSelector(_getReciterSuggestionTargetState,
(state: SuggestionNotificationsState) => state.suggestionTarget.processing
);

Expand All @@ -56,7 +56,7 @@ export const isreciterSuggestionTargetProcessingSelector = createSelector(_getRe
* @function getreciterSuggestionTargetTotalPagesSelector
* @return {number}
*/
export const getreciterSuggestionTargetTotalPagesSelector = createSelector(_getReciterSuggestionTargetState,
export const getReciterSuggestionTargetTotalPagesSelector = createSelector(_getReciterSuggestionTargetState,
(state: SuggestionNotificationsState) => state.suggestionTarget.totalPages
);

Expand All @@ -65,7 +65,7 @@ export const getreciterSuggestionTargetTotalPagesSelector = createSelector(_getR
* @function getreciterSuggestionTargetCurrentPageSelector
* @return {number}
*/
export const getreciterSuggestionTargetCurrentPageSelector = createSelector(_getReciterSuggestionTargetState,
export const getReciterSuggestionTargetCurrentPageSelector = createSelector(_getReciterSuggestionTargetState,
(state: SuggestionNotificationsState) => state.suggestionTarget.currentPage
);

Expand All @@ -74,7 +74,7 @@ export const getreciterSuggestionTargetCurrentPageSelector = createSelector(_get
* @function getreciterSuggestionTargetTotalsSelector
* @return {number}
*/
export const getreciterSuggestionTargetTotalsSelector = createSelector(_getReciterSuggestionTargetState,
export const getReciterSuggestionTargetTotalsSelector = createSelector(_getReciterSuggestionTargetState,
(state: SuggestionNotificationsState) => state.suggestionTarget.totalElements
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class SuggestionTargetsComponent implements OnInit {
distinctUntilChanged(),
take(1)
).subscribe((options: PaginationComponentOptions) => {
console.log('HELLO suggestion called!', options);
this.suggestionTargetsStateService.dispatchRetrieveReciterSuggestionTargets(
this.source,
options.pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class SuggestionTargetsEffects {
/**
* Fetch the current user suggestion
*/
refreshUserTargets$ = createEffect(() => this.actions$.pipe(
RefreshUserSuggestionsAction = createEffect(() => this.actions$.pipe(
ofType(SuggestionTargetActionTypes.REFRESH_USER_SUGGESTIONS),
switchMap((action: RefreshUserSuggestionsAction) => {
return this.store$.select((state: any) => state.core.auth.userId)
Expand Down
Loading

0 comments on commit 9b556fd

Please sign in to comment.