File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Methods
faqReportSubmit
|
faqReportSubmit()
|
|
|
fetchFaqReportConfig
|
fetchFaqReportConfig()
|
|
|
ngOnDestroy
|
ngOnDestroy()
|
|
|
statusChanged
|
statusChanged(event)
|
|
|
valueChanged
|
valueChanged(event)
|
|
|
unsubscribe
|
Default value : new Subject<void>()
|
|
import { Component, Input, OnInit } from '@angular/core';
import { ResourceService, ToasterService } from '@sunbird/shared';
import { ProfileService } from '@sunbird/profile';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import * as _ from 'lodash-es';
import { TelemetryService } from '@sunbird/telemetry';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-faq-report',
templateUrl: './faq-report.component.html',
styleUrls: ['./faq-report.component.scss']
})
export class FaqReportComponent implements OnInit {
@Input() faqData;
faqReportConfig;
unsubscribe = new Subject<void>();
formValues: any;
formStatus: any;
constructor(
private resourceService: ResourceService,
private toasterService: ToasterService,
private profileService: ProfileService,
private telemetryService: TelemetryService,
private activatedRoute: ActivatedRoute
) {
}
ngOnInit() {
this.fetchFaqReportConfig();
}
fetchFaqReportConfig() {
// FormAPI call
this.profileService.getFaqReportIssueForm().pipe(takeUntil(this.unsubscribe)).subscribe(formConfig => {
this.formStatus = undefined;
this.faqReportConfig = formConfig;
}, error => {
console.error('Unable to fetch form', error);
this.toasterService.error(_.get(this.resourceService, 'messages.emsg.m0005'));
});
}
valueChanged(event) {
this.formValues = event;
if (!(_.get(this.faqReportConfig, '1.templateOptions'))) {
return;
}
if (event.category === 'otherissues') {
this.faqReportConfig[1].templateOptions.hidden = true;
} else {
this.faqReportConfig[1].templateOptions.hidden = false;
}
}
statusChanged(event) {
this.formStatus = event;
}
faqReportSubmit() {
if (!this.formStatus || !this.formStatus.isValid) {
return false;
}
const params = [];
for (const [key, value] of Object.entries(this.formValues)) {
if (key === 'children') {
for (const [childKey, childValue] of Object.entries(this.formValues[key])) {
params.push({[childKey]: childValue});
}
} else {
params.push({[key]: value});
}
}
const telemetryContextObj = { env: 'portal', cdata: []};
const edata = { type: 'system', pageid: _.get(this.activatedRoute, 'snapshot.data.telemetry.pageid') };
const interactEvent = { context: telemetryContextObj, edata: { id: 'submit-clicked', ...edata, type: 'support' } };
const logEvent = {
context: telemetryContextObj,
edata: {
level: 'INFO',
message: 'faq',
params,
...edata
}
};
this.telemetryService.log(logEvent);
this.telemetryService.interact(interactEvent);
const message: string = _.get(this.faqData, 'constants.thanksForFeedbackMsg');
this.toasterService.custom({
message: message.replace('{{app_name}}', _.get(this.resourceService, 'instance')),
class: 'sb-toaster sb-toast-success sb-toast-normal'
});
this.faqReportConfig = undefined;
this.fetchFaqReportConfig();
}
ngOnDestroy() {
this.unsubscribe.next();
this.unsubscribe.complete();
}
}
<div class="faq-report-container">
<h6 class="pb-16">{{faqData?.constants?.tellMoreMsg}}</h6>
<sb-form class="faq-sbforms" [ngClass]="{'other-issue': formValues?.category === 'otherissues', '': formValues?.category !== 'otherissues'}" *ngIf="faqReportConfig"
[config]='faqReportConfig'
[platform]="'web'"
(valueChanges)="valueChanged($event)"
(statusChanges)="statusChanged($event)">
</sb-form>
<div class="sb-g">
<div class="sb-g-col-xs-12 sb-g-col-md-6 sb-g-col-lg-9 sb-g-col-xxxl-22">
<p>{{faqData?.constants?.triggerEmailMsg}}</p>
</div>
<div class="sb-g-col-xs-12 sb-g-col-md-6 sb-g-col-lg-3 sb-g-col-xxxl-10">
<button class="sb-btn sb-btn-primary sb-btn-normal submit-feedback" tabindex="0" (click)="faqReportSubmit()">
{{faqData?.constants?.submitButton}}
</button>
</div>
</div>
</div>
@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;
h6 {
color: var(--gray-800);
font-size: 1.125rem;
font-weight: bold;
}
p {
color: var(--gray-400);
font-size: 0.75rem;
}
sb-form.faq-sbforms {}
::ng-deep {
sb-form.faq-sbforms .multi-select-container .list-border {
background: var(--white);
border: 0px solid var(--rc-dddddd) !important;
}
.sb-textarea {
border-radius: 1rem !important;
}
.sb-modal-dropdown-web ul {
border: 0 solid var(--rc-dddddd) !important;
}
sb-form.faq-sbforms>div:first-child {
display: grid;
gap: calculateRem(16px);
grid-template-columns: auto;
@include respond-above(sm) {
grid-template-columns: auto auto;
div:nth-child(1) {
grid-column-start: 1;
grid-column-end: 2;
}
div:nth-child(2) {
grid-column-start: 2;
grid-column-end: 2;
}
div:nth-child(3) {
grid-column-start: 1;
grid-column-end: 3;
}
}
}
sb-form.faq-sbforms.other-issue>div:first-child {
@include respond-above(sm) {
div:nth-child(2) {
grid-column-start: 1;
grid-column-end: 3;
}
}
}
sb-form{
sb-multiple-dropdown{
.list-border{
ul{
padding: 0;
}
height: 3rem !important;
}
}
.sb-modal-dropdown-web {
ul{
top: auto !important;
border-radius: 2rem;
padding: 0 1rem;
overflow-y: auto !important;
overflow: hidden;
}
li {
margin: 0 !important;
padding: 0 !important;
> div {
cursor: pointer;
padding: calculateRem(16px);
}
}
}
sb-textarea{
textarea{
height: 16rem;
}
.remaining-length {
color: var(--gray-400) !important;
}
}
}
}
.submit-feedback{
float:right;
}
Legend
Html element with directive