Skip to content

Commit

Permalink
Merge pull request #7 from Galamoon/master
Browse files Browse the repository at this point in the history
v0.8.0
  • Loading branch information
shvykov committed Dec 12, 2018
2 parents 0d9dda8 + 3294603 commit 4ffac38
Show file tree
Hide file tree
Showing 10 changed files with 471 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Released]

## [0.8.0] - 2018-11-15
- Добавлен генератор номера мобильного телефона
- Добавлена настройка отображения детализации при генерации элементов
- Небольшие исправления

## [0.7.1] - 2018-10-18
### Fix
- Исправления генератора типа список
Expand Down
8 changes: 8 additions & 0 deletions admin/entity_profile_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@
value="20"> <?= Loc::getMessage('YLAB_DDATA_GENERATE_DURATION_COUNT') ?>
</td>
</tr>
<tr>
<td width="40%" class="adm-detail-content-cell-l">
<?= Loc::getMessage("YLAB_DDATA_GENERATE_DETAIL") ?>
</td>
<td class="adm-detail-content-cell-r">
<input type="checkbox" id="detail" name="detail" value="Y" checked>
</td>
</tr>
<?
$tabControl->BeginNextTab();
$tabControl->Buttons();
Expand Down
180 changes: 180 additions & 0 deletions admin/fragments/random_mobile_number_prepare_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?php
/**
* @global $arRequest
* @global $arOptions
* @global $sPropertyCode
*/

use Bitrix\Main\Localization\Loc;
use Ylab\Ddata\LoadUnits;

Loc::loadMessages(__FILE__);

$oRequest = \Bitrix\Main\Application::getInstance()->getContext()->getRequest();
$sEntityID = $oRequest->get('generator');
$oClasses = new LoadUnits();
$arClassesData = $oClasses->getDataUnits();

$arEntity = [];
foreach ($arClassesData as $arClass) {
if ($arClass['ID'] == $sEntityID) {
$arData = $arClass;
}
}

