Pārlūkot izejas kodu

cikkszamozas utan status update, uj termek hozzaadasa

master
Dukai Károly pirms 3 gadiem
vecāks
revīzija
c0c9b0c9d4
6 mainītis faili ar 52 papildinājumiem un 11 dzēšanām
  1. +4
    -0
      modules/custom/arlista/css/arlista.css
  2. +13
    -4
      modules/custom/arlista/js/arlista.js
  3. +2
    -0
      modules/custom/arlista/src/Factory/ProductFactory.php
  4. +26
    -0
      modules/custom/arlista/src/Form/Product/ProductAdd.php
  5. +6
    -6
      modules/custom/arlista/src/Form/Product/ProductUploadedList.php
  6. +1
    -1
      modules/custom/arlista/src/Service/CacheService.php

+ 4
- 0
modules/custom/arlista/css/arlista.css Parādīt failu

@@ -119,4 +119,8 @@ div.author,
span.hide-roller,
tr.correct-files-uploaded-file.row-for-hiding {
display: none;
}

div.form-type-number > label {
min-width: 33%;
}

+ 13
- 4
modules/custom/arlista/js/arlista.js Parādīt failu

@@ -255,6 +255,7 @@
revokeAxicoId: revokeAxicoId
};
let url = drupalSettings.arlista.host + "/update/category";
updateWorkFlowOnNumberingEvent(revokeAxicoId > 0, selected);
postPackageToUrl(package, url, false, selected);
});

@@ -340,7 +341,7 @@
success: function (data, status, xhr) {
$('html,body').css('cursor', 'initial');
selected.prop('disabled', false);
console.log(data);
//console.log(data);
$('#edit-axico-id-warranty-length').val(data.data)
return;
@@ -383,9 +384,18 @@
};

let url = drupalSettings.arlista.host + "/update/component";
updateWorkFlowOnNumberingEvent(revokeAxicoId > 0, selected);
postPackageToUrl(package, url, false, selected);
});

function updateWorkFlowOnNumberingEvent(revoking, selected){
let workFlow = 'NUMBERED';
if(revoking){
workFlow = 'COMPARED';
}
selected.closest('tr').children().last().find('.product-work-flow').val(workFlow);
}

/*
* # Update selected products component on select change
*/
@@ -496,7 +506,7 @@
$("#default_status_select").change(function (e) {
e.preventDefault();
let selected = $(this);
console.log(selected.val());
//console.log(selected.val());
if (selected.val() === 2 || selected.val() === "2") {
$("#enable-group-calculation-list").show();
}
@@ -521,7 +531,7 @@
method: "POST",
data: package,
success: function (data, status, xhr) {
console.log(data);
//console.log(data);
$('html,body').css('cursor', 'initial');
if(!data.success && redirect){
alert(data.message);
@@ -534,7 +544,6 @@
window.location.replace(document.URL);
}
if (selected) {
console.log('here');
let id = package.pid;
selected.closest('td').prev().text(data.data.axicoId[id]);
if (!data.data.axicoId[id]) {

+ 2
- 0
modules/custom/arlista/src/Factory/ProductFactory.php Parādīt failu

@@ -414,6 +414,8 @@ class ProductFactory extends AbstractFactory {
$product->setParentCategoryId(null);
$product->setParentComponentId(null);
$product->setWarranty(0);
$product->setAxicoId(null);
$product->setWorkFlow(WorkFlow::COMPARED);
$product = $this->save($product);
$result['optionValues'][$product->getId()] = $revokeAxicoIdselectOptionValue;
$result['revokedProducts'][$product->getId()] = $product;

+ 26
- 0
modules/custom/arlista/src/Form/Product/ProductAdd.php Parādīt failu

@@ -89,6 +89,7 @@ class ProductAdd extends ArlistaAbstractForm {
'#weight' => 30,
];
$sheetSetting = $this->getSheetSettingFactory()->findSettingBySheetIndex($manufacturer->getId(), $this->sheetIndex);

$enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSetting->getId(), $manufacturer->isComponentBased());
$options = [];
$options[0] = 'Kérem válasszon';
@@ -291,6 +292,15 @@ class ProductAdd extends ArlistaAbstractForm {
$form_state->setErrorByName('warranty', 'A garancia csak számjegyeket tartalmazhat (* egész hónapok száma)');
}
}
$manufacturer = $this->getManufacturerFactory()->find($this->mid);
if((!$manufacturer->isComponentBased() && (int) $form_state->getValue('category') == 0)
|| ($manufacturer->isComponentBased() && (int) $form_state->getValue('component') == 0)){
$errorName = 'category';
if($manufacturer->isComponentBased()){
$errorName = 'component';
}
$form_state->setErrorByName($errorName, 'Nincs termékcsoport vagy komponenscsoport!');
}
}

/**
@@ -352,6 +362,22 @@ class ProductAdd extends ArlistaAbstractForm {
];
$result = $this->getProductFactory()->compareProducts($result);
$result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result);

$product = $result['products'][0];
if ($product->isComponentBased()) {
$component = $this->getComponentFactory()->find($product->getParentComponentId());
$calculation = $this->getCalculationFactory()->findByComponent($component);
$calculation->setExchangeRate($this->getCalculationFactory()->getExchangeRate($product->getCurrency()));
} else {
$category = $this->getCategoryFactory()->find($product->getParentCategoryId());
$manufacturer = $this->getManufacturerFactory()->find($product->getParentManufacturerId());
$calculation = $this->getCalculationFactory()->findByManufacturerAndCategory($manufacturer, $category);
$calculation->setExchangeRate($this->getCalculationFactory()->getExchangeRate($product->getCurrency()));
}
$product->setCalculation($calculation);
$product->setCorrectStatus(Status::UJ);
$product->calculatePrices();
\Drupal::messenger()->addStatus('Sikeres mentés!');


+ 6
- 6
modules/custom/arlista/src/Form/Product/ProductUploadedList.php Parādīt failu

@@ -231,10 +231,10 @@ class ProductUploadedList extends ArlistaAbstractForm {
}
$this->manufacturersList = $this->getComponentManufacturersList($enabledComponents);
$this->enabledComponents = $enabledComponents;
$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(),
$sheetSetting->getId(), 'enabled_components'], $enabledComponents);
$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(),
$sheetSetting->getId(), 'enabled_components_manufacturers_list'], $this->manufacturersList);
//$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(),
// $sheetSetting->getId(), 'enabled_components'], $enabledComponents);
//$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(),
// $sheetSetting->getId(), 'enabled_components_manufacturers_list'], $this->manufacturersList);
} else {
$categories = $this->getCategoryFactory()->findAll('axico_id_name', 'ASC');
/* @var $category Category */
@@ -244,8 +244,8 @@ class ProductUploadedList extends ArlistaAbstractForm {
}
}
$this->enabledCategories = $enabledCategories;
$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(),
$sheetSetting->getId(), 'enabled_categories'], $enabledCategories);
//$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(),
// $sheetSetting->getId(), 'enabled_categories'], $enabledCategories);
}
}


+ 1
- 1
modules/custom/arlista/src/Service/CacheService.php Parādīt failu

@@ -24,7 +24,7 @@ class CacheService {
}

private function getStoringTime() : int {
return 24 * 60 * 60;
return 1 * 1 * 1;
}

public function getCachedDataByName(array $nameElements) {

Notiek ielāde…
Atcelt
Saglabāt