Skip to content
Snippets Groups Projects
Commit 5dea96a4 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[enh] Allow to update or add categories

[enh] Profile: allow to delete user profile
[enh] Home: change country map when locale changed
[enh] Search: categories name use localized (i18n) names, when possible
parent 7efcadcf
No related branches found
No related tags found
No related merge requests found
Pipeline #9586 failed
...@@ -8,7 +8,12 @@ angular.module('cesium.http.services', ['cesium.cache.services']) ...@@ -8,7 +8,12 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
var var
sockets = [], sockets = [],
defaultCachePrefix = 'csHttp-', defaultCachePrefix = 'csHttp-',
allCachePrefixes = {}; allCachePrefixes = {},
regexp = {
POSITIVE_INTEGER: /^\d+$/,
VERSION_PART_REGEXP: /^[0-9]+|alpha[0-9]+|beta[0-9]+|rc[0-9]+|[0-9]+-SNAPSHOT$/
}
;
if (!timeout) { if (!timeout) {
timeout=4000; // default timeout=4000; // default
...@@ -335,6 +340,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) ...@@ -335,6 +340,7 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
uri = 'http://' + path; uri = 'http://' + path;
} }
// Use a <a> element to parse
var parser = document.createElement('a'); var parser = document.createElement('a');
parser.href = uri; parser.href = uri;
...@@ -389,13 +395,13 @@ angular.module('cesium.http.services', ['cesium.cache.services']) ...@@ -389,13 +395,13 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
var parts = parseUri(uri); var parts = parseUri(uri);
if (!parts.protocol && options.type) { if (!parts.protocol && options.type) {
parts.protocol = (options.type == 'email') ? 'mailto:' : parts.protocol = (options.type === 'email') ? 'mailto:' :
((options.type == 'phone') ? 'tel:' : ''); ((options.type === 'phone') ? 'tel:' : '');
uri = parts.protocol + uri; uri = parts.protocol + uri;
} }
// On desktop, open into external tool // On desktop, open into external tool
if (parts.protocol == 'mailto:' && Device.isDesktop()) { if (parts.protocol === 'mailto:' && Device.isDesktop()) {
try { try {
nw.Shell.openExternal(uri); nw.Shell.openExternal(uri);
return; return;
...@@ -405,10 +411,10 @@ angular.module('cesium.http.services', ['cesium.cache.services']) ...@@ -405,10 +411,10 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
} }
} }
// Check if device is enable, on special tel: or mailto: protocole // Check if device is enable, on special tel: or mailto: protocol
var validProtocol = (parts.protocol == 'mailto:' || parts.protocol == 'tel:') && Device.enable; var validProtocol = (Device.enable && (parts.protocol === 'mailto:' || parts.protocol === 'tel:'));
if (!validProtocol) { if (!validProtocol) {
if (options.onError && typeof options.onError == 'function') { if (options.onError && typeof options.onError === 'function') {
options.onError(uri); options.onError(uri);
} }
return; return;
...@@ -491,11 +497,15 @@ angular.module('cesium.http.services', ['cesium.cache.services']) ...@@ -491,11 +497,15 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
// First, validate both numbers are true version numbers // First, validate both numbers are true version numbers
function validateParts(parts) { function validateParts(parts) {
for (var i = 0; i < parts.length; ++i) { for (var i = 0; i < parts.length; i++) {
if (!isPositiveInteger(parts[i])) { var isNumber = regexp.POSITIVE_INTEGER.test(parts[i]);
return false; // First part MUST be an integer
} if (i === 0 && !isNumber) return false;
parts[i] = parseInt(parts[i]); // If not integer, should be 'alpha', 'beta', etc.
if (!isNumber && !regexp.VERSION_PART_REGEXP.test(parts[i])) return false;
// Convert string to int (need by compare operators)
if (isNumber) parts[i] = parseInt(parts[i]);
} }
return true; return true;
} }
......
...@@ -395,9 +395,8 @@ function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils) ...@@ -395,9 +395,8 @@ function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils)
$focus('socialUrl'); $focus('socialUrl');
}; };
$scope.reorderSocialNetwork = function(social, fromIndex, toIndex) { $scope.reorderSocialNetwork = function(social, fromIndex, toIndex) {
if (!social || fromIndex == toIndex) return; // no changes if (!social || fromIndex === toIndex) return; // no changes
$scope.formData.socials.splice(fromIndex, 1); $scope.formData.socials.splice(fromIndex, 1);
$scope.formData.socials.splice(toIndex, 0, social); $scope.formData.socials.splice(toIndex, 0, social);
}; };
...@@ -416,7 +415,6 @@ function ESSocialsViewController($scope) { ...@@ -416,7 +415,6 @@ function ESSocialsViewController($scope) {
}); });
}; };
$scope.filterFn = function(social) { $scope.filterFn = function(social) {
return !social.recipient || social.valid; return !social.recipient || social.valid;
}; };
...@@ -623,7 +621,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { ...@@ -623,7 +621,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) {
$scope.searchModalOpened = false; $scope.searchModalOpened = false;
$scope.updateGeoPoint(res); $scope.updateGeoPoint(res);
}) })
.catch(function() { .catch(function(err) {
console.error(err); console.error(err);
$scope.searchModalOpened = false; $scope.searchModalOpened = false;
}); });
...@@ -737,7 +735,6 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, ...@@ -737,7 +735,6 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig,
// The default country used for address localisation // The default country used for address localisation
var defaultCountry = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.defaultCountry; var defaultCountry = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.defaultCountry;
//$scope.smallscreen = angular.isDefined($scope.smallscreen) ? $scope.smallscreen : UIUtils.screen.isSmall();
var loadingPosition = false; var loadingPosition = false;
var minLength = 3; var minLength = 3;
...@@ -800,7 +797,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, ...@@ -800,7 +797,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig,
} }
_.forEach($scope.locations||[], function(item, index) { _.forEach($scope.locations||[], function(item, index) {
item.selected = (index == $scope.selectLocationIndex); item.selected = (index === $scope.selectLocationIndex);
}); });
// TODO: scroll to item ? // TODO: scroll to item ?
...@@ -828,7 +825,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, ...@@ -828,7 +825,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig,
// Execute the given query // Execute the given query
return esGeo.point.searchByAddress(text) return esGeo.point.searchByAddress(text)
.then(function(res) { .then(function(res) {
if ($scope.requestId != requestId) return; // Skip apply if not same request: if ($scope.requestId !== requestId) return; // Skip apply if not same request:
loadingPosition = false; loadingPosition = false;
$scope.locations = res||[]; $scope.locations = res||[];
......
...@@ -297,7 +297,6 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil ...@@ -297,7 +297,6 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil
options.kind = 'ABUSE'; options.kind = 'ABUSE';
return $scope.toggleLike(event, options) return $scope.toggleLike(event, options)
.then(function() { .then(function() {
console.log('BEFORE display toast');
UIUtils.toast.show('COMMON.REPORT_ABUSE.CONFIRM.SENT'); UIUtils.toast.show('COMMON.REPORT_ABUSE.CONFIRM.SENT');
}); });
}; };
......
...@@ -79,7 +79,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran ...@@ -79,7 +79,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran
}) })
.then($scope.load) .then($scope.load)
.catch(function(err){ .catch(function(err){
if (err == 'CANCELLED') { if (err === 'CANCELLED') {
UIUtils.loading.hide(10); UIUtils.loading.hide(10);
$scope.cancel(); $scope.cancel();
return; return;
...@@ -191,6 +191,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran ...@@ -191,6 +191,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran
} }
if (!hasWaitDebounce) { if (!hasWaitDebounce) {
console.debug('[ES] [profile] Waiting debounce end, before saving...');
$scope.saving = true; $scope.saving = true;
return $timeout(function() { return $timeout(function() {
return $scope.save(silent, true); return $scope.save(silent, true);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
ng-repeat="social in formData.socials | filter:filterFn track by social.url" ng-repeat="social in formData.socials | filter:filterFn track by social.url"
id="social-{{social.url|formatSlug}}"> id="social-{{social.url|formatSlug}}">
<i class="icon ion-social-{{social.type}}" <i class="icon ion-social-{{social.type}}"
ng-class="{'ion-bookmark': social.type == 'other', 'ion-link': social.type == 'web', 'ion-email': social.type == 'email', 'ion-iphone': social.type == 'phone'}"></i> ng-class="{'ion-bookmark': social.type === 'other', 'ion-link': social.type === 'web', 'ion-email': social.type === 'email', 'ion-iphone': social.type === 'phone'}"></i>
<p ng-if="social.type && social.type != 'web'"> <p ng-if="social.type && social.type != 'web'">
{{social.type}} {{social.type}}
<i class="ion-locked" ng-if="social.recipient"></i> <i class="ion-locked" ng-if="social.recipient"></i>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment