remove section selection from add description pop up and fix dashboard home page sizes

This commit is contained in:
amentis 2024-03-22 09:41:35 +02:00
parent 76e251c14d
commit 4e61353f77
15 changed files with 183 additions and 190 deletions

View File

@ -19,6 +19,8 @@ public class RecentActivityItemLookup{
private String like; private String like;
private Boolean onlyDraft; private Boolean onlyDraft;
private Boolean onlyDmp;
private Boolean onlyDescription;
private List<UUID> userIds; private List<UUID> userIds;
private Paging page; private Paging page;
private BaseFieldSet project; private BaseFieldSet project;
@ -72,12 +74,30 @@ public class RecentActivityItemLookup{
this.orderField = orderField; this.orderField = orderField;
} }
public Boolean getOnlyDmp() {
return onlyDmp;
}
public void setOnlyDmp(Boolean onlyDmp) {
this.onlyDmp = onlyDmp;
}
public Boolean getOnlyDescription() {
return onlyDescription;
}
public void setOnlyDescription(Boolean onlyDescription) {
this.onlyDescription = onlyDescription;
}
public DescriptionLookup asDescriptionLookup() { public DescriptionLookup asDescriptionLookup() {
if (this.onlyDmp != null) return null;
DescriptionLookup lookup = new DescriptionLookup(); DescriptionLookup lookup = new DescriptionLookup();
lookup.setIsActive(List.of(IsActive.Active)); lookup.setIsActive(List.of(IsActive.Active));
if (this.like != null) lookup.setLike(this.like); if (this.like != null) lookup.setLike(this.like);
if (this.onlyDraft != null) lookup.setStatuses(List.of(DescriptionStatus.Draft)); if (this.onlyDraft != null) lookup.setStatuses(List.of(DescriptionStatus.Draft));
else lookup.setStatuses(List.of(DescriptionStatus.Draft, DescriptionStatus.Finalized));
if (this.userIds != null) { if (this.userIds != null) {
DmpLookup dmpLookup = new DmpLookup(); DmpLookup dmpLookup = new DmpLookup();
DmpUserLookup dmpUserLookup = new DmpUserLookup(); DmpUserLookup dmpUserLookup = new DmpUserLookup();
@ -105,6 +125,8 @@ public class RecentActivityItemLookup{
} }
public DmpLookup asDmpLookup() { public DmpLookup asDmpLookup() {
if (this.onlyDescription != null) return null;
DmpLookup lookup = new DmpLookup(); DmpLookup lookup = new DmpLookup();
lookup.setIsActive(List.of(IsActive.Active)); lookup.setIsActive(List.of(IsActive.Active));
if (this.like != null) lookup.setLike(this.like); if (this.like != null) lookup.setLike(this.like);

View File

@ -68,18 +68,23 @@ public class DashboardServiceImpl implements DashboardService {
List<RecentActivityItemEntity> recentActivityItemEntities = new ArrayList<>(); List<RecentActivityItemEntity> recentActivityItemEntities = new ArrayList<>();
DescriptionLookup descriptionLookup = model.asDescriptionLookup(); DescriptionLookup descriptionLookup = model.asDescriptionLookup();
descriptionLookup.getPage().setOffset(0); if (descriptionLookup != null) {
QueryResult<Description> descriptions = this.elasticQueryHelperService.collect(descriptionLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, new BaseFieldSet().ensure(Description._id).ensure(Description._updatedAt).ensure(Description._status).ensure(Description._label)); descriptionLookup.getPage().setOffset(0);
if (!this.conventionService.isListNullOrEmpty(descriptions.getItems())) { QueryResult<Description> descriptions = this.elasticQueryHelperService.collect(descriptionLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, new BaseFieldSet().ensure(Description._id).ensure(Description._updatedAt).ensure(Description._status).ensure(Description._label));
for (Description description : descriptions.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Description, description.getId(), description.getUpdatedAt(), description.getLabel(), description.getStatus().getValue())); if (!this.conventionService.isListNullOrEmpty(descriptions.getItems())) {
for (Description description : descriptions.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Description, description.getId(), description.getUpdatedAt(), description.getLabel(), description.getStatus().getValue()));
}
} }
DmpLookup dmpLookup = model.asDmpLookup(); DmpLookup dmpLookup = model.asDmpLookup();
dmpLookup.getPage().setOffset(0); if (dmpLookup != null){
QueryResult<Dmp> dmps = this.elasticQueryHelperService.collect(dmpLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._updatedAt).ensure(Dmp._label).ensure(Dmp._status)); dmpLookup.getPage().setOffset(0);
if (!this.conventionService.isListNullOrEmpty(dmps.getItems())) { QueryResult<Dmp> dmps = this.elasticQueryHelperService.collect(dmpLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._updatedAt).ensure(Dmp._label).ensure(Dmp._status));
for (Dmp dmp : dmps.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Dmp, dmp.getId(), dmp.getUpdatedAt(), dmp.getLabel(), dmp.getStatus().getValue())); if (!this.conventionService.isListNullOrEmpty(dmps.getItems())) {
for (Dmp dmp : dmps.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Dmp, dmp.getId(), dmp.getUpdatedAt(), dmp.getLabel(), dmp.getStatus().getValue()));
}
} }
Comparator<RecentActivityItemEntity> comparator = Comparator.comparing(RecentActivityItemEntity::getUpdatedAt); Comparator<RecentActivityItemEntity> comparator = Comparator.comparing(RecentActivityItemEntity::getUpdatedAt);
if (model.getOrderField() != null) { if (model.getOrderField() != null) {
@ -139,7 +144,7 @@ public class DashboardServiceImpl implements DashboardService {
dmpUserLookup.userIds(this.userScope.getUserId()); dmpUserLookup.userIds(this.userScope.getUserId());
dmpUserLookup.isActives(IsActive.Active); dmpUserLookup.isActives(IsActive.Active);
DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).dmpUserSubQuery(dmpUserLookup).versionStatuses(DmpVersionStatus.Current); DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).dmpUserSubQuery(dmpUserLookup).versionStatuses(List.of(DmpVersionStatus.Current, DmpVersionStatus.NotFinalized));
DashboardStatistics statistics = new DashboardStatistics(); DashboardStatistics statistics = new DashboardStatistics();
statistics.setDmpCount(dmpQuery.authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).count()); statistics.setDmpCount(dmpQuery.authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).count());

View File

@ -4,6 +4,8 @@ import { RecentActivityOrder } from "../common/enum/recent-activity-order";
export class RecentActivityItemLookup implements RecentActivityItemFilter { export class RecentActivityItemLookup implements RecentActivityItemFilter {
like: string; like: string;
onlyDraft: boolean; onlyDraft: boolean;
onlyDmp: boolean;
onlyDescription: boolean;
userIds: string; userIds: string;
page: Lookup.Paging; page: Lookup.Paging;
project: Lookup.FieldDirectives; project: Lookup.FieldDirectives;
@ -17,6 +19,8 @@ export class RecentActivityItemLookup implements RecentActivityItemFilter {
export interface RecentActivityItemFilter { export interface RecentActivityItemFilter {
like: string; like: string;
onlyDraft: boolean; onlyDraft: boolean;
onlyDmp: boolean;
onlyDescription: boolean;
userIds: string; userIds: string;
page: Lookup.Paging; page: Lookup.Paging;
project: Lookup.FieldDirectives; project: Lookup.FieldDirectives;

View File

@ -137,7 +137,6 @@ export class DashboardComponent extends BaseComponent implements OnInit {
addNewDescription() { addNewDescription() {
const formGroup = this.fb.group({ const formGroup = this.fb.group({
dmpId: this.fb.control(null, Validators.required), dmpId: this.fb.control(null, Validators.required),
sectionId: this.fb.control(null, Validators.required),
}) })
const dialogRef = this.dialog.open(StartNewDescriptionDialogComponent, { const dialogRef = this.dialog.open(StartNewDescriptionDialogComponent, {
@ -153,7 +152,7 @@ export class DashboardComponent extends BaseComponent implements OnInit {
if (result.startNewDmp) { if (result.startNewDmp) {
this.openNewDmpDialog(); this.openNewDmpDialog();
} else { } else {
this.router.navigate(['/descriptions', 'edit', result.formGroup.get('dmpId').value, result.formGroup.get('sectionId').value]); this.router.navigate(['/plans', 'edit', result.formGroup.get('dmpId').value]);
} }
} }
}); });

View File

@ -20,17 +20,17 @@
</mat-form-field> </mat-form-field>
<!-- End of Search Filter --> <!-- End of Search Filter -->
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 && page > 1" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && pageSize > pageLessSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious(false)">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadLess()">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button>
</div> </div>
<div *ngFor="let item of listingItems; let i = index"> <div *ngFor="let item of listingItems; let i = index">
<app-dmp-listing-item-component *ngIf="item.dmp" [showDivider]="i != (listingItems.length - 1)" [dmp]="item.dmp" [isPublic]="isPublic"></app-dmp-listing-item-component> <app-dmp-listing-item-component *ngIf="item.dmp" [showDivider]="i != (listingItems.length - 1)" [dmp]="item.dmp" [isPublic]="isPublic"></app-dmp-listing-item-component>
<app-description-listing-item-component *ngIf="item.description" [showDivider]="i != (listingItems.length - 1)" [description]="item.description" [isPublic]="isPublic" ></app-description-listing-item-component> <app-description-listing-item-component *ngIf="item.description" [showDivider]="i != (listingItems.length - 1)" [description]="item.description" [isPublic]="isPublic" ></app-description-listing-item-component>
</div> </div>
<div class="text-muted d-flex justify-content-center mt-5" *ngIf="!hasMoreActivity && listingItems && listingItems.length > 0"> <div class="text-muted d-flex justify-content-center mt-5" *ngIf="listingItems && listingItems.length > 0 && listingItems.length < pageSize">
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} {{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 && (listingItems.length >= startIndex + pageSize) && hasMoreActivity" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && (listingItems.length >= startIndex + pageSize)" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadMore()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button>
</div> </div>
</div> </div>

View File

@ -33,6 +33,7 @@ export class DraftsComponent extends BaseComponent implements OnInit {
lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
pageSize: number = 5; pageSize: number = 5;
pageLessSize= this.pageSize;
listingItems: RecentActivityItem[] = []; listingItems: RecentActivityItem[] = [];
public formGroup = new UntypedFormBuilder().group({ public formGroup = new UntypedFormBuilder().group({
@ -173,6 +174,31 @@ export class DraftsComponent extends BaseComponent implements OnInit {
] ]
}; };
this.getItems();
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
}
loadMore() {
this.pageSize = this.pageSize + this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
loadLess() {
this.pageSize = this.pageSize - this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
private getItems(){
this.listingItems = [];
this.dashboardService this.dashboardService
.getMyRecentActivityItems(this.lookup) .getMyRecentActivityItems(this.lookup)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
@ -193,32 +219,6 @@ export class DraftsComponent extends BaseComponent implements OnInit {
if (item.description.status != DescriptionStatus.Canceled) this.listingItems.push(item); if (item.description.status != DescriptionStatus.Canceled) this.listingItems.push(item);
} }
}) })
//this.totalCount = response.totalCount;
//this.totalCountDmps.emit(this.dmpActivities.length);
// if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) {
// let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value };
// if (this.formGroup.get("like").value) {
// queryParams['keyword'] = this.formGroup.get("like").value;
// }
// this.router.navigate(["/home"], { queryParams: queryParams })
// }
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);
// this.totalCountDmps.emit(this.totalCount);
// this.dmpActivities.forEach(dmpActivity => {
// const recentActivity: RecentActivity = {
// activityData: dmpActivity,
// activityType: RecentActivityType.Dmp
// };
// this.allRecentActivities.push(recentActivity)
// })
}); });
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
} }
} }

