feat: add new standalone components for system and organization management modules
This commit is contained in:
@@ -30,6 +30,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { MatDivider } from '@angular/material/divider';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
import { AlertService } from 'app/core/alert/alert.service';
|
||||
|
||||
/**
|
||||
* Create survey component.
|
||||
@@ -55,6 +56,7 @@ export class CreateSurveyComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
dialog = inject(MatDialog);
|
||||
private alertService = inject(AlertService);
|
||||
|
||||
/** Survey form. */
|
||||
surveyForm: UntypedFormGroup;
|
||||
@@ -244,6 +246,12 @@ export class CreateSurveyComponent implements OnInit {
|
||||
countryCode: this.surveyForm.value.countryCode.toUpperCase()
|
||||
});
|
||||
this.systemService.createSurvey(this.surveyForm.value).subscribe((response: any) => {
|
||||
if (response?.rollbackTransaction) {
|
||||
this.alertService.alert({
|
||||
type: 'Success',
|
||||
message: 'Survey creation has been submitted for approval.'
|
||||
});
|
||||
}
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { MatDivider } from '@angular/material/divider';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
import { AlertService } from 'app/core/alert/alert.service';
|
||||
|
||||
/**
|
||||
* Edit survey component.
|
||||
@@ -59,6 +60,7 @@ export class EditSurveyComponent {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
dialog = inject(MatDialog);
|
||||
private alertService = inject(AlertService);
|
||||
|
||||
/** Survey form. */
|
||||
surveyForm: UntypedFormGroup;
|
||||
@@ -299,6 +301,12 @@ export class EditSurveyComponent {
|
||||
this.systemService
|
||||
.editSurvey(this.route.snapshot.paramMap.get('id'), this.surveyForm.value)
|
||||
.subscribe((response: any) => {
|
||||
if (response?.rollbackTransaction) {
|
||||
this.alertService.alert({
|
||||
type: 'Success',
|
||||
message: 'Survey update has been submitted for approval.'
|
||||
});
|
||||
}
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import { SystemService } from '../system.service';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
import { AlertService } from 'app/core/alert/alert.service';
|
||||
|
||||
/**
|
||||
* Manage Surveys component.
|
||||
@@ -60,6 +61,7 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
export class ManageSurveysComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private systemService = inject(SystemService);
|
||||
private alertService = inject(AlertService);
|
||||
|
||||
/* Surveys data */
|
||||
surveysData: any;
|
||||
@@ -139,7 +141,14 @@ export class ManageSurveysComponent implements OnInit {
|
||||
* @param {any} survey Survey to activate.
|
||||
*/
|
||||
activate(survey: any) {
|
||||
this.systemService.activateSurvey(survey.id).subscribe(() => {
|
||||
this.systemService.activateSurvey(survey.id).subscribe((response: any) => {
|
||||
if (response?.rollbackTransaction) {
|
||||
this.alertService.alert({
|
||||
type: 'Success',
|
||||
message: 'Survey activation has been submitted for approval.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
// This mimics the server-side logic
|
||||
survey.validFrom = today;
|
||||
@@ -152,7 +161,14 @@ export class ManageSurveysComponent implements OnInit {
|
||||
* @param {any} survey Survey to deactivate.
|
||||
*/
|
||||
deactivate(survey: any) {
|
||||
this.systemService.deactivateSurvey(survey.id).subscribe(() => {
|
||||
this.systemService.deactivateSurvey(survey.id).subscribe((response: any) => {
|
||||
if (response?.rollbackTransaction) {
|
||||
this.alertService.alert({
|
||||
type: 'Success',
|
||||
message: 'Survey deactivation has been submitted for approval.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() - 1); // Set to yesterday
|
||||
const yesterday = date.toISOString().split('T')[0];
|
||||
|
||||
Reference in New Issue
Block a user