Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanconstantinescu committed Jul 30, 2019
2 parents 62d81de + 1d930a8 commit 8571e17
Show file tree
Hide file tree
Showing 26 changed files with 573 additions and 217 deletions.
241 changes: 124 additions & 117 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const routes: Routes = [

@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }),
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules, useHash: true }),
],
exports: [
RouterModule,
Expand Down
16 changes: 8 additions & 8 deletions src/app/assets/guards/asset-detail.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export class AssetDetailGuard implements CanActivate {
hasDetailedAsset(aId: number): Observable<boolean> {
return this.store.pipe(select(fromStore.hasDetailByAssetId(aId)))
.pipe(
tap((hasDetail: boolean) => {
if (!hasDetail) {
this.store.dispatch(new fromStore.LoadAssetDetail(aId));
}
}),
filter((hasDetail: boolean) => hasDetail),
take(1)
);
tap((hasDetail: boolean) => {
if (!hasDetail) {
this.store.dispatch(new fromStore.LoadAssetDetail(aId));
}
}),
filter((hasDetail: boolean) => hasDetail),
take(1)
);
}
}
2 changes: 1 addition & 1 deletion src/app/core/http/decisions-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DecisionsApiService {
}
}

return this.http.get<DecisionSummary[]>(environment.api_url + '/decisions/search', { params })
return this.http.get<DecisionSummary[]>(environment.api_url + '/search/asset', { params })
.pipe(
catchError(aError => observableThrowError(aError))
);
Expand Down
14 changes: 14 additions & 0 deletions src/app/core/models/decision-filter.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@ export class DecisionFilter {
fileNumber: string;
personId: string;
personName: string;

constructor(decisionNumber?: string, fileNumber?: string, personId?: string, personName?: string) {
this.decisionNumber = decisionNumber || null;
this.fileNumber = fileNumber || null;
this.personId = personId || null;
this.personName = personName || null;
}

getFormValues(form) {
if (this.hasOwnProperty(form.filterKey)) {
this[form.filterKey] = form.filterValue
return
}
}
}
6 changes: 5 additions & 1 deletion src/app/core/models/decision-response.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export interface DecisionResponse {
id: number;
name: string;
defendantName: string;
decisionNumber: string;
fileNumber: string;
stage: string;
assetId: number;
}
27 changes: 18 additions & 9 deletions src/app/core/models/decision-summary.model.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
export class DecisionSummary {
number: string;
date: Date;
id: number;
defendantName: string;
decisionNumber: string;
fileNumber: string;
emitterInstitution: string;
historicalStageId: number;
stage: string;
assetId: number;

constructor(number: string, date: Date, fileNumber: string, emitterInstitution: string, historicalStageId: number) {
this.number = number;
this.date = date;
constructor(
id: number,
defendantName: string,
decisionNumber: string,
fileNumber: string,
stage: string,
assetId: number
) {
this.id = id;
this.defendantName = defendantName;
this.decisionNumber = decisionNumber;
this.fileNumber = fileNumber;
this.emitterInstitution = emitterInstitution;
this.historicalStageId = historicalStageId;
this.stage = stage;
this.assetId = assetId;
}
}
24 changes: 20 additions & 4 deletions src/app/core/models/decision.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
export interface IDecision {
id: number;
name: string;
defendantName: string;
decisionNumber: string;
fileNumber: string;
stage: string;
assetId: number;
}

export class Decision {
id: number;
name: string;
defendantName: string;
decisionNumber: string;
fileNumber: string;
stage: string;
assetId: number;

constructor(aData?: IDecision) {
if (aData) {
Expand All @@ -15,13 +23,21 @@ export class Decision {

fromJson(aJson: IDecision) {
this.id = aJson.id;
this.name = aJson.name;
this.defendantName = aJson.defendantName;
this.decisionNumber = aJson.decisionNumber;
this.fileNumber = aJson.fileNumber;
this.stage = aJson.stage;
this.assetId = aJson.assetId;
}

toJson(): IDecision {
return {
id: this.id,
name: this.name,
defendantName: this.defendantName,
decisionNumber: this.decisionNumber,
fileNumber: this.fileNumber,
stage: this.stage,
assetId: this.assetId,
} as IDecision;
}
}
11 changes: 10 additions & 1 deletion src/app/core/services/decisions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { map, mergeMap, toArray } from 'rxjs/operators';

import { DecisionsApiService } from '../http';
import { Decision, DecisionResponse } from '../models';
import { Decision, DecisionFilter, DecisionResponse } from '../models';

@Injectable()
export class DecisionsService {
Expand All @@ -19,4 +19,13 @@ export class DecisionsService {
toArray()
);
}

public search(filter: DecisionFilter): Observable<Decision[]> {
return this.decisionsApiService.search(filter)
.pipe(
mergeMap(a => a),
map((aDecision: DecisionResponse) => new Decision(aDecision)),
toArray()
);
}
}
26 changes: 24 additions & 2 deletions src/app/core/store/actions/decisions.action.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Action } from '@ngrx/store';
import { Decision } from '../../models';
import { Decision, DecisionFilter } from '../../models';

export enum DecisionsActionTypes {
LoadDecisions = '[Decisions] Load Decisions',
LoadDecisionsFail = '[Decisions] Load Decisions Fail',
LoadDecisionsSuccess = '[Decisions] Load Decisions Success',
LoadSearchDecisions = '[Decisions] Load Search Decisions',
LoadSearchDecisionsFail = '[Decisions] Load Search Decisions Fail',
LoadSearchDecisionsSuccess = '[Decisions] Load Search Decisions Success',
}

// load decisions
Expand All @@ -23,8 +26,27 @@ export class LoadDecisionsSuccess implements Action {
constructor(public payload: Decision[]) {}
}

// load search decisions
export class LoadSearchDecisions implements Action {
readonly type: string = DecisionsActionTypes.LoadDecisions;
constructor(public payload?: any) {}
}

export class LoadSearchDecisionsFail implements Action {
readonly type: string = DecisionsActionTypes.LoadDecisionsFail;
constructor(public payload: any) {}
}

export class LoadSearchDecisionsSuccess implements Action {
readonly type: string = DecisionsActionTypes.LoadDecisionsSuccess;
constructor(public payload: Decision[]) {}
}

// action types
export type DecisionsAction =
LoadDecisions
| LoadDecisionsFail
| LoadDecisionsSuccess;
| LoadDecisionsSuccess
| LoadSearchDecisions
| LoadSearchDecisionsFail
| LoadSearchDecisionsSuccess;
15 changes: 15 additions & 0 deletions src/app/core/store/effects/decisions.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ export class DecisionsEffects {
})
);

