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AM8C,cACrBvB,gBAAiBvB,EAAMuB,gBACvBsL,oBAAqBrI,EACrB/F,MAAOuB,EAAMvB,MACbC,SAAU,8CACVN,WAAY,0DACZO,SAAU,gFAGdL,EAAuBC,UAAU+J,EAAUtI,EAC/C,EAEAwE,GACJ,G","sources":["webpack://VirtoCommerce.Pricing/./Scripts/pricing.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/assignment-detail.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/assignment-list.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/pricelist-detail.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/pricelist-item-list.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/pricelist-list.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/prices-list.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/pricing-main.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/item/item-pricelists-list.js","webpack://VirtoCommerce.Pricing/./Scripts/blades/item/item-prices.js","webpack://VirtoCommerce.Pricing/./Scripts/resources/pricing.js","webpack://VirtoCommerce.Pricing/./Scripts/selectors/catalog-selector.js","webpack://VirtoCommerce.Pricing/./Scripts/selectors/currency-selector.js","webpack://VirtoCommerce.Pricing/./Scripts/selectors/pricelist-selector.js","webpack://VirtoCommerce.Pricing/./Scripts/selectors/product-selector.js","webpack://VirtoCommerce.Pricing/./Scripts/widgets/assignmentsWidget.js","webpack://VirtoCommerce.Pricing/./Scripts/widgets/itemPricesWidget.js","webpack://VirtoCommerce.Pricing/./Scripts/widgets/pricesWidget.js"],"sourcesContent":["//Call this to register our module to main application\nvar moduleName = \"virtoCommerce.pricingModule\";\n\nif (AppDependencies != undefined) {\n AppDependencies.push(moduleName);\n}\n\nangular.module(moduleName, ['ui.grid.cellNav', 'ui.grid.edit', 'ui.grid.validate'])\n.config(\n ['$stateProvider', function ($stateProvider) {\n $stateProvider\n .state('workspace.pricingModule', {\n url: '/pricing',\n templateUrl: '$(Platform)/Scripts/common/templates/home.tpl.html',\n controller: [\n '$scope', 'platformWebApp.bladeNavigationService', function ($scope, bladeNavigationService) {\n var blade = {\n id: 'pricing',\n title: 'pricing.blades.pricing-main.title',\n subtitle: 'pricing.blades.pricing-main.subtitle',\n controller: 'virtoCommerce.pricingModule.pricingMainController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricing-main.tpl.html',\n isClosingDisabled: true\n };\n bladeNavigationService.showBlade(blade);\n //Need for isolate and prevent conflict module css to other modules \n $scope.moduleName = \"vc-pricing\";\n }\n ]\n });\n }]\n)\n.run(\n ['$http', '$compile', 'platformWebApp.mainMenuService', 'platformWebApp.widgetService', '$state', 'platformWebApp.authService', 'platformWebApp.metaFormsService', 'virtoCommerce.exportModule.genericViewerItemService',\n function ($http, $compile, mainMenuService, widgetService, $state, authService, metaFormsService, genericViewerItemService) {\n //Register module in main menu\n var menuItem = {\n path: 'browse/pricing',\n icon: 'fa fa-usd',\n title: 'pricing.main-menu-title',\n priority: 30,\n action: function () { $state.go('workspace.pricingModule'); },\n permission: 'pricing:access'\n };\n mainMenuService.addMenuItem(menuItem);\n\n //Register item prices widget\n var itemPricesWidget = {\n isVisible: function (blade) { return authService.checkPermission('pricing:read'); },\n controller: 'virtoCommerce.pricingModule.itemPricesWidgetController',\n size: [2, 1],\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/widgets/itemPricesWidget.tpl.html',\n };\n widgetService.registerWidget(itemPricesWidget, 'itemDetail');\n\n //Register pricelist widgets\n widgetService.registerWidget({\n isVisible: function (blade) { return !blade.isNew; },\n controller: 'virtoCommerce.pricingModule.pricesWidgetController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/widgets/pricesWidget.tpl.html',\n }, 'pricelistDetail');\n widgetService.registerWidget({\n controller: 'virtoCommerce.pricingModule.assignmentsWidgetController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/widgets/assignmentsWidget.tpl.html',\n }, 'pricelistDetail');\n\n $http.get('Modules/$(VirtoCommerce.Pricing)/Scripts/dynamicConditions/templates.html').then(function (response) {\n // compile the response, which will put stuff into the cache\n $compile(response.data);\n });\n\n //\n metaFormsService.registerMetaFields('VirtoCommerce.PricingModule.Data.ExportImport.ExportablePrice' + 'ExportFilter', [\n {\n name: 'pricelistSelector',\n title: \"pricing.selectors.titles.price-lists\",\n templateUrl: 'Modules/$(VirtoCommerce.Pricing)/Scripts/selectors/pricelist-selector.tpl.html',\n },\n {\n name: 'productSelector',\n title: \"pricing.selectors.titles.products\",\n templateUrl: 'Modules/$(VirtoCommerce.Pricing)/Scripts/selectors/product-selector.tpl.html',\n },\n {\n name: 'modifiedSince',\n title: \"pricing.selectors.titles.modified-since\",\n valueType: \"DateTime\"\n }]);\n\n metaFormsService.registerMetaFields('VirtoCommerce.PricingModule.Data.ExportImport.ExportablePricelist' + 'ExportFilter', [\n {\n name: 'currencySelector',\n title: \"pricing.selectors.titles.currencies\",\n templateUrl: 'Modules/$(VirtoCommerce.Pricing)/Scripts/selectors/currency-selector.tpl.html',\n }]);\n\n metaFormsService.registerMetaFields('VirtoCommerce.PricingModule.Data.ExportImport.ExportablePricelistFullData' + 'ExportFilter', [\n {\n name: 'currencySelector',\n title: \"pricing.selectors.titles.currencies\",\n templateUrl: 'Modules/$(VirtoCommerce.Pricing)/Scripts/selectors/currency-selector.tpl.html',\n }]);\n\n metaFormsService.registerMetaFields('VirtoCommerce.PricingModule.Data.ExportImport.ExportablePricelistAssignment' + 'ExportFilter', [\n {\n name: 'pricelistAssignmentSelector',\n title: \"pricing.selectors.titles.price-lists\",\n templateUrl: 'Modules/$(VirtoCommerce.Pricing)/Scripts/selectors/pricelist-selector.tpl.html',\n },\n {\n name: 'catalogSelector',\n title: \"Select Catalog\",\n templateUrl: 'Modules/$(VirtoCommerce.Pricing)/Scripts/selectors/catalog-selector.tpl.html',\n }\n ]);\n\n genericViewerItemService.registerViewer('Price', function (item) {\n var itemCopy = angular.copy(item);\n\n return {\n id: 'itemPrices',\n itemId: itemCopy.productId,\n priceListId: itemCopy.pricelistId,\n data: { prices: [itemCopy] },\n currency: itemCopy.currency,\n title: 'pricing.blades.prices-list.title',\n titleValues: { name: itemCopy.name },\n subtitle: 'pricing.blades.prices-list.subtitle',\n controller: 'virtoCommerce.pricingModule.pricesListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/prices-list.tpl.html'\n };\n });\n\n genericViewerItemService.registerViewer('Pricelist', function (item) {\n var itemCopy = angular.copy(item);\n\n return {\n id: 'listItemChild',\n controller: 'virtoCommerce.pricingModule.pricelistDetailController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricelist-detail.tpl.html',\n currentEntityId: itemCopy.id,\n title: itemCopy.name\n };\n });\n\n genericViewerItemService.registerViewer('PricelistAssignment', function (item) {\n var itemCopy = angular.copy(item);\n\n return {\n id: 'pricelistAssignmentDetail',\n controller: 'virtoCommerce.pricingModule.assignmentDetailController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/assignment-detail.tpl.html',\n currentEntityId: itemCopy.id,\n title: itemCopy.name,\n subtitle: 'pricing.blades.assignment-detail.subtitle'\n };\n });\n }]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.assignmentDetailController', ['$scope', 'virtoCommerce.catalogModule.catalogs', 'virtoCommerce.pricingModule.pricelists', 'virtoCommerce.pricingModule.pricelistAssignments', 'virtoCommerce.storeModule.stores', 'platformWebApp.bladeNavigationService', 'virtoCommerce.coreModule.common.dynamicExpressionService', 'platformWebApp.dialogService', function ($scope, catalogs, pricelists, assignments, stores, bladeNavigationService, dynamicExpressionService, dialogService) {\n var blade = $scope.blade;\n blade.updatePermission = 'pricing:update';\n\n $scope.pageSize = 20;\n\n blade.refresh = function (parentRefresh) {\n if (blade.isNew) {\n assignments.getNew(initializeBlade);\n } else {\n assignments.get({ id: blade.currentEntityId }, initializeBlade);\n if (parentRefresh && angular.isFunction(blade.parentBlade.refresh)) {\n blade.parentBlade.refresh();\n }\n }\n };\n\n function initializeBlade(data) {\n if (blade.isNew) {\n \tdata = angular.extend(blade.data, data);\n \tblade.data.pricelistId = blade.pricelistId;\n }\n\n if (data.dynamicExpression) {\n _.each(data.dynamicExpression.children, extendElementBlock);\n groupAvailableChildren(data.dynamicExpression.children[0]);\n }\n\n blade.currentEntity = angular.copy(data);\n blade.origEntity = data;\n blade.isLoading = false;\n\n if (!blade.isNew) {\n blade.toolbarCommands = [\n {\n name: \"platform.commands.save\",\n icon: 'fas fa-save',\n executeMethod: $scope.saveChanges,\n canExecuteMethod: canSave,\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.reset\",\n icon: 'fa fa-undo',\n executeMethod: function () {\n angular.copy(blade.origEntity, blade.currentEntity);\n },\n canExecuteMethod: isDirty,\n permission: blade.updatePermission\n }\n ];\n }\n }\n\n function isDirty() {\n return !angular.equals(blade.currentEntity, blade.origEntity) && blade.hasUpdatePermission();\n }\n\n function canSave() {\n return isDirty() && $scope.formScope && $scope.formScope.$valid && validateAssignment();\n }\n\n function validateAssignment() {\n return (!blade.currentEntity.storeId || !blade.currentEntity.catalogId) &&\n (blade.currentEntity.storeId || blade.currentEntity.catalogId)\n }\n\n $scope.setForm = function (form) { $scope.formScope = form; };\n\n $scope.cancelChanges = function () {\n $scope.bladeClose();\n };\n\n $scope.saveChanges = function () {\n // can't set dynamic \"required\" attribute in ui-scroll-drop-down template\n // so check if both \"storeId\" and \"catalogId\" are not null and only one of them is filled\n if (!validateAssignment()) {\n var dialog = {\n id: \"assignmentSaveValidationError\",\n title: \"pricing.dialogs.assignment-save-validation.title\",\n message: \"pricing.dialogs.assignment-save-validation.message\",\n }\n dialogService.showErrorDialog(dialog);\n return;\n }\n\n blade.isLoading = true;\n if (blade.currentEntity.dynamicExpression) {\n blade.currentEntity.dynamicExpression.availableChildren = undefined;\n _.each(blade.currentEntity.dynamicExpression.children, stripOffUiInformation);\n }\n\n if (blade.isNew) {\n assignments.save(blade.currentEntity, function (data) {\n blade.isNew = undefined;\n blade.currentEntityId = data.id;\n blade.refresh(true);\n }, function (error) {\n bladeNavigationService.setError('Error ' + error.status, blade);\n });\n } else {\n assignments.update(blade.currentEntity, function (data) {\n blade.refresh(true);\n }, function (error) {\n bladeNavigationService.setError('Error ' + error.status, blade);\n });\n }\n };\n\n blade.onClose = function (closeCallback) {\n bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, \"pricing.dialogs.assignment-save.title\", \"pricing.dialogs.assignment-save.message\");\n };\n\n // datepicker\n $scope.datepickers = {\n str: false,\n end: false\n }\n\n $scope.open = function ($event, which) {\n $event.preventDefault();\n $event.stopPropagation();\n\n $scope.datepickers[which] = true;\n };\n\n // Dynamic ExpressionBlock\n function extendElementBlock(expressionBlock) {\n var retVal = dynamicExpressionService.expressions[expressionBlock.id];\n if (!retVal) {\n retVal = { displayName: 'unknown element: ' + expressionBlock.id };\n }\n\n _.extend(expressionBlock, retVal);\n\n if (!expressionBlock.children) {\n expressionBlock.children = [];\n }\n\n _.each(expressionBlock.children, extendElementBlock);\n _.each(expressionBlock.availableChildren, extendElementBlock);\n return expressionBlock;\n }\n\n function groupAvailableChildren(expressionBlock) {\n results = _.groupBy(expressionBlock.availableChildren, 'groupName');\n expressionBlock.availableChildren = _.map(results, function (items, key) { return { displayName: key, subitems: items }; });\n }\n\n function stripOffUiInformation(expressionElement) {\n expressionElement.availableChildren = undefined;\n expressionElement.displayName = undefined;\n expressionElement.getValidationError = undefined;\n expressionElement.groupName = undefined;\n expressionElement.newChildLabel = undefined;\n expressionElement.templateURL = undefined;\n\n _.each(expressionElement.children, stripOffUiInformation);\n };\n\n $scope.catalogDataSource = (criteria) => catalogs.search(criteria);\n $scope.pricelistDataSource = (criteria) => pricelists.search(criteria);\n $scope.storeDataSource = (criteria) => stores.search(criteria);\n\n blade.refresh();\n}]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.assignmentListController', ['$scope', 'virtoCommerce.pricingModule.pricelistAssignments', 'platformWebApp.dialogService', 'platformWebApp.uiGridHelper', 'platformWebApp.bladeUtils', 'virtoCommerce.catalogModule.catalogs', '$localStorage',\n function ($scope, assignments, dialogService, uiGridHelper, bladeUtils, catalogs, $localStorage) {\n $scope.uiGridConstants = uiGridHelper.uiGridConstants;\n var blade = $scope.blade;\n var bladeNavigationService = bladeUtils.bladeNavigationService;\n var defaultDataRequest = {\n exportTypeName: 'VirtoCommerce.PricingModule.Data.ExportImport.ExportablePricelistAssignment',\n dataQuery: {\n exportTypeName: 'PricelistAssignmentExportDataQuery'\n }\n };\n var exportDataRequest = angular.copy(defaultDataRequest);\n var filter = blade.filter = $scope.filter = {};\n\n blade.refresh = function () {\n\n blade.isLoading = true;\n assignments.search(getSearchCriteria(), function (data) {\n //Loading catalogs for assignments because they do not contains them\n //Need to display name of catalog in assignments grid\n catalogs.search({ take: 1000, responseGroup: 'Info' }, function (results) {\n blade.isLoading = false;\n $scope.pageSettings.totalItems = data.totalCount;\n\n var priceAssignments = data.results;\n _.each(priceAssignments, function (x) {\n var catalog = _.findWhere(results.results, { id: x.catalogId });\n if (catalog) {\n x.catalog = catalog.name;\n }\n });\n\n blade.currentEntities = priceAssignments;\n });\n });\n blade.toolbarCommands[3].name = (filter.current || filter.keyword)\n ? \"pricing.commands.delete-filtered\"\n : \"pricing.commands.delete-all\";\n };\n\n $scope.selectNode = function (node, isNew) {\n $scope.selectedNodeId = node.id;\n\n var newBlade = {\n id: 'pricelistAssignmentDetail',\n controller: 'virtoCommerce.pricingModule.assignmentDetailController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/assignment-detail.tpl.html'\n };\n\n if (isNew) {\n angular.extend(newBlade, {\n isNew: true,\n pricelistId: blade.pricelistId,\n data: node,\n title: 'pricing.blades.assignment-detail.new-title'\n });\n } else {\n angular.extend(newBlade, {\n currentEntityId: node.id,\n title: node.name,\n subtitle: 'pricing.blades.assignment-detail.subtitle'\n });\n }\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n function isItemsChecked() {\n return $scope.gridApi && _.any($scope.gridApi.selection.getSelectedRows());\n }\n\n $scope.deleteList = function (list) {\n var dialog = {\n id: \"confirmDeleteItem\",\n title: \"pricing.dialogs.assignments-delete.title\",\n message: \"pricing.dialogs.assignments-delete.message\",\n callback: function (remove) {\n if (remove) {\n closeChildrenBlades();\n\n var itemIds = _.pluck(list, 'id');\n assignments.remove({ ids: itemIds }, function () {\n blade.refresh();\n }, function (error) {\n bladeNavigationService.setError('Error ' + error.status, blade);\n });\n }\n }\n };\n dialogService.showConfirmationDialog(dialog);\n };\n\n $scope.deleteAllFiltered = function () {\n var dialog = {\n id: \"confirmDeleteItems\",\n callback: function (confirm) {\n if (!confirm)\n return;\n closeChildrenBlades();\n blade.isLoading = true; \n var pricelistIds;\n if (filter.current) {\n pricelistIds = filter.current.pricelistIds;\n } else {\n pricelistIds = blade.pricelistId ? [blade.pricelistId] : [];\n }\n assignments.removeFiltered({\n pricelistIds: pricelistIds,\n keyword: filter.keyword\n }, function () {\n blade.refresh();\n });\n }\n };\n dialogService.showDialog(dialog, 'Modules/$(VirtoCommerce.Pricing)/Scripts/dialogs/deleteAll-dialog.tpl.html', 'platformWebApp.confirmDialogController');\n };\n\n function closeChildrenBlades() {\n angular.forEach(blade.childrenBlades.slice(), function (child) {\n bladeNavigationService.closeBlade(child);\n });\n }\n\n blade.headIcon = 'fa fa-anchor';\n blade.subtitle = 'pricing.blades.pricelist-assignment-list.subtitle';\n\n blade.toolbarCommands = [\n {\n name: \"platform.commands.refresh\", icon: 'fa fa-refresh',\n executeMethod: blade.refresh,\n canExecuteMethod: function () { return true; }\n },\n {\n name: \"platform.commands.add\", icon: 'fas fa-plus',\n executeMethod: function () {\n $scope.selectNode({}, true);\n },\n canExecuteMethod: function () { return true; },\n permission: 'pricing:create'\n },\n {\n name: \"platform.commands.delete\", icon: 'fas fa-trash-alt',\n executeMethod: function () {\n $scope.deleteList($scope.gridApi.selection.getSelectedRows());\n },\n canExecuteMethod: function () {\n return isItemsChecked();\n },\n permission: 'pricing:delete'\n },\n {\n name: \"pricing.commands.delete-all\",\n icon: 'fas fa-trash-alt',\n executeMethod: function () {\n $scope.deleteAllFiltered();\n },\n canExecuteMethod: function () {\n return blade.currentEntities && blade.currentEntities.length > 0;\n },\n permission: 'pricing:delete'\n },\n {\n name: \"platform.commands.export\",\n icon: 'fa fa-upload',\n canExecuteMethod: function () {\n return true;\n },\n executeMethod: function () {\n var isAllSelected = $scope.gridApi.selection.getSelectAllState();\n exportDataRequest.dataQuery.isAllSelected = isAllSelected;\n\n var selectedRows = $scope.gridApi.selection.getSelectedRows();\n\n exportDataRequest.dataQuery.objectIds = [];\n\n if ((exportDataRequest.dataQuery.objectIds && exportDataRequest.dataQuery.objectIds.length)\n || (!isAllSelected)) {\n exportDataRequest.dataQuery.objectIds = _.map(selectedRows, function (priceAssignments) {\n return priceAssignments.id;\n });\n }\n\n angular.extend(exportDataRequest.dataQuery, getSearchCriteria());\n\n var newBlade = {\n id: 'priceAssignmentExport',\n title: 'pricing.blades.exporter.priceAssignmentTitle',\n subtitle: 'pricing.blades.exporter.priceAssignmentSubtitle',\n controller: 'virtoCommerce.exportModule.exportSettingsController',\n template: 'Modules/$(VirtoCommerce.Export)/Scripts/blades/export-settings.tpl.html',\n exportDataRequest: exportDataRequest\n };\n bladeNavigationService.showBlade(newBlade, blade);\n }\n }\n ];\n\n filter.criteriaChanged = function () {\n\n if ($scope.pageSettings.currentPage > 1) {\n blade.refresh();\n $scope.pageSettings.currentPage = 1;\n } else {\n blade.refresh();\n }\n };\n // ui-grid\n $scope.setGridOptions = function (gridOptions) {\n $scope.gridOptions = gridOptions;\n\n gridOptions.onRegisterApi = function (gridApi) {\n gridApi.core.on.sortChanged($scope, function () {\n if (!blade.isLoading) blade.refresh();\n });\n };\n\n bladeUtils.initializePagination($scope);\n };\n\n function getSearchCriteria() {\n var result = {\n keyword: filter.keyword,\n sort: uiGridHelper.getSortExpression($scope),\n skip: ($scope.pageSettings.currentPage - 1) * $scope.pageSettings.itemsPerPageCount,\n take: $scope.pageSettings.itemsPerPageCount\n };\n if (filter.current) {\n result.pricelistIds = filter.current.pricelistIds;\n result.catalogIds = filter.current.catalogIds || [];\n } else {\n result.pricelistIds = blade.pricelistId ? [blade.pricelistId] : [];\n }\n\n return result;\n }\n if (!$localStorage.exportSearchFilters) {\n $localStorage.exportSearchFilters = [];\n }\n\n if (!$localStorage.exportSearchFilters[exportDataRequest.exportTypeName]) {\n $localStorage.exportSearchFilters[exportDataRequest.exportTypeName] = [{ name: 'export.blades.export-generic-viewer.labels.new-filter' }];\n }\n\n $scope.exportSearchFilters = $localStorage.exportSearchFilters[exportDataRequest.exportTypeName];\n\n if (!$localStorage.exportSearchFilterIds) {\n $localStorage.exportSearchFilterIds = [];\n }\n\n $scope.exportSearchFilterId = $localStorage.exportSearchFilterIds[exportDataRequest.exportTypeName];\n\n if ($scope.exportSearchFilterId) {\n filter.current = _.findWhere($scope.exportSearchFilters, { id: $scope.exportSearchFilterId });\n }\n\n filter.change = function () {\n $localStorage.exportSearchFilterId = filter.current ? filter.current.id : null;\n var metafieldsId = exportDataRequest.exportTypeName + 'ExportFilter';\n if (filter.current && !filter.current.id) {\n filter.current = null;\n showFilterDetailBlade({ isNew: true, metafieldsId: metafieldsId, exportTypeName: exportDataRequest.exportTypeName });\n } else {\n bladeNavigationService.closeBlade({ id: 'exportGenericViewerFilter' });\n\n if (!filter.current) {\n blade.resetRequestCustomFilter();\n }\n\n filter.criteriaChanged();\n }\n };\n\n filter.edit = function () {\n var metafieldsId = exportDataRequest.exportTypeName + 'ExportFilter';\n var filterDetailsParams = {\n data: filter.current,\n metafieldsId: metafieldsId,\n exportTypeName: exportDataRequest.exportTypeName\n };\n\n if (filter.current) {\n angular.extend(filterDetailsParams, { data: filter.current });\n }\n else {\n angular.extend(filterDetailsParams, { isNew: true });\n }\n\n showFilterDetailBlade(filterDetailsParams);\n };\n\n function showFilterDetailBlade(bladeData) {\n var newBlade = {\n id: 'exportGenericViewerFilter',\n controller: 'virtoCommerce.exportModule.exportGenericViewerFilterController',\n template: 'Modules/$(VirtoCommerce.Export)/Scripts/blades/export-generic-viewer-filter.tpl.html',\n onBeforeApply: blade.resetRequestCustomFilter\n };\n angular.extend(newBlade, bladeData);\n bladeNavigationService.showBlade(newBlade, blade);\n }\n\n filter.criteriaChanged = function () {\n blade.refresh();\n };\n\n filter.resetKeyword = function () {\n filter.keyword = undefined;\n\n if (exportDataRequest.dataQuery) {\n exportDataRequest.dataQuery.keyword = undefined;\n }\n }\n\n\n blade.resetRequestCustomFilter = function () {\n angular.copy(exportDataRequest, defaultDataRequest);\n }\n // actions on load\n //blade.refresh();\n }]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.pricelistDetailController', ['$scope', 'platformWebApp.bladeNavigationService', 'virtoCommerce.pricingModule.pricelists', 'virtoCommerce.pricingModule.pricelistsshort', 'platformWebApp.settings', 'virtoCommerce.coreModule.currency.currencyUtils',\n function ($scope, bladeNavigationService, pricelists, pricelistsshort, settings, currencyUtils) {\n var blade = $scope.blade;\n blade.updatePermission = 'pricing:update';\n\n blade.refresh = function (parentRefresh) {\n if (blade.isNew) {\n initializeBlade({ productPrices: [], assignments: [] });\n } else {\n pricelistsshort.get({ id: blade.currentEntityId }, function (data) {\n initializeBlade(data);\n if (parentRefresh) {\n blade.parentBlade.refresh();\n }\n });\n }\n };\n\n function initializeBlade(data) {\n if (!blade.isNew) {\n blade.title = data.name;\n }\n\n blade.currentEntity = angular.copy(data);\n blade.origEntity = data;\n blade.isLoading = false;\n }\n\n function isDirty() {\n return !angular.equals(blade.currentEntity, blade.origEntity) && blade.hasUpdatePermission();\n }\n\n function canSave() {\n return isDirty() && $scope.formScope && $scope.formScope.$valid;\n }\n\n $scope.cancelChanges = function () {\n angular.copy(blade.origEntity, blade.currentEntity);\n $scope.bladeClose();\n };\n $scope.saveChanges = function () {\n blade.isLoading = true;\n\n if (blade.isNew) {\n \tpricelists.save({}, blade.currentEntity, function (data) {\n \t\tangular.copy(blade.currentEntity, blade.origEntity);\n \t\t$scope.bladeClose();\n if (blade.saveCallback) {\n \tblade.saveCallback(data);\n }\n else {\n \tblade.parentBlade.refresh();\n } \n });\n } else {\n pricelists.update({}, blade.currentEntity, function (data) {\n blade.refresh(true);\n });\n }\n };\n\n $scope.setForm = function (form) { $scope.formScope = form; };\n\n blade.onClose = function (closeCallback) {\n bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, \"pricing.dialogs.pricelist-save.title\", \"pricing.dialogs.pricelist-save.message\");\n };\n\n blade.headIcon = blade.parentBlade.headIcon;\n\n function initializeToolbar() {\n if (!blade.isNew) {\n blade.toolbarCommands = [\n {\n name: \"platform.commands.save\",\n icon: 'fas fa-save',\n executeMethod: $scope.saveChanges,\n canExecuteMethod: canSave,\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.reset\",\n icon: 'fa fa-undo',\n executeMethod: function () {\n angular.copy(blade.origEntity, blade.currentEntity);\n },\n canExecuteMethod: isDirty,\n permission: blade.updatePermission\n }\n ];\n }\n }\n\n initializeToolbar();\n blade.refresh(false);\n $scope.currencyUtils = currencyUtils;\n }]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.pricelistItemListController', ['$scope', 'virtoCommerce.pricingModule.prices', '$filter', 'platformWebApp.bladeNavigationService', 'uiGridConstants', 'platformWebApp.uiGridHelper', 'platformWebApp.bladeUtils', 'platformWebApp.dialogService', '$translate', function ($scope, prices, $filter, bladeNavigationService, uiGridConstants, uiGridHelper, bladeUtils, dialogService, $translate) {\n $scope.uiGridConstants = uiGridConstants;\n $scope.noProductRowName = $translate.instant('pricing.blades.pricelist-item-list.labels.no-product-row-name');\n var blade = $scope.blade;\n var exportDataRequest = {\n exportTypeName: 'VirtoCommerce.PricingModule.Data.ExportImport.ExportablePrice',\n dataQuery: {\n exportTypeName: 'PriceExportDataQuery'\n }\n };\n\n blade.getSearchCriteria = function() {\n var result = {\n groupByProducts: true,\n pricelistIds: [blade.currentEntityId],\n keyword: filter.keyword,\n sort: uiGridHelper.getSortExpression($scope),\n skip: ($scope.pageSettings.currentPage - 1) * $scope.pageSettings.itemsPerPageCount,\n take: $scope.pageSettings.itemsPerPageCount\n }\n return result;\n }\n\n blade.refresh = function () {\n blade.isLoading = true;\n\n prices.search(blade.getSearchCriteria(), function (data) {\n blade.currentEntities = $scope.preparePrices(data.results);\n $scope.pageSettings.totalItems = data.totalCount;\n blade.totalItems = data.totalCount;\n\n blade.isLoading = false;\n }, function (error) { bladeNavigationService.setError('Error ' + error.status, blade); });\n };\n\n $scope.preparePrices = function(data) {\n _.each(data, (item) => {\n if(!item.product) {\n item.product = { name : $scope.noProductRowName};\n }\n });\n return data;\n }\n\n $scope.selectNode = function (node) {\n $scope.selectedNodeId = node.productId;\n\n var newBlade = {\n id: 'productItemPrices',\n itemId: node.productId,\n priceListId: blade.currentEntityId,\n data: node,\n currency: blade.currency,\n title: 'pricing.blades.prices-list.title',\n titleValues: { name: node.product.name },\n subtitle: 'pricing.blades.prices-list.subtitle',\n controller: 'virtoCommerce.pricingModule.pricesListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/prices-list.tpl.html'\n };\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n function openAddEntityWizard() {\n $scope.selectedNodeId = null;\n var selectedProducts = [];\n var newBlade = {\n id: \"CatalogItemsSelect\",\n title: \"Select items for pricing\", //catalogItemSelectController: hard-coded title\n controller: 'virtoCommerce.catalogModule.catalogItemSelectController',\n template: 'Modules/$(VirtoCommerce.Catalog)/Scripts/blades/common/catalog-items-select.tpl.html',\n breadcrumbs: [],\n toolbarCommands: [\n {\n name: \"pricing.commands.add-selected\", icon: 'fas fa-plus',\n executeMethod: function (blade) {\n addProductsToPricelist(selectedProducts, blade);\n },\n canExecuteMethod: function () {\n return selectedProducts.length > 0;\n }\n }]\n };\n\n newBlade.options = {\n checkItemFn: function (listItem, isSelected) {\n if (listItem.type === 'category') {\n newBlade.error = 'Categories are not supported';\n listItem.selected = undefined;\n } else {\n if (isSelected) {\n if (_.all(selectedProducts, function (x) { return x.id !== listItem.id; })) {\n selectedProducts.push(listItem);\n }\n }\n else {\n selectedProducts = _.reject(selectedProducts, function (x) { return x.id === listItem.id; });\n }\n newBlade.error = undefined;\n }\n }\n };\n\n bladeNavigationService.showBlade(newBlade, blade);\n }\n\n function addProductsToPricelist(products, theBlade) {\n theBlade.isLoading = true;\n\n // search for possible duplicating prices\n prices.search({\n priceListId: blade.currentEntityId,\n productIds: _.pluck(products, 'id')\n }, function (data) {\n var newItems = _.filter(products, function (product) {\n return _.all(data.results, function (x) {\n return x.productId !== product.id;\n })\n });\n\n var newProductPrices = _.map(newItems, function (x) {\n return {\n // productId: x.id,\n prices: [{ productId: x.id, list: 0, minQuantity: 1, currency: blade.currency, priceListId: blade.currentEntityId }]\n };\n });\n\n prices.update(newProductPrices, function () {\n bladeNavigationService.closeBlade(theBlade);\n blade.refresh();\n blade.parentWidgetRefresh();\n }, function (error) {\n bladeNavigationService.setError('Error ' + error.status, blade);\n });\n }, function (error) { bladeNavigationService.setError('Error ' + error.status, blade); });\n }\n\n $scope.deleteList = function (list) {\n var dialog = {\n id: \"confirmDeleteItem\",\n title: \"pricing.dialogs.pricelist-item-list-delete.title\",\n message: \"pricing.dialogs.pricelist-item-list-delete.message\",\n callback: function (remove) {\n if (remove) {\n bladeNavigationService.closeChildrenBlades(blade, function () {\n prices.remove({ priceListId: blade.currentEntityId, productIds: _.pluck(list, 'productId') }, function () {\n blade.refresh();\n blade.parentWidgetRefresh();\n },\n function (error) { bladeNavigationService.setError('Error ' + error.status, blade); });\n });\n }\n }\n }\n dialogService.showConfirmationDialog(dialog);\n }\n\n blade.exportPrices = function() {\n var isAllSelected = $scope.gridApi.selection.getSelectAllState();\n exportDataRequest.dataQuery.isAllSelected = isAllSelected;\n\n var selectedRows = $scope.gridApi.selection.getSelectedRows();\n\n exportDataRequest.dataQuery.objectIds = [];\n if (!isAllSelected && selectedRows) {\n var priceIds = _.pluck(_.flatten(_.pluck(selectedRows, 'prices')), 'id');\n exportDataRequest.dataQuery.objectIds = priceIds;\n }\n\n exportDataRequest.dataQuery.productIds = [];\n\n if ((exportDataRequest.dataQuery.productIds && exportDataRequest.dataQuery.productIds.length)\n || (!isAllSelected)) {\n exportDataRequest.dataQuery.productIds = _.map(selectedRows, function (product) {\n return product.productId;\n });\n }\n\n var searchCriteria = blade.getSearchCriteria();\n\n if (isAllSelected || (searchCriteria.pricelistIds && searchCriteria.pricelistIds.length > 0) || searchCriteria.keyword !== '') {\n exportDataRequest.dataQuery.isAnyFilterApplied = true;\n }\n\n angular.extend(exportDataRequest.dataQuery, searchCriteria);\n\n var newBlade = {\n id: 'priceExport',\n title: 'pricing.blades.exporter.priceTitle',\n subtitle: 'pricing.blades.exporter.priceSubtitle',\n controller: 'virtoCommerce.exportModule.exportSettingsController',\n template: 'Modules/$(VirtoCommerce.Export)/Scripts/blades/export-settings.tpl.html',\n exportDataRequest: exportDataRequest\n };\n bladeNavigationService.showBlade(newBlade, blade);\n }\n\n blade.toolbarCommands = [\n {\n name: \"platform.commands.refresh\", icon: 'fa fa-refresh',\n executeMethod: blade.refresh,\n canExecuteMethod: function () { return true; }\n },\n {\n name: \"platform.commands.add\", icon: 'fas fa-plus',\n executeMethod: openAddEntityWizard,\n canExecuteMethod: function () { return true; },\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.delete\", icon: 'fas fa-trash-alt',\n executeMethod: function () {\n $scope.deleteList($scope.gridApi.selection.getSelectedRows());\n },\n canExecuteMethod: function () {\n return $scope.gridApi && _.any($scope.gridApi.selection.getSelectedRows());\n },\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.export\",\n icon: 'fa fa-upload',\n canExecuteMethod: function () {\n return true;\n },\n executeMethod: function () {\n blade.exportPrices();\n }\n }\n ];\n\n $scope.getPriceRange = function (priceGroup) {\n var retVal;\n var allPrices = _.union(_.pluck(priceGroup.prices, 'list'), _.pluck(priceGroup.prices, 'sale'));\n var minprice = $filter('currency')(_.min(allPrices), '', 2);\n var maxprice = $filter('currency')(_.max(allPrices), '', 2);\n retVal = (minprice === maxprice ? minprice : minprice + '-' + maxprice);\n\n //else {\n // retVal = 'NO PRICE';\n //}\n\n return retVal;\n }\n\n var filter = $scope.filter = {};\n filter.criteriaChanged = function () {\n if ($scope.pageSettings.currentPage > 1) {\n $scope.pageSettings.currentPage = 1;\n } else {\n blade.refresh();\n }\n };\n\n // ui-grid\n $scope.setGridOptions = function (gridOptions) {\n $scope.gridOptions = gridOptions;\n\n gridOptions.onRegisterApi = function (gridApi) {\n gridApi.core.on.sortChanged($scope, function () {\n if (!blade.isLoading) blade.refresh();\n });\n };\n\n bladeUtils.initializePagination($scope);\n };\n\n //No need to call this because page 'pageSettings.currentPage' is watched!!! It would trigger subsequent duplicated req...\n //blade.refresh();\n }]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.pricelistListController', ['$scope', 'virtoCommerce.pricingModule.pricelists', 'platformWebApp.dialogService', 'platformWebApp.uiGridHelper', 'platformWebApp.bladeUtils', '$localStorage',\n function ($scope, pricelists, dialogService, uiGridHelper, bladeUtils, $localStorage) {\n var blade = $scope.blade;\n var bladeNavigationService = bladeUtils.bladeNavigationService;\n\n var defaultDataRequest = {\n exportTypeName: 'VirtoCommerce.PricingModule.Data.ExportImport.ExportablePricelist',\n dataQuery: {\n exportTypeName: 'PricelistExportDataQuery'\n }\n };\n var exportDataRequest = angular.copy(defaultDataRequest);\n var filter = blade.filter = $scope.filter = {};\n\n blade.refresh = function (parentRefresh) {\n blade.isLoading = true;\n return pricelists.search(getSearchCriteria(), function (data) {\n blade.isLoading = false;\n blade.currentEntities = data.results;\n $scope.pageSettings.totalItems = data.totalCount;\n\n if (parentRefresh === true && blade.parentRefresh) {\n blade.parentRefresh();\n }\n\n return data;\n }).$promise;\n };\n\n $scope.selectNode = function (node, isNew) {\n $scope.selectedNodeId = node.id;\n\n var newBlade = {\n id: 'listItemChild',\n controller: 'virtoCommerce.pricingModule.pricelistDetailController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricelist-detail.tpl.html'\n };\n\n if (isNew) {\n angular.extend(newBlade, {\n title: 'pricing.blades.pricelist-detail.title-new',\n isNew: true,\n saveCallback: function (newPricelist) {\n newBlade.isNew = false;\n blade.refresh(true).then(function () {\n newBlade.currentEntityId = newPricelist.id;\n bladeNavigationService.showBlade(newBlade, blade);\n });\n }\n // onChangesConfirmedFn: callback,\n });\n } else {\n angular.extend(newBlade, {\n currentEntityId: node.id,\n title: node.name,\n subtitle: blade.subtitle\n });\n }\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n function isItemsChecked() {\n return $scope.gridApi && _.any($scope.gridApi.selection.getSelectedRows());\n }\n\n $scope.deleteList = function (list) {\n var dialog = {\n id: \"confirmDeleteItem\",\n title: \"pricing.dialogs.pricelists-delete.title\",\n message: \"pricing.dialogs.pricelists-delete.message\",\n callback: function (remove) {\n if (remove) {\n bladeNavigationService.closeChildrenBlades(blade, function () {\n pricelists.remove({ ids: _.pluck(list, 'id') },\n function () {\n return blade.refresh(true);\n });\n });\n }\n }\n }\n dialogService.showConfirmationDialog(dialog);\n }\n\n blade.headIcon = 'fa fa-usd';\n blade.subtitle = 'pricing.blades.pricelist-list.subtitle';\n\n blade.toolbarCommands = [\n {\n name: \"platform.commands.refresh\", icon: 'fa fa-refresh',\n executeMethod: blade.refresh,\n canExecuteMethod: function () { return true; }\n },\n {\n name: \"platform.commands.add\", icon: 'fas fa-plus',\n executeMethod: function () {\n $scope.selectNode({}, true);\n },\n canExecuteMethod: function () {\n return true;\n },\n permission: 'pricing:create'\n },\n {\n name: \"platform.commands.delete\", icon: 'fas fa-trash-alt',\n executeMethod: function () {\n $scope.deleteList($scope.gridApi.selection.getSelectedRows());\n },\n canExecuteMethod: isItemsChecked,\n permission: 'pricing:delete'\n },\n {\n name: \"platform.commands.export\",\n icon: 'fa fa-upload',\n canExecuteMethod: function () {\n return true;\n },\n executeMethod: function () {\n var isAllSelected = $scope.gridApi.selection.getSelectAllState();\n exportDataRequest.dataQuery.isAllSelected = isAllSelected;\n\n var selectedRows = $scope.gridApi.selection.getSelectedRows();\n\n exportDataRequest.dataQuery.objectIds = [];\n\n if ((exportDataRequest.dataQuery.objectIds && exportDataRequest.dataQuery.objectIds.length) || (!isAllSelected)) {\n exportDataRequest.dataQuery.objectIds = _.map(selectedRows, function (pricelist) {\n return pricelist.id;\n });\n }\n\n exportDataRequest.dataQuery = angular.extend(exportDataRequest.dataQuery, getSearchCriteria());\n\n var newBlade = {\n id: 'pricelistExport',\n title: 'pricing.blades.exporter.priceListTitle',\n subtitle: 'pricing.blades.exporter.pricelistSubtitle',\n controller: 'virtoCommerce.exportModule.exportSettingsController',\n template: 'Modules/$(VirtoCommerce.Export)/Scripts/blades/export-settings.tpl.html',\n exportDataRequest: exportDataRequest,\n totalItemsCount: exportDataRequest.dataQuery.objectIds.length || $scope.pageSettings.totalItems\n\n };\n bladeNavigationService.showBlade(newBlade, blade);\n }\n }\n ];\n\n filter.criteriaChanged = function () {\n if ($scope.pageSettings.currentPage > 1) {\n $scope.pageSettings.currentPage = 1;\n } else {\n blade.refresh();\n }\n };\n\n // ui-grid\n $scope.setGridOptions = function (gridOptions) {\n $scope.gridOptions = gridOptions;\n\n gridOptions.onRegisterApi = function (gridApi) {\n gridApi.core.on.sortChanged($scope, function () {\n if (!blade.isLoading) blade.refresh();\n });\n };\n\n bladeUtils.initializePagination($scope);\n };\n\n\n\n if (!$localStorage.exportSearchFilters) {\n $localStorage.exportSearchFilters = {};\n }\n\n if (!$localStorage.exportSearchFilters[exportDataRequest.exportTypeName]) {\n $localStorage.exportSearchFilters[exportDataRequest.exportTypeName] = [{ name: 'export.blades.export-generic-viewer.labels.new-filter' }];\n }\n\n $scope.exportSearchFilters = $localStorage.exportSearchFilters[exportDataRequest.exportTypeName];\n\n if (!$localStorage.exportSearchFilterIds) {\n $localStorage.exportSearchFilterIds = {};\n }\n\n $scope.exportSearchFilterId = $localStorage.exportSearchFilterIds[exportDataRequest.exportTypeName];\n\n if ($scope.exportSearchFilterId) {\n filter.current = _.findWhere($scope.exportSearchFilters, { id: $scope.exportSearchFilterId });\n }\n\n filter.change = function () {\n $localStorage.exportSearchFilterIds[exportDataRequest.exportTypeName] = filter.current ? filter.current.id : null;\n\n var metafieldsId = exportDataRequest.exportTypeName + 'ExportFilter';\n if (filter.current && !filter.current.id) {\n filter.current = null;\n showFilterDetailBlade({ isNew: true, metafieldsId: metafieldsId, exportTypeName: exportDataRequest.exportTypeName });\n } else {\n bladeNavigationService.closeBlade({ id: 'exportGenericViewerFilter' });\n\n if (!filter.current) {\n blade.resetRequestCustomFilter();\n }\n\n filter.criteriaChanged();\n }\n };\n\n filter.edit = function () {\n var metafieldsId = exportDataRequest.exportTypeName + 'ExportFilter';\n var filterDetailsParams = {\n data: filter.current,\n metafieldsId: metafieldsId,\n exportTypeName: exportDataRequest.exportTypeName\n };\n\n if (filter.current) {\n angular.extend(filterDetailsParams, { data: filter.current });\n }\n else {\n angular.extend(filterDetailsParams, { isNew: true });\n }\n\n showFilterDetailBlade(filterDetailsParams);\n };\n\n function showFilterDetailBlade(bladeData) {\n var newBlade = {\n id: 'exportGenericViewerFilter',\n controller: 'virtoCommerce.exportModule.exportGenericViewerFilterController',\n template: 'Modules/$(VirtoCommerce.Export)/Scripts/blades/export-generic-viewer-filter.tpl.html',\n onBeforeApply: blade.resetRequestCustomFilter\n };\n angular.extend(newBlade, bladeData);\n bladeNavigationService.showBlade(newBlade, blade);\n }\n\n filter.criteriaChanged = function () {\n blade.refresh();\n };\n\n filter.resetKeyword = function () {\n filter.keyword = undefined;\n\n if (exportDataRequest.dataQuery) {\n exportDataRequest.dataQuery.keyword = undefined;\n }\n }\n\n blade.resetRequestCustomFilter = function () {\n angular.copy(exportDataRequest, defaultDataRequest);\n }\n\n function getSearchCriteria() {\n var result = {\n keyword: filter.keyword,\n sort: uiGridHelper.getSortExpression($scope),\n skip: ($scope.pageSettings.currentPage - 1) * $scope.pageSettings.itemsPerPageCount,\n take: $scope.pageSettings.itemsPerPageCount,\n responseGroup: \"NoDetails\"\n };\n\n if (filter.current) {\n result.currencies = filter.current.currencies;\n }\n return result;\n }\n\n // actions on load\n //blade.refresh();\n }]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.pricesListController', ['$scope', 'virtoCommerce.pricingModule.prices', 'platformWebApp.objCompareService', 'platformWebApp.bladeNavigationService', 'platformWebApp.uiGridHelper', 'virtoCommerce.pricingModule.priceValidatorsService', 'platformWebApp.ui-grid.extension', function ($scope, prices, objCompareService, bladeNavigationService, uiGridHelper, priceValidatorsService, gridOptionExtension) {\n $scope.uiGridConstants = uiGridHelper.uiGridConstants;\n var blade = $scope.blade;\n blade.updatePermission = 'pricing:update';\n\n blade.refresh = function () {\n blade.data.productId = blade.itemId;\n if (!blade.data.prices) {\n blade.data.prices = [];\n }\n\n blade.currentEntities = angular.copy(blade.data.prices);\n blade.origEntity = blade.data.prices;\n blade.isLoading = false;\n priceValidatorsService.setAllPrices(blade.currentEntities);\n };\n\n blade.onClose = function (closeCallback) {\n bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, \"pricing.dialogs.prices-save.title\", \"pricing.dialogs.prices-save.message\");\n };\n\n function isDirty() {\n return blade.currentEntities && !objCompareService.equal(blade.origEntity, blade.currentEntities) && blade.hasUpdatePermission()\n }\n\n function canSave() {\n return isDirty() && $scope.isValid();\n }\n\n $scope.cancelChanges = function () {\n $scope.bladeClose();\n };\n\n $scope.isValid = function () {\n return $scope.formScope && $scope.formScope.$valid &&\n _.all(blade.currentEntities, $scope.isListPriceValid) &&\n _.all(blade.currentEntities, $scope.isSalePriceValid) &&\n _.all(blade.currentEntities, $scope.isUniqueQty) &&\n (blade.currentEntities.length === 0 || _.some(blade.currentEntities, function (x) { return x.minQuantity === 1; }));\n }\n\n $scope.saveChanges = function () {\n blade.isLoading = true;\n\n angular.copy(blade.currentEntities, blade.origEntity);\n if (_.any(blade.currentEntities)) {\n prices.update({ id: blade.itemId }, blade.data, function (data) {\n $scope.bladeClose();\n blade.parentBlade.refresh();\n },\n function (error) { bladeNavigationService.setError('Error ' + error.status, $scope.blade); });\n }\n else {\n prices.remove({ priceListId: blade.priceListId, productIds: [blade.itemId] }, function () {\n $scope.bladeClose();\n blade.parentBlade.refresh();\n },\n function (error) { bladeNavigationService.setError('Error ' + error.status, blade); });\n }\n };\n\n $scope.delete = function (listItem) {\n if (listItem) {\n blade.currentEntities.splice(blade.currentEntities.indexOf(listItem), 1);\n }\n };\n\n $scope.setForm = function (form) { $scope.formScope = form; };\n\n blade.toolbarCommands = [\n {\n name: \"platform.commands.save\", icon: 'fas fa-save',\n executeMethod: $scope.saveChanges,\n canExecuteMethod: canSave,\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.reset\", icon: 'fa fa-undo',\n executeMethod: function () {\n angular.copy(blade.origEntity, blade.currentEntities);\n },\n canExecuteMethod: isDirty,\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.add\", icon: 'fas fa-plus',\n executeMethod: function () { addNewPrice(blade.currentEntities); },\n canExecuteMethod: function () { return true; },\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.delete\", icon: 'fas fa-trash-alt',\n executeMethod: function () {\n var selection = $scope.gridApi.selection.getSelectedRows();\n angular.forEach(selection, function (listItem) {\n blade.currentEntities.splice(blade.currentEntities.indexOf(listItem), 1);\n });\n },\n canExecuteMethod: function () {\n return $scope.gridApi && _.any($scope.gridApi.selection.getSelectedRows());\n },\n permission: blade.updatePermission\n }\n ];\n\n function addNewPrice(targetList) {\n var newEntity = { productId: blade.itemId, list: '', minQuantity: 1, currency: blade.currency, priceListId: blade.priceListId };\n targetList.push(newEntity);\n $scope.validateGridData();\n }\n\n $scope.isListPriceValid = priceValidatorsService.isListPriceValid;\n $scope.isSalePriceValid = priceValidatorsService.isSalePriceValid;\n $scope.isUniqueQty = priceValidatorsService.isUniqueQty;\n\n // ui-grid\n $scope.setGridOptions = function (gridId, gridOptions) {\n gridOptions.onRegisterApi = function (gridApi) {\n $scope.gridApi = gridApi;\n\n gridApi.edit.on.afterCellEdit($scope, function () {\n //to process validation for all rows in grid.\n //e.g. if we have two rows with the same count of min qty, both of this rows will be marked as error.\n //when we change data to valid in one row, another one should became valid too.\n //more info about ui-grid validation: https://github.com/angular-ui/ui-grid/issues/4152\n $scope.validateGridData();\n });\n\n $scope.validateGridData();\n };\n\n $scope.gridOptions = gridOptions;\n gridOptionExtension.tryExtendGridOptions(gridId, gridOptions);\n return gridOptions;\n };\n\n $scope.validateGridData = function () {\n if ($scope.gridApi) {\n angular.forEach(blade.currentEntities, function (rowEntity) {\n angular.forEach($scope.gridOptions.columnDefs, function (colDef) {\n $scope.gridApi.grid.validate.runValidators(rowEntity, colDef, rowEntity[colDef.name], undefined, $scope.gridApi.grid)\n });\n });\n }\n };\n\n $scope.datepickers = {};\n $scope.open = function ($event, which) {\n $event.preventDefault();\n $event.stopPropagation();\n $scope.datepickers[which] = true;\n };\n\n // actions on load\n blade.refresh();\n}])\n\n.factory('virtoCommerce.pricingModule.priceValidatorsService', [function () {\n var allPrices = {};\n return {\n setAllPrices: function (data) {\n allPrices = data;\n },\n isListPriceValid: function (data) {\n return data.list >= 0;\n },\n isSalePriceValid: function (data) {\n return _.isUndefined(data.sale) || data.list >= data.sale;\n },\n isUniqueQty: function (data) {\n // Disable unique quantity test when time filtering is used.\n if (data.startDate || data.endData) {\n return true;\n }\n return Math.round(data.minQuantity) > 0 && _.all(allPrices, function (x) { return x === data || Math.round(x.minQuantity) !== Math.round(data.minQuantity) || x.startDate || x.EndDate; });\n },\n isUniqueQtyForPricelist: function (data) {\n // Disable unique quantity test when time filtering is used.\n return Math.round(data.minQuantity) > 0 && _.filter(allPrices, function (price) { return price.pricelistId === data.pricelistId && price.minQuantity === data.minQuantity && !price.startDate && !price.EndDate && !data.startDate && !data.endDate; }).length <= 1;\n }\n };\n}])\n\n.run(\n ['platformWebApp.ui-grid.extension', 'virtoCommerce.pricingModule.priceValidatorsService', 'uiGridValidateService', function (gridOptionExtension, priceValidatorsService, uiGridValidateService) {\n \n uiGridValidateService.setValidator('listValidator', function (argument) {\n return function (oldValue, newValue, rowEntity, colDef) {\n // We should not test for existence here\n return _.isUndefined(newValue) || priceValidatorsService.isListPriceValid(rowEntity);\n };\n }, function (argument) { return 'List price is invalid '; });\n\n uiGridValidateService.setValidator('saleValidator', function (argument) {\n return function (oldValue, newValue, rowEntity, colDef) {\n return priceValidatorsService.isSalePriceValid(rowEntity);\n };\n }, function (argument) { return 'Sale price should not exceed List price'; });\n\n uiGridValidateService.setValidator('minQuantityValidator', function () {\n return function (oldValue, newValue, rowEntity, colDef) {\n return priceValidatorsService.isUniqueQty(rowEntity);\n };\n }, function () { return 'Quantity value should be unique'; });\n\n uiGridValidateService.setValidator('minQuantityForPricelistValidator', function () {\n return function (oldValue, newValue, rowEntity, colDef) {\n return priceValidatorsService.isUniqueQtyForPricelist(rowEntity);\n };\n }, function () { return 'Quantity value should be unique'; });\n }]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.pricingMainController', ['$scope', 'platformWebApp.bladeNavigationService', function ($scope, bladeNavigationService) {\n $scope.selectedNodeId = null;\n\n function initializeBlade() {\n var entities = [\n { name: 'pricing.blades.pricing-main.menu.pricelist-list.title', entityName: 'pricelist', icon: 'fa fa-usd' },\n { name: 'pricing.blades.pricing-main.menu.pricelist-assignment-list.title', entityName: 'assignment', icon: 'fa fa-anchor' }];\n $scope.blade.currentEntities = entities;\n $scope.blade.isLoading = false;\n\n $scope.blade.openBlade(entities[0]);\n };\n\n $scope.blade.openBlade = function (data) {\n $scope.selectedNodeId = data.entityName;\n\n var newBlade = {\n id: 'pricingList',\n title: data.name,\n controller: 'virtoCommerce.pricingModule.'+ data.entityName + 'ListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/' + data.entityName + '-list.tpl.html'\n };\n bladeNavigationService.showBlade(newBlade, $scope.blade);\n }\n\n $scope.blade.headIcon = 'fa fa-usd';\n\n initializeBlade();\n}]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.itemPricelistsListController', ['$scope', 'platformWebApp.bladeNavigationService', 'uiGridConstants', 'virtoCommerce.pricingModule.prices', 'virtoCommerce.catalogModule.catalogs', function ($scope, bladeNavigationService, uiGridConstants, prices, catalogs) {\n $scope.uiGridConstants = uiGridConstants;\n var blade = $scope.blade;\n\n blade.refresh = function () {\n \tblade.isLoading = true;\n \tprices.getProductPricelists({ id: blade.itemId }, function (pricelists) {\n \t //Loading catalogs for pricelists because they do not contains them\n \t //Need to display name of catalog in product item pricelists grid\n catalogs.search({ take: 1000, responseGroup: 'Info' }, function (catalogsList) {\n \t blade.isLoading = false;\n \t blade.currentEntities = [];\n \t _.each(pricelists, function (x) {\n \t if (x.prices.length > 0) {\n \t var pricelist = {\n \t priority: _.max(x.assignments, function (assignment) { return assignment.priority; }).priority\n \t };\n \t angular.extend(pricelist, x);\n \t pricelist.assignments = [x.assignment];\n\n \t var catalogsId = _.pluck(x.assignments, 'catalogId');\n \t var catalogsName = _.map(catalogsId, function (catalogId) {\n return _.findWhere(catalogsList.results, { id: catalogId }).name;\n });\n \t pricelist.catalog = catalogsName.join(', ');\n \t blade.currentEntities.push(pricelist);\n \t }\n \t });\n \t });\n\n \t\tif (!pricelists.length) {\n \t\t\tvar newPricelistBlade = {\n \t\t\t\tid: 'newPricelist',\n \t\t\t\tcontroller: 'virtoCommerce.pricingModule.pricelistDetailController',\n \t\t\t\ttemplate: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricelist-detail.tpl.html',\n \t\t\t\ttitle: 'pricing.blades.pricelist-detail.title-new',\n \t\t\t\tisNew: true,\n \t\t\t\tsaveCallback: function (pricelist) {\n \t\t\t\t\tblade.refresh();\n \t\t\t\t}\n \t\t\t};\n \t\t\tbladeNavigationService.showBlade(newPricelistBlade, blade);\n \t\t}\n \t});\n }\n\n $scope.openBlade = function (data) {\n $scope.selectedNodeId = data.id;\n\n var newBlade = {\n id: \"itemPrices\",\n itemId: blade.itemId,\n priceListId: data.id,\n data: data,\n currency: data.currency,\n title: data.name,\n subtitle: 'pricing.blades.prices-list.subtitle',\n controller: 'virtoCommerce.pricingModule.pricesListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/prices-list.tpl.html'\n };\n bladeNavigationService.showBlade(newBlade, blade);\n }\n\n blade.headIcon = 'fa fa-usd';\n blade.toolbarCommands = [\n {\n name: \"platform.commands.refresh\", icon: 'fa fa-refresh',\n executeMethod: blade.refresh,\n canExecuteMethod: function () {\n return true;\n }\n }\t\n ];\n\n // ui-grid\n $scope.setGridOptions = function (gridOptions) {\n $scope.gridOptions = gridOptions;\n };\n\n blade.refresh();\n}]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.itemPriceListController', ['$scope', 'platformWebApp.bladeNavigationService', 'uiGridConstants', 'virtoCommerce.pricingModule.prices', 'virtoCommerce.catalogModule.catalogs', 'virtoCommerce.storeModule.stores', 'platformWebApp.ui-grid.extension', 'platformWebApp.objCompareService', 'virtoCommerce.pricingModule.priceValidatorsService', 'platformWebApp.dialogService',\n function ($scope, bladeNavigationService, uiGridConstants, prices, catalogs, stores, gridOptionExtension, objCompareService, priceValidatorsService, dialogService) {\n $scope.uiGridConstants = uiGridConstants;\n var blade = $scope.blade;\n blade.updatePermission = 'pricing:update';\n\n blade.refresh = function() {\n blade.isLoading = true;\n prices.getProductPricelists({ id: blade.itemId },\n function (pricelists) {\n //Loading catalogs for assignments because they do not contains them\n //Need to display name of catalog in assignments grid\n catalogs.search({ take: 1000, responseGroup: 'Info' }, function (catalogData) {\n stores.search({ take: 1000, responseGroup: 'StoreInfo' }, function (storeData) {\n $scope.catalogsList = catalogData.results;\n $scope.storeList = storeData.results;\n\n blade.origEntity = [];\n\n //Collect all available pricelists\n blade.pricelistList = _.map(pricelists,\n function (pricelist) {\n return {\n id: pricelist.id,\n code: pricelist.name,\n currency: pricelist.currency,\n assignments: pricelist.assignments,\n displayName: pricelist.name + ' - ' + pricelist.currency\n };\n });\n blade.selectedPricelist = _.first(blade.pricelistList);\n\n var pricelistsWithPrices = _.filter(pricelists,\n function (pricelist) { return pricelist.prices.length > 0; });\n _.each(pricelistsWithPrices,\n function (pricelistWithPrices) {\n var priceListData = {\n name: pricelistWithPrices.name,\n currency: pricelistWithPrices.currency\n };\n\n var catalogsId = _.pluck(_.filter(pricelistWithPrices.assignments, function (assignemnt) { return assignemnt.catalogId }), 'catalogId');\n var catalogsName = _.map(catalogsId,\n function (catalogId) {\n var catalog = _.findWhere($scope.catalogsList, { id: catalogId });\n return catalog ? catalog.name : null;\n });\n priceListData.catalog = catalogsName.join(', ');\n\n var storeIds = _.pluck(_.filter(pricelistWithPrices.assignments, function (assignemnt) { return assignemnt.storeId }), 'storeId');\n var storeName = _.map(storeIds,\n function (storeId) {\n var store = _.findWhere($scope.storeList, { id: storeId });\n return store ? store.name : null;\n });\n priceListData.store = storeName.join(', ');\n\n _.each(pricelistWithPrices.prices,\n function (price) {\n var priceData = angular.copy(priceListData);\n priceData = angular.extend(price, priceData);\n blade.origEntity.push(priceData);\n });\n });\n\n blade.currentEntities = angular.copy(blade.origEntity);\n priceValidatorsService.setAllPrices(blade.currentEntities);\n blade.isLoading = false;\n }); \n });\n });\n };\n\n $scope.createNewPricelist = function () {\n var newBlade = {\n id: 'pricingList',\n controller: 'virtoCommerce.pricingModule.pricelistListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricelist-list.tpl.html',\n title: 'pricing.blades.pricing-main.menu.pricelist-list.title',\n parentRefresh: blade.refresh\n };\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n $scope.selectPricelist = function (entity) {\n var newBlade = {\n id: 'listItemChild',\n currentEntityId: entity.pricelistId,\n title: entity.name,\n controller: 'virtoCommerce.pricingModule.pricelistDetailController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricelist-detail.tpl.html'\n };\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n blade.onClose = function (closeCallback) {\n bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, \"pricing.dialogs.prices-save.title\", \"pricing.dialogs.prices-save.message\");\n };\n\n function isDirty() {\n return blade.currentEntities && !objCompareService.equal(blade.origEntity, blade.currentEntities) && blade.hasUpdatePermission()\n }\n\n function canSave() {\n return isDirty() && $scope.isValid();\n }\n\n $scope.isValid = function () {\n return $scope.formScope && $scope.formScope.$valid &&\n _.all(blade.currentEntities, $scope.isListPriceValid) &&\n _.all(blade.currentEntities, $scope.isSalePriceValid) &&\n _.all(blade.currentEntities, $scope.isUniqueQtyForPricelist) &&\n (blade.currentEntities.length == 0 || _.some(blade.currentEntities, function (x) { return x.minQuantity == 1; }));\n }\n\n $scope.saveChanges = function () {\n blade.isLoading = true;\n\n angular.copy(blade.currentEntities, blade.origEntity);\n if (_.any(blade.currentEntities)) {\n var productPrices = {\n productId: blade.itemId,\n product: blade.item,\n prices: blade.currentEntities\n };\n prices.update({ id: blade.itemId }, productPrices, function (data) {\n blade.refresh();\n },\n function (error) { bladeNavigationService.setError('Error ' + error.status, $scope.blade); });\n }\n };\n\n $scope.setForm = function (form) { $scope.formScope = form; }\n\n blade.toolbarCommands = [\n {\n name: \"platform.commands.save\",\n icon: 'fas fa-save',\n executeMethod: $scope.saveChanges,\n canExecuteMethod: canSave,\n permission: blade.updatePermission\n },\n {\n name: \"platform.commands.delete\",\n icon: 'fas fa-trash-alt',\n executeMethod: function () {\n var selection = $scope.gridApi.selection.getSelectedRows();\n var ids = _.map(selection, function (item) { return item.id; });\n\n if (selection.some(x => x.minQuantity == 1)) {\n var unselected = _.difference(blade.currentEntities, selection);\n\n if (unselected.length && !unselected.some(x => x.minQuantity == 1)) {\n var errorDialog = {\n id: \"itemDeleteError\",\n title: \"pricing.dialogs.item-prices-delete-error.title\",\n message: \"pricing.dialogs.item-prices-delete-error.message\"\n }\n dialogService.showErrorDialog(errorDialog);\n return;\n }\n }\n\n var dialog = {\n id: \"confirmDeleteItem\",\n title: \"pricing.dialogs.item-prices-delete-confirmation.title\",\n message: \"pricing.dialogs.item-prices-delete-confirmation.message\",\n callback: function (remove) {\n if (remove) {\n prices.removePrice({ priceIds: ids }, function () {\n //blade.refresh();\n angular.forEach(selection, function (listItem) {\n blade.currentEntities.splice(blade.currentEntities.indexOf(listItem), 1);\n });\n }, function (error) {\n bladeNavigationService.setError('Error ' + error.status, blade);\n });\n }\n }\n }\n dialogService.showConfirmationDialog(dialog);\n },\n canExecuteMethod: function () {\n return $scope.gridApi && _.any($scope.gridApi.selection.getSelectedRows());\n },\n permission: 'pricing:delete'\n },\n {\n name: \"platform.commands.refresh\",\n icon: 'fa fa-refresh',\n executeMethod: blade.refresh,\n canExecuteMethod: function () { return true; }\n }\n ];\n\n blade.addNewPrice = function (targetPricelist) {\n //populate prices data for correct work of validation service\n priceValidatorsService.setAllPrices(blade.currentEntities);\n\n var catalogsId = _.pluck(targetPricelist.assignments, 'catalogId');\n var catalogsName = _.map(catalogsId, function (catalogId) {\n var catalog = _.findWhere($scope.catalogsList, { id: catalogId });\n return catalog ? catalog.name : null;\n });\n catalogsName = _.filter(catalogsName, function (catalogName) { return catalogName !== null; });\n\n var storesId = _.pluck(targetPricelist.assignments, 'storeId');\n var storesName = _.map(storesId, function (storeId) {\n var store = _.findWhere($scope.storeList, { id: storeId });\n return store ? store.name : null;\n });\n storesName = _.filter(storesName, function (storeName) { return storeName !== null; });\n\n var newPrice = {\n productId: blade.itemId,\n list: '',\n minQuantity: 1,\n currency: targetPricelist.currency,\n pricelistId: targetPricelist.id,\n name: targetPricelist.code,\n catalog: catalogsName.join(', '),\n store: storesName.join(', ')\n };\n blade.currentEntities.push(newPrice);\n $scope.validateGridData();\n }\n\n $scope.isListPriceValid = priceValidatorsService.isListPriceValid;\n $scope.isSalePriceValid = priceValidatorsService.isSalePriceValid;\n $scope.isUniqueQtyForPricelist = priceValidatorsService.isUniqueQtyForPricelist;\n\n // ui-grid\n $scope.setGridOptions = function (gridId, gridOptions) {\n gridOptions.onRegisterApi = function (gridApi) {\n $scope.gridApi = gridApi;\n\n gridApi.edit.on.afterCellEdit($scope, function () {\n //to process validation for all rows in grid.\n //e.g. if we have two rows with the same count of min qty, both of this rows will be marked as error.\n //when we change data to valid in one row, another one should became valid too.\n //more info about ui-grid validation: https://github.com/angular-ui/ui-grid/issues/4152\n $scope.validateGridData();\n });\n\n $scope.validateGridData();\n };\n\n $scope.gridOptions = gridOptions;\n gridOptionExtension.tryExtendGridOptions(gridId, gridOptions);\n return gridOptions;\n };\n\n $scope.validateGridData = function () {\n if ($scope.gridApi) {\n angular.forEach(blade.currentEntities, function (rowEntity) {\n angular.forEach($scope.gridOptions.columnDefs, function (colDef) {\n $scope.gridApi.grid.validate.runValidators(rowEntity, colDef, rowEntity[colDef.name], undefined, $scope.gridApi.grid)\n });\n });\n }\n };\n\n $scope.datepickers = {};\n $scope.open = function ($event, which) {\n $event.preventDefault();\n $event.stopPropagation();\n $scope.datepickers[which] = true;\n };\n\n blade.refresh();\n}]);\n","angular.module('virtoCommerce.pricingModule')\n .factory('virtoCommerce.pricingModule.prices', ['$resource', function ($resource) {\n return $resource('api/products/:id/prices', { id: '@Id', catalogId: '@catalogId' }, {\n search: { url: 'api/catalog/products/prices/search' },\n getProductPrices: { isArray: true }, // is also used in other modules\n getProductPricesForWidget: { url: 'api/products/:id/:catalogId/pricesWidget', isArray: true },\n getProductPricelists: { url: 'api/catalog/products/:id/pricelists', isArray: true },\n update: { method: 'PUT' },\n remove: { method: 'DELETE', url: 'api/pricing/pricelists/:priceListId/products/prices' },\n removePrice: { method: 'DELETE', url: 'api/pricing/products/prices' }\n });\n }])\n .factory('virtoCommerce.pricingModule.pricelists', ['$resource', function ($resource) {\n return $resource('api/pricing/pricelists/:id', {}, {\n search: { url: 'api/pricing/pricelists' },\n update: { method: 'PUT' }\n });\n }])\n .factory('virtoCommerce.pricingModule.pricelistsshort', ['$resource', function ($resource) {\n return $resource('api/pricing/pricelistsshort/:id', {}, {\n search: { url: 'api/pricing/pricelists' },\n update: { method: 'PUT' }\n });\n }])\n .factory('virtoCommerce.pricingModule.pricelistAssignments', ['$resource', function ($resource) {\n return $resource('api/pricing/assignments/:id', { id: '@Id' }, {\n search: { url: 'api/pricing/assignments' },\n getNew: { url: 'api/pricing/assignments/new' },\n update: { method: 'PUT' },\n removeFiltered: { method: 'DELETE', url: 'api/pricing/filteredAssignments' }\n });\n }]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.catalogSelectorController', ['$scope', 'virtoCommerce.catalogModule.catalogs', function ($scope, catalogs) {\n catalogs.search({ take: 1000 }, function (result) {\n $scope.catalogs = angular.copy(result.results);\n });\n }]);\n","angular.module('virtoCommerce.pricingModule')\n .controller('virtoCommerce.pricingModule.currencySelectorController',\n [\n '$scope', 'virtoCommerce.coreModule.currency.currencyUtils',\n function($scope, currencyUtils) {\n $scope.currencies = currencyUtils.getCurrencies();\n }\n ]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.pricelistSelectorController', ['$scope', 'virtoCommerce.pricingModule.pricelists', function ($scope, pricelists) {\n pricelists.search({ take: 1000 }, function (result) {\n \t$scope.pricelists = result.results;\n });\n}]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.productSelectorController', ['$scope', 'platformWebApp.bladeNavigationService', function ($scope, bladeNavigationService) {\n var blade = $scope.blade;\n\n $scope.selectedCount = (blade.currentEntity.productIds || []).length;\n \n $scope.selectProducts = function () {\n var selection = blade.currentEntity.productIds || [];\n var options = {\n allowCheckingCategory: false,\n selectedItemIds: selection,\n checkItemFn: function (listItem, isSelected) {\n if (isSelected) {\n if (!_.find(selection, function (x) { return x.id == listItem.id; })) {\n selection.push(listItem.id);\n }\n }\n else {\n selection = _.reject(selection, function (x) { return x.id == listItem.id; });\n }\n }\n };\n var newBlade = {\n id: \"CatalogItemsSelect\",\n controller: 'virtoCommerce.catalogModule.catalogItemSelectController',\n template: 'Modules/$(VirtoCommerce.Catalog)/Scripts/blades/common/catalog-items-select.tpl.html',\n title: 'pricing.selectors.blades.titles.select-products',\n options: options,\n breadcrumbs: [],\n toolbarCommands: [\n {\n name: \"platform.commands.confirm\", icon: 'fa fa-check',\n executeMethod: function (pickingBlade) {\n blade.currentEntity.productIds = _.union(blade.currentEntity.productIds, selection);\n $scope.selectedCount = blade.currentEntity.productIds.length;\n bladeNavigationService.closeBlade(pickingBlade);\n },\n canExecuteMethod: function () {\n return _.any(selection);\n }\n }]\n };\n bladeNavigationService.showBlade(newBlade, blade);\n }\n}]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.assignmentsWidgetController', ['$scope', 'platformWebApp.bladeNavigationService', 'virtoCommerce.pricingModule.pricelistAssignments', function ($scope, bladeNavigationService, assignments) {\n\tvar blade = $scope.widget.blade;\n\tfunction refresh(pricelist) {\n\t\tif (pricelist) {\n\t\t\t$scope.widget.assignmentsCount = pricelist.assignments ? pricelist.assignments.length : 0;\n\t\t\tif (pricelist.id) {\n\t\t\t\treturn assignments.search({\n\t\t\t\t\tpriceListId: pricelist.id,\n\t\t\t\t\ttake: 0\n\t\t\t\t}, function (data) {\n\t\t\t\t\t$scope.widget.assignmentsCount = data.totalCount;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n $scope.openBlade = function () {\n var newBlade = {\n id: \"pricelistChild\",\n pricelistId: blade.currentEntity.id,\n currentEntity: blade.currentEntity,\n title: blade.title,\n subtitle: 'pricing.blades.pricelist-assignment-list.subtitle',\n controller: 'virtoCommerce.pricingModule.assignmentListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/assignment-list.tpl.html'\n };\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n $scope.$watch(\"widget.blade.currentEntity\", function (pricelist) {\n \trefresh(pricelist);\n });\n\n}]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.itemPricesWidgetController', ['$scope', '$filter', 'platformWebApp.bladeNavigationService', 'virtoCommerce.pricingModule.pricelists', 'virtoCommerce.pricingModule.prices', '$state', function ($scope, $filter, bladeNavigationService, pricelists, prices, $state) {\n var blade = $scope.blade;\n\n function refresh() {\n $scope.loading = true;\n return prices.getProductPricesForWidget({ id: blade.itemId, catalogId: blade.catalog.id }, function (productPrices) {\n $scope.loading = false;\n if (productPrices.length) {\n productPrices = _.groupBy(productPrices, 'currency');\n productPrices = _.max(_.values(productPrices), function (x) { return x.length; });\n var allPrices = _.union(_.pluck(productPrices, 'list'), _.pluck(productPrices, 'sale'));\n var minprice = _.min(allPrices);\n var maxprice = _.max(allPrices);\n var currency = _.any(productPrices) ? productPrices[0].currency : '';\n minprice = $filter('currency')(minprice, currency);\n maxprice = $filter('currency')(maxprice, currency);\n $scope.priceLabel = (minprice == maxprice ? minprice : minprice + ' - ' + maxprice);\n }\n return productPrices;\n });\n }\n\n $scope.openBlade = function () {\n if ($scope.loading)\n return;\n\n var productPricelistsBlade = {\n id: \"itemPrices\",\n itemId: blade.itemId,\n item: blade.item,\n parentWidgetRefresh: refresh,\n title: 'pricing.blades.item-prices.title',\n titleValues: { name: blade.item.name },\n subtitle: 'pricing.blades.item-prices.subtitle',\n controller: 'virtoCommerce.pricingModule.itemPriceListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/item/item-prices.tpl.html'\n };\n bladeNavigationService.showBlade(productPricelistsBlade, blade);\n };\n\n $scope.$watch(\"widget.blade.catalog.id\", function (id) {\n if (id) refresh();\n });\n\n}]);\n","angular.module('virtoCommerce.pricingModule')\n.controller('virtoCommerce.pricingModule.pricesWidgetController', ['$scope', 'platformWebApp.bladeNavigationService', 'virtoCommerce.pricingModule.prices', function ($scope, bladeNavigationService, prices) {\n var blade = $scope.widget.blade;\n\n function refresh() {\n $scope.priceCount = '...';\n\n prices.search({\n priceListId: blade.currentEntityId,\n take: 0\n }, function (data) {\n $scope.priceCount = data.totalCount;\n });\n }\n\n $scope.openBlade = function () {\n var newBlade = {\n id: \"pricelistChild\",\n currency: blade.currentEntity.currency,\n currentEntity: blade.currentEntity,\n currentEntityId: blade.currentEntityId,\n parentWidgetRefresh: refresh,\n title: blade.title,\n subtitle: 'pricing.blades.pricelist-item-list.subtitle',\n controller: 'virtoCommerce.pricingModule.pricelistItemListController',\n template: 'Modules/$(VirtoCommerce.Pricing)/Scripts/blades/pricelist-item-list.tpl.html'\n };\n\n bladeNavigationService.showBlade(newBlade, blade);\n };\n\n refresh();\n}]);"],"names":["moduleName","undefined","AppDependencies","push","angular","module","config","$stateProvider","state","url","templateUrl","controller","$scope","bladeNavigationService","showBlade","id","title","subtitle","template","isClosingDisabled","run","$http","$compile","mainMenuService","widgetService","$state","authService","metaFormsService","genericViewerItemService","menuItem","path","icon","priority","action","go","permission","addMenuItem","itemPricesWidget","isVisible","blade","checkPermission","size","registerWidget","isNew","get","then","response","data","registerMetaFields","name","valueType","registerViewer","item","itemCopy","copy","itemId","productId","priceListId","pricelistId","prices","currency","titleValues","currentEntityId","catalogs","pricelists","assignments","stores","dynamicExpressionService","dialogService","initializeBlade","expressionBlock","extend","dynamicExpression","_","each","children","extendElementBlock","results","groupBy","availableChildren","map","items","key","displayName","subitems","currentEntity","origEntity","isLoading","toolbarCommands","executeMethod","saveChanges","canExecuteMethod","canSave","updatePermission","isDirty","equals","hasUpdatePermission","formScope","$valid","validateAssignment","storeId","catalogId","retVal","expressions","stripOffUiInformation","expressionElement","getValidationError","groupName","newChildLabel","templateURL","pageSize","refresh","parentRefresh","getNew","isFunction","parentBlade","setForm","form","cancelChanges","bladeClose","save","error","setError","status","update","showErrorDialog","message","onClose","closeCallback","showConfirmationIfNeeded","datepickers","str","end","open","$event","which","preventDefault","stopPropagation","catalogDataSource","criteria","search","pricelistDataSource","storeDataSource","uiGridHelper","bladeUtils","$localStorage","uiGridConstants","defaultDataRequest","exportTypeName","dataQuery","exportDataRequest","filter","closeChildrenBlades","forEach","childrenBlades","slice","child","closeBlade","getSearchCriteria","result","keyword","sort","getSortExpression","skip","pageSettings","currentPage","itemsPerPageCount","take","current","pricelistIds","catalogIds","showFilterDetailBlade","bladeData","newBlade","onBeforeApply","resetRequestCustomFilter","responseGroup","totalItems","totalCount","priceAssignments","x","catalog","findWhere","currentEntities","selectNode","node","selectedNodeId","deleteList","list","dialog","callback","remove","itemIds","pluck","ids","showConfirmationDialog","deleteAllFiltered","confirm","removeFiltered","showDialog","headIcon","gridApi","selection","getSelectedRows","any","length","isAllSelected","getSelectAllState","selectedRows","objectIds","criteriaChanged","setGridOptions","gridOptions","onRegisterApi","core","on","sortChanged","initializePagination","exportSearchFilters","exportSearchFilterIds","exportSearchFilterId","change","metafieldsId","edit","filterDetailsParams","resetKeyword","pricelistsshort","settings","currencyUtils","productPrices","saveCallback","$filter","$translate","noProductRowName","instant","addProductsToPricelist","products","theBlade","productIds","newItems","product","all","newProductPrices","minQuantity","parentWidgetRefresh","groupByProducts","preparePrices","exportPrices","priceIds","flatten","searchCriteria","isAnyFilterApplied","selectedProducts","breadcrumbs","options","checkItemFn","listItem","isSelected","type","selected","reject","getPriceRange","priceGroup","allPrices","union","minprice","min","maxprice","max","currencies","$promise","newPricelist","pricelist","totalItemsCount","objCompareService","priceValidatorsService","gridOptionExtension","equal","isValid","setAllPrices","isListPriceValid","isSalePriceValid","isUniqueQty","some","delete","splice","indexOf","targetList","newEntity","validateGridData","gridId","afterCellEdit","tryExtendGridOptions","rowEntity","columnDefs","colDef","grid","validate","runValidators","factory","isUndefined","sale","startDate","endData","Math","round","EndDate","isUniqueQtyForPricelist","price","endDate","uiGridValidateService","setValidator","argument","oldValue","newValue","entities","openBlade","entityName","getProductPricelists","catalogsList","assignment","catalogsId","catalogsName","join","newPricelistBlade","catalogData","storeData","storeList","pricelistList","code","selectedPricelist","first","pricelistsWithPrices","pricelistWithPrices","priceListData","assignemnt","storeIds","storeName","store","priceData","createNewPricelist","selectPricelist","entity","unselected","difference","removePrice","addNewPrice","targetPricelist","catalogName","storesId","storesName","newPrice","$resource","getProductPrices","isArray","getProductPricesForWidget","method","getCurrencies","selectedCount","selectProducts","allowCheckingCategory","selectedItemIds","find","pickingBlade","widget","$watch","assignmentsCount","loading","values","priceLabel","productPricelistsBlade","priceCount"],"sourceRoot":""}