Compare commits
2 Commits
1bc88d8d69
...
adf3c9f321
| Author | SHA1 | Date | |
|---|---|---|---|
| adf3c9f321 | |||
| 40ac38a484 |
@@ -0,0 +1,8 @@
|
|||||||
|
package com.example.rhizome.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
|
||||||
|
public interface UpdateDepartment {
|
||||||
|
void updateDepartment(Department depart);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.example.rhizome.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||||
|
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||||
|
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||||
|
|
||||||
|
DepartmentRepository departmentRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UpdateDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||||
|
this.departmentRepository = departmentRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateDepartment(Department department) {
|
||||||
|
DepartmentEntity entity = new DepartmentEntity();
|
||||||
|
entity.setIdDepartment(department.getIdDepartment());
|
||||||
|
entity.setNmDepartment(department.getNmDepartment());
|
||||||
|
departmentRepository.save(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||||
|
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||||
|
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||||
|
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||||
|
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||||
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
|
import com.example.rhizome.app.presentation.form.SearchConditionDepartment;
|
||||||
|
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class UpdateDepartmentController {
|
||||||
|
// ログ出力用インスタンス
|
||||||
|
private final static Logger LOGGER = Logger.getLogger(DeleteDepartmentController.class.getName());
|
||||||
|
|
||||||
|
private static final String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
|
HttpSession httpSession;
|
||||||
|
UpdateDepartment updateDepartment;
|
||||||
|
SearchDepartment searchDepartment;
|
||||||
|
SearchEmployee searchEmployee;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UpdateDepartmentController(UpdateDepartment updateDepartment, SearchDepartment searchDepartment,
|
||||||
|
HttpSession httpSession, SearchEmployee searchEmployee) {
|
||||||
|
this.httpSession = httpSession;
|
||||||
|
this.updateDepartment = updateDepartment;
|
||||||
|
this.searchDepartment = searchDepartment;
|
||||||
|
this.searchEmployee = searchEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute
|
||||||
|
public SearchConditionDepartment searchConditionDepartment() {
|
||||||
|
return new SearchConditionDepartment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PermissionCheck
|
||||||
|
@SessionCheck
|
||||||
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_DEPARTMENT, method = RequestMethod.POST)
|
||||||
|
public String showUpdateDepartment(@RequestParam("idDepartment") Integer idDepartment, Model model) {
|
||||||
|
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Department> departmentList = searchDepartment
|
||||||
|
.searchBy(new com.example.rhizome.app.domain.model.SearchConditionDepartment(idDepartment, null));
|
||||||
|
if (departmentList.isEmpty()) {
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
|
new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||||
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO;
|
||||||
|
}
|
||||||
|
// 更新画面に遷移
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_INFO_FORM,
|
||||||
|
UpdateDepartmentForm.convertFrom(departmentList.get(0)));
|
||||||
|
|
||||||
|
// Update画面に遷移
|
||||||
|
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// エラー画面遷移
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_RESULT, method = RequestMethod.POST)
|
||||||
|
public String departmentUpdateResult(@ModelAttribute UpdateDepartmentForm updateDepartmentForm, Model model) {
|
||||||
|
|
||||||
|
final String NOTHING = "項目が空欄です。";
|
||||||
|
final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。";
|
||||||
|
final String NO_TARGET = "更新対象のデータが見つかりません。";
|
||||||
|
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||||
|
try {
|
||||||
|
|
||||||
|
boolean bo = updateDepartmentForm.hasRequiredValue();
|
||||||
|
if (bo == false) {
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
|
new MessageForm(NOTHING));
|
||||||
|
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||||
|
}
|
||||||
|
List<Department> departmentList = searchDepartment
|
||||||
|
.searchBy(new com.example.rhizome.app.domain.model.SearchConditionDepartment(null,
|
||||||
|
updateDepartmentForm.getNmDepartment()));
|
||||||
|
if (departmentList == null && departmentList.isEmpty()){
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
|
new MessageForm(DUPLICATION));
|
||||||
|
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||||
|
}
|
||||||
|
List<Department> departmentList2 = searchDepartment
|
||||||
|
.searchBy(new com.example.rhizome.app.domain.model.SearchConditionDepartment(
|
||||||
|
updateDepartmentForm.getIdDepartment(), null));
|
||||||
|
if (departmentList2 == null || departmentList2.isEmpty()) {
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
|
new MessageForm(NO_TARGET));
|
||||||
|
return PageReturnAttributeKeyword.UPDATE_DEPARTMENT_INFO_FORM;
|
||||||
|
}
|
||||||
|
Department department = new Department(updateDepartmentForm.getIdDepartment(),
|
||||||
|
updateDepartmentForm.getNmDepartment());
|
||||||
|
updateDepartment.updateDepartment(department);
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO,
|
||||||
|
new MessageForm(UPDATE_COMPLETE));
|
||||||
|
return PageReturnAttributeKeyword.UPDATE_DEPARTMENT_INFO_FORM;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// エラー画面遷移
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,5 +14,6 @@ public class PageReturnAttributeKeyword {
|
|||||||
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
||||||
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
||||||
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
||||||
|
public static final String UPDATE_DEPARTMENT_INFO_FORM = "updateDepartmentForm";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
public static final String UPDATE_EMPLOYEE_INPUT_HTML = "updateEmployeeInput";
|
public static final String UPDATE_EMPLOYEE_INPUT_HTML = "updateEmployeeInput";
|
||||||
public static final String SELECT_DEPARTMENT_HTML = "/selectDepartment";
|
public static final String SELECT_DEPARTMENT_HTML = "/selectDepartment";
|
||||||
public static final String ERROR_HTML = "error";
|
public static final String ERROR_HTML = "error";
|
||||||
|
public static final String UPDATE_DEPARTMENT_INPUT_HTML = "updateDepartmentInput";
|
||||||
// 共通(Controller)
|
// 共通(Controller)
|
||||||
public static final String INDEX_BLANK = "";
|
public static final String INDEX_BLANK = "";
|
||||||
public static final String INDEX_SLASH = "/";
|
public static final String INDEX_SLASH = "/";
|
||||||
@@ -45,11 +45,10 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
public static final String SHOW_UPDATE_EMPLOYEE = "/showUpdateEmployee";
|
public static final String SHOW_UPDATE_EMPLOYEE = "/showUpdateEmployee";
|
||||||
public static final String UPDATE_EMPLOYEE_RESULT = "/updateEmployeeResult";
|
public static final String UPDATE_EMPLOYEE_RESULT = "/updateEmployeeResult";
|
||||||
public static final String SELECT_DEPARTMENT_INFO = "/selectDepartmentInfo";
|
public static final String SELECT_DEPARTMENT_INFO = "/selectDepartmentInfo";
|
||||||
public static final String SELECT_DEPARTMENT_INFO_FORM_EMPTY ="/departmentAll";
|
public static final String SELECT_DEPARTMENT_INFO_FORM_EMPTY = "/departmentAll";
|
||||||
public static final String DELETE_DEPARTMENT = "/deleteDepartment";
|
public static final String DELETE_DEPARTMENT = "/deleteDepartment";
|
||||||
// Department
|
public static final String SHOW_UPDATE_DEPARTMENT = "/showUpdateDepartment";
|
||||||
// HTML
|
public static final String UPDATE_DEPARTMENT_RESULT = "/updateDepartmentResult";
|
||||||
// Controller
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理者向けのページリストを返す
|
* 管理者向けのページリストを返す
|
||||||
@@ -74,8 +73,9 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
UPDATE_EMPLOYEE_RESULT,
|
UPDATE_EMPLOYEE_RESULT,
|
||||||
SELECT_DEPARTMENT_INFO,
|
SELECT_DEPARTMENT_INFO,
|
||||||
SELECT_DEPARTMENT_INFO_FORM_EMPTY,
|
SELECT_DEPARTMENT_INFO_FORM_EMPTY,
|
||||||
DELETE_DEPARTMENT);
|
DELETE_DEPARTMENT,
|
||||||
|
SHOW_UPDATE_DEPARTMENT,
|
||||||
|
UPDATE_DEPARTMENT_RESULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UpdateDepartmentForm {
|
||||||
|
|
||||||
|
//部署ID
|
||||||
|
private Integer idDepartment;
|
||||||
|
//部署名
|
||||||
|
private String nmDepartment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に
|
||||||
|
* 変換します。
|
||||||
|
*
|
||||||
|
* @param departmentInfo business 層の DepartmentInfo インスタンス
|
||||||
|
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス
|
||||||
|
*/
|
||||||
|
public static UpdateDepartmentForm convertFrom(Department department) {
|
||||||
|
return new UpdateDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 画面用(presentation 層)の UpdateDepartmentForm クラスから business 層の Department クラスに
|
||||||
|
* 変換します。
|
||||||
|
*
|
||||||
|
* @param updateDepartmentForm 画面用(presentation 層)の UpdateDepartmentForm インスタンス
|
||||||
|
* @return business 層の Department インスタンス
|
||||||
|
*/
|
||||||
|
public static Department convertTo(UpdateDepartmentForm form) {
|
||||||
|
return new Department(form.getIdDepartment(), form.getNmDepartment());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasRequiredValue() {
|
||||||
|
if (idDepartment == null && (nmDepartment == null || nmDepartment.isBlank())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -78,12 +78,18 @@
|
|||||||
<td th:text="${departmentForm.idDepartment}"></td>
|
<td th:text="${departmentForm.idDepartment}"></td>
|
||||||
<td th:text="${departmentForm.nmDepartment}"></td>
|
<td th:text="${departmentForm.nmDepartment}"></td>
|
||||||
<td>
|
<td>
|
||||||
|
<!-- 更新フォーム -->
|
||||||
|
<form action="showUpdateDepartment" method="post" style="display: inline;">
|
||||||
|
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
||||||
|
<input type="submit" value="更新">
|
||||||
|
</form>
|
||||||
<!-- 削除フォーム -->
|
<!-- 削除フォーム -->
|
||||||
<form action="deleteDepartment" method="post" onsubmit="return confirm('本当に削除しますか?');"
|
<form action="deleteDepartment" method="post" onsubmit="return confirm('本当に削除しますか?');"
|
||||||
style="display: inline;">
|
style="display: inline;">
|
||||||
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
||||||
<input type="submit" value="削除">
|
<input type="submit" value="削除">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
71
src/main/resources/templates/updateDepartmentForm.html
Normal file
71
src/main/resources/templates/updateDepartmentForm.html
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||||
|
<!-- 外部のスクリプトファイルを読み込む -->
|
||||||
|
<script th:src="@{/js/common.js}"></script>
|
||||||
|
<!-- CSSの読み込み -->
|
||||||
|
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||||
|
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||||
|
<title>部署情報更新</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
部署情報更新
|
||||||
|
<div class="rightSection">
|
||||||
|
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||||
|
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||||
|
</div>
|
||||||
|
</h1>
|
||||||
|
<form action="/updateDepartmentResult" method="post" onsubmit="return confirm('本当によろしいですか?');"
|
||||||
|
th:object="${updateDepartmentForm}">
|
||||||
|
|
||||||
|
<div class="msgBox error" th:if="${messageError != null}">
|
||||||
|
<span class="error" th:text="${messageError.message}"></span>
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th class="header">部署ID</th>
|
||||||
|
<td>
|
||||||
|
<input class="readOnly" readonly="readonly" th:field="*{idDepartment}" type="text" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="header">部署名</th>
|
||||||
|
<td>
|
||||||
|
<input maxlength="50" placeholder="部署名" required="required" th:field="*{nmDepartment}"
|
||||||
|
type="text" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="btnArea" colspan="2"><input type="submit" value="更新" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
function selectSubmit() {
|
||||||
|
const form = document.createElement('form');
|
||||||
|
form.setAttribute('method', 'post');
|
||||||
|
form.setAttribute('action', 'departmentAll');
|
||||||
|
|
||||||
|
// 動的送信用のHidden
|
||||||
|
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||||
|
const inputField = document.createElement("input");
|
||||||
|
inputField.setAttribute("type", "hidden");
|
||||||
|
inputField.setAttribute("value", "departmentAll");
|
||||||
|
|
||||||
|
form.appendChild(inputField);
|
||||||
|
|
||||||
|
// フォームをDOMに追加
|
||||||
|
document.body.appendChild(form);
|
||||||
|
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</html>
|
||||||
71
src/main/resources/templates/updateDepartmentInput.html
Normal file
71
src/main/resources/templates/updateDepartmentInput.html
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||||
|
<!-- 外部のスクリプトファイルを読み込む -->
|
||||||
|
<script th:src="@{/js/common.js}"></script>
|
||||||
|
<!-- CSSの読み込み -->
|
||||||
|
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||||
|
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||||
|
<title>部署情報更新</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
部署情報更新
|
||||||
|
<div class="rightSection">
|
||||||
|
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||||
|
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||||
|
</div>
|
||||||
|
</h1>
|
||||||
|
<form action="/updateDepartmentResult" method="post" onsubmit="return confirm('本当によろしいですか?');"
|
||||||
|
th:object="${updateDepartmentForm}">
|
||||||
|
|
||||||
|
<div class="msgBox error" th:if="${messageError != null}">
|
||||||
|
<span class="error" th:text="${messageError.message}"></span>
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th class="header">部署ID</th>
|
||||||
|
<td>
|
||||||
|
<input class="readOnly" readonly="readonly" th:field="*{idDepartment}" type="text" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="header">部署名</th>
|
||||||
|
<td>
|
||||||
|
<input maxlength="50" placeholder="部署名" required="required" th:field="*{nmDepartment}"
|
||||||
|
type="text" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="btnArea" colspan="2"><input type="submit" value="更新" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
function selectSubmit() {
|
||||||
|
const form = document.createElement('form');
|
||||||
|
form.setAttribute('method', 'post');
|
||||||
|
form.setAttribute('action', 'departmentAll');
|
||||||
|
|
||||||
|
// 動的送信用のHidden
|
||||||
|
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||||
|
const inputField = document.createElement("input");
|
||||||
|
inputField.setAttribute("type", "hidden");
|
||||||
|
inputField.setAttribute("value", "departmentAll");
|
||||||
|
|
||||||
|
form.appendChild(inputField);
|
||||||
|
|
||||||
|
// フォームをDOMに追加
|
||||||
|
document.body.appendChild(form);
|
||||||
|
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -3,179 +3,151 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||||
<!-- 外部のスクリプトファイルを読み込む -->
|
<!-- 外部のスクリプトファイルを読み込む -->
|
||||||
<script th:src="@{/js/common.js}"></script>
|
<script th:src="@{/js/common.js}"></script>
|
||||||
<!-- CSSの読み込み -->
|
<!-- CSSの読み込み -->
|
||||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||||
<title>社員情報更新</title>
|
<title>社員情報更新</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>
|
<h1>
|
||||||
社員情報更新
|
社員情報更新
|
||||||
<div class="rightSection">
|
<div class="rightSection">
|
||||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||||
</div>
|
</div>
|
||||||
</h1>
|
</h1>
|
||||||
<form action="/updateEmployeeResult"
|
<form action="/updateEmployeeResult" method="post" onsubmit="return confirm('本当によろしいですか?');"
|
||||||
method="post"
|
th:object="${updateEmployeeInfoForm}">
|
||||||
onsubmit="return confirm('本当によろしいですか?');"
|
<div class="msgBox error" th:if="${messageError != null}">
|
||||||
th:object="${updateEmployeeInfoForm}"
|
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||||
>
|
</div>
|
||||||
<div class="msgBox error" th:if="${messageError != null}">
|
<table>
|
||||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
<tr>
|
||||||
</div>
|
<th class="header">社員ID</th>
|
||||||
<table>
|
<td>
|
||||||
<tr>
|
<label>
|
||||||
<th class="header">社員ID</th>
|
<input class="readOnly" readonly="readonly" th:field="*{idEmployee}" type="text" />
|
||||||
<td>
|
</label>
|
||||||
<label>
|
</td>
|
||||||
<input class="readOnly"
|
</tr>
|
||||||
readonly="readonly"
|
<tr>
|
||||||
th:field="*{idEmployee}"
|
<th class="header">社員名</th>
|
||||||
type="text"
|
<td>
|
||||||
/>
|
<label>
|
||||||
</label>
|
<input maxlength="50" placeholder="社員名" required="required" th:field="*{nmEmployee}"
|
||||||
</td>
|
type="text" />
|
||||||
</tr>
|
</label>
|
||||||
<tr>
|
</td>
|
||||||
<th class="header">社員名</th>
|
</tr>
|
||||||
<td>
|
<tr>
|
||||||
<label>
|
<th class="header">社員名フリガナ</th>
|
||||||
<input maxlength="50"
|
<td>
|
||||||
placeholder="社員名"
|
<label>
|
||||||
required="required"
|
<input maxlength="50" oninput="convertToKatakana(this)" placeholder="フリガナ" required="required"
|
||||||
th:field="*{nmEmployee}"
|
th:field="*{knEmployee}" type="text" />
|
||||||
type="text"
|
</label>
|
||||||
/>
|
</td>
|
||||||
</label>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<th class="header">メールアドレス</th>
|
||||||
<tr>
|
<td>
|
||||||
<th class="header">社員名フリガナ</th>
|
<label>
|
||||||
<td>
|
<input maxlength="100" placeholder="メールアドレス" required="required" th:field="*{mailAddress}"
|
||||||
<label>
|
type="email" />
|
||||||
<input maxlength="50"
|
</label>
|
||||||
oninput="convertToKatakana(this)"
|
</td>
|
||||||
placeholder="フリガナ"
|
</tr>
|
||||||
required="required"
|
<tr>
|
||||||
th:field="*{knEmployee}"
|
<th class="header">パスワード</th>
|
||||||
type="text"
|
<td>
|
||||||
/>
|
<label>
|
||||||
</label>
|
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$" placeholder="パスワード"
|
||||||
</td>
|
th:field="*{password}" type="password" />
|
||||||
</tr>
|
</label>
|
||||||
<tr>
|
</td>
|
||||||
<th class="header">メールアドレス</th>
|
</tr>
|
||||||
<td>
|
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||||
<label>
|
<tr>
|
||||||
<input maxlength="100"
|
<th></th>
|
||||||
placeholder="メールアドレス"
|
<td>
|
||||||
required="required"
|
<span style="font-size:8pt;
|
||||||
th:field="*{mailAddress}"
|
|
||||||
type="email"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th class="header">パスワード</th>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
|
||||||
placeholder="パスワード"
|
|
||||||
th:field="*{password}"
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
|
||||||
<tr>
|
|
||||||
<th></th>
|
|
||||||
<td>
|
|
||||||
<span style="font-size:8pt;
|
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
color:red;">
|
color:red;">
|
||||||
※半角英数字をそれぞれ1種類以上含む3-10文字
|
※半角英数字をそれぞれ1種類以上含む3-10文字
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">パスワード確認用</th>
|
<th class="header">パスワード確認用</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$" placeholder="パスワード確認用"
|
||||||
placeholder="パスワード確認用"
|
th:field="*{passwordConfirm}" type="password" />
|
||||||
th:field="*{passwordConfirm}"
|
</label>
|
||||||
type="password"
|
</td>
|
||||||
/>
|
</tr>
|
||||||
</label>
|
<tr>
|
||||||
</td>
|
<th class="header">管理者権限</th>
|
||||||
</tr>
|
<td>
|
||||||
<tr>
|
<label>
|
||||||
<th class="header">管理者権限</th>
|
<input id="adminAuth1" name="adminAuth" th:checked="${updateEmployeeInfoForm.adminAuth == 1}"
|
||||||
<td>
|
type="radio" value="1"> 管理者権限
|
||||||
<label>
|
</label>
|
||||||
<input id="adminAuth1" name="adminAuth" th:checked="${updateEmployeeInfoForm.adminAuth == 1}"
|
<label>
|
||||||
type="radio"
|
<input id="adminAuth0" name="adminAuth"
|
||||||
value="1"> 管理者権限
|
th:checked="${updateEmployeeInfoForm.adminAuth == null or updateEmployeeInfoForm.adminAuth == 0}"
|
||||||
</label>
|
type="radio" value="0">
|
||||||
<label>
|
一般権限
|
||||||
<input id="adminAuth0" name="adminAuth"
|
</label>
|
||||||
th:checked="${updateEmployeeInfoForm.adminAuth == null or updateEmployeeInfoForm.adminAuth == 0}"
|
</td>
|
||||||
type="radio"
|
</tr>
|
||||||
value="0">
|
<tr>
|
||||||
一般権限
|
<th class="header">所属部署</th>
|
||||||
</label>
|
<td>
|
||||||
</td>
|
<label>
|
||||||
</tr>
|
<select required="required" th:field="*{idDepartment}">
|
||||||
<tr>
|
<option th:each="department : ${departmentFormList}"
|
||||||
<th class="header">所属部署</th>
|
th:selected="${updateEmployeeInfoForm.idDepartment != null && department.idDepartment == updateEmployeeInfoForm.idDepartment}"
|
||||||
<td>
|
th:text="${department.nmDepartment}" th:value="${department.idDepartment}">
|
||||||
<label>
|
</option>
|
||||||
<select required="required" th:field="*{idDepartment}">
|
</select>
|
||||||
<option th:each="department : ${departmentFormList}"
|
</label>
|
||||||
th:selected="${updateEmployeeInfoForm.idDepartment != null && department.idDepartment == updateEmployeeInfoForm.idDepartment}"
|
</td>
|
||||||
th:text="${department.nmDepartment}"
|
</tr>
|
||||||
th:value="${department.idDepartment}">
|
<tr>
|
||||||
</option>
|
<td class="btnArea" colspan="2">
|
||||||
</select>
|
<input type="submit" value="更新" />
|
||||||
</label>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
</table>
|
||||||
<tr>
|
</form>
|
||||||
<td class="btnArea" colspan="2">
|
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
||||||
<input type="submit" value="更新"/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function selectSubmit() {
|
function selectSubmit() {
|
||||||
const form = document.createElement('form');
|
const form = document.createElement('form');
|
||||||
form.setAttribute('method', 'post');
|
form.setAttribute('method', 'post');
|
||||||
form.setAttribute('action', 'selectAll');
|
form.setAttribute('action', 'selectAll');
|
||||||
|
|
||||||
// 動的送信用のHidden
|
// 動的送信用のHidden
|
||||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||||
const inputField = document.createElement("input");
|
const inputField = document.createElement("input");
|
||||||
inputField.setAttribute("type", "hidden");
|
inputField.setAttribute("type", "hidden");
|
||||||
inputField.setAttribute("value", "selectAll");
|
inputField.setAttribute("value", "selectAll");
|
||||||
|
|
||||||
form.appendChild(inputField);
|
form.appendChild(inputField);
|
||||||
|
|
||||||
// フォームをDOMに追加
|
// フォームをDOMに追加
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
|
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user