|
@@ -0,0 +1,56 @@
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { Router } from '@angular/router';
|
|
|
+import { IonHeader,IonButton, IonContent, IonIcon,
|
|
|
+ IonCardHeader,IonCardTitle,IonCardContent, IonTitle,IonCard, IonToolbar } from '@ionic/angular/standalone';
|
|
|
+ import { FormsModule } from '@angular/forms';
|
|
|
+import { CloudQuery, CloudUser } from 'src/lib/ncloud';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-page-psysurvey',
|
|
|
+ templateUrl: './page-psysurvey.component.html',
|
|
|
+ styleUrls: ['./page-psysurvey.component.scss'],
|
|
|
+ standalone: true,
|
|
|
+ imports: [IonHeader,IonToolbar,IonTitle,IonContent,
|
|
|
+ IonCardTitle,FormsModule,
|
|
|
+ IonIcon,IonButton,IonCardContent,
|
|
|
+ IonCard,IonCardHeader,
|
|
|
+ CommonModule
|
|
|
+ ]
|
|
|
+})
|
|
|
+export class PagePsysurveyComponent implements OnInit {
|
|
|
+ surveys: any[] = [];
|
|
|
+ filteredSurveys: any[] = [];
|
|
|
+ userDepartment: string = '' ;
|
|
|
+
|
|
|
+ constructor(private router: Router) { }
|
|
|
+ goTab1(){
|
|
|
+ this.router.navigate(['tabs/tab1']);
|
|
|
+ }
|
|
|
+ goPublishSurvey(){
|
|
|
+ this.router.navigate(['tabs/page-publishsurvey'])
|
|
|
+ }
|
|
|
+
|
|
|
+ ngOnInit() {
|
|
|
+ this.getSurveys();
|
|
|
+ }
|
|
|
+
|
|
|
+ async getSurveys() {
|
|
|
+ let query = new CloudQuery("Survey");
|
|
|
+ this.surveys = await query.find();
|
|
|
+ this.filterSurveys();
|
|
|
+ }
|
|
|
+ filterSurveys() {
|
|
|
+ let user = new CloudUser();
|
|
|
+ console.log(user)
|
|
|
+ this.filteredSurveys = this.surveys.filter(survey => {
|
|
|
+ console.log(survey.get("audience"), user.get("department"))
|
|
|
+ return (survey.get("audience") === user.get("department") || survey.get("audience") === 'all');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|