Replace use of `WCF.Action.SimpleProxy` with `Ui/Object/Action`
authorMatthias Schmidt <gravatronics@live.com>
Sun, 21 Mar 2021 09:48:28 +0000 (10:48 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 21 Mar 2021 09:48:28 +0000 (10:48 +0100)
ts/WoltLabSuite/Core/Ui/Object/Action.ts
wcfsetup/install/files/acp/templates/languageList.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action.js

index 6c1d35fc519d5b698efb56ba0302132d28fb2e59..8ae30505fad3ba237bc65df550e558c833712e4e 100644 (file)
@@ -84,10 +84,14 @@ function executeAction(event: Event): void {
 }
 
 function processAction(actionElement: HTMLElement, data: ResponseData | DatabaseObjectActionResponse): void {
-  EventHandler.fire("WoltLabSuite/Core/Ui/Object/Action", actionElement.dataset.objectAction!, {
-    data,
-    objectElement: actionElement.closest(objectSelector),
-  } as ObjectActionData);
+  if (actionElement.dataset.objectActionSuccess === "reload") {
+    window.location.reload();
+  } else {
+    EventHandler.fire("WoltLabSuite/Core/Ui/Object/Action", actionElement.dataset.objectAction!, {
+      data,
+      objectElement: actionElement.closest(objectSelector),
+    } as ObjectActionData);
+  }
 }
 
 const actions = new Set<HTMLElement>();
index 48319d69e271445f175b48f198c2e9dc4f4a8648..ee51176b1fe9ba563494ca103c54ce1817892cbd 100644 (file)
@@ -1,19 +1,5 @@
 {include file='header' pageTitle='wcf.acp.language.list'}
 
-<script data-relocate="true">
-       $(function() {
-               new WCF.Action.SimpleProxy({
-                       action: 'setAsDefault',
-                       className: 'wcf\\data\\language\\LanguageAction',
-                       elements: $('.jsLanguageRow .jsSetAsDefaultButton')
-               }, {
-                       success: function(data, statusText, jqXHR) {
-                               window.location.reload();
-                       }
-               });
-       });
-</script>
-
 <header class="contentHeader">
        <div class="contentHeaderTitle">
                <h1 class="contentTitle">{lang}wcf.acp.language.list{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
@@ -58,7 +44,7 @@
                                                        
                                                        {if !$language->isDefault}
                                                                {objectAction action="toggle" isDisabled=$language->isDisabled}
-                                                               <span class="icon icon16 fa-check-circle jsSetAsDefaultButton jsTooltip pointer" title="{lang}wcf.acp.language.setAsDefault{/lang}" title="{lang}wcf.acp.language.setAsDefault{/lang}" data-object-id="{@$language->languageID}"></span>
+                                                               <span class="icon icon16 fa-check-circle jsObjectAction jsTooltip pointer" data-object-action="setAsDefault" data-object-action-success="reload" title="{lang}wcf.acp.language.setAsDefault{/lang}"></span>
                                                        {else}
                                                                <span class="icon icon16 fa-{if !$language->isDisabled}check-{/if}square-o disabled" title="{lang}wcf.global.button.{if $language->isDisabled}enable{else}disable{/if}{/lang}"></span>
                                                                <span class="icon icon16 fa-check-circle disabled" title="{lang}wcf.acp.language.setAsDefault{/lang}"></span>
index 45e4cef49006cb665b32ee1572d40623699004c2..391c3a85df7066a87a5e52cbc3ccc08ffb521e14 100644 (file)
@@ -76,10 +76,15 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Event/Handler", "../
         }
     }
     function processAction(actionElement, data) {
-        EventHandler.fire("WoltLabSuite/Core/Ui/Object/Action", actionElement.dataset.objectAction, {
-            data,
-            objectElement: actionElement.closest(objectSelector),
-        });
+        if (actionElement.dataset.objectActionSuccess === "reload") {
+            window.location.reload();
+        }
+        else {
+            EventHandler.fire("WoltLabSuite/Core/Ui/Object/Action", actionElement.dataset.objectAction, {
+                data,
+                objectElement: actionElement.closest(objectSelector),
+            });
+        }
     }
     const actions = new Set();
     function registerElements() {