]> WPIA git - gigi.git/commitdiff
upd: fix bootstrap buttons
authorFelix Dörre <felix@dogcraft.de>
Sat, 18 Jun 2016 13:02:23 +0000 (15:02 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sat, 18 Jun 2016 13:56:48 +0000 (15:56 +0200)
Change-Id: I87ed68d552f3f84998f858f7de5af2a043866e8f

src/org/cacert/gigi/pages/account/mail/MailManagementForm.java
src/org/cacert/gigi/pages/account/mail/MailManagementForm.templ
tests/org/cacert/gigi/pages/account/TestMailManagement.java

index 04ed69d2258d808736936b5db29dc225662f74e0..cbf143976ac6a7bdecf14ad8de9116fb30252ea3 100644 (file)
@@ -3,7 +3,6 @@ package org.cacert.gigi.pages.account.mail;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -32,20 +31,14 @@ public class MailManagementForm extends Form {
 
     @Override
     public boolean submit(PrintWriter out, HttpServletRequest req) {
-        Map<String, String[]> map = req.getParameterMap();
         try {
-            for (Entry<String, String[]> e : map.entrySet()) {
-                String k = e.getKey();
-                String[] p = k.split(":", 2);
-                if (p[0].equals("default")) {
-                    target.updateDefaultEmail(EmailAddress.getById(Integer.parseInt(p[1])));
-                }
-                if (p[0].equals("delete")) {
-                    target.deleteEmail(EmailAddress.getById(Integer.parseInt(p[1])));
-                }
-                if (p[0].equals("reping")) {
-                    EmailAddress.getById(Integer.parseInt(p[1])).requestReping(Page.getLanguage(req));
-                }
+            String d;
+            if ((d = req.getParameter("default")) != null) {
+                target.updateDefaultEmail(EmailAddress.getById(Integer.parseInt(d)));
+            } else if ((d = req.getParameter("delete")) != null) {
+                target.deleteEmail(EmailAddress.getById(Integer.parseInt(d)));
+            } else if ((d = req.getParameter("reping")) != null) {
+                EmailAddress.getById(Integer.parseInt(d)).requestReping(Page.getLanguage(req));
             }
         } catch (GigiApiException e) {
             e.format(out, Page.getLanguage(req));
index e942560b1bf4bd010cfcd214d1a077b9e57684a6..25c056db69d25cc092894162b13f3915fc99014c 100644 (file)
   </tr>
  <? foreach($emails) {?>
        <tr>
-               <td><input class="form-control" type="submit" name="default:<?=$id?>" value="<?=_Set as Default?>"<?=$default?>></td>
+               <td><button class="btn btn-primary" type="submit" name="default" value="<?=$id?>"<?=$default?>><?=_Set as Default?></button></td>
                <td><?=$verification?></td>
                <td><?=$last_verification?></td>
                <td><?=$address?></td>
-               <td><input class="form-control" type="submit" name="delete:<?=$id?>" value="<?=_Delete?>"<?=$deletable?>></td>
-               <td><input class="form-control" type="submit" name="reping:<?=$id?>" value="<?=_Request reping?>"></td>
+               <td><button class="btn btn-danger" type="submit" name="delete" value="<?=$id?>"<?=$deletable?>><?=_Delete?></button></td>
+               <td><button class="btn btn-primary" type="submit" name="reping" value="<?=$id?>"><?=_Request reping?></button></td>
        </tr>
  <? } ?>
   </tbody>
index 5fd14212ca9773b8a393c04eebd545d56e80ee40..bf73cd38c9c2cd8ef63e729b964977ce46eb0147 100644 (file)
@@ -89,7 +89,7 @@ public class TestMailManagement extends ClientTest {
     @Test
     public void testMailSetDefaultWeb() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
         EmailAddress addr = createVerifiedEmail(u);
-        assertNull(executeBasicWebInteraction(cookie, path, "default:" + addr.getId()));
+        assertNull(executeBasicWebInteraction(cookie, path, "default=" + addr.getId()));
         ObjectCache.clearAllCaches();
         assertEquals(User.getById(u.getId()).getEmail(), addr.getAddress());
     }
@@ -97,7 +97,7 @@ public class TestMailManagement extends ClientTest {
     @Test
     public void testMailSetDefaultWebUnverified() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
         EmailAddress addr = new EmailAddress(u, createUniqueName() + "test@test.tld", Locale.ENGLISH);
-        assertNotNull(executeBasicWebInteraction(cookie, path, "default:" + addr.getId()));
+        assertNotNull(executeBasicWebInteraction(cookie, path, "default=" + addr.getId()));
         assertNotEquals(User.getById(u.getId()).getEmail(), addr.getAddress());
         getMailReciever().clearMails();
     }
@@ -113,7 +113,7 @@ public class TestMailManagement extends ClientTest {
             }
         }
         assertNotEquals(id, -1);
-        assertNotNull(executeBasicWebInteraction(cookie, path, "default:" + id));
+        assertNotNull(executeBasicWebInteraction(cookie, path, "default=" + id));
         assertNotEquals(User.getById(u.getId()).getEmail(), u2.getEmail());
         getMailReciever().clearMails();
     }
@@ -121,7 +121,7 @@ public class TestMailManagement extends ClientTest {
     @Test
     public void testMailDeleteWeb() throws InterruptedException, GigiApiException, MalformedURLException, UnsupportedEncodingException, IOException {
         EmailAddress addr = createVerifiedEmail(u);
-        assertNull(executeBasicWebInteraction(cookie, path, "delete:" + addr.getId(), 0));
+        assertNull(executeBasicWebInteraction(cookie, path, "delete=" + addr.getId(), 0));
         User u = User.getById(this.u.getId());
         EmailAddress[] addresses = u.getEmails();
         for (int i = 0; i < addresses.length; i++) {
@@ -134,7 +134,8 @@ public class TestMailManagement extends ClientTest {
         EmailAddress[] addr = new EmailAddress[] {
                 createVerifiedEmail(u), createVerifiedEmail(u)
         };
-        assertNull(executeBasicWebInteraction(cookie, path, "delete:" + addr[0].getId() + "&delete:" + addr[1].getId(), 0));
+        assertNull(executeBasicWebInteraction(cookie, path, "delete=" + addr[0].getId(), 0));
+        assertNull(executeBasicWebInteraction(cookie, path, "delete=" + addr[1].getId(), 0));
         User u = User.getById(this.u.getId());
         EmailAddress[] addresses = u.getEmails();
         for (int i = 0; i < addresses.length; i++) {
@@ -147,14 +148,14 @@ public class TestMailManagement extends ClientTest {
     public void testMailDeleteWebFaulty() throws MalformedURLException, UnsupportedEncodingException, IOException {
         User u2 = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@test.tld", TEST_PASSWORD));
         EmailAddress em = u2.getEmails()[0];
-        assertNotNull(executeBasicWebInteraction(cookie, path, "delete:" + em.getId(), 0));
+        assertNotNull(executeBasicWebInteraction(cookie, path, "delete=" + em.getId(), 0));
         u2 = User.getById(u2.getId());
         assertNotEquals(u2.getEmails().length, 0);
     }
 
     @Test
     public void testMailDeleteWebPrimary() throws MalformedURLException, UnsupportedEncodingException, IOException {
-        assertNotNull(executeBasicWebInteraction(cookie, path, "delete:" + u.getEmails()[0].getId(), 0));
+        assertNotNull(executeBasicWebInteraction(cookie, path, "delete=" + u.getEmails()[0].getId(), 0));
         assertNotEquals(u.getEmails().length, 0);
     }
 }