-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added modal component for predefined form options. (#300)
- Loading branch information
1 parent
d4ffb24
commit 86788bb
Showing
11 changed files
with
260 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,74 @@ | ||
import { SharedModule } from '../shared/shared.module'; | ||
import { NgModule } from '@angular/core'; | ||
import { AnswerExtraQuestionsComponent } from './answer/answer-extra-questions/answer-extra-questions.component'; | ||
import { LoginComponent } from './login/login.component'; | ||
import { StatisticsValueComponent } from './statistics/statistics-value/statistics-value.component'; | ||
import { AnswerNoteComponent } from './answer/answer-note/answer-note.component'; | ||
import { StatisticsDetailsComponent } from './statistics/statistics-details/statistics-details.component'; | ||
import { CategoricalQuestionComponent } from './answer/categorical-question/categorical-question.component'; | ||
import { StatisticsCardComponent } from './statistics/statistics-card/statistics-card.component'; | ||
import { StatisticsComponent } from './statistics/statistics.component'; | ||
import { AnswerFormListComponent } from './answer/answer-form-list/answer-form-list.component'; | ||
import { AnswerDetailsComponent } from './answer/answer-details/answer-details.component'; | ||
import { AnswerComponent } from './answer/answer.component'; | ||
import { ObserversComponent } from './observers/observers.component'; | ||
import { AnswerListComponent } from './answer/answers-list/answer-list.component'; | ||
import { HeaderComponent } from './header/header.component'; | ||
import { ObserverCardComponent } from './observers/observer-card/observer-card.component'; | ||
import { OberverRowComponent } from './observers/oberver-row/oberver-row.component'; | ||
import { ObserverProfileComponent } from './observers/observer-profile/observer-profile.component'; | ||
import { NotificationsComponent } from './notifications/notifications.component'; | ||
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown'; | ||
import {SharedModule} from '../shared/shared.module'; | ||
import {NgModule} from '@angular/core'; | ||
import {AnswerExtraQuestionsComponent} from './answer/answer-extra-questions/answer-extra-questions.component'; | ||
import {LoginComponent} from './login/login.component'; | ||
import {StatisticsValueComponent} from './statistics/statistics-value/statistics-value.component'; | ||
import {AnswerNoteComponent} from './answer/answer-note/answer-note.component'; | ||
import {StatisticsDetailsComponent} from './statistics/statistics-details/statistics-details.component'; | ||
import {CategoricalQuestionComponent} from './answer/categorical-question/categorical-question.component'; | ||
import {StatisticsCardComponent} from './statistics/statistics-card/statistics-card.component'; | ||
import {StatisticsComponent} from './statistics/statistics.component'; | ||
import {AnswerFormListComponent} from './answer/answer-form-list/answer-form-list.component'; | ||
import {AnswerDetailsComponent} from './answer/answer-details/answer-details.component'; | ||
import {AnswerComponent} from './answer/answer.component'; | ||
import {ObserversComponent} from './observers/observers.component'; | ||
import {AnswerListComponent} from './answer/answers-list/answer-list.component'; | ||
import {HeaderComponent} from './header/header.component'; | ||
import {ObserverCardComponent} from './observers/observer-card/observer-card.component'; | ||
import {OberverRowComponent} from './observers/oberver-row/oberver-row.component'; | ||
import {ObserverProfileComponent} from './observers/observer-profile/observer-profile.component'; | ||
import {NotificationsComponent} from './notifications/notifications.component'; | ||
import {NgMultiSelectDropDownModule} from 'ng-multiselect-dropdown'; | ||
import {FormCreateComponent} from './forms/form-create/form-create.component'; | ||
import {SectionComponent} from './forms/section/section.component'; | ||
import {QuestionComponent} from './forms/question/question.component'; | ||
import {PredefinedOptionsModalComponent} from './forms/predefined-options-modal/predefined-options-modal.component'; | ||
import {OptionComponent} from './forms/option/option.component'; | ||
import {FormsComponent} from './forms/forms.component'; | ||
import {DragDropModule} from '@angular/cdk/drag-drop'; | ||
|
||
import { TableModule } from '../table/table.module' | ||
import { ObserverImportComponent } from './observers/observer-import/observer-import.component'; | ||
import {TableModule} from '../table/table.module' | ||
import {ObserverImportComponent} from './observers/observer-import/observer-import.component'; | ||
|
||
export let components = [ | ||
AnswerComponent, | ||
AnswerListComponent, | ||
AnswerDetailsComponent, | ||
AnswerFormListComponent, | ||
AnswerNoteComponent, | ||
CategoricalQuestionComponent, | ||
AnswerExtraQuestionsComponent, | ||
ObserversComponent, | ||
ObserverCardComponent, | ||
OberverRowComponent, | ||
ObserverProfileComponent, | ||
FormsComponent, | ||
FormCreateComponent, | ||
SectionComponent, | ||
QuestionComponent, | ||
OptionComponent, | ||
HeaderComponent, | ||
StatisticsComponent, | ||
StatisticsCardComponent, | ||
StatisticsDetailsComponent, | ||
StatisticsValueComponent, | ||
NotificationsComponent, | ||
LoginComponent, | ||
ObserverImportComponent, | ||
AnswerComponent, | ||
AnswerListComponent, | ||
AnswerDetailsComponent, | ||
AnswerFormListComponent, | ||
AnswerNoteComponent, | ||
CategoricalQuestionComponent, | ||
AnswerExtraQuestionsComponent, | ||
ObserversComponent, | ||
ObserverCardComponent, | ||
OberverRowComponent, | ||
ObserverProfileComponent, | ||
FormsComponent, | ||
FormCreateComponent, | ||
SectionComponent, | ||
QuestionComponent, | ||
PredefinedOptionsModalComponent, | ||
OptionComponent, | ||
HeaderComponent, | ||
StatisticsComponent, | ||
StatisticsCardComponent, | ||
StatisticsDetailsComponent, | ||
StatisticsValueComponent, | ||
NotificationsComponent, | ||
LoginComponent, | ||
ObserverImportComponent, | ||
]; | ||
|
||
@NgModule({ | ||
declarations: components, | ||
exports: components, | ||
imports: [ | ||
SharedModule, | ||
NgMultiSelectDropDownModule.forRoot(), | ||
DragDropModule, | ||
TableModule, | ||
] | ||
declarations: components, | ||
exports: components, | ||
imports: [ | ||
SharedModule, | ||
NgMultiSelectDropDownModule.forRoot(), | ||
DragDropModule, | ||
TableModule, | ||
] | ||
}) | ||
export class ComponentsModule { | ||
export class ComponentsModule { | ||
|
||
} | ||
|
17 changes: 17 additions & 0 deletions
17
src/app/components/forms/predefined-options-modal/predefined-options-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="modal-header"> | ||
<h6 class="modal-title">{{'PREDEFINED_OPTIONS_MODAL.TITLE' | translate}}</h6> | ||
</div> | ||
<div class="modal-body"> | ||
<p>{{'PREDEFINED_OPTIONS_MODAL.NOTE' | translate}}</p> | ||
<div *ngFor="let category of data"> | ||
{{ category.label | translate }} | ||
<div *ngFor="let option of category.options" class="node-children"> | ||
<input type="checkbox" [ngModel]="option.check" | ||
(ngModelChange)="check(option,$event);"/> {{ option.label | translate }} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-outline-secondary" (click)="modal.dismiss()">{{'CANCEL' | translate}}</button> | ||
<button type="button" class="btn btn-warning" (click)="modal.close(getChecked())">{{'ADD' | translate}}</button> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
src/app/components/forms/predefined-options-modal/predefined-options-modal.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.node-children { | ||
margin: 1.5px 1.5px 1.5px 15px; | ||
padding-left: 10px; | ||
} |
66 changes: 66 additions & 0 deletions
66
src/app/components/forms/predefined-options-modal/predefined-options-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap'; | ||
import predefinedOptions from '../../../../assets/configs/predefined-options.json'; | ||
|
||
interface Category { | ||
label: string; | ||
options: Option[]; | ||
} | ||
|
||
interface Option { | ||
label: string; | ||
check?: boolean; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-predefined-options-modal', | ||
templateUrl: './predefined-options-modal.component.html', | ||
styleUrls: ['./predefined-options-modal.component.scss'] | ||
}) | ||
export class PredefinedOptionsModalComponent implements OnInit { | ||
data: Category[]; | ||
private readonly checkboxPersistentData: any; | ||
|
||
constructor(public modal: NgbActiveModal) { | ||
if (!localStorage.getItem('selectedPredefinedOptions')) { | ||
localStorage.setItem('selectedPredefinedOptions', '{}'); | ||
} | ||
try { | ||
this.checkboxPersistentData = JSON.parse(localStorage.getItem('selectedPredefinedOptions')); | ||
} catch { | ||
localStorage.setItem('selectedPredefinedOptions', '{}'); | ||
this.checkboxPersistentData = {}; | ||
} | ||
|
||
this.data = predefinedOptions; | ||
|
||
this.data.forEach(category => { | ||
category.options.forEach(option => { | ||
if (option.label in this.checkboxPersistentData) | ||
this.check(option, this.checkboxPersistentData[option.label] === 'true') | ||
}) | ||
}) | ||
} | ||
|
||
check(option: Option, value: boolean) { | ||
option.check = value; | ||
this.checkboxPersistentData[option.label] = value ? 'true' : 'false'; | ||
localStorage.setItem('selectedPredefinedOptions', JSON.stringify(this.checkboxPersistentData)); | ||
} | ||
|
||
getChecked() { | ||
const result = [] | ||
this.data.forEach(category => { | ||
category.options.forEach(option => { | ||
if (option.check) | ||
result.push(option.label) | ||
}) | ||
}) | ||
return result; | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[ | ||
{ | ||
"label": "PREDEFINED_OPTIONS.CONFIRMATION.LABEL", | ||
"options": [ | ||
{ | ||
"label": "PREDEFINED_OPTIONS.CONFIRMATION.YES" | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.CONFIRMATION.NO" | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.CONFIRMATION.DONT_KNOW" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.RATING.LABEL", | ||
"options": [ | ||
{ | ||
"label": "PREDEFINED_OPTIONS.RATING.1" | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.RATING.2" | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.RATING.3" | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.RATING.4" | ||
}, | ||
{ | ||
"label": "PREDEFINED_OPTIONS.RATING.5" | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
86788bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: