Skip to content

Commit

Permalink
Merged dspace-cris-2023_02_x into DSC-1111-latest-version-maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
vins01-4science committed May 9, 2024
2 parents 304a49e + a77762a commit d8501ae
Show file tree
Hide file tree
Showing 24 changed files with 282 additions and 103 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/search-navbar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const page = {
}
};

xdescribe('Search from Navigation Bar', () => {
describe('Search from Navigation Bar', () => {
// NOTE: these tests currently assume this query will return results!
const query = TEST_SEARCH_TERM;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AdminEditUserAgreementComponent implements OnInit, OnDestroy {
this.subs.push(this.siteService.patch(this.site, operations).pipe(
getFirstCompletedRemoteData(),
).subscribe((restResponse) => {
if (restResponse.isSuccess) {
if (restResponse.hasSucceeded) {
this.notificationsService.success(this.translateService.get('admin.edit-user-agreement.success'));
if ( result === 'edit-with-reset' ) {
this.deleteAllUserAgreementMetadataValues();
Expand Down
14 changes: 11 additions & 3 deletions src/app/core/browse/search-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { map, switchMap } from 'rxjs/operators';
import { PaginatedList } from '../data/paginated-list.model';
import { RemoteData } from '../data/remote-data';
import { Item } from '../shared/item.model';
import { getFirstSucceededRemoteData } from '../shared/operators';
import { getFirstCompletedRemoteData } from '../shared/operators';
import { BrowseEntrySearchOptions } from './browse-entry-search-options.model';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
import { ItemDataService } from '../data/item-data.service';
Expand Down Expand Up @@ -107,8 +107,16 @@ export class SearchManager {
.filter((item) => hasValue(item));

const uuidList = this.extractUUID(items, environment.followAuthorityMetadata);

return uuidList.length > 0 ? this.itemService.findAllById(uuidList).pipe(getFirstSucceededRemoteData()) : of(null);
return uuidList.length > 0 ? this.itemService.findAllById(uuidList).pipe(
getFirstCompletedRemoteData(),
map(data => {
if (data.hasSucceeded) {
return of(data);
} else {
of(null);
}
})
) : of(null);
}

protected extractUUID(items: Item[], metadataToFollow: FollowAuthorityMetadata[]): string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
<div class="order-lg-2 w-100 mb-3">
<ng-container *ngFor="let attachmentConf of envMetadata">

<div class="content" [attr.data-test]="attachmentConf.name"
*ngIf="attachment.firstMetadataValue(attachmentConf.name) || attachmentConf.type == AdvancedAttachmentElementType.Attribute">
<div class="content"
[attr.data-test]="attachmentConf.name"
*ngIf="attachment.firstMetadataValue(attachmentConf.name) || attachmentConf.type == AdvancedAttachmentElementType.Attribute"
>
<strong>{{ 'cris-layout.advanced-attachment.'+attachmentConf.name | translate }}</strong>

<ng-container *ngIf="attachmentConf.type == AdvancedAttachmentElementType.Metadata">

<p class="text-break m-0" *ngIf="!attachmentConf.truncatable">
<p class="text-break m-0" *ngIf="!attachmentConf.truncatable && attachmentConf.name === attachmentTypeMetadata">
{{attachment.firstMetadataValue(attachmentConf.name) | titlecase}}
</p>

<p class="text-break m-0" *ngIf="!attachmentConf.truncatable && attachmentConf.name !== attachmentTypeMetadata">
{{attachment.firstMetadataValue(attachmentConf.name)}}
</p>

Expand All @@ -42,7 +48,7 @@

<ng-container *ngIf="attachmentConf.type == AdvancedAttachmentElementType.Attribute">
<ng-container *ngIf="attachmentConf.name == 'format'">
<p *ngIf="!(getFormat(attachment) | async) "class="text-muted">
<p *ngIf="!(getFormat(attachment) | async) " class="text-muted">
{{'cris-layout.advanced-attachment.label.not-present' | translate}}
</p>
<p class="word-break m-0">{{getFormat(attachment) | async}}</p>
Expand All @@ -53,7 +59,7 @@
</ng-container>

<ng-container *ngIf="attachmentConf.name == 'checksum'">
<p *ngIf="!(getChecksum(attachment)?.value) "class="text-muted">
<p *ngIf="!(getChecksum(attachment)?.value) " class="text-muted">
{{'cris-layout.advanced-attachment.label.not-present' | translate}}
</p>
<p class="word-break m-0">({{getChecksum(attachment).checkSumAlgorithm}}):{{ getChecksum(attachment).value }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export class BitstreamAttachmentComponent extends BitstreamRenderingModelCompone
*/
allAttachmentProviders: string[] = [];

/**
* Attachment metadata to be displayed in title case
*/

attachmentTypeMetadata = 'dc.type';

@Input()
attachment: Bitstream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div *ngFor="let attachment of (bitstreams$ | async)" class="mb-2">
<ds-truncatable [id]="attachment.id">
<ds-file-download-link [bitstream]="attachment" [enableRequestACopy]="true" [item]="item" [showIcon]="true">
<span data-test="title" *ngIf="fileName(attachment)"><span data-test="type" *ngIf="getType(attachment)" class="font-weight-bold">{{getType(attachment)}}: </span>{{fileName(attachment)}} ({{getSize(attachment) | dsFileSize}})</span>
<span data-test="title" *ngIf="fileName(attachment)"><span data-test="type" *ngIf="getType(attachment)" class="font-weight-bold">{{getType(attachment) | titlecase}}: </span>{{fileName(attachment)}} ({{getSize(attachment) | dsFileSize}})</span>
</ds-file-download-link>
<ds-truncatable-part [id]="attachment.id" [minLines]="1">
<span *ngIf="getDescription(attachment)" data-test="description">{{getDescription(attachment)}}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h2 class="mb-3">{{ 'info.end-user-agreement.head' | translate }}</h2>

<ds-markdown-viewer [value]="userAgreementText$ | async"></ds-markdown-viewer>
<ds-markdown-viewer [value]="(userAgreementText$ | async)"></ds-markdown-viewer>
30 changes: 16 additions & 14 deletions src/app/item-page/edit-item-page/edit-item-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
<h2 class="border-bottom">{{'item.edit.head' | translate}}</h2>
<div class="pt-2">
<ul class="nav nav-tabs justify-content-start" role="tablist">
<li *ngFor="let page of pages" class="nav-item" [attr.aria-selected]="page.page === currentPage" role="tab">
<a *ngIf="(page.enabled | async)"
class="nav-link"
[ngClass]="{'active' : page.page === currentPage}"
[routerLink]="['./' + page.page]">
{{'item.edit.tabs.' + page.page + '.head' | translate}}
</a>
<span [ngbTooltip]="'item.edit.tabs.disabled.tooltip' | translate">
<button *ngIf="!(page.enabled | async)"
class="nav-link disabled">
{{'item.edit.tabs.' + page.page + '.head' | translate}}
</button>
</span>
</li>
<ng-container *ngFor="let page of pages">
<li *ngIf="page.page != 'relationships'" [attr.aria-selected]="page.page === currentPage" role="tab" class="nav-item">
<a *ngIf="(page.enabled | async)"
class="nav-link"
[ngClass]="{'active' : page.page === currentPage}"
[routerLink]="['./' + page.page]">
{{'item.edit.tabs.' + page.page + '.head' | translate}}
</a>
<span [ngbTooltip]="'item.edit.tabs.disabled.tooltip' | translate">
<button *ngIf="!(page.enabled | async)"
class="nav-link disabled">
{{'item.edit.tabs.' + page.page + '.head' | translate}}
</button>
</span>
</li>
</ng-container>
</ul>
<div class="tab-pane active">
<div class="mb-4">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
<div [formGroup]="group" class="input-group">

<input ngbDatepicker class="form-control date-input" #datepicker="ngbDatepicker"
[attr.aria-labelledby]="'label_' + model.id"
[class.is-invalid]="showErrorMessages"
[displayMonths]="model.getAdditional('displayMonths', config['displayMonths'])"
[id]="id"
[firstDayOfWeek]="model.getAdditional('firstDayOfWeek', config['firstDayOfWeek'])"
[formControlName]="model.id"
[maxDate]="model.max"
[minDate]="model.min"
[name]="model.name"
[navigation]="model.getAdditional('navigation', config['navigation'])"
[ngClass]="getClass('element', 'control')"
[outsideDays]="model.getAdditional('outsideDays', config['outsideDays'])"
[placeholder]="model.placeholder"
[placement]="model.getAdditional('placement', 'bottom-left')"
[weekdays]="model.getAdditional('showWeekdays', config['showWeekdays'])"
[showWeekNumbers]="model.getAdditional('showWeekNumbers', config['showWeekNumbers'])"
[startDate]="model.focusedDate"
[value]="getInitDate()"
(blur)="onBlur($event)"
(dateSelect)="onChange($event)"
(change)="onChange($event)"
(focus)="onFocus($event)">
<input ngbDatepicker class="form-control date-input" #datepicker="ngbDatepicker"
[attr.aria-labelledby]="'label_' + model.id"
[class.is-invalid]="showErrorMessages"
[displayMonths]="model.getAdditional('displayMonths', config['displayMonths'])"
[id]="id"
[firstDayOfWeek]="model.getAdditional('firstDayOfWeek', config['firstDayOfWeek'])"
[formControlName]="model.id"
[maxDate]="model.max"
[minDate]="model.min"
[name]="model.name"
[navigation]="model.getAdditional('navigation', config['navigation'])"
[ngClass]="getClass('element', 'control')"
[outsideDays]="model.getAdditional('outsideDays', config['outsideDays'])"
[placeholder]="model.placeholder"
[placement]="model.getAdditional('placement', 'bottom-left')"
[weekdays]="model.getAdditional('showWeekdays', config['showWeekdays'])"
[showWeekNumbers]="model.getAdditional('showWeekNumbers', config['showWeekNumbers'])"
[startDate]="model.focusedDate"
[value]="formattedDate"
(blur)="onBlur($event)"
(dateSelect)="onChange($event)"
(change)="onChange($event)"
(focus)="onFocus($event)"
>

<div class="input-group-append">
<div class="input-group-append">

<button class="btn btn-outline-secondary"
type="button"
[attr.aria-labelledby]="'label_' + model.id"
[class.disabled]="model.disabled"
[disabled]="model.disabled"
(click)="datepicker.toggle()">
<button class="btn btn-outline-secondary"
type="button"
[attr.aria-labelledby]="'label_' + model.id"
[class.disabled]="model.disabled"
[disabled]="model.disabled"
(click)="datepicker.toggle()">

<i *ngIf="model.toggleIcon" class="{{model.toggleIcon}}" aria-hidden="true"></i>
<span *ngIf="model.toggleLabel">{{ model.toggleLabel }}</span>
<i *ngIf="model.toggleIcon" class="{{model.toggleIcon}}" aria-hidden="true"></i>
<span *ngIf="model.toggleLabel">{{ model.toggleLabel }}</span>

</button>
</button>

</div>
</div>

</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { NgbDateParserFormatter, NgbDatepicker, NgbDatepickerConfig, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import {
Expand All @@ -8,13 +8,16 @@ import {
DynamicFormLayoutService,
DynamicFormValidationService
} from '@ng-dynamic-forms/core';
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model';
import { hasValue } from '../../../../../empty.util';
import { Subscription } from 'rxjs';

@Component({
selector: 'ds-dynamic-date-picker-inline',
styleUrls: ['./dynamic-date-picker-inline.component.scss'],
templateUrl: './dynamic-date-picker-inline.component.html'
})
export class DsDatePickerInlineComponent extends DynamicFormControlComponent {
export class DsDatePickerInlineComponent extends DynamicFormControlComponent implements OnInit, OnDestroy{

@Input() bindId = true;
@Input() group: UntypedFormGroup;
Expand All @@ -26,6 +29,9 @@ export class DsDatePickerInlineComponent extends DynamicFormControlComponent {
@Output() focus: EventEmitter<any> = new EventEmitter();

@ViewChild(NgbDatepicker) ngbDatePicker: NgbDatepicker;
formattedDate: string;
private isOnFocus: boolean;
private modelChangeSub: Subscription;

constructor(protected layoutService: DynamicFormLayoutService,
protected validationService: DynamicFormValidationService,
Expand All @@ -35,7 +41,38 @@ export class DsDatePickerInlineComponent extends DynamicFormControlComponent {
super(layoutService, validationService);
}

ngOnInit() {
this.formattedDate = this.getInitDate();
this.modelChangeSub = this.model.valueChanges.subscribe(() => {
const newDate = this.getInitDate();
if (hasValue(newDate) && newDate !== this.formattedDate && !this.isOnFocus) {
this.formattedDate = newDate;
}
});
}

ngOnDestroy() {
if (hasValue(this.modelChangeSub)) {
this.modelChangeSub.unsubscribe();
}
}

getInitDate(): string {
return this.formatter.format(this.model.value as NgbDateStruct);
return this.model.value instanceof FormFieldMetadataValueObject ? this.model.value.value : this.formatter.format(this.model.value as NgbDateStruct);
}

onBlur(event) {
this.isOnFocus = false;
const newDate = this.getInitDate();
if (!hasValue(this.model.value) || newDate !== this.formattedDate) {
this.formattedDate = newDate;
this.blur.emit(event);
}
}

onFocus($event: any) {
super.onFocus($event);
this.isOnFocus = true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
protected selectedChipItemIndex: number;

private subs: Subscription[] = [];
private valueChangeSubscription: Subscription;

constructor(private vocabularyService: VocabularyService,
private formBuilderService: FormBuilderService,
Expand All @@ -70,12 +71,18 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent

ngOnInit() {
this.initChipsFromModelValue();
this.valueChangeSubscription = this.model.valueChanges.subscribe(() => {
this.initChipsFromModelValue();
});
}

ngOnDestroy(): void {
this.subs
.filter((sub) => hasValue(sub))
.forEach((sub) => sub.unsubscribe());
if (hasValue(this.valueChangeSubscription)) {
this.valueChangeSubscription.unsubscribe();
}
}

onBlur(event) {
Expand Down Expand Up @@ -103,7 +110,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
modalRef.componentInstance.group = this.group;
modalRef.componentInstance.model = this.model;

modalRef.componentInstance.editMode = this.selectedChipItem ? true : false;
modalRef.componentInstance.editMode = !!this.selectedChipItem;
modalRef.componentInstance.itemIndex = this.selectedChipItemIndex;
modalRef.componentInstance.item = this.selectedChipItem?.item;
modalRef.componentInstance.changedSecurity = false;
Expand All @@ -114,15 +121,23 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
modalRef.componentInstance.add.pipe(take(1)).subscribe((item) => {
this.chips.add(item);
});

if (hasValue(this.valueChangeSubscription)) {
this.valueChangeSubscription.unsubscribe();
}
modalRef.result.then(() => {
// close
this.selectedChipItemIndex = null;
this.selectedChipItem = null;
this.valueChangeSubscription = this.model.valueChanges.subscribe(() => {
this.initChipsFromModelValue();
});
}, () => {
// dismiss
this.selectedChipItemIndex = null;
this.selectedChipItem = null;
this.valueChangeSubscription = this.model.valueChanges.subscribe(() => {
this.initChipsFromModelValue();
});
});

return modalRef;
Expand All @@ -133,12 +148,13 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
if (this.model.isEmpty()) {
this.initChips([]);
} else {
initChipsValue$ = observableOf(this.model.value as any[]);
initChipsValue$ = observableOf(this.model.getGroupValue() as any[]);
// If authority
this.subs.push(initChipsValue$.pipe(
mergeMap((valueModel) => {
const returnList: Observable<any>[] = [];
valueModel.forEach((valueObj) => {

const returnObj = Object.keys(valueObj).map((fieldName) => {
let return$: Observable<any>;
if (isObject(valueObj[fieldName]) && this.hasValidAuthority(valueObj[fieldName]) && valueObj[fieldName].otherInformation === null) {
Expand Down Expand Up @@ -171,7 +187,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
}
return acc;
}, []),
filter((modelValues: any[]) => (this.model.value as any[]).length === modelValues.length)
filter((modelValues: any[]) => this.model.getGroupValue().length === modelValues.length)
).subscribe((modelValue) => {
this.model.value = modelValue;
this.initChips(modelValue);
Expand Down
Loading

0 comments on commit d8501ae

Please sign in to comment.