From 7f92579905c1bd596d547c8a423e043465f055d7 Mon Sep 17 00:00:00 2001
From: FuXiaoHei <fuxiaohei@hexiaz.com>
Date: Tue, 11 Mar 2014 11:41:38 +0800
Subject: [PATCH] finish user delete page ui

---
 public/css/gogs.css           | 10 +++++-----
 public/js/app.js              |  2 +-
 routers/user/setting.go       |  1 +
 routers/user/user.go          |  2 +-
 templates/user/delete.tmpl    | 35 ++++++++++++++++++++++++++++-------
 templates/user/publickey.tmpl |  2 +-
 templates/user/setting.tmpl   |  2 +-
 7 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/public/css/gogs.css b/public/css/gogs.css
index 4a4144babd..05e3081051 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -32,7 +32,7 @@ body {
     background-color: transparent;
 }
 
-.btn{
+.btn {
     cursor: pointer;
 }
 
@@ -234,7 +234,7 @@ body {
 
 /* gogits user setting */
 
-#gogs-user-setting-nav > h4, #gogs-user-setting-container > h4 ,#gogs-ssh-keys > h4{
+#gogs-user-setting-nav > h4, #gogs-user-setting-container > h4, #gogs-ssh-keys > h4, #gogs-user-delete > h4 {
     padding-bottom: 18px;
     margin-bottom: 18px;
     border-bottom: 1px solid #CCC;
@@ -263,11 +263,11 @@ body {
     border-bottom: 1px solid #DDD;
 }
 
-#gogs-ssh-keys .list-group-item:after{
+#gogs-ssh-keys .list-group-item:after {
     clear: both;
 }
 
-#gogs-ssh-keys .list-group-item:hover a.delete{
+#gogs-ssh-keys .list-group-item:hover a.delete {
     display: block;
 }
 
@@ -298,6 +298,6 @@ body {
     border-radius: 3px;
 }
 
-#gogs-ssh-form textarea{
+#gogs-ssh-form textarea {
     height: 16em;
 }
\ No newline at end of file
diff --git a/public/js/app.js b/public/js/app.js
index f6e1471204..a789122b1b 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -104,7 +104,7 @@ function initUserSetting(){
         var $this = $(this);
         Gogits.ajaxDelete("",{"id":$this.data("del")},function(json){
             if(json.ok){
-                $this.parent().remove();
+                window.location.reload();
             }else{
                 alert(json.err);
             }
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 96a02b6f46..0669784be0 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -56,6 +56,7 @@ func SettingSSHKeys(form auth.AddSSHKeyForm, r render.Render, data base.TmplData
 				"ok": true,
 			})
 		}
+		return
 	}
 
 	// Add new SSH key.
diff --git a/routers/user/user.go b/routers/user/user.go
index 51a84400ab..ca9dddaecd 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -134,7 +134,7 @@ func SignUp(form auth.RegisterForm, data base.TmplData, req *http.Request, r ren
 
 // TODO: unfinished
 func Delete(data base.TmplData, req *http.Request, r render.Render) {
-	data["Title"] = "Delete user"
+	data["Title"] = "Delete Account"
 
 	if req.Method == "GET" {
 		r.HTML(200, "user/delete", data)
diff --git a/templates/user/delete.tmpl b/templates/user/delete.tmpl
index 939048b421..7a9dcddfe6 100644
--- a/templates/user/delete.tmpl
+++ b/templates/user/delete.tmpl
@@ -1,12 +1,33 @@
 {{template "base/head" .}}
 {{template "base/navbar" .}}
+<div id="gogs-body" class="container">
+    <div id="gogs-user-setting-nav" class="col-md-3">
+        <h4>Account Setting</h4>
+        <ul class="list-group">
+            <li class="list-group-item"><a href="/user/setting">Account Profile</a></li>
+            <li class="list-group-item"><a href="#">Emails and Password</a></li>
+            <li class="list-group-item"><a href="#">Notifications</a></li>
+            <li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li>
+            <li class="list-group-item"><a href="#">Security</a></li>
+            <li class="list-group-item list-group-item-success"><a href="/user/delete">Delete Account</a></li>
+        </ul>
+    </div>
+    <div id="gogs-user-setting-container" class="col-md-9">
+        <form action="/user/delete" method="post" class="form-horizontal" id="gogs-user-delete">
+            <h4>Delete Account</h4>
+            <p class="alert alert-danger">Deleting your account is permanent. Sorry to see you go, if you have any feedback you can contact us.</p>
+            <div class="form-group">
+                <div class="col-md-3">
+                    <button type="submit" class="btn btn-danger btn-lg">Delete Account</button>
+                </div>
+            </div>
+        </form>
+    </div>
+</div>
+{{template "base/footer" .}}
+{{template "base/head" .}}
+{{template "base/navbar" .}}
 <div class="container" id="gogs-body">
-	<form action="/user/delete" method="post" class="form-horizontal">
-		<div class="form-group">
-		    <div class="col-md-offset-4 col-md-3">
-		    	<button type="submit" class="btn btn-danger">Delete user</button>
-		    </div>
-		</div>
-	</form>
+
 </div>
 {{template "base/footer" .}}
\ No newline at end of file
diff --git a/templates/user/publickey.tmpl b/templates/user/publickey.tmpl
index 7510616d86..0bd76593e7 100644
--- a/templates/user/publickey.tmpl
+++ b/templates/user/publickey.tmpl
@@ -9,7 +9,7 @@
             <li class="list-group-item"><a href="#">Notifications</a></li>
             <li class="list-group-item list-group-item-success"><a href="/user/setting/ssh/">SSH Keys</a></li>
             <li class="list-group-item"><a href="#">Security</a></li>
-            <li class="list-group-item"><a href="#">Kill Myself</a></li>
+            <li class="list-group-item"><a href="/user/delete">Delete Account</a></li>
         </ul>
     </div>
 
diff --git a/templates/user/setting.tmpl b/templates/user/setting.tmpl
index cc527a25ac..928d359a26 100644
--- a/templates/user/setting.tmpl
+++ b/templates/user/setting.tmpl
@@ -9,7 +9,7 @@
             <li class="list-group-item"><a href="#">Notifications</a></li>
             <li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li>
             <li class="list-group-item"><a href="#">Security</a></li>
-            <li class="list-group-item"><a href="#">Kill Myself</a></li>
+            <li class="list-group-item"><a href="/user/delete">Delete Account</a></li>
         </ul>
     </div>
     <div id="gogs-user-setting-container" class="col-md-9">