Skip to content

Commit

Permalink
Admin console / Improve form checks for group, category and source (g…
Browse files Browse the repository at this point in the history
…eonetwork#7449)

* Admin console / Improve form checks

* More consistent name column length for group, category and source (ie.
  255 char)
* Add form check for max length and highlight field with error on length
  and pattern
* Improve alignment of category list when there is no icon for a
  category

* Admin console / Improve form checks:
- Sources form: display a custom message if the portal identifier exceeds the maxlength
- Fix the activation of the Save button in forms: it was using 'dirty' property (incorrect) instead of the correct one $dirty
- Update report forms to remove the dirty property to activate the button to create the report (not required)

---------

Co-authored-by: Jose García <[email protected]>
  • Loading branch information
fxprunayre and josegar74 authored Dec 5, 2023
1 parent 0a05bac commit d7c60e3
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 44 deletions.
2 changes: 1 addition & 1 deletion domain/src/main/java/org/fao/geonet/domain/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public Group setId(int id) {
*
* @return group name
*/
@Column(nullable = false, length = 32)
@Column(nullable = false, length = 255)
public String getName() {
return _name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
$scope.selectCategory = function (c) {
$scope.cateroryUpdated = false;
$scope.categorySelected = c;

$scope.gnCategoryFrom.$setPristine();

$timeout(function () {
$("#categoryname").focus();
}, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
source.groupOwner = source.groupOwner || null;
$scope.source = source;
$scope.isNew = false;

$scope.gnSourceForm.$setPristine();
};

function filterSources() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
var data = response.data;

$scope.userSelected = data;
$scope.gnUserEdit.$setPristine();
$scope.userIsAdmin = data.profile === "Administrator";

$scope.userIsEnabled = data.enabled;
Expand Down Expand Up @@ -792,6 +793,8 @@
// that breaks the group management.
// TODO: Use custom controllers for groups and users management
$scope.groupSelected = angular.copy(g);
$scope.gnGroupEdit.$setPristine();

$scope.clear($scope.queue);
delete $scope.groupSelected.langlabel;

Expand Down
5 changes: 4 additions & 1 deletion web-ui/src/main/resources/catalog/locales/en-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@
"passwordPattern": "Password must contain at least 1 uppercase, 1 lowercase, 1 number and 1 symbol. Symbols include: `~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/?');",
"passwordOld": "Old password",
"passwordRepeat": "Repeat password",
"groupNameMaxlength": "Group name can not exceed 32 characters!",
"groupNameMaxlength": "Group name can not exceed 255 characters!",
"categoryNameMaxlength": "Category name can not exceed 255 characters!",
"portalNameMaxlength": "Portal name can not exceed 255 characters!",
"portalIdMaxlength": "Portal identifier can not exceed 255 characters!",
"groupDescriptionMaxlength": "Group description can not exceed 255 characters!",
"groupEmailMaxlength": "Group email can not exceed 128 characters!",
"pol": "Polski",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ng-class="{ 'active': c === categorySelected }"
data-ng-click="selectCategory(c)"
>
<span class="fa gn-icon-{{c.name}}"></span>
<span class="fa fa-fw gn-icon-{{c.name}}"></span>
{{c.label[lang]}}</a
>
<span
Expand Down Expand Up @@ -74,7 +74,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnCategoryFrom.$dirty"
data-ng-disabled="!gnCategoryFrom.$valid || !gnCategoryFrom.$dirty"
data-ng-click="saveCategory()"
>
<span class="fa fa-save"></span> {{"saveCategory"|translate}}
Expand All @@ -91,16 +91,28 @@
</div>
<div class="panel-body">
<fieldset>
<label data-translate="" class="col-lg-2 control-label">categoryName</label>
<div class="col-lg-10">
<div
data-ng-class="gnCategoryFrom.name.$error.required || gnCategoryFrom.name.$error.maxlength ? 'has-error' : ''"
>
<label data-translate="" class="control-label">categoryName</label>
<input
type="text"
id="categoryname"
name="name"
class="form-control"
autofocus=""
data-ng-model="categorySelected.name"
data-ng-required="true"
data-ng-maxlength="255"
/>
<p class="help-block">
<span
class="error"
data-ng-show="gnCategoryFrom.name.$error.maxlength"
data-translate=""
>categoryNameMaxlength</span
>
</p>
</div>
</fieldset>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnMetadataFileDownloadsReport.$valid && !gnMetadataFileDownloadsReport.dirty"
data-ng-disabled="!gnMetadataFileDownloadsReport.$valid"
data-ng-click="createReport('#gn-metadata-filedownloads-report', '../api/reports/datadownloads')"
>
<span class="fa fa-save"></span> {{"createReport"|translate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnMetadataFileUploadsReport.$valid && !gnMetadataFileUploadsReport.dirty"
data-ng-disabled="!gnMetadataFileUploadsReport.$valid"
data-ng-click="createReport('#gn-metadata-fileuploads-report', '../api/reports/datauploads')"
>
<span class="fa fa-save"></span> {{"createReport"|translate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnMetadataInternalReport.$valid && !gnMetadataInternalReport.dirty"
data-ng-disabled="!gnMetadataInternalReport.$valid"
data-ng-click="createReport('#gn-metadata-internal-report', '../api/reports/metadatainternal')"
>
<span class="fa fa-save"></span> {{"createReport"|translate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnMetadataUpdatedReport.$valid && !gnMetadataUpdatedReport.dirty"
data-ng-disabled="!gnMetadataUpdatedReport.$valid"
data-ng-click="createReport('#gn-metadata-updated-report', '../api/reports/metadataupdated')"
>
<span class="fa fa-save"></span> {{"createReport"|translate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnUsersReport.$valid && !gnUsersReport.dirty"
data-ng-disabled="!gnUsersReport.$valid"
data-ng-click="createReport('#gn-users-report', '../api/reports/users')"
>
<span class="fa fa-save"></span> {{"createReport"|translate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
<div data-gn-need-help="portal-configuration"></div>
</div>

<div class="col-lg-8" data-ng-if="source">
<div class="col-lg-8" data-ng-hide="!source">
<div class="panel panel-default">
<div class="panel-heading">
{{source.name}} ({{('source-' + source.type) | translate}})
<div class="btn-toolbar">
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="source.type === 'subportal' && !gnSourceForm.$valid && !gnSourceForm.dirty"
data-ng-disabled="source.type === 'subportal' && (!gnSourceForm.$valid || !gnSourceForm.$dirty)"
data-ng-click="updateSource()"
>
<i class="fa fa-floppy-o"></i>&nbsp;
Expand All @@ -103,35 +103,71 @@
<div class="panel-body">
<div data-ng-show="source.type === 'subportal'">
<form name="gnSourceForm">
<label data-translate="" class="gn-required">sourceUuid</label>
<input
type="text"
class="form-control"
data-ng-required="true"
data-ng-readonly="!isNew"
data-ng-disabled="::!user.isAdministrator()"
data-ng-pattern="/^[A-Za-z0-9\-_]+$/"
data-ng-model="source.uuid"
/>
<p class="help-block" data-translate="">sourceUuid-help</p>
<div
data-ng-class="gnSourceForm.sourceId.$error.required
|| gnSourceForm.sourceId.$error.maxlength
|| gnSourceForm.sourceId.$error.pattern ? 'has-error' : ''"
>
<label class="control-label gn-required" data-translate=""
>sourceUuid</label
>
<input
type="text"
class="form-control"
name="sourceId"
data-ng-required="true"
data-ng-readonly="!isNew"
data-ng-disabled="::!user.isAdministrator()"
data-ng-pattern="/^[A-Za-z0-9\-_]+$/"
data-ng-maxlength="255"
data-ng-model="source.uuid"
/>
<p class="help-block" data-translate="">sourceUuid-help</p>

<p class="help-block">
<span
class="error"
data-ng-show="gnSourceForm.sourceId.$error.maxlength"
data-translate=""
>portalIdMaxlength</span
>
</p>

<p
class="alert alert-info"
data-ng-if="source.uuid != ''"
data-translate=""
data-translate-values="{'uuid': source.uuid, 'lang': lang}"
>
sourceUrlInfo
</p>
</div>

<p
class="alert alert-info"
data-ng-if="source.uuid != ''"
data-translate=""
data-translate-values="{'uuid': source.uuid, 'lang': lang}"
<div
data-ng-class="gnSourceForm.name.$error.required
|| gnSourceForm.name.$error.maxlength
|| gnSourceForm.name.$error.pattern ? 'has-error' : ''"
>
sourceUrlInfo
</p>
<label data-translate="">sourceName</label>
<input
type="text"
data-ng-required="true"
class="form-control"
data-ng-pattern="/^[A-Za-z0-9\-_]+$/"
data-ng-model="source.name"
/>
<p class="help-block" data-translate="">sourceName-help</p>
<label class="control-label" data-translate="">sourceName</label>
<input
type="text"
name="name"
data-ng-required="true"
class="form-control"
data-ng-pattern="/^[A-Za-z0-9\-_]+$/"
data-ng-model="source.name"
data-ng-maxlength="255"
/>
<p class="help-block" data-translate="">sourceName-help</p>
<p class="help-block">
<span
class="error"
data-ng-show="gnSourceForm.name.$error.maxlength"
data-translate=""
>portalNameMaxlength</span
>
</p>
</div>

<label data-translate="">sourceFilter</label>
<input type="text" class="form-control" data-ng-model="source.filter" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<button
type="button"
class="btn btn-primary"
data-ng-disabled="!gnStaticPageEdit.$valid && !gnStaticPageEdit.dirty"
data-ng-disabled="!gnStaticPageEdit.$valid || !gnStaticPageEdit.$dirty"
data-gn-click-and-spin="saveStaticPage('#gn-static-page-edit')"
>
<i class="fa fa-save"></i>&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
type="button"
class="btn btn-primary pull-right"
data-ng-hide="!user.isUserAdminOrMore()"
data-ng-disabled="!gnGroupEdit.$valid && !gnGroupEdit.dirty"
data-ng-disabled="!gnGroupEdit.$valid || !gnGroupEdit.$dirty"
data-ng-click="saveGroup('#gn-group-edit', '#group-logo-upload')"
id="gn-btn-group-save"
>
Expand Down Expand Up @@ -123,7 +123,7 @@
class="form-control"
data-ng-disabled="!user.isAdministratorOrMore()"
data-ng-model="groupSelected.name"
data-ng-maxlength="32"
data-ng-maxlength="255"
data-ng-required="true"
/>
<p class="help-block" data-translate="">groupNameHelp</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<button
type="button"
class="btn btn-primary pull-right"
data-ng-disabled="!gnUserEdit.$valid && !gnUserEdit.dirty"
data-ng-disabled="!gnUserEdit.$valid || !gnUserEdit.$dirty"
data-ng-click="saveUser('#gn-user-edit')"
id="gn-btn-user-save"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALTER TABLE groups ALTER COLUMN name TYPE varchar(255);

UPDATE Settings SET value='4.4.1' WHERE name='system/platform/version';
UPDATE Settings SET value='0' WHERE name='system/platform/subVersion';

Expand Down

0 comments on commit d7c60e3

Please sign in to comment.