Skip to content

Commit

Permalink
Convert angular.isArray to Utilities.isArray (#7934)
Browse files Browse the repository at this point in the history
  • Loading branch information
MMasey authored Apr 10, 2020
1 parent 318fcbe commit b5b319f
Show file tree
Hide file tree
Showing 34 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

if (scope.user.avatars) {
scope.avatar = [];
if (angular.isArray(scope.user.avatars)) {
if (Utilities.isArray(scope.user.avatars)) {
for (var i = 0; i < scope.user.avatars.length; i++) {
scope.avatar.push({ value: scope.user.avatars[i] });
}
Expand All @@ -46,7 +46,7 @@

if (scope.user.avatars) {
scope.avatar = [];
if (angular.isArray(scope.user.avatars)) {
if (Utilities.isArray(scope.user.avatars)) {
for (var i = 0; i < scope.user.avatars.length; i++) {
scope.avatar.push({ value: scope.user.avatars[i] });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('umbraco.directives')
.directive('checklistModel', ['$parse', '$compile', function($parse, $compile) {
// contains
function contains(arr, item) {
if (angular.isArray(arr)) {
if (Utilities.isArray(arr)) {
for (var i = 0; i < arr.length; i++) {
if (angular.equals(arr[i], item)) {
return true;
Expand All @@ -21,7 +21,7 @@ angular.module('umbraco.directives')

// add
function add(arr, item) {
arr = angular.isArray(arr) ? arr : [];
arr = Utilities.isArray(arr) ? arr : [];
for (var i = 0; i < arr.length; i++) {
if (angular.equals(arr[i], item)) {
return arr;
Expand All @@ -33,7 +33,7 @@ angular.module('umbraco.directives')

// remove
function remove(arr, item) {
if (angular.isArray(arr)) {
if (Utilities.isArray(arr)) {
for (var i = 0; i < arr.length; i++) {
if (angular.equals(arr[i], item)) {
arr.splice(i, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
}
}
}
else if (angular.isArray(vm.value)) {
else if (Utilities.isArray(vm.value)) {
vm.viewModel = vm.value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function umbTreeDirective($q, $rootScope, treeService, notificationsService, use

/** Helper function to emit tree events */
function emitEvent(eventName, args) {
if (registeredCallbacks[eventName] && angular.isArray(registeredCallbacks[eventName])) {
if (registeredCallbacks[eventName] && Utilities.isArray(registeredCallbacks[eventName])) {
_.each(registeredCallbacks[eventName], function (c) {
c(args);//call it
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Use this directive to generate a thumbnail grid of media items.
};

var unbindItemsWatcher = scope.$watch('items', function(newValue, oldValue) {
if (angular.isArray(newValue)) {
if (Utilities.isArray(newValue)) {
activate();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function valPropertyMsg(serverValidationManager, localizationService) {
var errCount = 0;

for (var e in formCtrl.$error) {
if (angular.isArray(formCtrl.$error[e])) {
if (Utilities.isArray(formCtrl.$error[e])) {
errCount++;
}
}
Expand All @@ -111,8 +111,8 @@ function valPropertyMsg(serverValidationManager, localizationService) {
// is the only one, then we'll clear.

if (errCount === 0
|| (errCount === 1 && angular.isArray(formCtrl.$error.valPropertyMsg))
|| (formCtrl.$invalid && angular.isArray(formCtrl.$error.valServer))) {
|| (errCount === 1 && Utilities.isArray(formCtrl.$error.valPropertyMsg))
|| (formCtrl.$invalid && Utilities.isArray(formCtrl.$error.valServer))) {
scope.errorMsg = "";
formCtrl.$setValidity('valPropertyMsg', true);
} else if (showValidation && scope.errorMsg === "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
function link(scope, el, attr, ctrl) {

//if there are no containing form or valFormManager controllers, then we do nothing
if (!ctrl || !angular.isArray(ctrl) || ctrl.length !== 2 || !ctrl[0] || !ctrl[1]) {
if (!ctrl || !Utilities.isArray(ctrl) || ctrl.length !== 2 || !ctrl[0] || !ctrl[1]) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
var headers = config.headers ? config.headers : {};

//Here we'll check if we should ignore the error (either based on the original header set or the request configuration)
if (headers["x-umb-ignore-error"] === "ignore" || config.umbIgnoreErrors === true || (angular.isArray(config.umbIgnoreStatus) && config.umbIgnoreStatus.indexOf(rejection.status) !== -1)) {
if (headers["x-umb-ignore-error"] === "ignore" || config.umbIgnoreErrors === true || (Utilities.isArray(config.umbIgnoreStatus) && config.umbIgnoreStatus.indexOf(rejection.status) !== -1)) {
//exit/ignore
return $q.reject(rejection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,10 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
loginPageId: loginPageId,
errorPageId: errorPageId
};
if (angular.isArray(groups) && groups.length) {
if (Utilities.isArray(groups) && groups.length) {
publicAccess.groups = groups;
}
else if (angular.isArray(usernames) && usernames.length) {
else if (Utilities.isArray(usernames) && usernames.length) {
publicAccess.usernames = usernames;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function angularHelper($q) {
//this is sequential promise chaining, it's not pretty but we need to do it this way.
//$q.all doesn't execute promises in sequence but that's what we want to do here.

if (!angular.isArray(promises)) {
if (!Utilities.isArray(promises)) {
throw "promises must be an array";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ angular.module('umbraco.services')
load: function (pathArray, scope, defaultAssetType) {
var promise;

if (!angular.isArray(pathArray)) {
if (!Utilities.isArray(pathArray)) {
throw "pathArray must be an array";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function fileManager($rootScope) {
}

var metaData = [];
if (angular.isArray(args.metaData)) {
if (Utilities.isArray(args.metaData)) {
metaData = args.metaData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function formHelper(angularHelper, serverValidationManager, notificationsService
if (!args || !args.notifications) {
return false;
}
if (angular.isArray(args.notifications)) {
if (Utilities.isArray(args.notifications)) {
for (var i = 0; i < args.notifications.length; i++) {
notificationsService.showNotification(args.notifications[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@

selection.length = 0;

if (angular.isArray(items)) {
if (Utilities.isArray(items)) {
for (i = 0; items.length > i; i++) {
var item = items[i];
item.selected = false;
}
}

if(angular.isArray(folders)) {
if(Utilities.isArray(folders)) {
for (i = 0; folders.length > i; i++) {
var folder = folders[i];
folder.selected = false;
Expand All @@ -366,7 +366,7 @@
var checkbox = $event.target;
var clearSelection = false;

if (!angular.isArray(items)) {
if (!Utilities.isArray(items)) {
return;
}

Expand Down Expand Up @@ -413,7 +413,7 @@

function selectAllItemsToggle(items, selection) {

if (!angular.isArray(items)) {
if (!Utilities.isArray(items)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
//now we need to check if this custom config key is defined in our baseline, if it is we don't want to
//overwrite the baseline config item if it is an array, we want to concat the items in the array, otherwise
//if it's an object it will overwrite the baseline
if (angular.isArray(config[i]) && angular.isArray(tinyMceConfig.customConfig[i])) {
if (Utilities.isArray(config[i]) && Utilities.isArray(tinyMceConfig.customConfig[i])) {
//concat it and below this concat'd array will overwrite the baseline in angular.extend
tinyMceConfig.customConfig[i] = config[i].concat(tinyMceConfig.customConfig[i]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Umbraco.Web.UI.Client/src/common/services/tree.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS

/** Internal method to track expanded paths on a tree */
_trackExpandedPaths: function (node, expandedPaths) {
if (!node.children || !angular.isArray(node.children) || node.children.length == 0) {
if (!node.children || !Utilities.isArray(node.children) || node.children.length == 0) {
return;
}

Expand Down Expand Up @@ -174,7 +174,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
//we determine this based on the server variables
if (Umbraco.Sys.ServerVariables.umbracoPlugins &&
Umbraco.Sys.ServerVariables.umbracoPlugins.trees &&
angular.isArray(Umbraco.Sys.ServerVariables.umbracoPlugins.trees)) {
Utilities.isArray(Umbraco.Sys.ServerVariables.umbracoPlugins.trees)) {

var found = _.find(Umbraco.Sys.ServerVariables.umbracoPlugins.trees, function (item) {
return invariantEquals(item.alias, treeAlias);
Expand Down Expand Up @@ -473,7 +473,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS

for (var i = 0; i < treeNode.children.length; i++) {
var child = treeNode.children[i];
if (child.children && angular.isArray(child.children) && child.children.length > 0) {
if (child.children && Utilities.isArray(child.children) && child.children.length > 0) {
//recurse
found = this.getDescendantNode(child, id);
if (found) {
Expand Down Expand Up @@ -773,7 +773,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
if (!args.path) {
throw "No path defined on args object for syncTree";
}
if (!angular.isArray(args.path)) {
if (!Utilities.isArray(args.path)) {
throw "Path must be an array";
}
if (args.path.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
*/
dictionaryToQueryString: function (queryStrings) {

if (angular.isArray(queryStrings)) {
if (Utilities.isArray(queryStrings)) {
return _.map(queryStrings, function (item) {
var key = null;
var val = null;
Expand Down Expand Up @@ -254,7 +254,7 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
// so we know which property it belongs to on the server side
var fileKey = "file_" + args.files[f].alias + "_" + (args.files[f].culture ? args.files[f].culture : "");

if (angular.isArray(args.files[f].metaData) && args.files[f].metaData.length > 0) {
if (Utilities.isArray(args.files[f].metaData) && args.files[f].metaData.length > 0) {
fileKey += ("_" + args.files[f].metaData.join("_"));
}
formData.append(fileKey, args.files[f].file);
Expand Down Expand Up @@ -322,7 +322,7 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
//validate input, jsonData can be an array of key/value pairs or just one key/value pair.
if (!jsonData) { throw "jsonData cannot be null"; }

if (angular.isArray(jsonData)) {
if (Utilities.isArray(jsonData)) {
_.each(jsonData, function (item) {
if (!item.key || !item.value) { throw "jsonData array item must have both a key and a value property"; }
});
Expand All @@ -340,7 +340,7 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
transformRequest: function(data) {
var formData = new FormData();
//add the json data
if (angular.isArray(data)) {
if (Utilities.isArray(data)) {
_.each(data, function(item) {
formData.append(item.key, !Utilities.isString(item.value) ? Utilities.toJson(item.value) : item.value);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function MacroPickerController($scope, entityResource, macroResource, umbPropEdi
.then(function (data) {

//go to next page if there are params otherwise we can just exit
if (!angular.isArray(data) || data.length === 0) {
if (!Utilities.isArray(data) || data.length === 0) {

if (insertIfNoParameters) {
$scope.model.submit($scope.model);
Expand Down Expand Up @@ -104,12 +104,12 @@ function MacroPickerController($scope, entityResource, macroResource, umbPropEdi
entityResource.getAll("Macro", ($scope.model.dialogData && $scope.model.dialogData.richTextEditor && $scope.model.dialogData.richTextEditor === true) ? "UseInEditor=true" : null)
.then(function (data) {

if (angular.isArray(data) && data.length == 0) {
if (Utilities.isArray(data) && data.length == 0) {
$scope.nomacros = true;
}

//if 'allowedMacros' is specified, we need to filter
if (angular.isArray($scope.model.dialogData.allowedMacros) && $scope.model.dialogData.allowedMacros.length > 0) {
if (Utilities.isArray($scope.model.dialogData.allowedMacros) && $scope.model.dialogData.allowedMacros.length > 0) {
$scope.macros = _.filter(data, function(d) {
return _.contains($scope.model.dialogData.allowedMacros, d.alias);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ angular.module("umbraco")
var folderImage = $scope.images[folderIndex];
var imageIsSelected = false;

if ($scope.model && angular.isArray($scope.model.selection)) {
if ($scope.model && Utilities.isArray($scope.model.selection)) {
for (var selectedIndex = 0;
selectedIndex < $scope.model.selection.length;
selectedIndex++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ angular.module("umbraco").controller("Umbraco.Editors.TreePickerController",
openMiniListView(args.node);
}

if (angular.isArray(args.children)) {
if (Utilities.isArray(args.children)) {

//iterate children
_.each(args.children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
$scope.error = err;

//show any notifications
if (angular.isArray(err.data.notifications)) {
if (Utilities.isArray(err.data.notifications)) {
for (var i = 0; i < err.data.notifications.length; i++) {
notificationsService.showNotification(err.data.notifications[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.ColorPickerControl
// Make an array from the dictionary
var items = [];

if (angular.isArray($scope.model.prevalues)) {
if (Utilities.isArray($scope.model.prevalues)) {

for (var i in $scope.model.prevalues) {
var oldValue = $scope.model.prevalues[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.MultiValuesControl
$scope.hasError = false;
$scope.focusOnNew = false;

if (!angular.isArray($scope.model.value)) {
if (!Utilities.isArray($scope.model.value)) {

//make an array from the dictionary
var items = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ angular.module('umbraco')
}

function populate(data) {
if (angular.isArray(data)) {
if (Utilities.isArray(data)) {
_.each(data, function (item, i) {
$scope.add(item);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function ColorPickerController($scope, $timeout) {
initActiveColor();
}

if (!angular.isArray($scope.model.config.items)) {
if (!Utilities.isArray($scope.model.config.items)) {
//make an array from the dictionary
var items = [];
for (var i in $scope.model.config.items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
});
});

if (!angular.isArray($scope.model.value)) {
if (!Utilities.isArray($scope.model.value)) {
//make an array from the dictionary
var items = [];
for (var i in $scope.model.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
dataTypeKey: $scope.model.dataTypeKey,
currentNode: editorState ? editorState.current : null,
callback: function (data) {
if (angular.isArray(data)) {
if (Utilities.isArray(data)) {
_.each(data, function (item, i) {
$scope.add(item);
});
Expand Down Expand Up @@ -233,7 +233,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
$scope.currentPicker = dialogOptions;

$scope.currentPicker.submit = function (model) {
if (angular.isArray(model.selection)) {
if (Utilities.isArray(model.selection)) {
_.each(model.selection, function (item, i) {
$scope.add(item);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.DropdownFlexibleCo
$scope.model.value = [$scope.model.singleDropdownValue];
}

if (angular.isArray($scope.model.config.items)) {
if (Utilities.isArray($scope.model.config.items)) {
//PP: I dont think this will happen, but we have tests that expect it to happen..
//if array is simple values, convert to array of objects
if (!Utilities.isObject($scope.model.config.items[0])){
Expand Down
Loading

0 comments on commit b5b319f

Please sign in to comment.