Add pending items to item list on form submit
authorMatthias Schmidt <gravatronics@live.com>
Mon, 19 Aug 2019 16:11:25 +0000 (18:11 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 19 Aug 2019 16:11:25 +0000 (18:11 +0200)
Close WoltLab/com.woltlab.wcf.conversation#129

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js
wcfsetup/install/files/lib/form/TagSearchForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index dd02c80e64d9aa146cbfba70fd0a101ace37f927..02485596e039ebd6070d7a1c65b31653fdf615fd 100644 (file)
@@ -97,6 +97,13 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSu
                                        }
                                        
                                        form.addEventListener('submit', (function() {
+                                               if (this._acceptsNewItems(elementId)) {
+                                                       var value = _data.get(elementId).element.value.trim();
+                                                       if (value.length) {
+                                                               this._addItem(elementId, { objectId: 0, value: value });
+                                                       }
+                                               }
+                                               
                                                var values = this.getValues(elementId);
                                                if (options.submitFieldName.length) {
                                                        var input;
@@ -114,6 +121,16 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSu
                                                }
                                        }).bind(this));
                                }
+                               else {
+                                       form.addEventListener('submit', function() {
+                                               if (this._acceptsNewItems(elementId)) {
+                                                       var value = _data.get(elementId).element.value.trim();
+                                                       if (value.length) {
+                                                               this._addItem(elementId, {objectId: 0, value: value});
+                                                       }
+                                               }
+                                       }.bind(this));
+                               }
                        }
                        
                        this._setup();
index 7b6d9f41d8ed231ddc036b4f51944076a6a917e2..74c63b7b7d2bf756cc57b0249097b121690d197d 100644 (file)
@@ -84,7 +84,13 @@ class TagSearchForm extends AbstractCaptchaForm {
                
                if (!empty($this->tagNames)) {
                        $this->tags = TagEngine::getInstance()->getTagsByName($this->tagNames, $this->languageID);
-                       if (empty($this->tags)) {
+                       if (count($this->tagNames) !== count($this->tags)) {
+                               WCF::getTPL()->assign('unknownTags', array_diff($this->tagNames, array_map(function(Tag $tag) {
+                                       return $tag->getTitle();
+                               }, $this->tags)));
+                               throw new UserInputException('tags', 'unknownTags');
+                       }
+                       else if (empty($this->tags)) {
                                throw new UserInputException('tags');
                        }
                }
index b77a39eb81ac8088d8ae3beb3949dac3d6e7656b..7ca7f82ee381cb57c55b65e43568fdf0b6a554fc 100644 (file)
@@ -4377,6 +4377,7 @@ Dateianhänge:
                <item name="wcf.tagging.taggedObjects.noResults"><![CDATA[Es wurden keine Einträge mit diesem Tag gefunden.]]></item>
                <item name="wcf.tagging.objectType.com.woltlab.wcf.article"><![CDATA[Artikel]]></item>
                <item name="wcf.tagging.taggedObjects.com.woltlab.wcf.article"><![CDATA[Artikel mit dem Tag „{$tag->name}“]]></item>
+               <item name="wcf.tagging.tags.error.unknownTags"><![CDATA[Die folgenden Tags existieren nicht: {implode from=$unknownTags item=unknownTag}{$unknownTag}{/implode}.]]></item>
        </category>
        <category name="wcf.user">
                <item name="wcf.user.confirmEmail"><![CDATA[E-Mail-Adresse wiederholen]]></item>
index eb1a4bb0cfe730834cea1f9e08888f91016b3936..2714015cc3ef212f56b6483554a8d38b4c5399ca 100644 (file)
@@ -4379,6 +4379,7 @@ Attachments:
                <item name="wcf.tagging.taggedObjects.noResults"><![CDATA[No items matched this tag.]]></item>
                <item name="wcf.tagging.objectType.com.woltlab.wcf.article"><![CDATA[Articles]]></item>
                <item name="wcf.tagging.taggedObjects.com.woltlab.wcf.article"><![CDATA[Articles Tagged with “{$tag->name}”]]></item>
+               <item name="wcf.tagging.tags.error.unknownTags"><![CDATA[The following tags do no exist: {implode from=$unknownTags item=unknownTag}{$unknownTag}{/implode}.]]></item>
        </category>
        <category name="wcf.user">
                <item name="wcf.user.confirmEmail"><![CDATA[Confirm Email]]></item>