Fixed import menu in pref side nav missing.
This commit is contained in:
parent
48a929c49d
commit
17f9328c8a
7 changed files with 35 additions and 14 deletions
|
|
@ -120,7 +120,7 @@ public static class Seed
|
||||||
new AppUserSideNavStream()
|
new AppUserSideNavStream()
|
||||||
{
|
{
|
||||||
Name = "browse-authors",
|
Name = "browse-authors",
|
||||||
StreamType = SideNavStreamType.BrowseAuthors,
|
StreamType = SideNavStreamType.BrowsePeople,
|
||||||
Order = 6,
|
Order = 6,
|
||||||
IsProvided = true,
|
IsProvided = true,
|
||||||
Visible = true
|
Visible = true
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,5 @@ public enum SideNavStreamType
|
||||||
ExternalSource = 6,
|
ExternalSource = 6,
|
||||||
AllSeries = 7,
|
AllSeries = 7,
|
||||||
WantToRead = 8,
|
WantToRead = 8,
|
||||||
BrowseAuthors = 9
|
BrowsePeople = 9
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ export class SortFieldPipe implements PipeTransform {
|
||||||
transform<T extends number>(value: T, entityType: ValidFilterEntity): string {
|
transform<T extends number>(value: T, entityType: ValidFilterEntity): string {
|
||||||
|
|
||||||
switch (entityType) {
|
switch (entityType) {
|
||||||
case "series":
|
case 'series':
|
||||||
return this.seriesSortFields(value as SortField);
|
return this.seriesSortFields(value as SortField);
|
||||||
case "person":
|
case 'person':
|
||||||
return this.personSortFields(value as PersonSortField);
|
return this.personSortFields(value as PersonSortField);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,33 @@ export class AccountService {
|
||||||
return roles.some(role => user.roles.includes(role));
|
return roles.some(role => user.roles.includes(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If User or Admin, will return false
|
||||||
|
* @param user
|
||||||
|
* @param restrictedRoles
|
||||||
|
*/
|
||||||
|
hasAnyRestrictedRole(user: User, restrictedRoles: Array<Role> = []) {
|
||||||
|
if (!user || !user.roles) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (restrictedRoles.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user is an admin, they have the role
|
||||||
|
if (this.hasAdminRole(user)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (restrictedRoles.length > 0 && restrictedRoles.some(role => user.roles.includes(role))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
hasAdminRole(user: User) {
|
hasAdminRole(user: User) {
|
||||||
return user && user.roles.includes(Role.Admin);
|
return user && user.roles.includes(Role.Admin);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,6 @@ export class MetadataFilterRowComponent<TFilter extends number = number, TSort e
|
||||||
uiLabel: Signal<FilterRowUi | null> = computed(() => null);
|
uiLabel: Signal<FilterRowUi | null> = computed(() => null);
|
||||||
isMultiSelectDropdownAllowed: Signal<boolean> = computed(() => false);
|
isMultiSelectDropdownAllowed: Signal<boolean> = computed(() => false);
|
||||||
|
|
||||||
sortFieldOptions: Signal<{title: string, value: TFilter}[]> = computed(() => []);
|
|
||||||
filterFieldOptions: Signal<{title: string, value: TFilter}[]> = computed(() => []);
|
filterFieldOptions: Signal<{title: string, value: TFilter}[]> = computed(() => []);
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
@ -210,9 +209,6 @@ export class MetadataFilterRowComponent<TFilter extends number = number, TSort e
|
||||||
return this.comparisonSignal() === FilterComparison.Contains || this.comparisonSignal() === FilterComparison.NotContains || this.comparisonSignal() === FilterComparison.MustContains;
|
return this.comparisonSignal() === FilterComparison.Contains || this.comparisonSignal() === FilterComparison.NotContains || this.comparisonSignal() === FilterComparison.MustContains;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.sortFieldOptions = computed(() => {
|
|
||||||
return this.filterUtilitiesService.getSortFields(this.entityType());
|
|
||||||
});
|
|
||||||
this.filterFieldOptions = computed(() => {
|
this.filterFieldOptions = computed(() => {
|
||||||
return this.filterUtilitiesService.getFilterFields(this.entityType());
|
return this.filterUtilitiesService.getFilterFields(this.entityType());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<label for="sort-options" class="form-label">{{t('sort-by-label')}}</label>
|
<label for="sort-options" class="form-label">{{t('sort-by-label')}}</label>
|
||||||
<app-sort-button [disabled]="filterSettings().sortDisabled" (update)="updateSortOrder($event)" [isAscending]="isAscendingSort" />
|
<app-sort-button [disabled]="filterSettings().sortDisabled" (update)="updateSortOrder($event)" [isAscending]="isAscendingSort" />
|
||||||
<select id="sort-options" class="form-select" formControlName="sortField" style="height: 38px;">
|
<select id="sort-options" class="form-select" formControlName="sortField" style="height: 38px;">
|
||||||
@for(field of filterFieldOptions(); track field.value) {
|
@for(field of sortFieldOptions(); track field.value) {
|
||||||
<option [value]="field.value">{{field.title}}</option>
|
<option [value]="field.value">{{field.title}}</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -273,13 +273,11 @@ export class PreferenceNavComponent implements AfterViewInit {
|
||||||
hasAnyChildren(user: User, section: PrefSection) {
|
hasAnyChildren(user: User, section: PrefSection) {
|
||||||
// Filter out items where the user has a restricted role
|
// Filter out items where the user has a restricted role
|
||||||
const visibleItems = section.children.filter(item =>
|
const visibleItems = section.children.filter(item =>
|
||||||
item.restrictRoles.length === 0 || !this.accountService.hasAnyRole(user, item.restrictRoles)
|
(item.restrictRoles.length === 0 || !this.accountService.hasAnyRestrictedRole(user, item.restrictRoles)) &&
|
||||||
|
(item.roles.length === 0 || this.accountService.hasAnyRole(user, item.roles))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if the user has any allowed roles in the remaining items
|
return visibleItems.length > 0;
|
||||||
return visibleItems.some(item =>
|
|
||||||
this.accountService.hasAnyRole(user, item.roles)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse() {
|
collapse() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue