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

2024/07/30

サービスの戻り値をObservableに変更
parent 56967393
......@@ -64,7 +64,10 @@ export class PassListComponent implements OnInit {
*/
ngOnInit(): void {
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 {
* 初期処理
*/
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) {
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 {
this.agencyId = this.agencyList.keys().next().value;
}
......@@ -86,7 +93,10 @@ export class StaffListComponent implements OnInit {
*/
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 {
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 = [];
......
......@@ -45,10 +45,16 @@ export class StaffRegistComponent implements OnInit {
*/
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) {
this.agencyId = this.staffInfoModel?.agencyId;
......
......@@ -76,7 +76,10 @@ export class UserListComponent implements OnInit {
* 検索
*/
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 {
......
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
/**
* ログインサービス
......@@ -13,16 +14,20 @@ export class LoginService {
* @param password パスワード
* @returns 認証成功(true)/失敗(false)
*/
login(email?: string, password?: string): boolean {
login(email?: string, password?: string): Observable<boolean> {
let ret = true;
//TODO
if (!email) {
alert("メールアドレスが入力されていません");
return false;
ret = false;
}
if (!password) {
if (ret && !password) {
alert("パスワードが入力されていません");
return false;
ret = false;
}
return true;
//return ret;
return new Observable<boolean>(o => {
o.next(ret);
});
}
}
import { Injectable } from '@angular/core';
import { PassModel } from '../model/pass.model';
import { Observable } from 'rxjs';
/**
* 定期券サービス
......@@ -13,7 +14,7 @@ export class PassService {
* @param customerId 利用者ID
* @returns 定期券一覧
*/
getList(customerId: string): PassModel[] {
getList(customerId: string): Observable<PassModel[]> {
//TODO
const passList: PassModel[] = [];
if (customerId) {
......@@ -32,7 +33,10 @@ export class PassService {
passList.push(model);
}
}
return passList;
//return passList;
return new Observable<PassModel[]>(o => {
o.next(passList);
});
}
/**
......
import { Injectable } from '@angular/core';
import { StaffInfoModel } from '../model/staff-info.model';
import { Observable } from 'rxjs';
/**
* 担当者サービス
......@@ -13,7 +14,7 @@ export class StaffService {
* @param agencyId 事業者ID
* @returns 担当者情報一覧
*/
getList(agencyId?: string): StaffInfoModel[] {
getList(agencyId?: string): Observable<StaffInfoModel[]> {
//TODO
const staffList: StaffInfoModel[] = [];
if (agencyId) {
......@@ -30,28 +31,34 @@ export class StaffService {
staffList.push(model);
}
}
return staffList;
//return staffList;
return new Observable<StaffInfoModel[]>(o => {
o.next(staffList);
});
}
/**
* 事業者一覧取得
* @returns 事業者一覧
*/
getAgencyList(): Map<string, string> {
getAgencyList(): Observable<Map<string, string>> {
//TODO
const agencyList = new Map();
for (let i = 0; i < 5; i++) {
const str = String(i + 1);
agencyList.set("000" + str, "事業所" + str);
}
return agencyList;
//return agencyList;
return new Observable<Map<string, string>>(o => {
o.next(agencyList);
});
}
/**
* 権限一覧取得
* @returns 権限一覧
*/
getRoleList(): Map<string, string> {
getRoleList(): Observable<Map<string, string>> {
//TODO
const roleList = new Map();
for (let i = 0; i < 3; i++) {
......@@ -59,7 +66,10 @@ export class StaffService {
roleList?.set(str, "権限" + str)
}
return roleList;
//return roleList;
return new Observable<Map<string, string>>(o => {
o.next(roleList);
});
}
/**
......
import { Injectable } from '@angular/core';
import { UserInfoModel } from '../model/user-info.model';
import { Observable } from 'rxjs';
/**
* 利用者サービス
......@@ -14,7 +15,7 @@ export class UserService {
* @param name 利用者名
* @returns 利用者一覧
*/
getList(name?: string): UserInfoModel[] {
getList(name?: string): Observable<UserInfoModel[]> {
//TODO
const userList: UserInfoModel[] = [];
if (name) {
......@@ -29,6 +30,9 @@ export class UserService {
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