summaryrefslogtreecommitdiffstats
path: root/warehouse/src/main/webapp/WEB-INF/pages/account/modify.jsp
blob: 79937cf6ce75020e3d5f7446f72d96e294885c5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<style type="text/css">
	label{
	margin-top:15px;
	}
	/* .col-sm-4 {
	 margin-top:-16px;
	} */
	#e_au {
	height:auto;
	}
	.div-label{
	margin-top:-10px;
	}
</style>
<!-- navigationDialog dialog -->
<jsp:include page="../navigationDialog.jsp" flush="true"></jsp:include>
<c:choose>
	<c:when test="${not empty modelErrors}">
		<div class="alert alert-danger" id="modalErrorArea" role="alert">
			&nbsp;${modelErrors}
		</div>
	</c:when>
	<c:otherwise>
		<div class="card mb-3" id="defaultForm">
			<div class="card-body card-change-password pt0">
		      <!-- <div class="card-header"></div> -->
			<div class="alert alert-danger" id="modalErrorArea" role="alert"<c:choose>
				<c:when test="${not empty modelErrors}">style="display: block"</c:when>
				<c:otherwise>style="display: none"</c:otherwise>
				</c:choose>>
				<c:if test="${not empty modelErrors}">
					&nbsp;${modelErrors}
				</c:if>
			</div>
		      <div class="card-body"  style="min-height:530px;">
		      	<div class="alert alert-danger" style="display:none" id="modalErrorArea" role="alert"></div>
		        <form id="registerForm" class="was-validated" action = "accountList">
		        <input type="hidden" id="e_userId" value="${appInfo.userId}">
		          <div class="form-group row">
		            <div class="col-md-3 div-label"><label for="e_userName" class="notNull">User Name </label></div>
		            <div class="col-md-9">
		              <input class="form-control style-height" maxlength="32" placeholder="Maximum length is 32 characters" id="e_userName" name="e_userName" type="text" value="${appInfo.userName}"  required>
		            </div>
		          </div>
		          <c:if test="${empty appInfo.userId}">
		          <div class="form-group row">
		            <div class="col-md-3 div-label"><label for="e_userPw" class="notNull">Password</label></div>
		            <div class="col-md-9">
		              <input class="form-control input-color style-height" id="e_userPw" name="e_userPw" type="password" maxlength="32"  placeholder="Between 6 and 32 characters" value="${appInfo.userPw}"  required>
		            </div>
		          </div>
		          <div class="form-group row">
		            <div class="col-md-3 div-label"><label for="e_reuserPw" class="notNull">Password Confirmation</label></div>
		            <div class="col-md-9">
		              <input class="form-control input-color style-height"  id="e_reuserPw" name="e_reuserPw" type="password" maxlength="32" placeholder="The same as the password above" value="${appInfo.reuserPw}"  required>
		            </div>
		          </div>
		          </c:if>
		          <div class="form-group row">
		            <div class="col-md-3 div-label"><label for="e_mailAddress" class="notNull">Mail Address</label></div>
		            <div class="col-md-9">
		              <input class="form-control input-color style-height"  id="e_mailAddress" maxlength="32" placeholder="Only letters, numbers, and underlines can be used" name="e_mailAddress" value="${appInfo.mailAddress}"  required>
		            </div>
		          </div>
		          <div class="form-group row">
                     <div class="col-md-3 div-label"><label for="e_au" class="notNull">Authority</label></div>
                     <div class="col-md-9">
                      <select id="e_au" class="form-control" required>
                        <c:forEach var="list" items="${authorityList}">
                           <option value="${list.value}" <c:if test="${list.value eq appInfo.auId}">selected="selected"</c:if>>${list.label}</option>
                        </c:forEach>
                     </select> 
                	</div>
                </div>
		        </form>
		       <div style="float:right" class="col-md-0">
		        <button type="button" class="btn btn-primary form-btn-w-70" id="btn-save-edit" onclick="saveaccountForm()">save</button>
		       <%--  <button type="button" class="btn btn-cancel form-btn-w-70" Style="background-Color:gray" onclick="Commons.showContent('<%=basePath%>/account/')">back</button> --%>
		      </div>
		      </div>
		    </div>
		</div>
	</c:otherwise>
</c:choose>

<script src="<%=basePath%>/js/constant.js"></script>
<script>
$(function(){
	Commons.appendRedAsterisk();
	var e_userId = $('#e_userId').val();
	if(e_userId !== ""){
		$('#e_mailAddress')[0].style.border = "1px solid #28a745";
	}
    $('#e_userPw').bind('input propertychange', function() {
        if($('#e_userPw').val().length > 5 ){
    	    $('#e_userPw')[0].style.border = "1px solid #28a745";
    	}else{
    	    $('#e_userPw')[0].style.border = "1px solid red";
    	}
    });
    $('#e_reuserPw').bind('input propertychange', function() {
    	if($('#e_reuserPw').val().length > 5 ){
    	    $('#e_reuserPw')[0].style.border = "1px solid #28a745";
    	}else{
    	    $('#e_reuserPw')[0].style.border = "1px solid red";
    	}
    });
    $('#e_mailAddress').bind('input propertychange', function() {
    	var szReg=/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
    	           
    	if(!szReg.test($('#e_mailAddress').val())){
    		$('#e_mailAddress')[0].style.border = "1px solid red";
    	}else{
    		$('#e_mailAddress')[0].style.border = "1px solid #28a745";
    	}
    });
});
var accountForm = function() {
	this.userId = '';
	this.userPw = '';
	this.userName = '';
	this.auId = '';
	this.mailAddress = '';
	this.userPw = '';
	this.reuserPw = '';
};

var $errorArea = $('#modalErrorArea');
var saveaccountForm = function() {
	$("#btn-save-edit").attr('disabled',true);
	$errorArea.empty();
	$errorArea.css("display", "none");
	var tf = new accountForm();
	tf.userId = $('#e_userId').val();
	tf.reuserPw = $('#e_reuserPw').val();
	tf.userPw = $('#e_userPw').val();
	tf.userName = $('#e_userName').val();
	tf.auId = $('#e_au').val();
	tf.mailAddress = $('#e_mailAddress').val();

	$.ajax({
		url: '<%=basePath%>/account/update',
		cache: false,
		type: 'POST',
		data: {form: JSON.stringify(tf)},
		success: function (data) {
			var json = JSON.parse(data);
			if(200 == json.result) {
				Commons.showContent('<%=basePath%>' + json.forward);
			} else if(401 == json.result) {
				var errorContent = '';
				for (var i in json.message) {
					errorContent += '<div>' + json.message[i] + '</div>';
				}
				$errorArea.empty().append(errorContent);
				$errorArea.css("display", "block");
				$("#btn-save-edit").attr('disabled',false);
			} else if(500 == json.result) {
				var errorContent = '';
				for (var i in json.message) {
					errorContent += '<div>' + json.message[i] + '</div>';
				}
				$errorArea.empty().append(errorContent);
				$errorArea.css("display", "block");
				$("#btn-save-edit").attr('disabled',false);
			}
		}
	});
	/* }
	} */
};
</script>