Improved 'add participants' overlay
authorAlexander Ebert <ebert@woltlab.com>
Tue, 5 Mar 2013 01:36:48 +0000 (02:36 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 5 Mar 2013 01:36:48 +0000 (02:36 +0100)
Fixes #56

files/js/WCF.Conversation.js
files/lib/data/conversation/ConversationAction.class.php
templates/conversationAddParticipants.tpl

index 60cd3051cfb486b4f40ec528bd8604547926da3e..6402e6e437f97e0a794f0a481e93e2be8cbd6d52 100644 (file)
@@ -724,7 +724,7 @@ WCF.Conversation.AddParticipants = Class.extend({
                        case 'addParticipants':
                                if (data.returnValues.errorMessage) {
                                        this._dialog.find('dl.jsAddParticipants').addClass('formError');
-                                       $('<span class="formError">' + data.returnValues.errorMessage + '</span>').appendTo(this._dialog.find('dl.jsAddParticipants > dd'));
+                                       $('<small class="innerError">' + data.returnValues.errorMessage + '</small>').appendTo(this._dialog.find('dl.jsAddParticipants > dd'));
                                        return;
                                }
                                
@@ -733,6 +733,7 @@ WCF.Conversation.AddParticipants = Class.extend({
                                        $notification.show();
                                }
                                
+                               this._dialog.find('dl.jsAddParticipants').removeClass('formError').find('small.innerError').remove();
                                this._dialog.wcfDialog('close');
                        break;
                        
index 227ca9cc155aae539d6660d5295103cb9ff1f00f..70a9d8ad7d3da2498e302af2542ab14029003e2a 100644 (file)
@@ -536,7 +536,8 @@ class ConversationAction extends AbstractDatabaseObjectAction implements IClipbo
                catch (UserInputException $e) {
                        $errorMessage = '';
                        foreach ($e->getType() as $type) {
-                               $errorMessage .= WCF::getLanguage()->get('wcf.conversation.participants.error.'.$type);
+                               if (!empty($errorMessage)) $errorMessage .= ' ';
+                               $errorMessage .= WCF::getLanguage()->getDynamicVariable('wcf.conversation.participants.error.'.$type['type'], array('username' => $type['username']));
                        }
                        
                        return array(
@@ -551,19 +552,31 @@ class ConversationAction extends AbstractDatabaseObjectAction implements IClipbo
                        // check for already added participants
                        $participantIDs = array_diff($participantIDs, $this->conversation->getParticipantIDs());
                        if (!empty($participantIDs)) {
-                               $conversationAction = new ConversationAction(array($this->conversation), 'update', array('participants' => $participantIDs));
+                               $data = array();
+                               if ($this->conversation->isDraft) {
+                                       $draftData = unserialize($this->conversation->draftData);
+                                       $draftData['participants'] = array_merge($draftData['participants'], $participantIDs);
+                                       $data = array('data' => array('draftData' => serialize($draftData)));
+                               }
+                               else {
+                                       $data = array('participants' => $participantIDs);
+                               }
+                               
+                               $conversationAction = new ConversationAction(array($this->conversation), 'update', $data);
                                $conversationAction->executeAction();
                                
                                $count = count($participantIDs);
                                $successMessage = WCF::getLanguage()->getDynamicVariable('wcf.conversation.edit.addParticipants.success', array('count' => $count));
                                
                                ConversationModificationLogHandler::getInstance()->addParticipants($this->conversation->getDecoratedObject(), $participantIDs);
+                               
+                               if (!$this->conversation->isDraft) {
+                                       // update participant summary
+                                       $this->conversation->updateParticipantSummary();
+                               }
                        }
                }
                
-               // update participant summary
-               $this->conversation->updateParticipantSummary();
-               
                return array(
                        'actionName' => 'addParticipants',
                        'count' => $count,
index 9a25317bd7fd8487333e4743aaa8755b8530c99b..7113213acf3ead01fc2f773a48aef1a3fa034258 100644 (file)
@@ -1,7 +1,7 @@
 <fieldset>
        <legend>{lang}wcf.conversation.edit.addParticipants{/lang}</legend>
        
-       <dl>
+       <dl class="jsAddParticipants">
                <dt><label for="participantsInput">{lang}wcf.conversation.participants{/lang}</label></dt>
                <dd>
                        <textarea id="participantsInput" name="participants" class="long" cols="40" rows="2"></textarea>