diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 1c908573cc..30afe65c3a 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -349,7 +349,7 @@ angular $rootScope.$broadcast("RemoveIndicator"); } - if(_.contains(trans.from().name, 'output') && trans.to().name === 'jobs'){ + if(_.includes(trans.from().name, 'output') && trans.to().name === 'jobs'){ $state.reload(); } }); @@ -375,7 +375,7 @@ angular $rootScope.user_is_system_auditor = Authorization.getUserInfo('is_system_auditor'); // state the user refreshes we want to open the socket, except if the user is on the login page, which should happen after the user logs in (see the AuthService module for that call to OpenSocket) - if (!_.contains($location.$$url, '/login')) { + if (!_.includes($location.$$url, '/login')) { ConfigService.getConfig().then(function() { Timer.init().then(function(timer) { $rootScope.sessionTimer = timer; diff --git a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js index eeecf9e4c0..2f528e1620 100644 --- a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js +++ b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js @@ -90,7 +90,7 @@ export default if(streamConfig && streamConfig.activityStream) { if(streamConfig.activityStreamTarget) { stateGoParams.target = streamConfig.activityStreamTarget; - let isTemplateTarget = _.contains(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget); + let isTemplateTarget = _.includes(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget); stateGoParams.activity_search = { or__object1__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget, or__object2__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget, diff --git a/awx/ui/client/src/bread-crumb/bread-crumb.service.js b/awx/ui/client/src/bread-crumb/bread-crumb.service.js index b3d510047d..eb7a8f81e5 100644 --- a/awx/ui/client/src/bread-crumb/bread-crumb.service.js +++ b/awx/ui/client/src/bread-crumb/bread-crumb.service.js @@ -25,7 +25,7 @@ export default if(expandedBreadcrumbWidth > availableWidth) { let widthToTrim = expandedBreadcrumbWidth - availableWidth; // Sort the crumbs from biggest to smallest - let sortedCrumbs = _.sortByOrder(crumbs, ["origWidth"], ["desc"]); + let sortedCrumbs = _.orderBy(crumbs, ["origWidth"], ["desc"]); let maxWidth; for(let i=0; i (form.fields[i].ngShow && form.fields[i].ngShow.indexOf(v) > -1)) .map(i => [i, processValue($scope[i], i, form.fields[i])])); diff --git a/awx/ui/client/src/shared/multi-select-list/multi-select-list.controller.js b/awx/ui/client/src/shared/multi-select-list/multi-select-list.controller.js index 1d7044af28..9cd4766769 100644 --- a/awx/ui/client/src/shared/multi-select-list/multi-select-list.controller.js +++ b/awx/ui/client/src/shared/multi-select-list/multi-select-list.controller.js @@ -36,10 +36,10 @@ export default ['$scope', $scope.selection.selectedItems = _items.filter(function(item) { return item.isSelected; - }).pluck('value').value(); + }).map('value').value(); $scope.selection.deselectedItems = - _items.pluck('value').difference($scope.selection.selectedItems) + _items.map('value').difference($scope.selection.selectedItems) .value(); /** diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index edfa33dcdf..d1e2fbe9c4 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -310,12 +310,12 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc return []; } if(defaultParams) { - let stripped =_.pick(params, (value, key) => { + let stripped =_.pickBy(params, (value, key) => { // setting the default value of a term to null in a state definition is a very explicit way to ensure it will NEVER generate a search tag, even with a non-default value return defaultParams[key] !== value && key !== 'order_by' && key !== 'page' && key !== 'page_size' && defaultParams[key] !== null; }); let strippedCopy = _.cloneDeep(stripped); - if(_.keys(_.pick(defaultParams, _.keys(strippedCopy))).length > 0){ + if(_.keys(_.pickBy(defaultParams, _.keys(strippedCopy))).length > 0){ for (var key in strippedCopy) { if (strippedCopy.hasOwnProperty(key)) { let value = strippedCopy[key]; @@ -418,7 +418,7 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc termParams = searchWithoutKey(term, singleSearchParam); } - params = _.merge(params, termParams, combineSameSearches); + params = _.mergeWith(params, termParams, combineSameSearches); }); return params; diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js index 90eef5e23b..4a1c486b1b 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js @@ -102,7 +102,7 @@ function SmartSearchController ( const listName = $scope.list.name; const baseRelatedTypePath = `models.${listName}.base.${rootField}.type`; - const isRelatedSearchTermField = (_.contains($scope.models[listName].related, rootField)); + const isRelatedSearchTermField = (_.includes($scope.models[listName].related, rootField)); const isBaseModelRelatedSearchTermField = (_.get($scope, baseRelatedTypePath) === 'field'); return (isRelatedSearchTermField || isBaseModelRelatedSearchTermField); @@ -254,7 +254,7 @@ function SmartSearchController ( defaults[key] = queryset[key]; } }); - const cleared = _(defaults).omit(_.isNull).value(); + const cleared = _(defaults).omitBy(_.isNull).value(); delete cleared.page; queryset = cleared; diff --git a/awx/ui/client/src/teams/edit/teams-edit.controller.js b/awx/ui/client/src/teams/edit/teams-edit.controller.js index dc9beea14d..db6eab8bee 100644 --- a/awx/ui/client/src/teams/edit/teams-edit.controller.js +++ b/awx/ui/client/src/teams/edit/teams-edit.controller.js @@ -21,7 +21,9 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest', $scope.canEdit = me.get('summary_fields.user_capabilities.edit'); $scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0; $scope.team_id = id; - setScopeFields(data); + _.forEach(form.fields, (value, key) => { + $scope[key] = data[key]; + }); $scope.organization_name = data.summary_fields.organization.name; OrgAdminLookup.checkForAdminAccess({organization: data.organization}) @@ -36,19 +38,6 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest', }); } - // @issue I think all this really want to do is _.forEach(form.fields, (field) =>{ $scope[field] = data[field]}) - function setScopeFields(data) { - _(data) - .pick(function(value, key) { - return form.fields.hasOwnProperty(key) === true; - }) - .forEach(function(value, key) { - $scope[key] = value; - }) - .value(); - return; - } - // prepares a data payload for a PUT request to the API function processNewData(fields) { var data = {}; diff --git a/awx/ui/client/src/users/edit/users-edit.controller.js b/awx/ui/client/src/users/edit/users-edit.controller.js index f44c34b2a8..d54cfa03e3 100644 --- a/awx/ui/client/src/users/edit/users-edit.controller.js +++ b/awx/ui/client/src/users/edit/users-edit.controller.js @@ -17,7 +17,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest', '$state', 'i18n', 'resolvedModels', 'resourceData', function($scope, $rootScope, $stateParams, UserForm, Rest, ProcessErrors, GetBasePath, Wait, CreateSelect2, $state, i18n, models, resourceData) { - + for (var i = 0; i < user_type_options.length; i++) { user_type_options[i].label = i18n._(user_type_options[i].label); } @@ -28,12 +28,16 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest', id = $stateParams.user_id, defaultUrl = GetBasePath('users') + id, user_obj = resourceData.data; - + $scope.breadcrumb.user_name = user_obj.username; init(); function init() { + _.forEach(form.fields, (value, key) => { + $scope[key] = user_obj[key]; + }); + $scope.canEdit = me.get('summary_fields.user_capabilities.edit'); $scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0; $scope.isCurrentlyLoggedInUser = (parseInt(id) === $rootScope.current_user.id); @@ -73,9 +77,6 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest', $scope.$watch('user_obj.summary_fields.user_capabilities.edit', function(val) { $scope.canAdd = (val === false) ? false : true; }); - - setScopeFields(user_obj); - } function user_type_sync($scope) { @@ -107,19 +108,6 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest', }; } - - function setScopeFields(data) { - _(data) - .pick(function(value, key) { - return form.fields.hasOwnProperty(key) === true; - }) - .forEach(function(value, key) { - $scope[key] = value; - }) - .value(); - return; - } - $scope.redirectToResource = function(resource) { let type = resource.summary_fields.resource_type.replace(/ /g , "_"); var id = resource.related[type].split("/")[4]; diff --git a/awx/ui/npm-shrinkwrap.json b/awx/ui/npm-shrinkwrap.json index a6399afa6f..df94a6f67e 100644 --- a/awx/ui/npm-shrinkwrap.json +++ b/awx/ui/npm-shrinkwrap.json @@ -223,6 +223,11 @@ } } }, + "lodash": { + "version": "3.8.0", + "from": "lodash@>=3.8.0 <3.9.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.8.0.tgz" + }, "rrule": { "version": "2.2.0-dev", "from": "jkbrzt/rrule#4ff63b2f8524fd6d5ba6e80db770953b5cd08a0c", @@ -233,7 +238,7 @@ "angular-tz-extensions": { "version": "0.5.2", "from": "git+https://git@github.com/ansible/angular-tz-extensions.git#v0.5.2", - "resolved": "git+https://git@github.com/ansible/angular-tz-extensions.git#9cabb05d58079092bfb29ccae721b35b46f28af6", + "resolved": "git://github.com/ansible/angular-tz-extensions.git#9cabb05d58079092bfb29ccae721b35b46f28af6", "dependencies": { "jquery": { "version": "3.3.1", @@ -1496,7 +1501,15 @@ "version": "0.19.0", "from": "cheerio@>=0.19.0 <0.20.0", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.19.0.tgz", - "dev": true + "dev": true, + "dependencies": { + "lodash": { + "version": "3.10.1", + "from": "lodash@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "dev": true + } + } }, "chokidar": { "version": "1.7.0", @@ -5420,6 +5433,12 @@ "resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz", "dev": true, "dependencies": { + "lodash": { + "version": "3.10.1", + "from": "lodash@>=3.8.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "dev": true + }, "source-map": { "version": "0.5.7", "from": "source-map@>=0.5.3 <0.6.0", @@ -5723,6 +5742,12 @@ "from": "inquirer@>=0.8.2 <0.9.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.8.5.tgz", "dev": true + }, + "lodash": { + "version": "3.10.1", + "from": "lodash@>=3.6.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "dev": true } } }, @@ -5796,9 +5821,9 @@ "dev": true }, "lodash": { - "version": "3.8.0", - "from": "lodash@>=3.8.0 <3.9.0", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.8.0.tgz" + "version": "4.17.10", + "from": "lodash@>=4.17.10 <4.18.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz" }, "lodash._arraycopy": { "version": "3.0.0", @@ -6317,6 +6342,12 @@ "from": "glob@>=5.0.0 <6.0.0", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", "dev": true + }, + "lodash": { + "version": "3.10.1", + "from": "lodash@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "dev": true } } }, diff --git a/awx/ui/package.json b/awx/ui/package.json index cec81e6f31..cc9c156b47 100644 --- a/awx/ui/package.json +++ b/awx/ui/package.json @@ -121,7 +121,7 @@ "jquery-ui": "^1.12.1", "js-yaml": "^3.2.7", "legacy-loader": "0.0.2", - "lodash": "~3.8.0", + "lodash": "~4.17.10", "lr-infinite-scroll": "git+https://git@github.com/lorenzofox3/lrInfiniteScroll", "moment": "^2.19.4", "ng-toast": "git+https://git@github.com/ansible/ngToast#v2.1.1",