Skip to content
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

Adding Filter-scenario to add-scenario component #168

Merged
merged 2 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
59 changes: 36 additions & 23 deletions src/app/course/add-scenario/add-scenario.component.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<clr-modal #addModal [(clrModalOpen)]="addOpen" [clrModalSize]="'lg'">
<h3 class="modal-title">Add Scenario</h3>
<div class="modal-body">
<i>Select scenarios to add to the course. Scenarios will be appended to the current set of scenarios.</i>
<br/>
<i>Filter by using the <clr-icon shape="filter"></clr-icon> icon in the table column headers.</i>
<clr-datagrid [(clrDgSelected)]="selectedScenarios">
<clr-dg-column [clrDgField]="'id'">Id</clr-dg-column>
<clr-dg-column [clrDgField]="'name'">Name</clr-dg-column>
<clr-dg-column [clrDgField]="'description'">Description</clr-dg-column>
<h3 class="modal-title">Add Scenario</h3>
<div class="modal-body">
<i
>Select scenarios to add to the course. Scenarios will be appended to the
current set of scenarios.</i
>
<br />
<i
>Filter by using the <clr-icon shape="filter"></clr-icon> icon in the
table column headers.</i
>
<filter-scenarios
(filterScenarioEventEmitter)="setScenarioList($event)"
></filter-scenarios>

<clr-dg-row *clrDgItems="let s of scenarios" [clrDgItem]="s">
<clr-dg-cell>{{ s.id }}</clr-dg-cell>
<clr-dg-cell>{{ s.name }}</clr-dg-cell>
<clr-dg-cell>{{ s.description }}</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>
<br/>
Scenarios to add: <span *ngFor="let s of selectedScenarios">{{ s.id }}, </span>
</div>
<div class="modal-footer">
<button class="btn btn-danger-outline" (click)="addOpen = false">Cancel</button>
<button class="btn btn-success" (click)="save()">Add Scenario</button>
</div>
</clr-modal>
<clr-datagrid [(clrDgSelected)]="selectedScenarios">
<clr-dg-column [clrDgField]="'id'">Id</clr-dg-column>
<clr-dg-column [clrDgField]="'name'">Name</clr-dg-column>
<clr-dg-column [clrDgField]="'description'">Description</clr-dg-column>

<clr-dg-row *clrDgItems="let s of filteredScenarios" [clrDgItem]="s">
<clr-dg-cell>{{ s.id }}</clr-dg-cell>
<clr-dg-cell>{{ s.name }}</clr-dg-cell>
<clr-dg-cell>{{ s.description }}</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>
<br />
Scenarios to add:
<span *ngFor="let s of selectedScenarios">{{ s.id }}, </span>
</div>
<div class="modal-footer">
<button class="btn btn-danger-outline" (click)="addOpen = false">
Cancel
</button>
<button class="btn btn-success" (click)="save()">Add Scenario</button>
</div>
</clr-modal>
15 changes: 12 additions & 3 deletions src/app/course/add-scenario/add-scenario.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import {
Component,
Input,
Output,
EventEmitter,
ViewChild,
} from '@angular/core';
import { Scenario } from 'src/app/data/scenario';
import { ClrModal } from '@clr/angular';

Expand All @@ -10,14 +16,15 @@ export class AddScenarioComponent {
public addOpen: boolean = false;

public selectedScenarios = [];
public filteredScenarios: Scenario[] = [];

@Input()
public scenarios: Scenario[] = []; // TODO - convert this to ues shared service w/ client-side caching

@Output()
public selected: EventEmitter<Scenario[]> = new EventEmitter();

@ViewChild("addModal") addModal: ClrModal;
@ViewChild('addModal') addModal: ClrModal;

save(): void {
this.selected.emit(this.selectedScenarios);
Expand All @@ -28,5 +35,7 @@ export class AddScenarioComponent {
this.selectedScenarios = [];
this.addModal.open();
}

setScenarioList(scenarios: Scenario[]) {
this.filteredScenarios = scenarios;
}
}