Skip to content

Commit 2a42db0

Browse files
committed
fix
1 parent 7681d58 commit 2a42db0

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

modules/structs/org.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type OrganizationPermissions struct {
3030
// CreateOrgOption options for creating an organization
3131
type CreateOrgOption struct {
3232
// required: true
33-
UserName string `json:"username" binding:"Required"`
34-
FullName string `json:"full_name"`
33+
UserName string `json:"username" binding:"Required;Username;MaxSize(40)"`
34+
FullName string `json:"full_name" binding:"MaxSize(100)"`
3535
Description string `json:"description" binding:"MaxSize(255)"`
3636
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
3737
Location string `json:"location" binding:"MaxSize(50)"`
@@ -45,7 +45,7 @@ type CreateOrgOption struct {
4545

4646
// EditOrgOption options for editing an organization
4747
type EditOrgOption struct {
48-
FullName string `json:"full_name"`
48+
FullName string `json:"full_name" binding:"MaxSize(100)"`
4949
Description string `json:"description" binding:"MaxSize(255)"`
5050
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
5151
Location string `json:"location" binding:"MaxSize(50)"`

templates/org/create.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "base/alert" .}}
1212
<div class="inline required field {{if .Err_OrgName}}error{{end}}">
1313
<label for="org_name">{{.locale.Tr "org.org_name_holder"}}</label>
14-
<input id="org_name" name="org_name" value="{{.org_name}}" autofocus required>
14+
<input id="org_name" name="org_name" value="{{.org_name}}" autofocus required maxlength="40">
1515
<span class="help">{{.locale.Tr "org.org_name_helper"}}</span>
1616
</div>
1717

templates/org/settings/options.tmpl

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@
1414
{{.CsrfTokenHtml}}
1515
<div class="required field {{if .Err_Name}}error{{end}}">
1616
<label for="org_name">{{.locale.Tr "org.org_name_holder"}}
17-
<span class="text red gt-hidden" id="org-name-change-prompt"> {{.locale.Tr "org.settings.change_orgname_prompt"}}</span>
18-
<span class="text red gt-hidden" id="org-name-change-redirect-prompt"> {{.locale.Tr "org.settings.change_orgname_redirect_prompt"}}</span>
17+
<span class="text red gt-hidden" id="org-name-change-prompt">
18+
<br>{{.locale.Tr "org.settings.change_orgname_prompt"}}<br>{{.locale.Tr "org.settings.change_orgname_redirect_prompt"}}
19+
</span>
1920
</label>
20-
<input id="org_name" name="name" value="{{.Org.Name}}" data-org-name="{{.Org.Name}}" autofocus required>
21+
<input id="org_name" name="name" value="{{.Org.Name}}" data-org-name="{{.Org.Name}}" autofocus required maxlength="40">
2122
</div>
2223
<div class="field {{if .Err_FullName}}error{{end}}">
2324
<label for="full_name">{{.locale.Tr "org.org_full_name_holder"}}</label>
24-
<input id="full_name" name="full_name" value="{{.Org.FullName}}">
25+
<input id="full_name" name="full_name" value="{{.Org.FullName}}" maxlength="100">
2526
</div>
2627
<div class="field {{if .Err_Description}}error{{end}}">
2728
<label for="description">{{$.locale.Tr "org.org_desc"}}</label>
28-
<textarea id="description" name="description" rows="2">{{.Org.Description}}</textarea>
29+
<textarea id="description" name="description" rows="2" maxlength="255">{{.Org.Description}}</textarea>
2930
</div>
3031
<div class="field {{if .Err_Website}}error{{end}}">
3132
<label for="website">{{.locale.Tr "org.settings.website"}}</label>
32-
<input id="website" name="website" type="url" value="{{.Org.Website}}">
33+
<input id="website" name="website" type="url" value="{{.Org.Website}}" maxlength="255">
3334
</div>
3435
<div class="field">
3536
<label for="location">{{.locale.Tr "org.settings.location"}}</label>
36-
<input id="location" name="location" value="{{.Org.Location}}">
37+
<input id="location" name="location" value="{{.Org.Location}}" maxlength="50">
3738
</div>
3839

3940
<div class="ui divider"></div>

web_src/js/features/common-organization.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
import $ from 'jquery';
22
import {initCompLabelEdit} from './comp/LabelEdit.js';
3-
import {hideElem, showElem} from '../utils/dom.js';
3+
import {toggleElem} from '../utils/dom.js';
44

55
export function initCommonOrganization() {
66
if ($('.organization').length === 0) {
77
return;
88
}
99

10-
if ($('.organization.settings.options').length > 0) {
11-
$('#org_name').on('keyup', function () {
12-
const $prompt = $('#org-name-change-prompt');
13-
const $prompt_redirect = $('#org-name-change-redirect-prompt');
14-
if ($(this).val().toString().toLowerCase() !== $(this).data('org-name').toString().toLowerCase()) {
15-
showElem($prompt);
16-
showElem($prompt_redirect);
17-
} else {
18-
hideElem($prompt);
19-
hideElem($prompt_redirect);
20-
}
21-
});
22-
}
10+
$('.organization.settings.options #org_name').on('input', function () {
11+
const nameChanged = $(this).val().toLowerCase() !== $(this).attr('data-org-name').toLowerCase();
12+
toggleElem('#org-name-change-prompt', nameChanged);
13+
});
2314

2415
// Labels
2516
initCompLabelEdit('.organization.settings.labels');

0 commit comments

Comments
 (0)