Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.woltlab.wcf/fileDelete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<file>acp/images/wcfLogoWhite.svg</file>
<file>acp/install.php</file>
<file>acp/js/WCF.ACP.User.js</file>
<file>acp/js/WCF.ACP.Language.js</file>
<file>acp/js/WCF.ACP.Language.min.js</file>
<file>acp/js/wcombined.min.js</file>
<file>acp/post_install.php</file>
<file>acp/pre_update_com.woltlab.wcf_2.1.php</file>
Expand Down
80 changes: 80 additions & 0 deletions ts/WoltLabSuite/Core/Acp/Ui/Language/ItemList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Handles language item list.
*
* @author Olaf Braun
* @copyright 2001-2024 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/

import { dboAction } from "WoltLabSuite/Core/Ajax";
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
import { getPhrase } from "WoltLabSuite/Core/Language";
import { confirmationFactory } from "WoltLabSuite/Core/Component/Confirmation";
import { show as showNotification } from "WoltLabSuite/Core/Ui/Notification";

interface BeginEditResponse {
languageItem: string;
isCustomLanguageItem: boolean;
template: string;
}

export function init() {
document.querySelectorAll<HTMLElement>(".jsLanguageItem").forEach((button) => {
button.addEventListener("click", () => {
void beginEdit(parseInt(button.dataset.languageItemId!, 10));
});
});
}

async function beginEdit(languageItemID: number) {
const result = (await dboAction("prepareEdit", "wcf\\data\\language\\item\\LanguageItemAction")
.objectIds([languageItemID])
.dispatch()) as BeginEditResponse;

const dialog = dialogFactory()
.fromHtml(result.template)
.asPrompt(
result.isCustomLanguageItem
? {
extra: getPhrase("wcf.global.button.delete"),
}
: undefined,
);

dialog.addEventListener("extra", () => {
void confirmationFactory()
.custom(getPhrase("wcf.global.confirmation.title"))
.message(getPhrase("wcf.acp.language.item.delete.confirmMessage"))
.then((result) => {
if (result) {
void dboAction("deleteCustomLanguageItems", "wcf\\data\\language\\item\\LanguageItemAction")
.objectIds([languageItemID])
.dispatch();

dialog.close();

window.location.reload();
}
});
});

dialog.addEventListener("primary", () => {
const languageItemValue = dialog.querySelector<HTMLInputElement>('[name="languageItemValue"]')?.value;
const languageCustomItemValue = dialog.querySelector<HTMLInputElement>('[name="languageCustomItemValue"]')?.value;
const languageUseCustomValue = dialog.querySelector<HTMLInputElement>('[name="languageUseCustomValue"]')?.checked;

void dboAction("edit", "wcf\\data\\language\\item\\LanguageItemAction")
.objectIds([languageItemID])
.payload({
languageItemValue: languageItemValue ?? null,
languageCustomItemValue: languageCustomItemValue ?? null,
languageUseCustomValue: languageUseCustomValue ?? null,
})
.dispatch()
.then(() => {
showNotification();
});
});

dialog.show(result.languageItem);
}
155 changes: 0 additions & 155 deletions wcfsetup/install/files/acp/js/WCF.ACP.Language.js

This file was deleted.

1 change: 0 additions & 1 deletion wcfsetup/install/files/acp/js/WCF.ACP.Language.min.js

This file was deleted.

16 changes: 3 additions & 13 deletions wcfsetup/install/files/acp/templates/languageItemEditDialog.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dl class="wide">
<dt></dt>
<dd>
<textarea rows="5" cols="60" name="languageItemValue" id="overlayLanguageItemValue"{if $item->languageItemOriginIsSystem} readonly{/if}>{$item->languageItemValue}</textarea>
<textarea rows="5" cols="60" name="languageItemValue"{if $item->languageItemOriginIsSystem} readonly{/if}>{$item->languageItemValue}</textarea>
</dd>
</dl>
</section>
Expand Down Expand Up @@ -32,23 +32,13 @@
<dl class="wide">
<dt></dt>
<dd>
<textarea rows="5" cols="60" name="languageCustomItemValue" id="overlayLanguageCustomItemValue">{$item->languageCustomItemValue}</textarea>
<textarea rows="5" cols="60" name="languageCustomItemValue">{$item->languageCustomItemValue}</textarea>
</dd>
</dl>

<dl class="wide">
<dt></dt>
<dd><label><input type="checkbox" name="languageUseCustomValue" id="overlayLanguageUseCustomValue" value="1"{if $item->languageUseCustomValue} checked{/if}> {lang}wcf.acp.language.item.useCustomValue{/lang}</label></dd>
<dd><label><input type="checkbox" name="languageUseCustomValue" value="1"{if $item->languageUseCustomValue} checked{/if}> {lang}wcf.acp.language.item.useCustomValue{/lang}</label></dd>
</dl>
</section>
{/if}

<input type="hidden" name="languageItemID" id="overlayLanguageItemID" value="{$item->languageItemID}">

<div class="formSubmit">
<button type="button" class="button buttonPrimary jsSubmitLanguageItem" accesskey="s">{lang}wcf.global.button.submit{/lang}</button>

{if $item->isCustomLanguageItem}
<button type="button" class="button jsDeleteLanguageItem">{lang}wcf.global.button.delete{/lang}</button>
{/if}
</div>
9 changes: 4 additions & 5 deletions wcfsetup/install/files/acp/templates/languageItemList.tpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{include file='header' pageTitle="wcf.acp.language.item.list"}

<script data-relocate="true" src="{@$__wcf->getPath()}acp/js/WCF.ACP.Language.js?v={@LAST_UPDATE_TIME}"></script>
<script data-relocate="true">
$(function() {
WCF.Language.add('wcf.acp.language.item.delete.confirmMessage', '{jslang}wcf.acp.language.item.delete.confirmMessage{/jslang}');
new WCF.ACP.Language.ItemList();
{jsphrase name='wcf.acp.language.item.delete.confirmMessage'}

require(['WoltLabSuite/Core/Acp/Ui/Language/ItemList'], ({ init }) => {
init();
});
</script>

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function prepareEdit()

return [
'languageItem' => $item->languageItem,
'isCustomLanguageItem' => $item->isCustomLanguageItem,
'template' => WCF::getTPL()->fetch('languageItemEditDialog'),
];
}
Expand Down