View File

@ -22,17 +22,17 @@
</mat-form-field> </mat-form-field>
<!-- End of Search Filter --> <!-- End of Search Filter -->
</div> </div>
<div *ngIf="allRecentActivities && allRecentActivities.length > 0 && page > 1" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && pageSize > pageLessSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious(false)">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadLess()">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button>
</div> </div>
<div *ngFor="let item of listingItems; let i = index"> <div *ngFor="let item of listingItems; let i = index">
<app-dmp-listing-item-component *ngIf="item.dmp" [showDivider]="i != (listingItems.length - 1)" [dmp]="item.dmp" [isPublic]="isPublic"></app-dmp-listing-item-component> <app-dmp-listing-item-component *ngIf="item.dmp" [showDivider]="i != (listingItems.length - 1)" [dmp]="item.dmp" [isPublic]="isPublic"></app-dmp-listing-item-component>
<app-description-listing-item-component *ngIf="item.description" [showDivider]="i != (listingItems.length - 1)" [description]="item.description" [isPublic]="isPublic" ></app-description-listing-item-component> <app-description-listing-item-component *ngIf="item.description" [showDivider]="i != (listingItems.length - 1)" [description]="item.description" [isPublic]="isPublic" ></app-description-listing-item-component>
</div> </div>
<div class="text-muted d-flex justify-content-center mt-5" *ngIf="!hasMoreActivity && allRecentActivities && allRecentActivities.length > 0"> <div class="text-muted d-flex justify-content-center mt-5" *ngIf="listingItems && listingItems.length > 0 && listingItems.length < pageSize">
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} {{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
</div> </div>
<div *ngIf="allRecentActivities && allRecentActivities.length > 0 && (allRecentActivities.length >= startIndex + pageSize) && hasMoreActivity" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && listingItems.length >= startIndex + pageSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadMore()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button>
</div> </div>
</div> </div>

View File

@ -33,6 +33,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
pageSize: number = 5; pageSize: number = 5;
pageLessSize= this.pageSize;
listingItems: RecentActivityItem[]= []; listingItems: RecentActivityItem[]= [];
public formGroup = new UntypedFormBuilder().group({ public formGroup = new UntypedFormBuilder().group({
@ -171,47 +172,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
] ]
}; };
this.dashboardService this.getItems();
.getMyRecentActivityItems(this.lookup)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
response.forEach(item => {
if (item.dmp){
if (item.dmp.descriptions) {
if (item.dmp.status == DmpStatus.Finalized) {
item.dmp.descriptions = item.dmp.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized);
} else {
item.dmp.descriptions = item.dmp.descriptions.filter(x => x.isActive === IsActive.Active && x.status != DescriptionStatus.Canceled);
}
}
item.dmp.dmpUsers = item.dmp.dmpUsers.filter(x=> x.isActive === IsActive.Active);
this.listingItems.push(item);
}
if (item.description){
if (item.description.status != DescriptionStatus.Canceled) this.listingItems.push(item);
}
})
//this.totalCount = response.totalCount;
//this.totalCountDmps.emit(this.dmpActivities.length);
// if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) {
// let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value };
// if (this.formGroup.get("like").value) {
// queryParams['keyword'] = this.formGroup.get("like").value;
// }
// this.router.navigate(["/home"], { queryParams: queryParams })
// }
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);
// this.totalCountDmps.emit(this.totalCount);
// this.dmpActivities.forEach(dmpActivity => {
// const recentActivity: RecentActivity = {
// activityData: dmpActivity,
// activityType: RecentActivityType.Dmp
// };
// this.allRecentActivities.push(recentActivity)
// })
});
this.formGroup.get('like').valueChanges this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500)) .pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh()); .subscribe(x => this.refresh());
@ -219,4 +181,42 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh()); .subscribe(x => this.refresh());
} }
loadMore() {
this.pageSize = this.pageSize + this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
loadLess() {
this.pageSize = this.pageSize - this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
private getItems(){
this.listingItems = [];
this.dashboardService
.getMyRecentActivityItems(this.lookup)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
response.forEach(item => {
if (item.dmp){
if (item.dmp.descriptions) {
if (item.dmp.status == DmpStatus.Finalized) {
item.dmp.descriptions = item.dmp.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized);
} else {
item.dmp.descriptions = item.dmp.descriptions.filter(x => x.isActive === IsActive.Active && x.status != DescriptionStatus.Canceled);
}
}
item.dmp.dmpUsers = item.dmp.dmpUsers.filter(x=> x.isActive === IsActive.Active);
this.listingItems.push(item);
}
if (item.description){
if (item.description.status != DescriptionStatus.Canceled) this.listingItems.push(item);
}
})
});
}
} }

