Commit bdafc9d4 authored by 伊藤雄大's avatar 伊藤雄大

2024/07/30

サービスの戻り値をObservableに変更
parent 56967393
...@@ -64,7 +64,10 @@ export class PassListComponent implements OnInit { ...@@ -64,7 +64,10 @@ export class PassListComponent implements OnInit {
*/ */
ngOnInit(): void { ngOnInit(): void {
if (this.model && this.model.customerId) { if (this.model && this.model.customerId) {
this.passList = this.passService.getList(this.model.customerId); //this.passList = this.passService.getList(this.model.customerId);
this.passService.getList(this.model.customerId).subscribe((ret: PassModel[]) => {
this.passList = ret;
});
} }
} }
......
...@@ -71,11 +71,18 @@ export class StaffListComponent implements OnInit { ...@@ -71,11 +71,18 @@ export class StaffListComponent implements OnInit {
* 初期処理 * 初期処理
*/ */
ngOnInit(): void { ngOnInit(): void {
this.agencyList = this.staffService.getAgencyList(); //this.agencyList = this.staffService.getAgencyList();
this.staffService.getAgencyList().subscribe((ret: Map<string, string>) => {
this.agencyList = ret;
});
if (this.agencyId) { if (this.agencyId) {
this.agencyName = this.agencyList.get(this.agencyId); this.agencyName = this.agencyList.get(this.agencyId);
//担当者一覧取得 //担当者一覧取得
this.staffList = this.staffService.getList(this.agencyId); //this.staffList = this.staffService.getList(this.agencyId);
this.staffService.getList(this.agencyId).subscribe((ret: StaffInfoModel[]) => {
this.staffList = ret;
});
} else { } else {
this.agencyId = this.agencyList.keys().next().value; this.agencyId = this.agencyList.keys().next().value;
} }
...@@ -86,7 +93,10 @@ export class StaffListComponent implements OnInit { ...@@ -86,7 +93,10 @@ export class StaffListComponent implements OnInit {
*/ */
onClickSearch(): void { onClickSearch(): void {
//担当者一覧取得 //担当者一覧取得
this.staffList = this.staffService.getList(this.agencyId); //this.staffList = this.staffService.getList(this.agencyId);
this.staffService.getList(this.agencyId).subscribe((ret: StaffInfoModel[]) => {
this.staffList = ret;
});
} }
/** /**
...@@ -120,7 +130,10 @@ export class StaffListComponent implements OnInit { ...@@ -120,7 +130,10 @@ export class StaffListComponent implements OnInit {
this.staffService.delete(emailList); this.staffService.delete(emailList);
//一覧再取得 //一覧再取得
this.staffList = this.staffService.getList(this.agencyId); //this.staffList = this.staffService.getList(this.agencyId);
this.staffService.getList(this.agencyId).subscribe((ret: StaffInfoModel[]) => {
this.staffList = ret;
});
//↓プロトタイプで行削除の動きを見せるため //↓プロトタイプで行削除の動きを見せるため
const array = []; const array = [];
......
...@@ -45,10 +45,16 @@ export class StaffRegistComponent implements OnInit { ...@@ -45,10 +45,16 @@ export class StaffRegistComponent implements OnInit {
*/ */
ngOnInit(): void { ngOnInit(): void {
//事業所一覧 //事業所一覧
this.agencyList = this.staffService.getAgencyList(); //this.agencyList = this.staffService.getAgencyList();
this.staffService.getAgencyList().subscribe((ret: Map<string, string>) => {
this.agencyList = ret;
});
//権限一覧 //権限一覧
this.roleList = this.staffService.getRoleList(); //this.roleList = this.staffService.getRoleList();
this.staffService.getRoleList().subscribe((ret: Map<string, string>) => {
this.roleList = ret;
});
if (this.staffInfoModel !== null) { if (this.staffInfoModel !== null) {
this.agencyId = this.staffInfoModel?.agencyId; this.agencyId = this.staffInfoModel?.agencyId;
......
...@@ -76,7 +76,10 @@ export class UserListComponent implements OnInit { ...@@ -76,7 +76,10 @@ export class UserListComponent implements OnInit {
* 検索 * 検索
*/ */
onClickSearch(): void { onClickSearch(): void {
this.userList = this.userService.getList(this.userName); //this.userList = this.userService.getList(this.userName);
this.userService.getList(this.userName).subscribe((ret: UserInfoModel[]) => {
this.userList = ret;
});
} }
onGridReady(params: any): void { onGridReady(params: any): void {
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
/** /**
* ログインサービス * ログインサービス
...@@ -13,16 +14,20 @@ export class LoginService { ...@@ -13,16 +14,20 @@ export class LoginService {
* @param password パスワード * @param password パスワード
* @returns 認証成功(true)/失敗(false) * @returns 認証成功(true)/失敗(false)
*/ */
login(email?: string, password?: string): boolean { login(email?: string, password?: string): Observable<boolean> {
let ret = true;
//TODO //TODO
if (!email) { if (!email) {
alert("メールアドレスが入力されていません"); alert("メールアドレスが入力されていません");
return false; ret = false;
} }
if (!password) { if (ret && !password) {
alert("パスワードが入力されていません"); alert("パスワードが入力されていません");
return false; ret = false;
} }
return true; //return ret;
return new Observable<boolean>(o => {
o.next(ret);
});
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { PassModel } from '../model/pass.model'; import { PassModel } from '../model/pass.model';
import { Observable } from 'rxjs';
/** /**
* 定期券サービス * 定期券サービス
...@@ -13,7 +14,7 @@ export class PassService { ...@@ -13,7 +14,7 @@ export class PassService {
* @param customerId 利用者ID * @param customerId 利用者ID
* @returns 定期券一覧 * @returns 定期券一覧
*/ */
getList(customerId: string): PassModel[] { getList(customerId: string): Observable<PassModel[]> {
//TODO //TODO
const passList: PassModel[] = []; const passList: PassModel[] = [];
if (customerId) { if (customerId) {
...@@ -32,7 +33,10 @@ export class PassService { ...@@ -32,7 +33,10 @@ export class PassService {
passList.push(model); passList.push(model);
} }
} }
return passList; //return passList;
return new Observable<PassModel[]>(o => {
o.next(passList);
});
} }
/** /**
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { StaffInfoModel } from '../model/staff-info.model'; import { StaffInfoModel } from '../model/staff-info.model';
import { Observable } from 'rxjs';
/** /**
* 担当者サービス * 担当者サービス
...@@ -13,7 +14,7 @@ export class StaffService { ...@@ -13,7 +14,7 @@ export class StaffService {
* @param agencyId 事業者ID * @param agencyId 事業者ID
* @returns 担当者情報一覧 * @returns 担当者情報一覧
*/ */
getList(agencyId?: string): StaffInfoModel[] { getList(agencyId?: string): Observable<StaffInfoModel[]> {
//TODO //TODO
const staffList: StaffInfoModel[] = []; const staffList: StaffInfoModel[] = [];
if (agencyId) { if (agencyId) {
...@@ -30,28 +31,34 @@ export class StaffService { ...@@ -30,28 +31,34 @@ export class StaffService {
staffList.push(model); staffList.push(model);
} }
} }
return staffList; //return staffList;
return new Observable<StaffInfoModel[]>(o => {
o.next(staffList);
});
} }
/** /**
* 事業者一覧取得 * 事業者一覧取得
* @returns 事業者一覧 * @returns 事業者一覧
*/ */
getAgencyList(): Map<string, string> { getAgencyList(): Observable<Map<string, string>> {
//TODO //TODO
const agencyList = new Map(); const agencyList = new Map();
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
const str = String(i + 1); const str = String(i + 1);
agencyList.set("000" + str, "事業所" + str); agencyList.set("000" + str, "事業所" + str);
} }
return agencyList; //return agencyList;
return new Observable<Map<string, string>>(o => {
o.next(agencyList);
});
} }
/** /**
* 権限一覧取得 * 権限一覧取得
* @returns 権限一覧 * @returns 権限一覧
*/ */
getRoleList(): Map<string, string> { getRoleList(): Observable<Map<string, string>> {
//TODO //TODO
const roleList = new Map(); const roleList = new Map();
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
...@@ -59,7 +66,10 @@ export class StaffService { ...@@ -59,7 +66,10 @@ export class StaffService {
roleList?.set(str, "権限" + str) roleList?.set(str, "権限" + str)
} }
return roleList; //return roleList;
return new Observable<Map<string, string>>(o => {
o.next(roleList);
});
} }
/** /**
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { UserInfoModel } from '../model/user-info.model'; import { UserInfoModel } from '../model/user-info.model';
import { Observable } from 'rxjs';
/** /**
* 利用者サービス * 利用者サービス
...@@ -14,7 +15,7 @@ export class UserService { ...@@ -14,7 +15,7 @@ export class UserService {
* @param name 利用者名 * @param name 利用者名
* @returns 利用者一覧 * @returns 利用者一覧
*/ */
getList(name?: string): UserInfoModel[] { getList(name?: string): Observable<UserInfoModel[]> {
//TODO //TODO
const userList: UserInfoModel[] = []; const userList: UserInfoModel[] = [];
if (name) { if (name) {
...@@ -29,6 +30,9 @@ export class UserService { ...@@ -29,6 +30,9 @@ export class UserService {
userList.push(model); userList.push(model);
} }
} }
return userList; //return userList;
return new Observable<UserInfoModel[]>(o => {
o.next(userList);
});
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment