[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX][REF] Admin Notifications: extract inline "Myself" handler to prefill the...
"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a2d1c0c9e361_381962c0274c@gitlab-sidekiq-low-urgency-cpu-bound-v2-c9f44b7d4-zwljt.mail> |
ushindi bienvenu pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
b5522bd2 by Joseph Ushindi at 2026-06-13T08:41:39+00:00
[FIX][REF] Admin Notifications: extract inline "Myself" handler to prefill the admin username to a dedicated JS file
---
* Avoid redundant select value synchronization
* [FIX] Refactor(notifications): extract inline "Myself" handler to dedicated JS.
See merge request tikiwiki/tiki!10049
- - - - -
4 changed files:
- src/js/vue-widgets/element-plus-ui/src/components/Autocomplete/Autocomplete.vue
- src/js/vue-widgets/element-plus-ui/src/utils/applyAutocomplete.js
- templates/tiki-admin_notifications.tpl
- tiki-admin_notifications.php
Changes:
=====================================
src/js/vue-widgets/element-plus-ui/src/components/Autocomplete/Autocomplete.vue
=====================================
@@ -1,5 +1,5 @@
<script setup>
-import { onMounted, ref, watchEffect } from 'vue';
+import { onMounted, ref, watch } from 'vue';
import { fetchSuggestions } from '../../helpers/autocomplete/remote';
import ConfigWrapper from '../ConfigWrapper.vue';
@@ -11,8 +11,22 @@ const shouldRefocusOnBlur = ref(false);
const modelValue = ref(props.value);
const autocompleteRef = ref(null);
+const setValue = (val) => {
+ modelValue.value = val;
+};
-props._expose({ value: modelValue });
+// This ensures that if jQuery changes the 'value' prop/attribute, Vue reacts
+watch(
+ () => props.value,
+ (newVal) => {
+ modelValue.value = newVal;
+ }
+);
+
+props._expose({
+ value: modelValue,
+ setValue,
+});
const handleFetchSuggestions = (query, callback) => {
const wrappedCallback = (results) => {
@@ -52,9 +66,6 @@ onMounted(() => {
}
})
-watchEffect(() => {
- modelValue.value = props.value;
-});
</script>
<script>
=====================================
src/js/vue-widgets/element-plus-ui/src/utils/applyAutocomplete.js
=====================================
@@ -72,6 +72,16 @@ export default function applyAutocomplete(element, remoteSourceUrl = null, sourc
element.setAttribute("element-plus-ref", elementUniqueId);
element.style.display = "none";
element.parentNode.insertBefore(elementPlusUi, element.nextSibling);
+ const syncUiValue = () => {
+ const newValue = element.value;
+ if (typeof elementPlusUi.setValue === "function") {
+ elementPlusUi.setValue(newValue);
+ return;
+ }
+ elementPlusUi.value = newValue;
+ };
+
+ element.addEventListener("change", syncUiValue);
return elementPlusUi;
}
=====================================
templates/tiki-admin_notifications.tpl
=====================================
@@ -43,8 +43,7 @@
$("#" + $("select[name='destination']").val() + "row").show();
$("input[name='" + $("select[name='destination']").val() + "']").trigger("focus");
$("input[name='" + $("select[name='destination']").val() + "']").removeAttr("disabled");
- }
- );
+ });
{/jq}
</div>
</div>
@@ -57,7 +56,12 @@
{autocomplete element='#flogin' type='username'}
</div>
<div class="col-sm-3">
- <a href="#" onclick="document.getElementById('flogin').value='{$user}'; return false;" class="btn btn-link" role="button">{tr}Myself{/tr}</a>
+ <a href="#"
+ onclick="var inp = document.getElementById('flogin'); inp.value='{$user|escape:javascript}'; inp.dispatchEvent(new Event('change')); return false;"
+ class="btn btn-link"
+ role="button">
+ {tr}Myself{/tr}
+ </a>
</div>
</div>
<div class="mb-3 row" id="emailrow" style="display:none">
=====================================
tiki-admin_notifications.php
=====================================
@@ -25,15 +25,17 @@ $inputConfiguration = [
'email' => 'email', //post
'event' => 'text', //post
'action' => 'alpha', //post
- ] ,
+ ],
'staticKeyFiltersForArrays' => [
'checked' => 'text', //post
- ] ,
+ ],
]
];
// Initialization
require_once('tiki-setup.php');
+
use Tiki\Sections;
+
$section = Sections::SECTION_ADMIN_LAYOUT;
Sections::setCurrentSection($section);
$access->check_permission(['tiki_p_admin_notifications']);
@@ -150,6 +152,7 @@ if ($prefs['feature_forums'] == 'y') {
$forums = $commentslib->get_outbound_emails();
$smarty->assign_by_ref('forums', $forums);
}
+
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b5522bd2c53b9410f91d3909b17208a9d7ff38a2
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b5522bd2c53b9410f91d3909b17208a9d7ff38a2
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs