module refactor

This commit is contained in:
Daniel Rodriguez 2021-09-20 17:24:43 +02:00
parent 6304971674
commit 3eb73961f3
13 changed files with 58 additions and 15 deletions

View file

@ -6,11 +6,11 @@ import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: '',
loadChildren: () => import('../modules/pool/pool.module').then(m => m.PoolModule) loadChildren: () => import('../modules/layout/layout.module').then(m => m.LayoutModule)
}, },
{ {
path: '**', path: '**',
loadChildren: () => import('../modules/pool/pool.module').then(m => m.PoolModule) loadChildren: () => import('../modules/layout/layout.module').then(m => m.LayoutModule)
} }
]; ];

View file

@ -1,7 +1,7 @@
<div id="nav"> <div id="nav">
<img src="../../assets/images/logo.png" alt="TFTPaths"> <img src="../../assets/images/logo.png" alt="TFTPaths">
</div> </div>
<app-home></app-home> <<router-outlet></router-outlet>>
<div id="footer"> <div id="footer">
</div> </div>

View file

@ -0,0 +1,23 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LayoutComponent } from './components/layout/layout.component';
const routes: Routes = [
{ path: '',
component: LayoutComponent,
children: [
{
path: '',
loadChildren: () => import('../pool/pool.module').then(m => m.PoolModule)
}
]
},
{ path: '**', component: LayoutComponent, pathMatch: 'full' }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class LayoutRoutingModule { }

View file

@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LayoutComponent } from './components/layout/layout.component';
import { PoolModule } from '../pool/pool.module';
import { LayoutRoutingModule } from './layout-routing.module';
@NgModule({
declarations: [
LayoutComponent
],
imports: [
CommonModule,
LayoutRoutingModule,
PoolModule
]
})
export class LayoutModule { }

View file

@ -13,12 +13,12 @@ import { DataToShare } from 'src/models/dataToShare';
@Component({ @Component({
selector: 'app-home', selector: 'app-pool',
templateUrl: './home.component.html', templateUrl: './pool.component.html',
styleUrls: ['./home.component.scss'] styleUrls: ['./pool.component.scss']
}) })
export class HomeComponent implements OnInit, OnDestroy { export class PoolComponent implements OnInit, OnDestroy {
formFilters: FormGroup; formFilters: FormGroup;
bonusesPool: Bonus[] = []; bonusesPool: Bonus[] = [];
champions: Champion[] = []; champions: Champion[] = [];

View file

@ -1,11 +1,11 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { LayoutComponent } from 'src/modules/pool/components/layout/layout.component'; import { PoolComponent } from './components/pool/pool.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component: LayoutComponent, pathMatch: 'full' }, { path: '', component: PoolComponent, pathMatch: 'full' },
{ path: '**', component: LayoutComponent, pathMatch: 'full' } { path: '**', component: PoolComponent, pathMatch: 'full' }
]; ];
@NgModule({ @NgModule({

View file

@ -6,13 +6,11 @@ import { ReactiveFormsModule } from '@angular/forms';
import { PoolService } from 'src/modules/pool/services/pool.service'; import { PoolService } from 'src/modules/pool/services/pool.service';
import { LayoutComponent } from './components/layout/layout.component'; import { PoolComponent } from './components/pool/pool.component';
import { HomeComponent } from './components/home/home.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
LayoutComponent, PoolComponent
HomeComponent
], ],
imports: [ imports: [
CommonModule, CommonModule,

View file

@ -152,9 +152,11 @@ export class PoolService {
* Update role pool * Update role pool
*/ */
updatePool() { updatePool() {
let pool = [];
this.championsPool.forEach(champion => { this.championsPool.forEach(champion => {
this.rolesPool = _.union(this.rolesPool, champion.roles); pool = _.union(this.rolesPool, champion.roles);
}); });
this.rolesPool = pool;
} }
/** /**

View file

@ -20,6 +20,7 @@ export class Constants {
public static championName = 'name'; public static championName = 'name';
public static roles = traits.map(trait => trait.name); public static roles = traits.map(trait => trait.name);
public static bonuses: Bonus [] = traits.reduce((previous, current) => { public static bonuses: Bonus [] = traits.reduce((previous, current) => {
current.sets.forEach(set => { current.sets.forEach(set => {
previous.push({ previous.push({