1
0
Fork 0
forked from forgejo/forgejo

Fix Org edit page bugs: renaming detection, maxlength (#24161) (#24171)

Backport #24161 by @wxiaoguang

## Before

* The renaming detection is wrong (eg: pasting a new name into the input
doesn't trigger the detection)
* The renaming prompt layout is not good
* Some MaxSize/maxlength rules is missing


Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2023-04-17 12:20:47 -04:00 committed by GitHub
parent c4f569b9a5
commit 3d3c740636
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 25 deletions

View file

@ -1,25 +1,16 @@
import $ from 'jquery';
import {initCompLabelEdit} from './comp/LabelEdit.js';
import {hideElem, showElem} from '../utils/dom.js';
import {toggleElem} from '../utils/dom.js';
export function initCommonOrganization() {
if ($('.organization').length === 0) {
return;
}
if ($('.organization.settings.options').length > 0) {
$('#org_name').on('keyup', function () {
const $prompt = $('#org-name-change-prompt');
const $prompt_redirect = $('#org-name-change-redirect-prompt');
if ($(this).val().toString().toLowerCase() !== $(this).data('org-name').toString().toLowerCase()) {
showElem($prompt);
showElem($prompt_redirect);
} else {
hideElem($prompt);
hideElem($prompt_redirect);
}
});
}
$('.organization.settings.options #org_name').on('input', function () {
const nameChanged = $(this).val().toLowerCase() !== $(this).attr('data-org-name').toLowerCase();
toggleElem('#org-name-change-prompt', nameChanged);
});
// Labels
initCompLabelEdit('.organization.settings.labels');