View File

@ -20,16 +20,16 @@
</mat-form-field> </mat-form-field>
<!-- End of Search Filter --> <!-- End of Search Filter -->
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 && page > 1" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && pageSize > pageLessSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious(false)">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadLess()">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button>
</div> </div>
<div *ngFor="let item of listingItems; let i = index"> <div *ngFor="let item of listingItems; let i = index">
<app-description-listing-item-component *ngIf="item" [showDivider]="i != (listingItems.length - 1)" [description]="item" [isPublic]="isPublic" ></app-description-listing-item-component> <app-description-listing-item-component *ngIf="item" [showDivider]="i != (listingItems.length - 1)" [description]="item" [isPublic]="isPublic" ></app-description-listing-item-component>
</div> </div>
<div class="text-muted d-flex justify-content-center mt-5" *ngIf="!hasMoreResults && listingItems && listingItems.length > 0"> <div class="text-muted d-flex justify-content-center mt-5" *ngIf="listingItems && listingItems.length > 0 && listingItems.length < pageSize">
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} {{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 && listingItems.length >= pageSize && hasMoreResults" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && listingItems.length >= pageSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadMore()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button>
</div> </div>
</div> </div>

View File

@ -29,6 +29,7 @@ export class RecentEditedDescriptionActivityComponent extends BaseComponent impl
lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
pageSize: number = 5; pageSize: number = 5;
pageLessSize= this.pageSize;
listingItems: Description[] = []; listingItems: Description[] = [];
@ -118,6 +119,7 @@ export class RecentEditedDescriptionActivityComponent extends BaseComponent impl
this.formGroup.get('order').setValue(this.order.UpdatedAt); this.formGroup.get('order').setValue(this.order.UpdatedAt);
} }
this.lookup.page = { size: this.pageSize, offset: 0 }; this.lookup.page = { size: this.pageSize, offset: 0 };
this.lookup.onlyDescription = true;
this.lookup.orderField = this.formGroup.get('order').value; this.lookup.orderField = this.formGroup.get('order').value;
this.lookup.like = this.formGroup.get('like').value; this.lookup.like = this.formGroup.get('like').value;
this.lookup.project = { this.lookup.project = {
@ -145,6 +147,31 @@ export class RecentEditedDescriptionActivityComponent extends BaseComponent impl
] ]
}; };
this.getItems();
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
}
loadMore() {
this.pageSize = this.pageSize + this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
loadLess() {
this.pageSize = this.pageSize - this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
getItems(){
this.listingItems = [];
this.dashboardService this.dashboardService
.getMyRecentActivityItems(this.lookup) .getMyRecentActivityItems(this.lookup)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
@ -154,32 +181,6 @@ export class RecentEditedDescriptionActivityComponent extends BaseComponent impl
if (item.description.status != DescriptionStatus.Canceled) this.listingItems.push(item.description); if (item.description.status != DescriptionStatus.Canceled) this.listingItems.push(item.description);
} }
}) })
// this.totalCount = response.count;
//this.totalCountDmps.emit(this.dmpActivities.length);
// if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) {
// let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value };
// if (this.formGroup.get("like").value) {
// queryParams['keyword'] = this.formGroup.get("like").value;
// }
// this.router.navigate(["/home"], { queryParams: queryParams })
// }
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);
// this.totalCountDmps.emit(this.totalCount);
// this.dmpActivities.forEach(dmpActivity => {
// const recentActivity: RecentActivity = {
// activityData: dmpActivity,
// activityType: RecentActivityType.Dmp
// };
// this.allRecentActivities.push(recentActivity)
// })
}); });
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
} }
} }

