Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced angular.extend with Utilities.extend #10023

Merged
merged 12 commits into from
May 27, 2021
Merged
8 changes: 8 additions & 0 deletions src/Umbraco.Web.UI.Client/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
"targets": "last 2 version, not dead, > 0.5%, not ie 11"
}
]
],
"plugins": [
[
"@babel/plugin-proposal-object-rest-spread",
{
"useBuiltIns": true
}
]
]
}
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI.Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"devDependencies": {
"@babel/core": "7.6.4",
"@babel/preset-env": "7.6.3",
"@babel/plugin-proposal-object-rest-spread": "7.13.8",
"autoprefixer": "9.6.5",
"caniuse-lite": "^1.0.30001037",
"cssnano": "4.1.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ angular.module("umbraco.directives")
maxImageSize: editorConfig.maxImageSize
};

angular.extend(baseLineConfigObj, standardConfig);
Utilities.extend(baseLineConfigObj, standardConfig);

baseLineConfigObj.setup = function (editor) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@
* umbAceEditorConfig merged with user options via json in attribute or data binding
* @type object
*/
var opts = angular.extend({}, options, scope.umbAceEditor);

var opts = Utilities.extend({}, options, scope.umbAceEditor);

//load ace libraries here...

Expand Down Expand Up @@ -273,7 +272,7 @@
return;
}

opts = angular.extend({}, options, scope.umbAceEditor);
opts = Utilities.extend({}, options, scope.umbAceEditor);

opts.callbacks = [opts.onLoad];
if (opts.onLoad !== options.onLoad) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
//change asc/desct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function entityResource($q, $http, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
//change asc/desct
Expand Down Expand Up @@ -512,7 +512,7 @@ function entityResource($q, $http, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
//change asc/desct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function logResource($q, $http, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;

Expand Down Expand Up @@ -140,7 +140,7 @@ function logResource($q, $http, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function logViewerResource($q, $http, umbRequestHelper) {
}

//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);

//now copy back to the options we will use
options = defaults;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
//change asc/desct
Expand Down Expand Up @@ -563,7 +563,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function memberResource($q, $http, umbDataFormatter, umbRequestHelper) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
//change asc/desct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function relationTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
Utilities.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
//change asc/desct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function keyboardService($window, $timeout) {

var elt;
// Initialize opt object
opt = angular.extend({}, defaultOpt, opt);
opt = Utilities.extend(defaultOpt, opt);
bjarnef marked this conversation as resolved.
Show resolved Hide resolved
label = label.toLowerCase();
elt = opt.target;
if(typeof opt.target === 'string'){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ function searchResultFormatter(umbRequestHelper) {

function configureDefaultResult(content, treeAlias, appAlias) {
content.editorPath = appAlias + "/" + treeAlias + "/edit/" + content.id;
angular.extend(content.metaData, { treeAlias: treeAlias });
Utilities.extend(content.metaData, { treeAlias: treeAlias });
}

function configureContentResult(content, treeAlias, appAlias) {
content.menuUrl = umbRequestHelper.getApiUrl("contentTreeBaseUrl", "GetMenu", [{ id: content.id }, { application: appAlias }]);
content.editorPath = appAlias + "/" + treeAlias + "/edit/" + content.id;
angular.extend(content.metaData, { treeAlias: treeAlias });
Utilities.extend(content.metaData, { treeAlias: treeAlias });
content.subTitle = content.metaData.Url;
}

function configureMemberResult(member, treeAlias, appAlias) {
member.menuUrl = umbRequestHelper.getApiUrl("memberTreeBaseUrl", "GetMenu", [{ id: member.id }, { application: appAlias }]);
member.editorPath = appAlias + "/" + treeAlias + "/edit/" + (member.key ? member.key : member.id);
angular.extend(member.metaData, { treeAlias: treeAlias });
Utilities.extend(member.metaData, { treeAlias: treeAlias });
member.subTitle = member.metaData.Email;
}

function configureMediaResult(media, treeAlias, appAlias) {
media.menuUrl = umbRequestHelper.getApiUrl("mediaTreeBaseUrl", "GetMenu", [{ id: media.id }, { application: appAlias }]);
media.editorPath = appAlias + "/" + treeAlias + "/edit/" + media.id;
angular.extend(media.metaData, { treeAlias: treeAlias });
Utilities.extend(media.metaData, { treeAlias: treeAlias });
}

return {
Expand All @@ -34,4 +34,4 @@ function searchResultFormatter(umbRequestHelper) {
};
}

angular.module('umbraco.services').factory('searchResultFormatter', searchResultFormatter);
angular.module('umbraco.services').factory('searchResultFormatter', searchResultFormatter);
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s

};

angular.extend(config, pasteConfig);

Utilities.extend(config, pasteConfig);

if (tinyMceConfig.customConfig) {

Expand All @@ -481,7 +480,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
//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 (Utilities.isArray(config[i]) && Utilities.isArray(tinyMceConfig.customConfig[i])) {
//concat it and below this concat'd array will overwrite the baseline in angular.extend
//concat it and below this concat'd array will overwrite the baseline in Utilities.extend
tinyMceConfig.customConfig[i] = config[i].concat(tinyMceConfig.customConfig[i]);
}
}
Expand All @@ -498,7 +497,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
}
}

