This commit is contained in:
2026-04-12 21:43:39 +02:00
parent 63bd1e73f2
commit f72a5019e9
27 changed files with 1791 additions and 266 deletions

View File

@@ -1135,6 +1135,7 @@ return [
'pattern' => 'Wzorzec nazwy produktu',
'script' => 'Skrypt generujacy',
'output_dir' => 'Katalog wyjsciowy',
'requires_photo' => 'Wymaga zdjecia',
'active' => 'Status',
'actions' => 'Akcje',
],

View File

@@ -41,6 +41,14 @@ $scripts = is_array($scripts ?? null) ? $scripts : [];
<input class="form-control" type="text" name="output_dir" placeholder="<?= $e($t('settings.project_mapping.placeholders.output_dir')) ?>">
</label>
<label class="form-field pm-form__field pm-form__field--check">
<span class="field-label">&nbsp;</span>
<span class="checkbox-row">
<input type="checkbox" name="requires_photo" value="1">
<?= $e($t('settings.project_mapping.fields.requires_photo')) ?>
</span>
</label>
<div class="pm-form__actions">
<button type="submit" class="btn btn--action"><?= $e($t('settings.project_mapping.actions.add')) ?></button>
</div>
@@ -60,6 +68,7 @@ $scripts = is_array($scripts ?? null) ? $scripts : [];
<th><?= $e($t('settings.project_mapping.fields.pattern')) ?></th>
<th><?= $e($t('settings.project_mapping.fields.script')) ?></th>
<th><?= $e($t('settings.project_mapping.fields.output_dir')) ?></th>
<th class="text-center"><?= $e($t('settings.project_mapping.fields.requires_photo')) ?></th>
<th class="text-center"><?= $e($t('settings.project_mapping.fields.active')) ?></th>
<th class="text-center"><?= $e($t('settings.project_mapping.fields.actions')) ?></th>
</tr>
@@ -70,6 +79,7 @@ $scripts = is_array($scripts ?? null) ? $scripts : [];
<td class="pm-row__pattern"><?= $e((string) $mapping['product_name_pattern']) ?></td>
<td class="pm-row__script"><?= $e((string) $mapping['script_name']) ?></td>
<td class="pm-row__dir"><?= $e((string) ($mapping['output_dir'] ?? '-')) ?></td>
<td class="text-center"><?= !empty($mapping['requires_photo']) ? '✓' : '' ?></td>
<td class="text-center">
<form action="/settings/project-mappings/<?= (int) $mapping['id'] ?>/toggle" method="post" class="inline-form">
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
@@ -83,7 +93,8 @@ $scripts = is_array($scripts ?? null) ? $scripts : [];
data-id="<?= (int) $mapping['id'] ?>"
data-pattern="<?= $e((string) $mapping['product_name_pattern']) ?>"
data-script="<?= $e((string) $mapping['script_name']) ?>"
data-output-dir="<?= $e((string) ($mapping['output_dir'] ?? '')) ?>">
data-output-dir="<?= $e((string) ($mapping['output_dir'] ?? '')) ?>"
data-requires-photo="<?= !empty($mapping['requires_photo']) ? '1' : '0' ?>">
<?= $e($t('settings.project_mapping.actions.edit')) ?>
</button>
<button type="button" class="btn btn--sm btn--danger js-pm-delete"
@@ -126,6 +137,13 @@ $scripts = is_array($scripts ?? null) ? $scripts : [];
<input class="form-control" type="text" name="output_dir">
</label>
<label class="form-field mt-8">
<span class="checkbox-row">
<input type="checkbox" name="requires_photo" value="1">
<?= $e($t('settings.project_mapping.fields.requires_photo')) ?>
</span>
</label>
<div class="mt-12">
<button type="submit" class="btn btn--action"><?= $e($t('settings.project_mapping.actions.save')) ?></button>
<button type="button" class="btn btn--outline js-pm-modal-close"><?= $e($t('settings.project_mapping.actions.cancel')) ?></button>
@@ -146,6 +164,7 @@ document.addEventListener('DOMContentLoaded', function() {
form.querySelector('[name="product_name_pattern"]').value = this.dataset.pattern;
form.querySelector('[name="script_name"]').value = this.dataset.script;
form.querySelector('[name="output_dir"]').value = this.dataset.outputDir || '';
form.querySelector('[name="requires_photo"]').checked = this.dataset.requiresPhoto === '1';
modal.style.display = 'flex';
});
});
@@ -156,22 +175,31 @@ document.addEventListener('DOMContentLoaded', function() {
});
});
function submitDelete(id, token) {
var f = document.createElement('form');
f.method = 'post';
f.action = '/settings/project-mappings/' + id + '/delete';
var t = document.createElement('input');
t.type = 'hidden'; t.name = '_token'; t.value = token;
f.appendChild(t);
document.body.appendChild(f);
f.submit();
}
document.querySelectorAll('.js-pm-delete').forEach(function(btn) {
btn.addEventListener('click', function() {
var id = this.dataset.id;
var token = this.dataset.token;
if (typeof window.OrderProAlerts !== 'undefined') {
window.OrderProAlerts.confirm('<?= $e($t('settings.project_mapping.confirm_delete')) ?>', function() {
var f = document.createElement('form');
f.method = 'post';
f.action = '/settings/project-mappings/' + id + '/delete';
var t = document.createElement('input');
t.type = 'hidden'; t.name = '_token'; t.value = token;
f.appendChild(t);
document.body.appendChild(f);
f.submit();
});
if (!window.OrderProAlerts || typeof window.OrderProAlerts.confirm !== 'function') {
return;
}
window.OrderProAlerts.confirm({
title: '<?= $e($t('settings.project_mapping.actions.delete')) ?>',
message: '<?= $e($t('settings.project_mapping.confirm_delete')) ?>',
danger: true
}).then(function(confirmed) {
if (confirmed) submitDelete(id, token);
});
});
});
});