View File

@ -20,8 +20,8 @@
</mat-form-field> </mat-form-field>
<!-- End of Search Filter --> <!-- End of Search Filter -->
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 && page > 1" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && pageSize > pageLessSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious(false)">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadLess()">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadNextOrPrevious(false)">{{'GENERAL.ACTIONS.LOAD-LESS' | translate}}</button>
</div> </div>
<div *ngFor="let item of listingItems; let i = index"> <div *ngFor="let item of listingItems; let i = index">
<app-dmp-listing-item-component *ngIf="item" [showDivider]="i != (listingItems.length - 1)" [dmp]="item" [isPublic]="isPublic"></app-dmp-listing-item-component> <app-dmp-listing-item-component *ngIf="item" [showDivider]="i != (listingItems.length - 1)" [dmp]="item" [isPublic]="isPublic"></app-dmp-listing-item-component>
@ -98,10 +98,10 @@
</mat-menu> </mat-menu>
</div> </div>
</div> --> </div> -->
<div class="text-muted d-flex justify-content-center mt-5" *ngIf="!hasMoreResults && listingItems && listingItems.length > 0"> <div class="text-muted d-flex justify-content-center mt-5" *ngIf="listingItems && listingItems.length > 0 && listingItems.length < pageSize">
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} {{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 && listingItems.length >= pageSize && hasMoreResults" class="d-flex justify-content-center"> <div *ngIf="listingItems && listingItems.length > 0 && listingItems.length >= pageSize" class="d-flex justify-content-center">
<button type="button" class="btn-load-more" (click)="loadNextOrPrevious()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button> <button type="button" class="btn-load-more" (click)="loadMore()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button>
</div> </div>
</div> </div>

View File

@ -31,6 +31,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
pageSize: number = 5; pageSize: number = 5;
pageLessSize= this.pageSize;
@Output() totalCountDmps: EventEmitter<any> = new EventEmitter(); @Output() totalCountDmps: EventEmitter<any> = new EventEmitter();
@ -126,6 +127,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
this.formGroup.get('order').setValue(this.order.UpdatedAt); this.formGroup.get('order').setValue(this.order.UpdatedAt);
} }
this.lookup.page = { size: this.pageSize, offset: 0 }; this.lookup.page = { size: this.pageSize, offset: 0 };
this.lookup.onlyDmp = true;
this.lookup.orderField = this.formGroup.get('order').value; this.lookup.orderField = this.formGroup.get('order').value;
this.lookup.like = this.formGroup.get('like').value; this.lookup.like = this.formGroup.get('like').value;
this.lookup.project = { this.lookup.project = {
@ -153,6 +155,31 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
] ]
}; };
this.getItems();
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
}
loadMore() {
this.pageSize = this.pageSize + this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
loadLess() {
this.pageSize = this.pageSize - this.pageLessSize;
this.lookup.page = { size: this.pageSize, offset: 0 };
this.getItems();
}
private getItems(){
this.listingItems = [];
this.dashboardService this.dashboardService
.getMyRecentActivityItems(this.lookup) .getMyRecentActivityItems(this.lookup)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
@ -171,47 +198,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
} }
}) })
//this.totalCount = response.totalCount;
//this.totalCountDmps.emit(this.dmpActivities.length);
// if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) {
// let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value };
// if (this.formGroup.get("like").value) {
// queryParams['keyword'] = this.formGroup.get("like").value;
// }
// this.router.navigate(["/home"], { queryParams: queryParams })
// }
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);
// this.totalCountDmps.emit(this.totalCount);
// this.dmpActivities.forEach(dmpActivity => {
// const recentActivity: RecentActivity = {
// activityData: dmpActivity,
// activityType: RecentActivityType.Dmp
// };
// this.allRecentActivities.push(recentActivity)
// })
}); });
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
// const datasetDataTableRequest: DataTableRequest<DatasetCriteria> = new DataTableRequest(0, 5, { fields: fields });
// datasetDataTableRequest.criteria = new DatasetCriteria();
// datasetDataTableRequest.criteria.like = "";
// this.datasetService
// .getPaged(datasetDataTableRequest)
// .subscribe(response => {
// this.datasetActivities = response.data;
// this.datasetActivities.forEach(datasetActivity => {
// const recentActivity: RecentActivity = {
// activityData: datasetActivity,
// activityType: RecentActivityType.Dataset
// };
// this.allRecentActivities.push(recentActivity)
// })
// });
} }
} }

View File

@ -359,7 +359,6 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
addNewDescription() { addNewDescription() {
const formGroup = this.fb.group({ const formGroup = this.fb.group({
dmpId: this.fb.control(null, Validators.required), dmpId: this.fb.control(null, Validators.required),
sectionId: this.fb.control(null, Validators.required),
}) })
const dialogRef = this.dialog.open(StartNewDescriptionDialogComponent, { const dialogRef = this.dialog.open(StartNewDescriptionDialogComponent, {
@ -375,7 +374,7 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
if (result.startNewDmp) { if (result.startNewDmp) {
this.openNewDmpDialog(); this.openNewDmpDialog();
} else { } else {
this.router.navigate(['/descriptions', 'edit', result.formGroup.get('dmpId').value, result.formGroup.get('sectionId').value]); this.router.navigate(['/plans', 'edit', result.formGroup.get('dmpId').value]);
} }
} }
}); });

View File

@ -13,14 +13,6 @@
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmpId')" placeholder="{{'START-NEW-DESCRIPTION-DIALOG.SELECT-DMP' | translate}}" [configuration]="dmpAutoCompleteConfiguration"></app-single-auto-complete> <app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmpId')" placeholder="{{'START-NEW-DESCRIPTION-DIALOG.SELECT-DMP' | translate}}" [configuration]="dmpAutoCompleteConfiguration"></app-single-auto-complete>
</mat-form-field> </mat-form-field>
</div> </div>
<div *ngIf="this.sections.length > 1">
<mat-form-field>
<mat-label>{{'START-NEW-DESCRIPTION-DIALOG.DMP-SECTION' | translate}}</mat-label>
<mat-select [formControl]="formGroup.get('sectionId')">
<mat-option *ngFor="let section of sections" [value]="section.id">{{section.label}}</mat-option>
</mat-select>
</mat-form-field>
</div>
</div> </div>
<div class="row mt-2"> <div class="row mt-2">
<div class="col-auto pb-4"> <div class="col-auto pb-4">

