1
0
Fork 0
mirror of synced 2025-04-14 22:51:01 +00:00

Правка подключения js функций

Правка js
Правка вывода кнопок
Добавление переводов
Правка подстановки кастомных свойств новому профилю
This commit is contained in:
Ivan Chaplygin 2024-12-03 17:27:58 +03:00
parent 20ba4844df
commit 9a2d4b9c67
8 changed files with 126 additions and 92 deletions
intaro.retailcrm

View file

@ -553,7 +553,7 @@ if ($STEP === 1) {
<?php } ?>
</select>
<button id="delete-custom-row" class="adm-btn-save" type="button">Удалить</button>
<button id="delete-custom-row" class="adm-btn-save" type="button" style="margin-left: 10px"><?= GetMessage('DELETE_PROPERTY');?></button>
</td>
<?php } ?>
</tr>
@ -562,7 +562,7 @@ if ($STEP === 1) {
?>
</tbody>
</table>
<button class="adm-btn-save add-custom-row" type="button"><?= GetMessage('ADD_PROPERTY');?></button>
<button class="adm-btn-save add-custom-row" type="button" style="margin-top: 10px;"><?= GetMessage('ADD_PROPERTY');?></button>
<br>
<br>
</div>
@ -582,7 +582,7 @@ if ($STEP === 1) {
</td>
<td class="adm-list-table-cell">
<select name="iblockPropertySku_" id="iiblockPropertySku_" class="property-export" onchange="propertyChange(this)" style="width: 200px"></select>
<button id="delete-new-custom-row" class="adm-btn-save" type="button">Удалить</button>
<button id="delete-new-custom-row" class="adm-btn-save" type="button" style="margin-left: 10px"><?= GetMessage('DELETE_PROPERTY');?></button>
</td>
</tr>
</template>
@ -681,6 +681,87 @@ if ($STEP === 1) {
<?php CJSCore::Init(['jquery']);?>
<?php CUtil::InitJSCore(['intaro_custom_props']); ?>
<script type="text/javascript">
$('.add-custom-row').click(function () {
createCustomPropsRaw($(this));
});
$(document).on('click', '#delete-new-custom-row', function () {
deleteCustomPropRow($(this));
});
$(document).on('click', '#delete-custom-row', function () {
let buttonElem = $(this);
addCustomPropToDelete(buttonElem);
deleteCustomPropRow(buttonElem);
});
$(document).on('blur', 'input[name="custom-property-title"]', function () {
let inputElem = $(this);
let newPropertyTitle = inputElem.val();
if (!newPropertyTitle) {
return;
}
let newPropertyCode = getUniquePropertyCode(newPropertyTitle);
addCustomPropCodeToSelectAttributes(newPropertyCode, inputElem);
});
$('#submit-form').submit(function (formEvent) {
formEvent.preventDefault();
let savePromise = null;
let deletePromise = null;
let formElem = formEvent.currentTarget;
let profileId = $($('input[name="PROFILE_ID"]')).val();
setCustomProperties();
if (Object.keys(customProps).length > 0) {
savePromise = BX.ajax.runAction('intaro:retailcrm.api.customexportprops.save', {
json: {
properties: customProps,
profileId: profileId
},
}).then(addParamsToSetupFieldsList());
}
if (Object.keys(customPropsToDelete).length > 0) {
deletePromise = BX.ajax.runAction('intaro:retailcrm.api.customexportprops.delete', {
json: {
properties: customPropsToDelete,
profileId: profileId
},
}).then(deleteParamsFromSetupFieldsList());
}
const promises = [savePromise, deletePromise].filter(Boolean);
if (promises.length > 0) {
Promise.all(promises)
.finally(() => {
formElem.submit();
});
} else {
formElem.submit();
}
});
const setupFieldsListElement = $('input[name="SETUP_FIELDS_LIST"]');
let customProps = {};
let customPropsToDelete = {};
const setupFieldsParamsToFill = [
'iblockPropertySku_',
'iblockPropertyUnitSku_',
'iblockPropertyProduct_',
'iblockPropertyUnitProduct_',
'highloadblockb_hlsys_marking_code_group_',
'highloadblock_productb_hlsys_marking_code_group_',
'highloadblockeshop_color_reference_',
'highloadblock_producteshop_color_reference_',
'highloadblockeshop_brand_reference_',
'highloadblock_producteshop_brand_reference_'
];
function checkLoadStatus(object)
{
if (object.checked) {

View file

@ -51,7 +51,7 @@ $arJsConfig = [
'rel' => [],
],
'intaro_custom_props' => [
'js' => '/bitrix/js/intaro/custom-props-export.js',
'js' => '/bitrix/js/intaro/export/custom-props-export.js',
'rel' => [],
],
];

View file

@ -1,83 +1,3 @@
const setupFieldsListElement = $('input[name="SETUP_FIELDS_LIST"]');
let customProps = {};
let customPropsToDelete = {};
const setupFieldsParamsToFill = [
'iblockPropertySku_',
'iblockPropertyUnitSku_',
'iblockPropertyProduct_',
'iblockPropertyUnitProduct_',
'highloadblockb_hlsys_marking_code_group_',
'highloadblock_productb_hlsys_marking_code_group_',
'highloadblockeshop_color_reference_',
'highloadblock_producteshop_color_reference_',
'highloadblockeshop_brand_reference_',
'highloadblock_producteshop_brand_reference_'
];
$('.add-custom-row').click(function () {
createCustomPropsRaw($(this));
});
$(document).on('click', '#delete-new-custom-row', function () {
deleteCustomPropRow($(this));
});
$(document).on('click', '#delete-custom-row', function () {
let buttonElem = $(this);
addCustomPropToDelete(buttonElem);
deleteCustomPropRow(buttonElem);
});
$(document).on('blur', 'input[name="custom-property-title"]', function () {
let inputElem = $(this);
let newPropertyTitle = inputElem.val();
if (!newPropertyTitle) {
return;
}
let newPropertyCode = getUniquePropertyCode(newPropertyTitle);
addCustomPropCodeToSelectAttributes(newPropertyCode, inputElem);
});
$('#submit-form').submit(function (formEvent) {
formEvent.preventDefault();
let savePromise = null;
let deletePromise = null;
let formElem = formEvent.currentTarget;
let profileId = $($('input[name="PROFILE_ID"]')).val();
setCustomProperties();
if (Object.keys(customProps).length > 0) {
savePromise = BX.ajax.runAction('intaro:retailcrm.api.customexportprops.save', {
json: {
properties: customProps,
profileId: profileId
},
}).then(addParamsToSetupFieldsList());
}
if (Object.keys(customPropsToDelete).length > 0) {
deletePromise = BX.ajax.runAction('intaro:retailcrm.api.customexportprops.delete', {
json: {
properties: customPropsToDelete,
profileId: profileId
},
}).then(deleteParamsFromSetupFieldsList());
}
const promises = [savePromise, deletePromise].filter(Boolean);
if (promises.length > 0) {
Promise.all(promises)
.finally(() => {
formElem.submit();
});
} else {
formElem.submit();
}
});
function deleteCustomPropRow(deleteButton)
{

View file

@ -47,3 +47,5 @@ $MESS['BASE_PRICE'] = 'Base price';
$MESS['WAIT'] = 'Loading...';
$MESS["OFFERS_VALUE"] = "Maximum number of trade offers for a product";
$MESS["LOAD_NON_ACTIVITY"] = "Unload inactive products, services and trade offers";
$MESS["ADD_PROPERTY"] = "Add property";
$MESS["DELETE_PROPERTY"] = "Delete";

View file

@ -47,4 +47,5 @@ $MESS["UNIT_MEASUREMENT_KG"] = "кг.";
$MESS['BASE_PRICE'] = 'Базовая цена';
$MESS['WAIT'] = 'Загрузка...';
$MESS["OFFERS_VALUE"] = "Максимальное количество торговых предложений у товара";
$MESS["ADD_PROPERTY"] = "Добавить";
$MESS["ADD_PROPERTY"] = "Добавить свойство";
$MESS["DELETE_PROPERTY"] = "Удалить";

View file

@ -34,11 +34,15 @@ trait InstallerTrait
$file->putContents("");
}
$pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . Constants::MODULE_ID . '/install/export/bitrix/js/intaro/custom-props-export.js';
$pathFrom = $_SERVER['DOCUMENT_ROOT'] .
'/bitrix/modules/' .
Constants::MODULE_ID .
'/install/export/bitrix/js/intaro/export'
;
CopyDirFiles(
$pathFrom,
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/intaro',
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/intaro/export/',
true,
true,
false

View file

@ -147,11 +147,12 @@ class SettingsService
$this->getPriceTypes();
$this->getVatRates();
$this->exportProfileId = $profileId ?? 'tmp';
$this->exportProfileId = $profileId ?? '0';
$this->profileCatalogsOptionName = sprintf('exportProfileId_%s_catalogs', $this->exportProfileId);
//$this->setProfileCatalogsOptionName();//Установка названия каталога смысла не вижу от метода
$this->linkNewProfile();
$this->deleteEmptyProfileCatalogs();
$this->deleteUnusedOptions();
$this->customPropList = $this->getNewProps();//получаеют свойства с разделениекм на каталоги. Но не понял при чем custom в названии
$this->defaultPropList = $this->getIblockPropsPreset(); //названия базовых свойств (код свойства для icml - перевод)
@ -187,6 +188,31 @@ class SettingsService
];
}
private function deleteUnusedOptions()
{
//здесь удаление из b_options удаленных профилей
/* if (CModule::IncludeModule("sale")) {
$profiles = CSaleExport::GetList(['ID' => 'DESC'], ['NAME' => 'retailcrm']);
$ids = [];
while ($profile = $profiles->Fetch()) {
$ids[(int) $profile['ID']] = (int) $profile['ID'];
break;
}
if ($ids === []) {
return;
}
sort($ids);
for ($i = 0; $i < end($ids); ++$i) {
}
}*/
}
private function getPriceTypes()
{
$dbPriceType = CCatalogGroup::GetList(['SORT' => 'ASC'], [], [], [], ['ID', 'NAME', 'BASE']);
@ -934,7 +960,7 @@ class SettingsService
$currentProfileCatalogs = unserialize(COption::GetOptionString(self::MODULE_ID, $this->profileCatalogsOptionName));
if (!$currentProfileCatalogs) {
$tmpProfileName = 'exportProfileId_tmp_catalogs';
$tmpProfileName = 'exportProfileId_0_catalogs';
$currentProfileCatalogs = unserialize(COption::GetOptionString(self::MODULE_ID, $tmpProfileName));
if ($currentProfileCatalogs) {
@ -948,7 +974,7 @@ class SettingsService
$propsCatalog = unserialize(COption::GetOptionString(self::MODULE_ID, $optionName));
if (!$propsCatalog) {
$tmpOptionName = sprintf('exportCustomProps_ProfileId_%s_catalogId_%s', 'tmp', $catalogId);
$tmpOptionName = sprintf('exportCustomProps_ProfileId_%s_catalogId_%s', '0', $catalogId);
$propsCatalog = unserialize(COption::GetOptionString(self::MODULE_ID, $tmpOptionName));
if ($propsCatalog) {

View file

@ -1192,11 +1192,11 @@ function update()
function loadJsExport()
{
$pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/install/export/bitrix/js/intaro/custom-props-export.js';
$pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/install/export/bitrix/js/intaro/export';
CopyDirFiles(
$pathFrom,
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/intaro',
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/intaro/export/',
true,
true,
false