@Effect()
loadDecisionsSearch$ = this.actions$
.pipe(
ofType(decisionActions.DecisionsActionTypes.LoadSearchDecisions),
map((action: decisionActions.LoadSearchDecisions) => action.payload),
switchMap((aPayload) => {
return this.decisionsService
.search(aPayload)
.pipe(
map(aDecisions => new decisionActions.LoadSearchDecisionsSuccess(aDecisions)),
catchError(error => of(new decisionActions.LoadSearchDecisionsFail(error)))
)
})
);

constructor(private actions$: Actions,
private decisionsService: DecisionsService
) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/store/selectors/decisions.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSelector } from '@ngrx/store';

import { Decision } from '@app/core/models/decision.model';
import { Decision, DecisionFilter } from '../../models';
import * as fromFeature from '../reducers';
import * as fromDecisions from '../reducers/decisions.reducer';

Expand Down Expand Up @@ -34,3 +34,4 @@ export const getDecisionById = (aDecisionId: number) => createSelector(
getDecisionsEntities,
(entities) => entities[aDecisionId] || undefined
);
export const getDecisionSearchLoaded = createSelector(getDecisionState, fromDecisions.getDecisionsLoaded);
7 changes: 7 additions & 0 deletions src/app/search/containers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SearchComponent } from './search/search.component';

export const components: any[] = [
SearchComponent,
];

export * from './search/search.component';
61 changes: 61 additions & 0 deletions src/app/search/containers/search/search.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<section id="search-page" class="page-view">
<div class="mat-elevation-z8 table-wrapper">
<div class="table-header">
<form (ngSubmit)="onSubmit()" [formGroup]="searchForm" fxLayout="row">
<mat-form-field fxFlex="29" fxFlexOffset="10">
<mat-select name="filterKey" placeholder="Categorie" formControlName="filterKey">
<mat-option *ngFor="let filterProperty of filterProperties" [value]="filterProperty.value">{{
filterProperty.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="39">
<input matInput name="filterValue" placeholder="Introdu numarul" formControlName="filterValue"/>
</mat-form-field>
<button fxFlex="10" mat-raised-button><i class="material-icons">search</i></button>
</form>
</div>
<div *ngIf="tableConfig.dataSource" class="table-content">
<mat-table #table [dataSource]="tableConfig.dataSource" matSort fxFlex matSortActive="id" matSortDirection="desc">
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef mat-sort-header>ID</mat-header-cell>
<mat-cell *matCellDef="let decisionSummary">{{ decisionSummary.id }}</mat-cell>
</ng-container>

<ng-container matColumnDef="defendantName">
<mat-header-cell *matHeaderCellDef mat-sort-header>Nume</mat-header-cell>
<mat-cell *matCellDef="let decisionSummary">{{ decisionSummary.name }}</mat-cell>
</ng-container>

<ng-container matColumnDef="decisionNumber">
<mat-header-cell *matHeaderCellDef mat-sort-header>Numar decizie</mat-header-cell>
<mat-cell *matCellDef="let decisionSummary">{{ decisionSummary.type }}</mat-cell>
</ng-container>

<ng-container matColumnDef="fileNumber">
<mat-header-cell *matHeaderCellDef mat-sort-header>Numar dosar</mat-header-cell>
<mat-cell *matCellDef="let decisionSummary">{{ decisionSummary.getAddress() }}</mat-cell>
</ng-container>

<ng-container matColumnDef="stage">
<mat-header-cell *matHeaderCellDef mat-sort-header>Stadiu</mat-header-cell>
<mat-cell *matCellDef="let decisionSummary">{{ decisionSummary.getAddress() }}</mat-cell>
</ng-container>

<ng-container matColumnDef="buttons">
<mat-header-cell *matHeaderCellDef>Overview</mat-header-cell>
<mat-cell *matCellDef="let row">
<button mat-raised-button (click)="viewAsset(row)"><i class="material-icons">View</i></button>
</mat-cell>
</ng-container>

<mat-header-row *matHeaderRowDef="tableConfig.displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: tableConfig.displayedColumns;"></mat-row>
</mat-table>

<div class="table-footer">
<mat-paginator #paginator [hidePageSize]="true" [pageSize]="20" [showFirstLastButtons]="true"></mat-paginator>
</div>
</div>
</div>
</section>
78 changes: 78 additions & 0 deletions src/app/search/containers/search/search.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@import 'variables';

.page-view {
height: calc(100% - #{$anabi-header-height});
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

// material table layout
.table-wrapper {
box-sizing: border-box;
margin: $anabi-table-margin;
height: calc(100% - #{2 * $anabi-table-margin});
width: calc(100% - #{2 * $anabi-table-margin});
min-height: calc(100% - #{2 * $anabi-table-margin});
min-width: calc(100% - #{2 * $anabi-table-margin});
display: flex;
flex-direction: column;

.table-header {
form {
width: 100%;
mat-form-field {
margin-left: $anabi-table-margin;
}
button {
background-color: $search-button-color;
height: $search-button-height;
border-radius: 0px;
}
}
}
.table-header,
.table-footer {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
min-height: 100px;
padding: 2 * $anabi-table-padding;

mat-form-field {
flex-grow: 1;
height: 60px;
}
}

.table-header,
.table-footer,
.mat-paginator {
background-color: $anabi-table-accent;
}

.mat-table {
overflow-y: auto;
flex: 1 1 auto;

.mat-header-row {
position: sticky;
top: 0;
background: white;
}
}
}

// material dialog types
mat-dialog-container {
.mat-dialog-title {
font-weight: bold;
}

.mat-dialog-actions:last-child {
margin-bottom: 0;
padding-bottom: 0;
}
}
Loading

0 comments on commit 8571e17

Please sign in to comment.