8087 forEach utility method (#8088)
This commit is contained in:
@@ -64,7 +64,7 @@ angular.module("umbraco.directives")
|
||||
//Support one or more attribute properties to update
|
||||
var keys = attrs.localize.split(',');
|
||||
|
||||
keys.forEach((value, key) => {
|
||||
Utilities.forEach(keys, (value, key) => {
|
||||
var attr = element.attr(value);
|
||||
|
||||
if (attr) {
|
||||
|
||||
@@ -158,9 +158,9 @@ When this combination is hit an overview is opened with shortcuts based on the m
|
||||
};
|
||||
|
||||
function onInit() {
|
||||
scope.model.forEach(shortcutGroup => {
|
||||
Utilities.forEach(scope.model, shortcutGroup => {
|
||||
|
||||
shortcutGroup.shortcuts.forEach(shortcut => {
|
||||
Utilities.forEach(shortcutGroup.shortcuts, shortcut => {
|
||||
shortcut.platformKeys = [];
|
||||
|
||||
// get shortcut keys for mac
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
function registerAllTours() {
|
||||
tours = [];
|
||||
return tourResource.getTours().then(function (tourFiles) {
|
||||
tourFiles.forEach(tourFile => {
|
||||
Utilities.forEach(tourFiles, tourFile => {
|
||||
|
||||
tourFile.tours.forEach(newTour => {
|
||||
Utilities.forEach(tourFile.tours, newTour => {
|
||||
validateTour(newTour);
|
||||
validateTourRegistration(newTour);
|
||||
tours.push(newTour);
|
||||
@@ -251,7 +251,7 @@
|
||||
*/
|
||||
function validateTourRegistration(tour) {
|
||||
// check for existing tours with the same alias
|
||||
tours.forEach(existingTour => {
|
||||
Utilities.forEach(tours, existingTour => {
|
||||
if (existingTour.alias === tour.alias) {
|
||||
throw "A tour with the alias " + tour.alias + " is already registered";
|
||||
}
|
||||
@@ -267,17 +267,17 @@
|
||||
var deferred = $q.defer();
|
||||
currentUserResource.getTours().then(function (storedTours) {
|
||||
|
||||
storedTours.forEach(storedTour => {
|
||||
Utilities.forEach(storedTours, storedTour => {
|
||||
|
||||
if (storedTour.completed === true) {
|
||||
tours.forEach(tour => {
|
||||
Utilities.forEach(tours, tour => {
|
||||
if (storedTour.alias === tour.alias) {
|
||||
tour.completed = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (storedTour.disabled === true) {
|
||||
tours.forEach(tour => {
|
||||
Utilities.forEach(tours, tour => {
|
||||
if (storedTour.alias === tour.alias) {
|
||||
tour.disabled = true;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
//execute them sequentially
|
||||
|
||||
// set selected language to active
|
||||
$scope.languages.forEach(language => {
|
||||
Utilities.forEach($scope.languages, language => {
|
||||
language.active = false;
|
||||
});
|
||||
|
||||
|
||||
@@ -104,6 +104,16 @@
|
||||
return JSON.parse(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not equivalent to angular.forEach. But like the angularJS method this does not fail on null or undefined.
|
||||
*/
|
||||
const forEach = (obj, iterator) => {
|
||||
if (obj) {
|
||||
return obj.forEach(iterator);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
let _utilities = {
|
||||
noop: noop,
|
||||
copy: copy,
|
||||
@@ -117,7 +127,8 @@
|
||||
isNumber: isNumber,
|
||||
isObject: isObject,
|
||||
fromJson: fromJson,
|
||||
toJson: toJson
|
||||
toJson: toJson,
|
||||
forEach: forEach
|
||||
};
|
||||
|
||||
if (typeof (window.Utilities) === 'undefined') {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
var totalInfo = 0;
|
||||
|
||||
// count total number of statusses
|
||||
group.checks.forEach(check => {
|
||||
Utilities.forEach(group.checks, check => {
|
||||
|
||||
if (check.status) {
|
||||
check.status.forEach(status => {
|
||||
@@ -95,22 +95,24 @@
|
||||
group.checkCounter = 0;
|
||||
group.loading = true;
|
||||
|
||||
checks.forEach(check => {
|
||||
check.loading = true;
|
||||
if (checks) {
|
||||
checks.forEach(check => {
|
||||
check.loading = true;
|
||||
|
||||
healthCheckResource.getStatus(check.id)
|
||||
.then(function (response) {
|
||||
check.status = response;
|
||||
group.checkCounter = group.checkCounter + 1;
|
||||
check.loading = false;
|
||||
healthCheckResource.getStatus(check.id)
|
||||
.then(function (response) {
|
||||
check.status = response;
|
||||
group.checkCounter = group.checkCounter + 1;
|
||||
check.loading = false;
|
||||
|
||||
// when all checks are done, set global group result
|
||||
if (group.checkCounter === checks.length) {
|
||||
setGroupGlobalResultType(group);
|
||||
group.loading = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
// when all checks are done, set global group result
|
||||
if (group.checkCounter === checks.length) {
|
||||
setGroupGlobalResultType(group);
|
||||
group.loading = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openGroup(group) {
|
||||
|
||||
Reference in New Issue
Block a user