View File

@ -33,7 +33,7 @@ export class StartNewDescriptionDialogComponent extends BaseComponent {
getSelectedItem: (selectedItem: any) => this.dmpService.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), getSelectedItem: (selectedItem: any) => this.dmpService.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])),
displayFn: (item: Dmp) => item.label, displayFn: (item: Dmp) => item.label,
titleFn: (item: Dmp) => item.label, titleFn: (item: Dmp) => item.label,
valueAssign: (item: Dmp) => this.findSection(item), valueAssign: (item: Dmp) => item.id,
}; };
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[], statuses?: DmpStatus[], dmpDescriptionTemplateSubQuery?: DmpDescriptionTemplateLookup): DmpLookup { private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[], statuses?: DmpStatus[], dmpDescriptionTemplateSubQuery?: DmpDescriptionTemplateLookup): DmpLookup {
@ -48,11 +48,6 @@ export class StartNewDescriptionDialogComponent extends BaseComponent {
nameof<Dmp>(x => x.id), nameof<Dmp>(x => x.id),
nameof<Dmp>(x => x.label), nameof<Dmp>(x => x.label),
nameof<Dmp>(x => x.createdAt), nameof<Dmp>(x => x.createdAt),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
] ]
}; };
if (dmpDescriptionTemplateSubQuery != null) lookup.dmpDescriptionTemplateSubQuery = dmpDescriptionTemplateSubQuery; if (dmpDescriptionTemplateSubQuery != null) lookup.dmpDescriptionTemplateSubQuery = dmpDescriptionTemplateSubQuery;
@ -94,17 +89,6 @@ export class StartNewDescriptionDialogComponent extends BaseComponent {
this.dialogRef.close(this.data); this.dialogRef.close(this.data);
} }
findSection(dmp: Dmp){
this.sections = dmp.blueprint.definition.sections.filter(x => x.hasTemplates == true);
if(this.sections.length == 1){
this.formGroup.get('sectionId').setValue(this.sections[0].id);
}else {
this.formGroup.get('sectionId').setValue(null);
}
return dmp.id
}
getDatasetDisplay(item: any): string { getDatasetDisplay(item: any): string {
// if (!this.isPublic) { // if (!this.isPublic) {
// return (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label']; // return (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label'];