$oData = new $arData['CLASS']($sProfileID, $sPropertyCode, $sGeneratorID);
$arCode = $oData->arCode;
$arNumbersStart = $oData->arStart;
$arNumbersFinish = $oData->arFinish;
$sCountryCode = $oData->sCountryCode;
$sGenerationOption = $oData->sGenerationOption;
$arRangeNumbers = $oData->arRangeNumbers;
?>
<script type='text/javascript'>
BX.ready(function () {
var inputOptions = BX.findChild(
BX(document),
{
attribute: {
'name': '<?= $sPropertyName ?>[<?= $sGeneratorID ?>]'
}
},
true,
true
)[0];
if (inputOptions) {
var optionsValue = JSON.parse(inputOptions.value);
}
if (inputOptions != undefined) {
Object.keys(optionsValue).forEach(function (key, item) {
var optionsForm = BX.findChild(
BX('WindowEntityDataForm'),
{
attribute: {
'name': 'option[' + key + ']'
}
},
true,
true
)[0];
if (optionsForm) {
optionsForm.value = optionsValue[key];
}
});
}
var generationConstructorWrapper = BX.findChild(
document,
{
attribute: {
'class': 'generation-constructor'
}
},
true,
true
);
var generationRangeWrapper = BX.findChild(
document,
{
attribute: {
'class': 'generation-range'
}
},
true,
true
);
BX.bind(BX('generation'), 'change', function () {
changeGenerationOption(this.value)
});
changeGenerationOption(BX('generation').value);
function changeGenerationOption(sOption) {
if (sOption === 'constructor') {
generationRangeWrapper.forEach(function (value) {
BX.style(value, 'display', 'none')
});
generationConstructorWrapper.forEach(function (value) {
BX.style(value, 'display', 'table-row')
});
} else if (sOption === 'range') {
generationRangeWrapper.forEach(function (value) {
BX.style(value, 'display', 'table-row')
});
generationConstructorWrapper.forEach(function (value) {
BX.style(value, 'display', 'none')
});
} else {
generationRangeWrapper.forEach(function (value) {
BX.style(value, 'display', 'none')
});
generationConstructorWrapper.forEach(function (value) {
BX.style(value, 'display', 'none')
});
}
}
});
</script>
<table class="adm-detail-content-table edit-table">
<tbody>
<tr>
<td width="40%" class="adm-detail-content-cell-l"><?= Loc::getMessage("YLAB_SMS_MOBILE_NUMBER_COUNTRY_CODE") ?></td>
<td width="60%" class="adm-detail-content-cell-r">
<input type="text" name="option[country-code]" value="<?= $sCountryCode ?>">
</td>
</tr>
<tr>
<td width="40%" class="adm-detail-content-cell-l"><?= Loc::getMessage("YLAB_SMS_MOBILE_NUMBER_GENERATION_OPTION") ?></td>
<td width="60%" class="adm-detail-content-cell-r">
<select name="option[generation-option]" id="generation">
<option value=""><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_CHOOSE_VALUE") ?></option>
<option value="constructor" <?= $sGenerationOption == 'constructor' ? 'selected' : '' ?>><?= Loc::getMessage("YLAB_SMS_MOBILE_NUMBER_GENERATION_OPTION_CONSTRUCTOR") ?></option>
<option value="range" <?= $sGenerationOption == 'range' ? 'selected' : '' ?>><?= Loc::getMessage("YLAB_SMS_MOBILE_NUMBER_GENERATION_OPTION_RANGE") ?></option>
</select>
</td>
</tr>
<tr class="generation-constructor" style="display: <?= $sGenerationOption == 'constructor' ? 'table-row' : 'none' ?>">
<td width="40%" class="adm-detail-content-cell-l"><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_CODE") ?></td>
<td width="60%" class="adm-detail-content-cell-r">
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_FROM") ?>
<input type="text" class="data-option" name="option[code-from]" maxlength="3" value="<?= $arCode[0] ?>"/>
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_TO") ?>
<input type="text" class="data-option" name="option[code-to]" maxlength="3" value="<?= $arCode[1] ?>"/>
</td>
</tr>
<tr class="generation-constructor" style="display: <?= $sGenerationOption == 'constructor' ? 'table-row' : 'none' ?>">
<td width="40%" class="adm-detail-content-cell-l"><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_START_NUMBERS") ?></td>
<td width="60%" class="adm-detail-content-cell-r">
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_FROM") ?>
<input type="text" class="data-option" name="option[number-start-from]" maxlength="3" value="<?= $arNumbersStart[0] ?>"/>
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_TO") ?>
<input type="text" class="data-option" name="option[number-start-to]" maxlength="3" value="<?= $arNumbersStart[1] ?>"/>
</td>
</tr>
<tr class="generation-constructor" style="display: <?= $sGenerationOption == 'constructor' ? 'table-row' : 'none' ?>">
<td width="40%" class="adm-detail-content-cell-l"><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_FINISH_NUMBERS") ?></td>
<td width="60%" class="adm-detail-content-cell-r">
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_FROM") ?>
<input type="text" class="data-option" name="option[number-finish-from]" maxlength="4" value="<?= $arNumbersFinish[0] ?>"/>
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_TO") ?>
<input type="text" class="data-option" name="option[number-finish-to]" maxlength="4" value="<?= $arNumbersFinish[1] ?>"/>
</td>
</tr>
<tr class="generation-range" style="display: <?= $sGenerationOption == 'range' ? 'table-row' : 'none' ?>">
<td width="40%" class="adm-detail-content-cell-l"><?= Loc::getMessage("YLAB_SMS_MOBILE_NUMBER_RANGE_NUMBERS") ?></td>
<td width="60%" class="adm-detail-content-cell-r">
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_FROM") ?>
<input type="text" class="data-option" name="option[range-from]" minlength="10" value="<?= $arRangeNumbers[0] ?>"/>
<?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_TO") ?>
<input type="text" class="data-option" name="option[range-to]" minlength="10" value="<?= $arRangeNumbers[1] ?>"/>
</td>
</tr>
<td colspan="2" align="center">
<div class="adm-info-message-wrap" align="center">
<div class="adm-info-message">
<p><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_HELPER_1") ?></p>
<p><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_HELPER_2") ?></p>
<p><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_HELPER_3") ?></p>
<p><?= Loc::getMessage("YLAB_DDATA_MOBILE_NUMBER_HELPER_4") ?></p>
</div>
</div>
</td>
</tbody>
</table>
29 changes: 23 additions & 6 deletions assets/js/WindowEntityProfileGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,35 @@ var clean_test_table = '<div style="height: 200px; overflow: scroll">' +
'</table>' +
'</div>';

function set_start(val) {
function set_start(val, bDetail = true) {
document.getElementById('work_start').disabled = val ? 'disabled' : '';
document.getElementById('work_stop').disabled = val ? '' : 'disabled';
document.getElementById('progress').style.display = val ? 'block' : 'none';
if (bDetail) {
document.getElementById('progress').style.display = val ? 'block' : 'none';
}
iCountElements = document.getElementById('count-elements').value;
iDuration = document.getElementById('duration').value;
sAjaxPath = document.getElementById('ajax-path').value;

if (val) {
ShowWaitWindow();
document.getElementById('result').innerHTML = clean_test_table;
if (!bDetail) {
document.getElementById('result').style.display = 'none';
} else {
document.getElementById('result').style.display = 'block';
}
document.getElementById('status').innerHTML = BX.message('YLAB_DDATA_RUN');

document.getElementById('percent').innerHTML = '0%';
document.getElementById('indicator').style.width = '0%';


CHttpRequest.Action = work_onload;
CHttpRequest.Send(sAjaxPath + '&count=' + iCountElements + '&duration=' + iDuration);
}
else
} else {
CloseWaitWindow();
}
}

