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'])
var
sockets = [],
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) {
timeout=4000; // default
......@@ -335,6 +340,7 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
uri = 'http://' + path;
}
// Use a <a> element to parse
var parser = document.createElement('a');
parser.href = uri;
......@@ -389,13 +395,13 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
var parts = parseUri(uri);
if (!parts.protocol && options.type) {
parts.protocol = (options.type == 'email') ? 'mailto:' :
((options.type == 'phone') ? 'tel:' : '');
parts.protocol = (options.type === 'email') ? 'mailto:' :
((options.type === 'phone') ? 'tel:' : '');
uri = parts.protocol + uri;
}
// On desktop, open into external tool
if (parts.protocol == 'mailto:' && Device.isDesktop()) {
if (parts.protocol === 'mailto:' && Device.isDesktop()) {
try {
nw.Shell.openExternal(uri);
return;
......@@ -405,10 +411,10 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
}
}
// Check if device is enable, on special tel: or mailto: protocole
var validProtocol = (parts.protocol == 'mailto:' || parts.protocol == 'tel:') && Device.enable;
// Check if device is enable, on special tel: or mailto: protocol
var validProtocol = (Device.enable && (parts.protocol === 'mailto:' || parts.protocol === 'tel:'));
if (!validProtocol) {
if (options.onError && typeof options.onError == 'function') {
if (options.onError && typeof options.onError === 'function') {
options.onError(uri);
}
return;
......@@ -491,11 +497,15 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
// First, validate both numbers are true version numbers
function validateParts(parts) {
for (var i = 0; i < parts.length; ++i) {
if (!isPositiveInteger(parts[i])) {
return false;
}
parts[i] = parseInt(parts[i]);
for (var i = 0; i < parts.length; i++) {
var isNumber = regexp.POSITIVE_INTEGER.test(parts[i]);
// First part MUST be an integer
if (i === 0 && !isNumber) return false;
// 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;
}
......
......@@ -395,9 +395,8 @@ function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils)
$focus('socialUrl');
};
$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(toIndex, 0, social);
};
......@@ -416,7 +415,6 @@ function ESSocialsViewController($scope) {
});
};
$scope.filterFn = function(social) {
return !social.recipient || social.valid;
};
......@@ -532,17 +530,17 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) {
});
};
$scope.onCityChanged = function() {
if ($scope.loading) return;
if ($scope.formPosition.enable) {
if ($scope.formData.geoPoint) {
// Invalidate the position
$scope.formData.geoPoint.lat = undefined;
$scope.formData.geoPoint.lon = undefined;
}
return $scope.tryToLocalize();
$scope.onCityChanged = function() {
if ($scope.loading) return;
if ($scope.formPosition.enable) {
if ($scope.formData.geoPoint) {
// Invalidate the position
$scope.formData.geoPoint.lat = undefined;
$scope.formData.geoPoint.lon = undefined;
}
};
return $scope.tryToLocalize();
}
};
$scope.onUseGeopointChanged = function() {
if ($scope.loading) return;
......@@ -623,7 +621,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) {
$scope.searchModalOpened = false;
$scope.updateGeoPoint(res);
})
.catch(function() {
.catch(function(err) {
console.error(err);
$scope.searchModalOpened = false;
});
......@@ -737,7 +735,6 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig,
// The default country used for address localisation
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 minLength = 3;
......@@ -800,7 +797,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig,
}
_.forEach($scope.locations||[], function(item, index) {
item.selected = (index == $scope.selectLocationIndex);
item.selected = (index === $scope.selectLocationIndex);
});
// TODO: scroll to item ?
......@@ -828,7 +825,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig,
// Execute the given query
return esGeo.point.searchByAddress(text)
.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;
$scope.locations = res||[];
......
......@@ -297,7 +297,6 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil
options.kind = 'ABUSE';
return $scope.toggleLike(event, options)
.then(function() {
console.log('BEFORE display toast');
UIUtils.toast.show('COMMON.REPORT_ABUSE.CONFIRM.SENT');
});
};
......
......@@ -79,7 +79,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran
})
.then($scope.load)
.catch(function(err){
if (err == 'CANCELLED') {
if (err === 'CANCELLED') {
UIUtils.loading.hide(10);
$scope.cancel();
return;
......@@ -191,6 +191,7 @@ function ESViewEditProfileController($scope, $q, $timeout, $state, $focus, $tran
}
if (!hasWaitDebounce) {
console.debug('[ES] [profile] Waiting debounce end, before saving...');
$scope.saving = true;
return $timeout(function() {
return $scope.save(silent, true);
......
......@@ -21,7 +21,7 @@
ng-repeat="social in formData.socials | filter:filterFn track by social.url"
id="social-{{social.url|formatSlug}}">
<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'">
{{social.type}}
<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.
Finish editing this message first!
Please register or to comment