PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/
popup
angular.module('ui.popup') .service('popup_product', ['popup_product_option_combination','popup_product_bulk_price','$file_manager','communication','popup_form','$templateCache','$filter',function(popup_product_option_combination,popup_product_bulk_price,$file_manager,communication,popup_form,$templateCache,$filter) { this.open = function(opt) { opt = opt || {}; return popup_form.open({ name:'product', data:opt.data, controller: function($scope) { var popupProductCategoryTree_recursiveTpl = '<i class="jstree-icon" ng-click="openCategoryItem(item)"></i>'+ '<i class="jstree-cat-icon"></i>'+ '<input type="checkbox" value="{{item.value}}" ng-model="item.checked" ng-change="selectedCategory()" />'+ '<label>{{item.name}}</label>'+ '<ul class="jstree">' + '<li ng-class="{\'jstree-close\': angular.isDefined(item.items) && item.opened,\'jstree-leaf\':!angular.isDefined(item.items) }" ng-repeat="item in item.items" ng-include="\'popupProductCategoryTree_recursiveTpl.html\'" ng-model="item">' + '</li>'+ '</ul>'; $templateCache.put('popupProductCategoryTree_recursiveTpl.html', popupProductCategoryTree_recursiveTpl); communication.getList('product_categories', {},'ecommerce.catalog.category').then(function(json) { $scope.product_categories_list = angular.copy(json); mergeCategories(); }); if($scope.data != undefined && $scope.data.main_category != undefined && $scope.data.main_category.id != undefined) { $scope.data.default_category_id = $scope.data.main_category.id } communication.getList('taxClass', {}).then( function(json) { $scope.taxes = json; }); $scope.showMorePrice=0; /* $scope.data.optionset_id = $scope.data.optionset_id || 0; $scope.data.optionset_rules = $scope.data.optionset_rules || []; communication.getList('option_sets', {}, 'ecommerce.catalog.product').then( function(json) { $scope.option_sets = json; mergeVariants(); }); var processOptionsetRule = function(rule) { var options = $scope.option_sets[$scope.data.optionset_id]; var opts = rule.options; for(var i = 0;i < opts.length;i++) { } } var getSelectedOptionset = function() { for(var i = 0;i < $scope.option_sets.length;i++) { if($scope.data.optionset_id == $scope.option_sets[i].id) return $scope.option_sets[i]; } } var refactorOptionRule = function(rule) { var selected_option_set = getSelectedOptionset(); if(selected_option_set.options == undefined) return; var option_string = selected_option_set.name + ':'; var seperator = ''; for(var i = 0;i < selected_option_set.options.length;i++) { var option = selected_option_set.options[i]; var rule_options = rule.options; var rule_string = ''; for(var j = 0;j < rule_options.length;j++) { var rule_option = rule_options[i]; var option_items = option.option_items; if(rule_option.id == option.id) { var value = rule_option.value; if(value== undefined) { continue; } if(Array.isArray(value)) { var kv = []; for(var k = 0; k < value.length;k++) { for(var l = 0; l < option_items.length;l++) { if(option_items[l].id == value[k]) { kv.push(option_items[l].name); } } } rule_string = kv.join(window.t('LBL_OR')); } else { for(var l = 0; l < option_items.length;l++) { if(option_items[l].id == value) { rule_string = option_items[l].name; } } } } option_string += seperator + rule_string; } } rule.option_string = option_string; } $scope.addOptionSetRule = function() { popup_product_option_combination.open({ product_id: $scope.data.id || 0, option_set:getSelectedOptionset() }).result.then(function(result) { refactorOptionRule(result); $scope.data.optionset_rules.push(result); }); } */ $scope.data.status = $scope.data.status || 1; $scope.data.weight = $scope.data.weight || 0; $scope.data.price = $scope.data.price || 0; var images = []; if($scope.data.images != undefined) { for(var i in $scope.data.images ) { if(!$scope.data.images.hasOwnProperty(i)) continue; images.push($scope.data.images[i]['url']); } } $scope.data.images = images; if($scope.data.images.length == 0 && $scope.data.image !=undefined && $scope.data.image.length > 0) { $scope.data.images.push($scope.data.image); } $scope.onUploadComplete = function(files) { if(files!= undefined && files.length > 0) { var file = files[0].response; $scope.data.images.push(file.full_url) ; } }; $scope.removeImage = function(index) { $scope.data.images.splice(index,1) ; } $scope.editImage = function(index) { $file_manager.open().result.then(function(images) { if(images.length == 0) return; var image = images[0]; $scope.data.images[index] = (image.full_url) ; }); } $scope.addImage = function() { $file_manager.open().result.then(function(images) { if(images.length == 0) return; for(var i = 0; i < images.length;i++) { var image = images[i]; $scope.data.images.push(image.full_url) ; } }); } $scope.addAttribute = function() { $scope.data.product_attributes = $scope.data.product_attributes || []; $scope.data.product_attributes.push({name:'', value:'',group_name:''}); } $scope.deleteAttribute = function(index) { $scope.data.product_attributes = $scope.data.product_attributes || []; $scope.data.product_attributes.splice(index, 1); } var mergeCategories = function() { function checkCat(cat) { if($scope.data.categories != undefined) { for(var i = 0;i < $scope.data.categories.length;i++) { if($scope.data.categories[i].id == cat.id) cat.checked = true; } if(angular.isDefined(cat.items)) { for(var i = 0;i < cat.items.length;i++) { checkCat(cat.items[i]); } } } } for(var i = 0;i < $scope.product_categories_list.length;i++) { checkCat($scope.product_categories_list[i]); } $scope.selectedCategories= angular.copy($scope.data.categories); } $scope.selectedCategories=[]; $scope.selectedCategory = function() { $scope.selectedCategories=[]; function checkCat(cat) { if(cat.checked) $scope.selectedCategories.push(cat); if(angular.isDefined(cat.items)) { for(var i = 0;i < cat.items.length;i++) { checkCat(cat.items[i]); } } } for(var i = 0;i < $scope.product_categories_list.length;i++) { checkCat($scope.product_categories_list[i]); } $scope.data.categories = $scope.selectedCategories; } /*$scope.bulk_prices = []; var product_id = $scope.data.id || 0; if(product_id != 0) { communication.api('getBulk_Prices',{id:product_id},'ecommerce.catalog.product').then(function(json) { $scope.bulk_prices = json; }); } $scope.addBulkPrice = function() { $scope.bulk_prices.push({curr_symbol_right:$scope.curr_symbol_right,curr_symbol_left:$scope.curr_symbol_left}); } $scope.deleteBulkPrice = function(index) { $scope.bulk_prices.splice(index, 1); } $scope.changeAmountType = function(index) { var amount_type = $scope.bulk_prices[index].amount_type; switch(amount_type) { case 1: case 3: case '1': case '3': $scope.bulk_prices[index].curr_symbol_right = $scope.curr_symbol_right; $scope.bulk_prices[index].curr_symbol_left = $scope.curr_symbol_left; break; case 2: case '2': default: $scope.bulk_prices[index].curr_symbol_right = '%'; $scope.bulk_prices[index].curr_symbol_left = ''; break; } } $scope.data.product_variants = []; var mergeVariants = function() { $scope.selected_option_set = getSelectedOptionset(); if($scope.data.skus != undefined) { var skus_options = $scope.data.skus_options; var option_sets = $scope.option_sets; for(var i in $scope.data.skus) { if(!$scope.data.skus.hasOwnProperty(i)) continue; var variant = angular.copy($scope.data.skus[i]); if(skus_options != undefined) { variant.options = []; for(var j in skus_options) { if(!skus_options.hasOwnProperty(j)) continue; if(skus_options[j].products_sku_id == variant.id) { variant.options .push({id:skus_options[j].option_id, value:skus_options[j].value}); } } } $scope.data.product_variants.push(variant); } } } $scope.addVariant = function() { $scope.selected_option_set = getSelectedOptionset(); var opts = []; for(var i = 0;i < $scope.selected_option_set.options.length;i++ ) { opt = {id: $scope.selected_option_set.options[i].id, value:''}; opts.push(opt); } var new_variant = { options:opts }; $scope.data.product_variants.push(new_variant); } $scope.changeOptionSet = function() { $scope.selected_option_set = getSelectedOptionset(); $scope.data.product_variants = []; console.log($scope.selected_option_set); } $scope.generateVariants = function() { } $scope.deleteVariant = function(index) { $scope.data.product_variants.splice(index,1); } $scope.editVariant = function(index) { }*/ }, size:'lg', execute_path:'ecommerce.catalog.product', form_name:'ProductForm' }); } }]);
[+]
..
[-] profile.js
[edit]
[-] pagelist.js
[edit]
[-] order.js
[edit]
[-] customer_group.js
[edit]
[-] module_list.js
[edit]
[-] backgroundeditor.js
[edit]
[-] product.js
[edit]
[-] visualcsseditor.js
[edit]
[-] shipping_rule.js
[edit]
[-] profile_change_password.js
[edit]
[-] review.js
[edit]
[-] contributor_invite.js
[edit]
[-] dbfilter.js
[edit]
[-] tax_class.js
[edit]
[-] special_module_style_editor.js
[edit]
[-] idletimeout.js
[edit]
[-] address.js
[edit]
[-] contributor.js
[edit]
[-] login.js
[edit]
[-] skin.js
[edit]
[-] mail.js
[edit]
[-] discount.js
[edit]
[-] customer.js
[edit]
[-] productgrid.js
[edit]
[-] socialsharebuttonconfig.js
[edit]
[-] news.js
[edit]
[-] color.js
[edit]
[-] palette.js
[edit]
[-] newsgrid.js
[edit]
[-] product_option_combination_grid.js
[edit]
[-] page.js
[edit]
[-] product_option.js
[edit]
[-] tax_rate.js
[edit]
[-] coupons.js
[edit]
[-] zone.js
[edit]
[-] product_bulk_price.js
[edit]
[-] option_set.js
[edit]
[-] product_option_combination.js
[edit]