]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move validateEventForm function and fix success handling
authorBart Visscher <bartv@thisnet.nl>
Fri, 16 Sep 2011 15:06:57 +0000 (17:06 +0200)
committerBart Visscher <bartv@thisnet.nl>
Fri, 16 Sep 2011 15:06:57 +0000 (17:06 +0200)
apps/calendar/ajax/editevent.php
apps/calendar/js/calendar.js
apps/calendar/templates/part.editevent.php
apps/calendar/templates/part.newevent.php

index d8dae7a324ba649d376ccd22005ee4378d9f8d14..aef2e6f78b4368a6351c171758796679c3e03d32 100644 (file)
@@ -24,7 +24,7 @@ if(!OC_USER::isLoggedIn()) {
 $errarr = OC_Calendar_Object::validateRequest($_POST);
 if($errarr){
        //show validate errors
-       $errarr["error"] = "true";
+       $errarr['status'] = 'error';
        echo json_encode($errarr);
        exit;
 }else{
@@ -48,6 +48,6 @@ if($errarr){
                $calendar = OC_Calendar_Calendar::findCalendar($request['calendar']);
                OC_Calendar_Object::moveToCalendar($id, $cal);
        }
-       echo json_encode(array("success"=>"true"));
+       echo json_encode(array('status' => 'success'));
 }
 ?> 
index d18a9573742003d40700e828b7c4459bc199fed5..c0629bab6258f4d609e3ae3508e4016d12a2ab22 100644 (file)
@@ -322,6 +322,45 @@ Calendar={
                                });
                        }
                },
+               validateEventForm:function(url){
+                       var post = $( "#event_form" ).serialize();
+                       $("#errorbox").html("");
+                       $.post(url, post,
+                               function(data){
+                                       if(data.status == "error"){
+                                               var output = "Missing fields: <br />";
+                                               if(data.title == "true"){
+                                                       output = output + "Title<br />";
+                                               }
+                                               if(data.cal == "true"){
+                                                       output = output + "Calendar<br />";
+                                               }
+                                               if(data.from == "true"){
+                                                       output = output + "From Date<br />";
+                                               }
+                                               if(data.fromtime == "true"){
+                                                       output = output + "From Time<br />";
+                                               }
+                                               if(data.to == "true"){
+                                                       output = output + "To Date<br />";
+                                               }
+                                               if(data.totime == "true"){
+                                                       output = output + "To Time<br />";
+                                               }
+                                               if(data.endbeforestart == "true"){
+                                                       output = "The event ends before it starts!";
+                                               }
+                                               if(data.dberror == "true"){
+                                                       output = "There was a database fail!";
+                                               }
+                                               $("#errorbox").html(output);
+                                       } else
+                                       if(data.status == 'success'){
+                                               $('#event').dialog('destroy').remove();
+                                               Calendar.UI.loadEvents();
+                                       }
+                               },"json");
+               },
                createEventPopup:function(e){
                        var popup = $(this).data('popup');
                        if (!popup){
@@ -808,43 +847,3 @@ $(document).ready(function(){
 //event vars
 Calendar.UI.loadEvents();
 
-function validate_event_form(url){
-       var post = $( "#event_form" ).serialize();
-       $("#errorbox").html("");
-       $.post(url, post,
-               function(data){
-                       if(data.error == "true"){
-                               var output = "Missing fields: <br />";
-                               if(data.title == "true"){
-                                       output = output + "Title<br />";
-                               }
-                               if(data.cal == "true"){
-                                       output = output + "Calendar<br />";
-                               }
-                               if(data.from == "true"){
-                                       output = output + "From Date<br />";
-                               }
-                               if(data.fromtime == "true"){
-                                       output = output + "From Time<br />";
-                               }
-                               if(data.to == "true"){
-                                       output = output + "To Date<br />";
-                               }
-                               if(data.totime == "true"){
-                                       output = output + "To Time<br />";
-                               }
-                               if(data.endbeforestart == "true"){
-                                       output = "The event ends before it starts!";
-                               }
-                               if(data.dberror == "true"){
-                                       output = "There was a database fail!";
-                               }
-                               $("#errorbox").html(output);
-                       }else{
-                               window.location.reload();
-                       }
-                       if(data.success == true){
-                               location.reload();
-                       }
-               },"json");
-}
index 8c6053dc88a8c5efb2a0c2c074c37fc259a8d0f9..859828216b82ac40abad9fe766c50fa7d96c6f7b 100644 (file)
@@ -4,7 +4,7 @@
 <?php echo $this->inc("part.eventform"); ?>
        <div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
        <span id="actions">
-               <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_event_form('ajax/editevent.php');">
+               <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
        </span>
        </form>
 </div>
index 2c8ba7b907d0849d7c1e665d235bee7a40f5a551..b1e2a5eab848ecb53c108cf7e2d3c30f70ef8b74 100644 (file)
@@ -3,7 +3,7 @@
 <?php echo $this->inc("part.eventform"); ?>
        <div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
        <span id="actions">
-               <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_event_form('ajax/newevent.php');">
+               <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/newevent.php');">
        </span>
        </form>
 </div>