misc fixes

This commit is contained in:
lotte
2019-05-08 16:32:32 +02:00
parent 8865d6e049
commit 22bd69ba13
7 changed files with 61 additions and 35 deletions

View File

@@ -138,13 +138,18 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
parentID: 'new', parentID: 'new',
active: false, active: false,
visible: true, visible: true,
// model: {
// type: MenuItemType.ONCLICK,
// text: 'menu.section.new_item',
// function: () => {
// this.modalService.open(CreateItemParentSelectorComponent);
// }
// } as OnClickMenuItemModel,
model: { model: {
type: MenuItemType.ONCLICK, type: MenuItemType.LINK,
text: 'menu.section.new_item', text: 'menu.section.new_item',
function: () => { link: '/submit'
this.modalService.open(CreateItemParentSelectorComponent); } as LinkMenuItemModel,
}
} as OnClickMenuItemModel,
}, },
{ {
id: 'new_item_version', id: 'new_item_version',
@@ -154,7 +159,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.new_item_version', text: 'menu.section.new_item_version',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
@@ -230,7 +235,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.import_metadata', text: 'menu.section.import_metadata',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -241,7 +246,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.import_batch', text: 'menu.section.import_batch',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
/* Export */ /* Export */
@@ -264,7 +269,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.export_community', text: 'menu.section.export_community',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -275,7 +280,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.export_collection', text: 'menu.section.export_collection',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -286,7 +291,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.export_item', text: 'menu.section.export_item',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, { }, {
id: 'export_metadata', id: 'export_metadata',
@@ -296,7 +301,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.export_metadata', text: 'menu.section.export_metadata',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
@@ -320,7 +325,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.access_control_people', text: 'menu.section.access_control_people',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -331,7 +336,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.access_control_groups', text: 'menu.section.access_control_groups',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -342,7 +347,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.access_control_authorizations', text: 'menu.section.access_control_authorizations',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
@@ -377,7 +382,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.find_withdrawn_items', text: 'menu.section.find_withdrawn_items',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{ {
@@ -388,7 +393,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.find_private_items', text: 'menu.section.find_private_items',
link: '/admin/items' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
@@ -435,7 +440,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.curation_task', text: 'menu.section.curation_task',
link: '/curation' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
icon: 'filter', icon: 'filter',
index: 7 index: 7
@@ -449,7 +454,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.statistics_task', text: 'menu.section.statistics_task',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
icon: 'chart-bar', icon: 'chart-bar',
index: 8 index: 8
@@ -463,7 +468,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: { model: {
type: MenuItemType.LINK, type: MenuItemType.LINK,
text: 'menu.section.control_panel', text: 'menu.section.control_panel',
link: '#' link: ''
} as LinkMenuItemModel, } as LinkMenuItemModel,
icon: 'cogs', icon: 'cogs',
index: 9 index: 9

View File

@@ -18,8 +18,8 @@ import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorat
templateUrl: './expandable-admin-sidebar-section.component.html', templateUrl: './expandable-admin-sidebar-section.component.html',
styleUrls: ['./expandable-admin-sidebar-section.component.scss'], styleUrls: ['./expandable-admin-sidebar-section.component.scss'],
animations: [rotate, slide, bgColor] animations: [rotate, slide, bgColor]
}) })
@rendersSectionForMenu(MenuID.ADMIN, true) @rendersSectionForMenu(MenuID.ADMIN, true)
export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit { export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit {
/** /**

View File

@@ -1,18 +1,19 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs'; import { EMPTY, Observable } from 'rxjs';
import { RemoteData } from '../core/data/remote-data'; import { RemoteData } from '../core/data/remote-data';
import { getSucceededRemoteData } from '../core/shared/operators'; import { getSucceededRemoteData } from '../core/shared/operators';
import { ItemDataService } from '../core/data/item-data.service'; import { ItemDataService } from '../core/data/item-data.service';
import { Item } from '../core/shared/item.model'; import { Item } from '../core/shared/item.model';
import { tap } from 'rxjs/operators'; import { hasValue } from '../shared/empty.util';
import { find, map } from 'rxjs/operators';
/** /**
* This class represents a resolver that requests a specific item before the route is activated * This class represents a resolver that requests a specific item before the route is activated
*/ */
@Injectable() @Injectable()
export class ItemPageResolver implements Resolve<RemoteData<Item>> { export class ItemPageResolver implements Resolve<RemoteData<Item>> {
constructor(private itemService: ItemDataService) { constructor(private itemService: ItemDataService, private router: Router) {
} }
/** /**
@@ -22,8 +23,16 @@ export class ItemPageResolver implements Resolve<RemoteData<Item>> {
* @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route * @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route
*/ */
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> {
return this.itemService.findById(route.params.id).pipe( return this.itemService.findById(route.params.id)
getSucceededRemoteData() .pipe(
find((RD) => hasValue(RD.error) || RD.hasSucceeded),
map((RD) => {
if (hasValue(RD.error)) {
this.router.navigateByUrl('/404', { skipLocationChange: true });
return null;
}
return RD;
})
); );
} }
} }

View File

@@ -5,7 +5,7 @@
</a> </a>
<nav class="navbar navbar-light navbar-expand-md float-right px-0"> <nav class="navbar navbar-light navbar-expand-md float-right px-0">
<a href="#" class="px-1"><i class="fas fa-search fa-lg fa-fw" [title]="'nav.search' | translate"></i></a> <a href="/search" class="px-1"><i class="fas fa-search fa-lg fa-fw" [title]="'nav.search' | translate"></i></a>
<ds-lang-switch></ds-lang-switch> <ds-lang-switch></ds-lang-switch>
<ds-auth-nav-menu></ds-auth-nav-menu> <ds-auth-nav-menu></ds-auth-nav-menu>
<div class="pl-2"> <div class="pl-2">

View File

@@ -1 +1 @@
<a class="nav-item nav-link" [routerLink]="getRouterLink()">{{item.text | translate}}</a> <a class="nav-item nav-link" [ngClass]="{'disabled': !hasLink}" [routerLink]="getRouterLink()">{{item.text | translate}}</a>

View File

@@ -1,8 +1,9 @@
import { Component, Inject, Input } from '@angular/core'; import { Component, Inject, Input, OnInit } from '@angular/core';
import { LinkMenuItemModel } from './models/link.model'; import { LinkMenuItemModel } from './models/link.model';
import { MenuItemType } from '../initial-menus-state'; import { MenuItemType } from '../initial-menus-state';
import { rendersMenuItemForType } from '../menu-item.decorator'; import { rendersMenuItemForType } from '../menu-item.decorator';
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config'; import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
import { isNotEmpty } from '../../empty.util';
/** /**
* Component that renders a menu section of type LINK * Component that renders a menu section of type LINK
@@ -12,13 +13,22 @@ import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
templateUrl: './link-menu-item.component.html' templateUrl: './link-menu-item.component.html'
}) })
@rendersMenuItemForType(MenuItemType.LINK) @rendersMenuItemForType(MenuItemType.LINK)
export class LinkMenuItemComponent { export class LinkMenuItemComponent implements OnInit {
item: LinkMenuItemModel; item: LinkMenuItemModel;
hasLink: boolean;
constructor(@Inject('itemModelProvider') item: LinkMenuItemModel, @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) { constructor(@Inject('itemModelProvider') item: LinkMenuItemModel, @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) {
this.item = item; this.item = item;
} }
ngOnInit(): void {
this.hasLink = isNotEmpty(this.item.link);
}
getRouterLink() { getRouterLink() {
if (this.hasLink) {
return this.EnvConfig.ui.nameSpace + this.item.link; return this.EnvConfig.ui.nameSpace + this.item.link;
} }
return undefined;
}
} }

View File

@@ -6,6 +6,7 @@ import { RouterModule } from '@angular/router';
import { LinkMenuItemComponent } from './menu-item/link-menu-item.component'; import { LinkMenuItemComponent } from './menu-item/link-menu-item.component';
import { TextMenuItemComponent } from './menu-item/text-menu-item.component'; import { TextMenuItemComponent } from './menu-item/text-menu-item.component';
import { OnClickMenuItemComponent } from './menu-item/onclick-menu-item.component'; import { OnClickMenuItemComponent } from './menu-item/onclick-menu-item.component';
import { CommonModule } from '@angular/common';
const COMPONENTS = [ const COMPONENTS = [
MenuSectionComponent, MenuSectionComponent,
@@ -23,7 +24,8 @@ const ENTRY_COMPONENTS = [
const MODULES = [ const MODULES = [
TranslateModule, TranslateModule,
RouterModule RouterModule,
CommonModule
]; ];
const PROVIDERS = [ const PROVIDERS = [