Skip to content

NRPT-749 NRPT-754 Add Court Convictions BCMI #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import { ChangeDetectorRef } from '@angular/core';
// import { FormControl, FormGroup } from '@angular/forms';
import { takeUntil } from 'rxjs/operators';


@Component({
selector: 'app-mines-administrative-penalty-add-edit',
templateUrl: './mines-administrative-penalty-add-edit.component.html',
styleUrls: ['./mines-administrative-penalty-add-edit.component.scss']
})
export class MinesAdministrativePenaltyAddEditComponent extends
AdministrativePenaltyAddEditComponent implements OnInit {

export class MinesAdministrativePenaltyAddEditComponent extends AdministrativePenaltyAddEditComponent
implements OnInit {
public componentTitle = 'BCMI Administrative Penalty Record';
public defaultAgency = 'EMLI';
public defaultAuthor = 'BC Government';
Expand All @@ -32,7 +30,7 @@ export class MinesAdministrativePenaltyAddEditComponent extends
protected utils: Utils,
protected _changeDetectionRef: ChangeDetectorRef,
// @ts-ignore used by record-association component
protected storeService: StoreService,
protected storeService: StoreService
) {
super(
route,
Expand All @@ -45,7 +43,7 @@ export class MinesAdministrativePenaltyAddEditComponent extends
_changeDetectionRef,
storeService
);
}
}

ngOnInit() {
this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => {
Expand All @@ -65,24 +63,31 @@ export class MinesAdministrativePenaltyAddEditComponent extends
unlistedMine: ''
};
}
super.buildForm();
super.subscribeToFormControlChanges();
this.loading = false;
this._changeDetectionRef.detectChanges();
super.buildForm();
super.subscribeToFormControlChanges();
this.loading = false;
this._changeDetectionRef.detectChanges();
});
}

navigateToDetails() {
this.router.navigate(
['records', 'administrative-penalties', this.currentRecord._id, 'detail']
);
this.router.navigate(['records', 'administrative-penalties', this.currentRecord._id, 'detail']);
}

async submit() {
await super.save();
this.router.navigate(
['mines', 'enforcement-actions', 'administrative-penalties', this.currentRecord._id, 'detail']
);

if (!this.isEditing) {
this.router.navigate(['mines', 'enforcement-actions']);
} else {
this.router.navigate([
'mines',
'enforcement-actions',
'administrative-penalties',
this.currentRecord._id,
'detail'
]);
}
}