function work_onload(result) {
Expand All @@ -42,7 +50,6 @@ function work_onload(result) {
strNextRequest = CurrentStatus[1];
strCurrentAction = CurrentStatus[2];
bError = CurrentStatus[3];

iCountElements = document.getElementById('count-elements').value;
iDuration = document.getElementById('duration').value;

Expand Down Expand Up @@ -83,4 +90,14 @@ function work_onload(result) {
alert(e);
}
}
}
}

BX.ready(function () {
BX.bind(BX('detail'), 'change', function () {
if (this.checked) {
BX('work_start').setAttribute('onclick', 'set_start(1)');
} else {
BX('work_start').setAttribute('onclick', 'set_start(1, false)');
}
});
});
4 changes: 2 additions & 2 deletions install/version.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$arModuleVersion = array(
'VERSION' => '0.7.1',
'VERSION_DATE' => '2018-11-08'
'VERSION' => '0.8.0',
'VERSION_DATE' => '2018-11-15'
);
5 changes: 4 additions & 1 deletion lang/ru/admin/entity_profile_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
$MESS['YLAB_DDATA_GENERATE_DURATION'] = "Длительность шага";
$MESS['YLAB_DDATA_GENERATE_DURATION_COUNT'] = " сек.";
$MESS['YLAB_DDATA_GENERATE_RESULT_SUCCESS'] = 'Добавлены записи с ID #ELEMENTS#';
$MESS['YLAB_DDATA_GENERATE_RESULT_ERROR'] = "Ошибка: #ERROR#', 'true";
$MESS['YLAB_DDATA_GENERATE_RESULT_ERROR'] = "Ошибка: #ERROR#', 'true";
$MESS["YLAB_DDATA_GENERATE_DETAIL"] = "
Детальное отображение генерации:
";
16 changes: 16 additions & 0 deletions lang/ru/admin/fragments/random_mobile_number_prepare_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?
$MESS["YLAB_DDATA_MOBILE_NUMBER_CODE"] = "Код города / сети :";
$MESS["YLAB_DDATA_MOBILE_NUMBER_START_NUMBERS"] = "Диапазон первых 3 чисел номера: ";
$MESS["YLAB_DDATA_MOBILE_NUMBER_FINISH_NUMBERS"] = "Диапазон оставшихся чисел номера: ";
$MESS["YLAB_DDATA_MOBILE_NUMBER_FROM"] = " от ";
$MESS["YLAB_DDATA_MOBILE_NUMBER_TO"] = " до ";
$MESS["YLAB_SMS_MOBILE_NUMBER_COUNTRY_CODE"] = "Код страны";
$MESS["YLAB_SMS_MOBILE_NUMBER_GENERATION_OPTION"] = "Вариант генерации";
$MESS["YLAB_SMS_MOBILE_NUMBER_GENERATION_OPTION_CONSTRUCTOR"] = "Конструктор номера";
$MESS["YLAB_SMS_MOBILE_NUMBER_GENERATION_OPTION_RANGE"] = "Диапазон номеров";
$MESS["YLAB_SMS_MOBILE_NUMBER_RANGE_NUMBERS"] = "Диапазон номеров";
$MESS["YLAB_DDATA_MOBILE_NUMBER_CHOOSE_VALUE"] = "Выберите значение";
$MESS["YLAB_DDATA_MOBILE_NUMBER_HELPER_1"] = "Для использования данного генератора доступны 2 варианта: ";
$MESS["YLAB_DDATA_MOBILE_NUMBER_HELPER_2"] = "Конструктор номера - данные генерируются на основе введённых данных конструктора";
$MESS["YLAB_DDATA_MOBILE_NUMBER_HELPER_3"] = "Диапазон номеров - данные генерируются из диапазона указанных номеров";
$MESS["YLAB_DDATA_MOBILE_NUMBER_HELPER_4"] = "Поле Код страны является необязательным.";
3 changes: 3 additions & 0 deletions lang/ru/lib/data/randommobilenumber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?
$MESS["YLAB_DDATA_RANDOM_MOBILE_NUMBER_NAME"] = "Генератор случайного номера мобильного телефона";
$MESS["YLAB_DDATA_DATA_UNIT_MOBILE_NUMBER_EXCEPTION_STATIC"] = "Метод getValue вызван статически";
Loading

0 comments on commit 4ffac38

Please sign in to comment.