Implement save as new.
authorJan Schneider <jan@horde.org>
Tue, 16 Mar 2010 14:56:40 +0000 (15:56 +0100)
committerJan Schneider <jan@horde.org>
Tue, 16 Mar 2010 15:33:56 +0000 (16:33 +0100)
kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php
kronolith/templates/index/edit.inc

index e5e61e4..aff76f2 100644 (file)
@@ -3172,6 +3172,12 @@ KronolithCore = {
                 e.stop();
                 break;
 
+            case 'kronolithEventSaveAsNew':
+                this.saveEvent(true);
+                elt.disable();
+                e.stop();
+                break;
+
             case 'kronolithTaskSave':
                 this.saveTask();
                 elt.disable();
@@ -3872,13 +3878,13 @@ KronolithCore = {
         this.updateCalendarDropDown('kronolithEventTarget');
         this.toggleAllDay(false);
         this.openTab($('kronolithEventForm').down('.tabset a.kronolithTabLink'));
-        $('kronolithEventForm').enable();
         this.disableAlarmMethods();
         $('kronolithEventForm').reset();
         if (Kronolith.conf.maps.driver) {
             $('kronolithEventMapLink').hide();
         }
         $('kronolithEventSave').show();
+        $('kronolithEventSaveAsNew').show();
         $('kronolithEventDelete').show();
         $('kronolithEventForm').down('.kronolithFormActions .kronolithSeparator').show();
         if (id) {
@@ -3910,6 +3916,7 @@ KronolithCore = {
             $('kronolithEventEndDate').setValue(d.toString(Kronolith.conf.date_format));
             $('kronolithEventEndTime').setValue(d.toString(Kronolith.conf.time_format));
             $('kronolithEventLinkExport').up('span').hide();
+            $('kronolithEventSaveAsNew').hide();
             RedBox.showHtml($('kronolithEventDialog').show());
         }
     },
@@ -3917,7 +3924,7 @@ KronolithCore = {
     /**
      * Submits the event edit form to create or update an event.
      */
-    saveEvent: function()
+    saveEvent: function(asnew)
     {
         if (this.wrongFormat.size()) {
             this.showNotifications([{ type: 'horde.warning', message: Kronolith.text.fix_form_values }]);
@@ -3936,7 +3943,8 @@ KronolithCore = {
                           .merge({
                               view: this.view,
                               view_start: start,
-                              view_end: end
+                              view_end: end,
+                              as_new: !!asnew
                           }),
                       function(r) {
                           if (r.response.events && eventid) {
@@ -4152,7 +4160,6 @@ KronolithCore = {
 
         if (!ev.pe) {
             $('kronolithEventSave').hide();
-            $('kronolithEventForm').disable();
             kronolithETagAc.disable();
             $('kronolithEventTabTags').select('label').each(function(e) {e.hide()});
         } else {
@@ -4161,9 +4168,6 @@ KronolithCore = {
         if (!ev.pd) {
             $('kronolithEventDelete').hide();
         }
-        if (!ev.pe && !ev.pd) {
-            $('kronolithEventForm').down('.kronolithFormActions .kronolithSeparator').hide();
-        }
 
         this.setTitle(ev.t);
         RedBox.showHtml($('kronolithEventDialog').show());
index a9eedf9..328c758 100644 (file)
@@ -81,6 +81,9 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
             return $result;
         }
 
+        if ($this->_vars->as_new) {
+            unset($this->_vars->event);
+        }
         if (!$this->_vars->event) {
             $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
             if ($perms->hasAppPermission('max_events') !== true &&
index 43a877c..d62c74b 100644 (file)
 
 <div class="kronolithFormActions">
   <input id="kronolithEventSave" type="button" value="<?php echo _("Save") ?>" class="button ok" />
+  <input id="kronolithEventSaveAsNew" type="button" value="<?php echo _("Save As New") ?>" class="button ok" />
   <input id="kronolithEventDelete" type="button" value="<?php echo _("Delete") ?>" class="button ko" />
   <span class="kronolithSeparator"><?php echo _("or") ?></span> <a class="kronolithFormCancel"><?php echo _("Cancel") ?></a>
 </div>