Skip to content

Commit c2279fd

Browse files
committed
third commit
1 parent 7b033fc commit c2279fd

File tree

7 files changed

+139
-8
lines changed

7 files changed

+139
-8
lines changed

src/main/java/com/sapanywhere/app/controller/EmployeeController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
import com.sapanywhere.app.entity.Employee;
2828
import com.sapanywhere.app.entity.Files;
2929
import com.sapanywhere.app.model.EmployeeInfoForm;
30+
import com.sapanywhere.app.model.setting.ApproverListView;
3031
import com.sapanywhere.app.repository.EmployeeRepository;
32+
import com.sapanywhere.app.service.ApproverService;
3133
import com.sapanywhere.app.service.CompanyService;
3234
import com.sapanywhere.app.service.EmployeeService;
3335
import com.sapanywhere.app.service.FileService;
36+
import com.sapanywhere.app.service.UserService;
3437
import com.sapanywhere.app.service.user.UserInfo;
3538

3639
@Controller
@@ -51,15 +54,24 @@ public class EmployeeController {
5154

5255
@Autowired
5356
private FileService fileService;
57+
58+
@Autowired
59+
private ApproverService approverService;
5460

61+
@Autowired
62+
private UserService userService;
63+
5564
@ModelAttribute("companyInfo")
5665
public Company getCompanyInfo(){
5766
return this.companyService.findById((long) 1);
5867
}
5968

6069
@RequestMapping(value = "/information.html",method = RequestMethod.GET)
61-
public String createPage(@AuthenticationPrincipal UserInfo userInfo, EmployeeInfoForm employeeInfoForm){
70+
public String createPage(@AuthenticationPrincipal UserInfo userInfo, EmployeeInfoForm employeeInfoForm,ApproverListView approverListView){
71+
approverListView.setApprovers(this.approverService.findAllApproves());
72+
approverListView.setUsers(this.userService.findAll());
6273
System.out.println(userInfo.getUser().getId());
74+
System.out.println(approverListView.getApprovers().iterator().next().getUser().getEmail());
6375
Employee employee = employeeRepository.findByUser(userInfo.getUser());
6476
System.out.println(employee.getFirstName());
6577
employeeInfoForm.setByEmployee(employee);

src/main/java/com/sapanywhere/app/model/setting/ApproverListView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public ApproverListView(Iterable<Approver> approvers, Iterable<User> users) {
1515
this.setApprovers(approvers);
1616
this.users = users;
1717
}
18+
1819

1920
private Iterable<Approver> approvers = new ArrayList<Approver>();
2021
private Iterable<User> users = new ArrayList<User>();
@@ -34,4 +35,5 @@ public Iterable<Approver> getApprovers() {
3435
public void setApprovers(Iterable<Approver> approvers) {
3536
this.approvers = approvers;
3637
}
38+
3739
}

src/main/resources/messages_en.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ employee.info.gender = Gender:
5858
employee.info.department = Department:
5959
employee.info.position = Position:
6060
employee.info.entrydate = Entry Date:
61-
61+
employee.info.company = Company Name:
62+
employee.approval.table.title=Approver Information
6263
#Company
6364
company.info.header = Company Infomation
6465
company.info.department = Department Infomation
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.employee.information .modal-dialog {
2+
width: 500px;
3+
margin:100px auto;
4+
}
5+
6+
.employee.information .modal-dialog .modal-content {
7+
min-height: 600px;
8+
}
9+
10+
.employee.information .modal-dialog .modal-content .modal-footer {
11+
bottom: 0;
12+
position: absolute;
13+
left: 0;
14+
right: 0;
15+
}
16+
17+
.employee.information .modal-dialog .modal-content .modal-body {
18+
padding-top: 0px;
19+
}
20+
21+
.employee.information .modal-dialog .modal-content .modal-body .row {
22+
height: 40px;
23+
line-height: 40px; border-bottom : 1px solid #e5e5e5;
24+
padding: 0 15px;
25+
border-bottom: 1px solid #e5e5e5;
26+
cursor: pointer;
27+
}
28+
29+
.employee.information .modal-dialog .modal-content .modal-body .row:hover{
30+
background: #e5e5e5;
31+
}
32+
33+
.employee.information tbody{
34+
border-bottom: 1px solid #ddd;
35+
}
36+
37+
.employee.information td .col-xs-3{
38+
padding:0px;
39+
}

src/main/resources/templates/employee/information.html

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
11
<!DOCTYPE html>
22
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
3-
43
<head>
54
<title>Human Resource</title>
65
<script type="text/javascript" th:src="@{/libs/jquery-2.1.4/jquery-2.1.4.min.js}"></script>
76
<script type="text/javascript" th:src="@{/libs/bootstrap-3.3.5/js/bootstrap.min.js}"></script>
87
<link rel="stylesheet" th:href="@{/libs/bootstrap-3.3.5/css/bootstrap.min.css}"></link>
98
<link rel="stylesheet" th:href="@{/css/common.css}"></link>
109
<link rel="stylesheet" th:href="@{/css/employee.css}"></link>
11-
<script type="text/javascript">
10+
<script th:inline="javascript">
11+
$(document).on("click", ".modal-dialog .modal-body .row", function(evn) {
12+
var userApproverId = $("#chooseApproverDialog").data("userApproverId");
13+
var approverId = $(this).data("approverid");
14+
$.ajax({
15+
type : "POST",
16+
url : "/setting/updateApprover",
17+
data : JSON.stringify({
18+
id : userApproverId,
19+
approverId : approverId
20+
}),
21+
success : function() {
22+
$('#chooseApproverDialog').modal('hide')
23+
location.reload();
24+
},
25+
contentType : 'application/json'
26+
});
27+
});
1228

29+
$(document).on("show.bs.modal", "#chooseApproverDialog", function(event) {
30+
var link = $(event.relatedTarget)
31+
var userApproverId = link.data('id')
32+
$(this).data("userApproverId", userApproverId);
33+
})
1334
</script>
1435
</head>
1536

@@ -93,14 +114,72 @@
93114
<span th:if="${employeeInfoForm.entryDate != null}" th:text="${employeeInfoForm.entryDate}"></span>
94115
</th>
95116
</tr>
117+
<tr>
118+
<th>
119+
<span class="glyphicon glyphicon-th-large" aria-hidden="true"></span>
120+
<span th:text= "#{employee.info.company}"></span>
121+
<span th:text= "${companyInfo.name}"></span>
122+
</th>
123+
<th>
124+
</th>
125+
</tr>
96126
</thead>
97127
</table>
98128
</div>
99129
<div class= "media-right">
100-
<a href="#" th:href="@{/edit.html}" role="button" class="btn btn-default btn-xs"> Edit</a>
130+
<a href="#" th:href="@{/edit.html}" role="button" class="btn btn-default btn-xs"> Edit</a>
101131
</div>
102132
</div>
103133
</div>
134+
135+
<div class="panel panel-default approvel-listview" th:object="${approverListView}">
136+
<div class="panel-heading" th:text="#{employee.approval.table.title}"></div>
137+
<div class="panel-body">
138+
<table class="table">
139+
<thead>
140+
<tr>
141+
<th th:text="#{setting.approval.table.column.userName}"></th>
142+
<th th:text="#{setting.approval.table.column.approverName}"></th>
143+
</tr>
144+
</thead>
145+
<tbody>
146+
<tr th:each="it,iterableObj : *{approvers}" th:if = "(${it.user.id} == ${currentUserInfo.user.id})">
147+
<td th:text="${it.user.fullName}"></td>
148+
<td class="approverColumn" th:if="${it.approver != null}">
149+
<div class="col-xs-3" th:text="${it.approver.fullName}"></div> <a class="col-xs-3" href="#" data-toggle="modal" data-target="#chooseApproverDialog" th:attr="data-id=${it.id}" th:text="#{setting.approval.table.link.changeApprover}"></a>
150+
</td>
151+
<td class="approverColumn" th:if="${it.approver == null}">
152+
<div>
153+
<a href="#" id = "${iterableObj.index + 1}" data-toggle="modal" data-target="#chooseApproverDialog" th:attr="data-id=${it.id}" th:text="#{setting.approval.table.link.bindApprover}"></a>
154+
</div>
155+
</td>
156+
</tr>
157+
</tbody>
158+
</table>
159+
</div>
160+
</div>
161+
<!-- Modal Choose Approver Dialog -->
162+
<div class="modal fade" id="chooseApproverDialog" tabindex="-1" role="dialog" th:object="${approverListView}" aria-labelledby="chooseApproverDialog-title">
163+
<div class="modal-dialog" role="document">
164+
<div class="modal-content">
165+
<div class="modal-header">
166+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
167+
<span aria-hidden="true">&times;</span>
168+
</button>
169+
<h4 class="modal-title" id="chooseApproverDialog-title">Selector Approvers</h4>
170+
</div>
171+
<div class="modal-body">
172+
<div class="row" th:each="it:*{users}" th:attr="data-approverId=${it.id}">
173+
<div th:text="${it.fullName}"></div>
174+
</div>
175+
</div>
176+
<div class="modal-footer">
177+
<button type="button" class="btn btn-default" data-dismiss="modal" th:text="#{common.button.cancal}"></button>
178+
</div>
179+
</div>
180+
</div>
181+
</div>
182+
104183
</div>
105184
</body>
106185
</html>

src/main/resources/templates/overview/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</div>
102102
</div>
103103

104-
<div class="panel panel-default approvel-listview" th:if="${overviewPage.isShowWaitApproveList()}">
104+
<div class="panel panel-default approvel-listview">
105105
<div class="panel-heading" th:text="#{overview.waitForApprove.table.title}"></div>
106106
<div class="panel-body">
107107
<table class="table">

src/main/resources/templates/settings/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@
190190
</div>
191191
</td>
192192
</tr>
193-
194-
195193
</tbody>
196194
</table>
197195
</div>

0 commit comments

Comments
 (0)