From 8673786dfcfa611628dc66ab96975d5a00d5ca59 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Tue, 7 Feb 2017 11:45:44 +0100 Subject: [PATCH] ES profile: avoid to long name - fix #308 --- www/plugins/es/js/services/user-services.js | 10 +++++++++- www/plugins/es/templates/user/edit_profile.html | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js index d4fc8f302..64050acb6 100644 --- a/www/plugins/es/js/services/user-services.js +++ b/www/plugins/es/js/services/user-services.js @@ -342,7 +342,11 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se var avatar = esHttp.image.fromHit(host, port, hit, 'avatar'); _.forEach(values, function(data) { // name (basic or highlighted) - data.name=hit._source.title; + data.name = hit._source.title; + // Avoid too long name (workaround for #308) + if (data.name && data.name.length > 30) { + data.name = data.name.substr(0, 27) + '...'; + } if (hit.highlight) { if (hit.highlight.title) { data.name = hit.highlight.title[0]; @@ -387,6 +391,10 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se .then(function(profile) { if (profile) { data.name = profile.name; + // Avoid too long name (workaround for #308) + if (data.name && data.name.length > 30) { + data.name = data.name.substr(0, 27) + '...'; + } data.avatar = profile.avatar; data.profile = profile.source; diff --git a/www/plugins/es/templates/user/edit_profile.html b/www/plugins/es/templates/user/edit_profile.html index 85ab1c3b3..e2ccca819 100644 --- a/www/plugins/es/templates/user/edit_profile.html +++ b/www/plugins/es/templates/user/edit_profile.html @@ -64,6 +64,7 @@ id="profile-name" ng-model="formData.title" ng-model-options="{ debounce: 350 }" + ng-maxlength="30" required> </ion-item> <div class="form-errors" @@ -72,6 +73,9 @@ <div class="form-error" ng-message="required"> <span translate="ERROR.FIELD_REQUIRED"></span> </div> + <div class="form-error" ng-message="maxlength"> + <span translate="ERROR.FIELD_TOO_LONG_WITH_LENGTH" translate-values="{maxLength: 30}"></span> + </div> </div> <!-- description --> -- GitLab