angular.extend(config, tinyMceConfig.customConfig);
Utilities.extend(config, tinyMceConfig.customConfig);
}

return config;
Expand Down
3 changes: 2 additions & 1 deletion src/Umbraco.Web.UI.Client/src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
/**
* Facade to angular.extend
* Use this with Angular objects, for vanilla JS objects, use Object.assign()
* This is an alias as it to allow passing an unknown number of arguments
ronaldbarendse marked this conversation as resolved.
Show resolved Hide resolved
*/
const extend = (dst, src) => angular.extend(dst, src);
const extend = angular.extend;

/**
* Equivalent to angular.isFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.ColorPickerControl
};

//map the user config
angular.extend(config, $scope.model.config);
Utilities.extend(config, $scope.model.config);

//map back to the model
$scope.model.config = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function mediaPickerController($scope, entityResource, iconHelper, editorService

//combine the dialogOptions with any values returned from the server
if ($scope.model.config) {
angular.extend(dialogOptions, $scope.model.config);
Utilities.extend(dialogOptions, $scope.model.config);
}

$scope.openTreePicker = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module('umbraco')

//combine the config with any values returned from the server
if ($scope.model.config) {
angular.extend(config, $scope.model.config);
Utilities.extend(config, $scope.model.config);
}

if ($scope.model.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
delete $scope.model.config.startNode;
}
//merge the server config on top of the default config, then set the server config to use the result
$scope.model.config = angular.extend(defaultConfig, $scope.model.config);
$scope.model.config = Utilities.extend(defaultConfig, $scope.model.config);

// if the property is mandatory, set the minCount config to 1 (unless of course it is set to something already),
// that way the minCount/maxCount validation handles the mandatory as well
Expand Down Expand Up @@ -189,7 +189,7 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso

//since most of the pre-value config's are used in the dialog options (i.e. maxNumber, minNumber, etc...) we'll merge the
// pre-value config on to the dialog options
angular.extend(dialogOptions, $scope.model.config);
Utilities.extend(dialogOptions, $scope.model.config);

dialogOptions.dataTypeKey = $scope.model.dataTypeKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function dateTimePickerController($scope, angularHelper, dateHelper, validationM
};

// map the user config
$scope.model.config = angular.extend(config, $scope.model.config);
$scope.model.config = Utilities.extend(config, $scope.model.config);;

// ensure the format doesn't get overwritten with an empty string
if ($scope.model.config.format === "" || $scope.model.config.format === undefined || $scope.model.config.format === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.DropdownFlexibleCo
};

//map the user config
angular.extend(config, $scope.model.config);
Utilities.extend(config, $scope.model.config);

//map back to the model
$scope.model.config = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ angular.module("umbraco")
// allowed for this template based on the current config.

_.each(found.sections, function (templateSection, index) {
angular.extend($scope.model.value.sections[index], Utilities.copy(templateSection));
Utilities.extend($scope.model.value.sections[index], Utilities.copy(templateSection));
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ angular.module('umbraco')
function setModelValueWithSrc(src) {
if (!$scope.model.value || !$scope.model.value.src) {
//we are copying to not overwrite the original config
$scope.model.value = angular.extend(Utilities.copy($scope.model.config), { src: src });
$scope.model.value = Utilities.extend(Utilities.copy($scope.model.config), { src: src });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
media.loading = true;
entityResource.getById(media.udi, "Media")
.then(function (mediaEntity) {
angular.extend(media, mediaEntity);
Utilities.extend(media, mediaEntity);
media.thumbnail = mediaHelper.resolveFileFromEntity(media, true);
media.loading = false;
});
Expand Down Expand Up @@ -226,7 +226,7 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
// we need to update all the media items
vm.mediaItems.forEach(media => {
if (media.id === model.mediaNode.id) {
angular.extend(media, mediaEntity);
Utilities.extend(media, mediaEntity);
media.thumbnail = mediaHelper.resolveFileFromEntity(media, true);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function memberPickerController($scope, entityResource, iconHelper, editorServic
//since most of the pre-value config's are used in the dialog options (i.e. maxNumber, minNumber, etc...) we'll merge the
// pre-value config on to the dialog options
if ($scope.model.config) {
angular.extend(dialogOptions, $scope.model.config);
Utilities.extend(dialogOptions, $scope.model.config);
}

$scope.openMemberPicker = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ angular.module("umbraco")
});

};

angular.extend(baseLineConfigObj, standardConfig);
Utilities.extend(baseLineConfigObj, standardConfig);

// We need to wait for DOM to have rendered before we can find the element by ID.
$timeout(function () {
Expand Down