Skip to content

Commit

Permalink
feat: Updated src/app/features/user-area/user-modu
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 1, 2023
1 parent be49fd0 commit 5014e3b
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/app/features/user-area/user-modules/user-modules.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ModuleMinimalViewConfig } from 'src/app/components/module-parts/module-
import { SupabaseService } from 'src/app/features/backend/supabase.service';
import { SubManager } from 'src/app/shared-interproject/directives/subscription-manager';
import { UserAreaDataService } from '../user-area-data.service';
import { ModuleUtilService } from 'src/app/services/module-util.service';

export interface UserModulesComponentViewConfig {
hideAddModulesButton: boolean;
Expand All @@ -22,13 +23,36 @@ export class UserModulesComponent extends SubManager {
@Input() modulesViewConfig: ModuleMinimalViewConfig;
@Input() userModulesComponentViewConfig: UserModulesComponentViewConfig = userModulesDefaultViewConfig;
@Input() readonly encloseVertically = true;
modules$ = this.dataService.modules$.pipe(
map(modules => this.moduleUtilService.sortModules(modules, 'type'))
);

constructor(
public backend: SupabaseService,
public dataService: UserAreaDataService
public dataService: UserAreaDataService,
private moduleUtilService: ModuleUtilService
) {
super();
this.dataService.updateModulesData$.next();

}

}
onSortChange(sortBy: string) {
this.modules$ = this.modules$.pipe(
map(modules => this.moduleUtilService.sortModules(modules, sortBy))
);
}

onGroupChange(groupBy: string) {
this.modules$ = this.modules$.pipe(
map(modules => {
if (groupBy === 'type') {
return this.moduleUtilService.groupModulesByType(modules);
} else if (groupBy === 'manufacturer') {
return this.moduleUtilService.groupByManufacturer(modules);
} else {
return modules;
}
})
);
}

0 comments on commit 5014e3b

Please sign in to comment.