cancel() {
Expand All @@ -93,7 +98,13 @@ export class MinesAdministrativePenaltyAddEditComponent extends
if (!this.isEditing) {
this.router.navigate(['mines', 'enforcement-actions']);
} else {
this.router.navigate(['mines', 'enforcement-actions', 'administrative-penalties', this.currentRecord._id, 'detail']);
this.router.navigate([
'mines',
'enforcement-actions',
'administrative-penalties',
this.currentRecord._id,
'detail'
]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { takeUntil } from 'rxjs/operators';
import { AdministrativePenaltyDetailComponent } from '../../../records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component';
import { RecordUtils } from '../../../records/utils/record-utils';
import { FactoryService } from '../../../services/factory.service';

import { StoreService } from 'nrpti-angular-components';

@Component({
selector: 'app-mines-administrative-penalty-detail',
Expand All @@ -21,20 +21,20 @@ export class MinesAdministrativePenaltyDetailComponent extends AdministrativePen
public router: Router,
public changeDetectionRef: ChangeDetectorRef,
public factoryService: FactoryService,
private storeService: StoreService
) {
super(route, router, changeDetectionRef, factoryService);
}

ngOnInit() {
this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => {
if (!res || !res.record || !res.mines) {
if (!res || !res.record) {
alert("Uh-oh, couldn't load mines AdministrativePenalty");
this.router.navigate(['mines', 'enforcement-actions']);
return;
}

const record = res.record[0] && res.record[0].data;
const mines = res.mines[0].data.searchResults;

this.data = {
_master: new AdministrativePenalty(record),
Expand All @@ -44,6 +44,7 @@ export class MinesAdministrativePenaltyDetailComponent extends AdministrativePen
[]
};

const mines = this.storeService.getItem('mines') || [];
this.mine = mines.filter(elem => elem._sourceRefId === this.data._master.mineGuid);

this.populateTextFields();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
<main class="container-fluid-padding">
<form *ngIf="!loading" [formGroup]="myForm" novalidate>
<section>
<div class="row">
<div class="col-6">
<h4 class="blue-header">BCMI Offense Prosecution Record</h4>
<span *ngIf="isEditing" class="grey-subtext ml-2">{{ lastEditedSubText }}</span>
</div>
<div class="col-6 right-justified-action-btn">
<div class="row mb-2">
<div class="col-12">
<button type="button" class="btn btn-link" (click)="cancel()">Cancel</button>
<button class="btn btn-primary" type="submit" (click)="submit()">
<i class="material-icons">
save
</i>
&nbsp;
<span *ngIf="!isEditing">Save Record</span>
<span *ngIf="isEditing">Update Record</span>
</button>
</div>
</div>
<div class="row">
<div class="col-7"></div>
<div class="col-5">
<span class="grey-subtext">
If content is published on any site, clicking the Save/Update Record button will update the public site
immediately
</span>
</div>
</div>
</div>
</div>
<h4>Basic Information</h4>
<div class="flex-container">
<div class="label-pair" *ngIf="myForm && myForm.controls.dateIssued">
<label for="dateIssued">Date of Judgement</label>
<lib-date-picker
[control]="myForm.controls.dateIssued"
[isValidate]="true"
[minDate]="datepickerMinDate"
[maxDate]="datepickerMaxDate"
></lib-date-picker>
</div>
<div class="label-pair">
<label for="recordType">Type</label>
<input
readonly
name="recordType"
id="recordType"
type="text"
value="Offence Prosecution"
class="form-control"
/>
</div>
<div class="label-pair">
<label for="issuingAgency">Issuing Agency</label>
<input
readonly
name="recordType"
id="recordType"
type="text"
[value]="this.convertAcronyms(this.myForm.get('issuingAgency').value)"
class="form-control"
/>
</div>
<div class="label-pair">
<label for="author">Author</label>
<input readonly name="recordType" id="recordType" type="text" value="BC Government" class="form-control" />
</div>
<div class="label-pair">
<label for="recordName">Record Name</label>
<input name="recordName" id="recordName" type="text" formControlName="recordName" class="form-control" />
</div>
</div>
<record-association-edit
[formGroup]="this.myForm.get('association')"
[mines]="this.storeService.getItem('mines')"
[epicProjects]="[]"
[minesOnly]="true"
(mineLocation)="mineLocation = $event"
>
</record-association-edit>
</section>

<section>
<h4>Issued To</h4>
<app-entity-add-edit [formGroup]="this.myForm.controls.issuedTo"></app-entity-add-edit>
</section>

<section>
<h4>Contravention</h4>
<app-legislation-add-edit [formGroup]="this.myForm.get('legislation')"></app-legislation-add-edit>
<div class="flex-container">
<div class="label-pair">
<label for="offence">Offence</label>
<input readonly name="offence" id="offence" formControlName="offence" class="form-control" />
<span
*ngIf="this.myForm.get('legislation.act').value && !this.myForm.get('offence').value"
class="grey-subtext"
>
No description available for the selected combination of act, regulation, section, subsection and paragraph.
Please double-check that you have filled out those fields correctly; if they are correct, please contact the
system administrator at
<a href="mailto:[email protected]">[email protected]</a>
to request a new description be added to the system.
</span>
</div>
</div>
<h4>Penalties</h4>
<app-penalty-add-edit [formArray]="this.myForm.controls.penalties"></app-penalty-add-edit>
</section>

<section>
<h4>Location Details</h4>
<div class="flex-container">
<div class="label-pair">
<label for="location">Location Description</label>
<input name="location" id="location" type="text" formControlName="location" class="form-control" />
</div>
<div class="label-pair xsm">
<label for="latitude">Latitude</label>
<input name="latitude" id="latitude" type="number" formControlName="latitude" class="form-control" />
</div>
<div class="label-pair xsm">
<label for="longitude">Longitude</label>
<input name="longitude" id="longitude" type="number" formControlName="longitude" class="form-control" />
</div>
</div>
</section>

<section>
<div class="flex-container">
<p class="mr-2">
<strong>Select how you would like to associate information</strong>
</p>
<div name="convictionInfoType" class="radio-group">
<div class="radio">
<input
type="radio"
name="convictionInfoType"
formControlName="convictionInfoType"
id="convictionInfoUrl"
value="url"
/>
<label for="convictionInfoUrl">
URL
</label>
</div>
<div class="radio">
<input
type="radio"
name="convictionInfoType"
formControlName="convictionInfoType"
id="convictionInfoText"
value="text"
/>
<label for="convictionInfoText">
Text Input
</label>
</div>
</div>
</div>
<div *ngIf="this.myForm.get('convictionInfoType').value === 'url'">
<app-document-edit
[documents]="currentRecord ? currentRecord.documents : []"
(documentsToDelete)="documentsToDelete = $event"
></app-document-edit>
<app-document-link-staging
(linksChanged)="links = $event"
(documentsChanged)="documents = $event"
></app-document-link-staging>
</div>
<!-- BCMI description is used to store the text Court Conviction info. Should also be used for NRCED summary -->
<div *ngIf="this.myForm.get('convictionInfoType').value === 'text'">
<div class="flex-container">
<div class="label-pair med">
<label for="bcmiDescription">Court Conviction (Offense Prosecution)</label>
<textarea
name="bcmiDescription"
id="bcmiDescription"
type="text"
formControlName="bcmiDescription"
class="form-control"
rows="5"
></textarea>
</div>
</div>
</div>
</section>

<section>
<div class="row mb-4">
<div class="col-2">
<h4 class="blue-header mb-0">BCMI Site Content</h4>
</div>
<div class="col-4">
<mat-slide-toggle
name="publishBcmi"
id="publishBcmi"
formControlName="publishBcmi"
(change)="togglePublish($event, 'bcmi')"
[checked]="myForm.controls.publishBcmi.value"
ngDefaultControl
>
{{ myForm.controls.publishBcmi.value ? 'Published' : 'Unpublished' }}
</mat-slide-toggle>
<span class="grey-subtext d-block">*Changes made will take effect once you click "Update Record"</span>
</div>
</div>
<div class="row mb-4">
<div class="col-2">
<h4 class="blue-header mb-0">NRCED Site Content</h4>
</div>
<div class="col-4">
<mat-slide-toggle
name="publishNrced"
id="publishNrced"
formControlName="publishNrced"
(change)="togglePublish($event, 'nrced')"
[checked]="myForm.controls.publishNrced.value"
ngDefaultControl
>
{{ myForm.controls.publishNrced.value ? 'Published' : 'Unpublished' }}
</mat-slide-toggle>
<span class="grey-subtext d-block">*Changes made will take effect once you click "Update Record"</span>
</div>
</div>
</section>
</form>
<div class="row mt-4">
<div class="col-6"></div>
<div class="col-6 right-justified-action-btn">
<div class="row mb-2">
<div class="col-12">
<button type="button" class="btn btn-link" (click)="cancel()">Cancel</button>
<button class="btn btn-primary" type="submit" (click)="submit()">
<i class="material-icons">
save
</i>
&nbsp;
<span *ngIf="!isEditing">Save Record</span>
<span *ngIf="isEditing">Update Record</span>
</button>
</div>
</div>
<div class="row">
<div class="col-7"></div>
<div class="col-5">
<span class="grey-subtext">
If content is published on any site, clicking the Save/Update Record button will update the public site
immediately
</span>
</div>
</div>
</div>
</div>
</main>
Loading