Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/components/minishop3/lexicon/en/vue.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
$_lang['customer_updated'] = 'Customer updated successfully';
$_lang['customer_deleted'] = 'Customer deleted successfully';
$_lang['customer_delete_confirm_title'] = 'Confirm Deletion';
$_lang['customer_delete_confirm_message'] = 'Are you sure you want to delete customer #{id}?';
$_lang['customer_delete_confirm_message'] = 'Are you sure you want to delete the customer with ID {id}?';
$_lang['customer_new_password'] = 'New Password';
$_lang['customer_password_placeholder'] = 'Leave empty to keep current password';
$_lang['customer_password_hint'] = 'Enter a new password or generate one automatically. Leave empty to keep the current password.';
Expand Down
2 changes: 1 addition & 1 deletion core/components/minishop3/lexicon/ru/vue.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
$_lang['customer_updated'] = 'Клиент успешно обновлен';
$_lang['customer_deleted'] = 'Клиент успешно удален';
$_lang['customer_delete_confirm_title'] = 'Подтверждение удаления';
$_lang['customer_delete_confirm_message'] = 'Вы уверены, что хотите удалить клиента #{id}?';
$_lang['customer_delete_confirm_message'] = 'Вы уверены, что хотите удалить клиента с идентификатором {id}?';
$_lang['customer_new_password'] = 'Новый пароль';
$_lang['customer_password_placeholder'] = 'Оставьте пустым, чтобы не менять';
$_lang['customer_password_hint'] = 'Введите новый пароль или сгенерируйте автоматически. Оставьте пустым, если не хотите менять пароль.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public function up()
'frozen' => 0,
'width' => null,
'min_width' => '200px',
'config' => json_encode(['type' => 'template', 'template' => '{first_name} {last_name}'], JSON_UNESCAPED_UNICODE),
'config' => json_encode(
['type' => 'template', 'template' => '{first_name} {last_name}'],
JSON_UNESCAPED_UNICODE
),
'is_system' => 0,
'is_default' => 1,
],
Expand Down Expand Up @@ -129,10 +132,30 @@ public function up()
'config' => json_encode([
'type' => 'actions',
'actions' => [
['name' => 'addresses', 'handler' => 'addresses', 'icon' => 'pi-map-marker', 'label' => 'addresses'],
['name' => 'edit', 'handler' => 'edit', 'icon' => 'pi-pencil', 'label' => 'edit'],
['name' => 'delete', 'handler' => 'delete', 'icon' => 'pi-trash', 'label' => 'delete', 'severity' => 'danger', 'confirm' => true, 'confirmMessage' => 'customer_delete_confirm_message']
]
[
'name' => 'addresses',
'handler' => 'addresses',
'icon' => 'pi-map-marker',
'label' => 'addresses',
],
[
'name' => 'edit',
'handler' => 'edit',
'icon' => 'pi-pencil',
'label' => 'edit',
],
[
'name' => 'delete',
'handler' => 'delete',
'icon' => 'pi-trash',
'label' => 'delete',
'severity' => 'danger',
'confirm' => true,
'confirmTitle' => 'customer_delete_confirm_title',
'confirmMessage' => 'customer_delete_confirm_message',
'confirmAccept' => 'delete',
],
],
], JSON_UNESCAPED_UNICODE),
'is_system' => 1,
'is_default' => 1,
Expand Down
4 changes: 2 additions & 2 deletions core/components/minishop3/src/Services/GridConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ protected function validateActionsConfig(array $config): array
return ['success' => false, 'message' => 'actions must be an array'];
}

// Validate each action
$allowedHandlers = ['edit', 'delete', 'view', 'refresh'];
// Built-in Vue manager handlers (see vueManager/src/actionRegistry.js)
$allowedHandlers = ['edit', 'delete', 'view', 'refresh', 'addresses', 'publish', 'duplicate'];
$actionNames = [];

foreach ($actions as $index => $action) {
Expand Down
3 changes: 3 additions & 0 deletions vueManager/src/components/ActionsColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
* label: 'edit', // Lexicon key or text
* severity: null, // PrimeVue severity: danger, secondary, success, etc.
* confirm: false, // Confirmation required
* confirmTitle: '...', // Confirm dialog title (lexicon key, optional)
* confirmMessage: '...', // Confirmation message (lexicon key)
* confirmAccept: '...', // Accept button label (lexicon key, optional)
* confirmReject: '...', // Reject button label (lexicon key, optional)
* permission: 'ms3_save', // Access permission (optional)
* visible: true, // Button visibility
* disabled: false, // Disabled state
Expand Down
116 changes: 58 additions & 58 deletions vueManager/src/components/CustomersGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ const editingAddress = ref(null)
const addressFormVisible = ref(false)
const savingAddress = ref(false)

/** Delete row action: aligned with `20251127000002_seed_customers_grid_config` (lexicon keys). */
const CUSTOMER_GRID_DELETE_ACTION = {
name: 'delete',
handler: 'delete',
icon: 'pi-trash',
label: 'delete',
severity: 'danger',
confirm: true,
confirmTitle: 'customer_delete_confirm_title',
confirmMessage: 'customer_delete_confirm_message',
confirmAccept: 'delete',
}

/**
* Load customers list
*/
Expand Down Expand Up @@ -203,42 +216,29 @@ async function saveCustomer() {
}

/**
* Delete customer
* Delete customer (called after confirmation in ActionsColumn / useActions)
*/
function deleteCustomer(customer) {
confirm.require({
message: _('customer_delete_confirm_message').replace(
'{name}',
getCustomerDisplayName(customer)
),
header: _('customer_delete_confirm_title'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: _('delete'),
rejectLabel: _('cancel'),
acceptClass: 'p-button-danger',
accept: async () => {
try {
await request.delete(`/api/mgr/customers/${customer.id}`)
async function deleteCustomer(customer) {
try {
await request.delete(`/api/mgr/customers/${customer.id}`)

toast.add({
severity: 'success',
summary: _('success'),
detail: _('customer_deleted'),
life: 3000,
})
toast.add({
severity: 'success',
summary: _('success'),
detail: _('customer_deleted'),
life: 3000,
})

await loadCustomers()
} catch (error) {
console.error('[CustomersGrid] Error deleting customer:', error)
toast.add({
severity: 'error',
summary: _('error'),
detail: error.message || _('error_deleting_data'),
life: 5000,
})
}
},
})
await loadCustomers()
} catch (error) {
console.error('[CustomersGrid] Error deleting customer:', error)
toast.add({
severity: 'error',
summary: _('error'),
detail: error.message || _('error_deleting_data'),
life: 5000,
})
}
}

/**
Expand Down Expand Up @@ -583,40 +583,40 @@ function getDefaultColumns() {
actions: [
{ name: 'addresses', handler: 'addresses', icon: 'pi-map-marker', label: 'addresses' },
{ name: 'edit', handler: 'edit', icon: 'pi-pencil', label: 'edit' },
{
name: 'delete',
handler: 'delete',
icon: 'pi-trash',
label: 'delete',
severity: 'danger',
confirm: true,
confirmMessage: 'customer_delete_confirm_message',
},
{ ...CUSTOMER_GRID_DELETE_ACTION },
],
},
]
}

/**
* Ensure delete action uses customer-specific confirm copy (covers API-loaded grid config).
*/
function applyCustomerDeleteConfirmDefaults(actions) {
return actions.map(action => {
const handler = action.handler || action.name
if (handler !== 'delete') return action
return {
...action,
confirmTitle: action.confirmTitle || 'customer_delete_confirm_title',
confirmMessage: action.confirmMessage || 'customer_delete_confirm_message',
confirmAccept: action.confirmAccept || 'delete',
}
})
}

/**
* Get action configuration for column
*/
function getActionsConfig(column) {
if (!column.actions || column.actions.length === 0) {
return [
{ name: 'addresses', handler: 'addresses', icon: 'pi-map-marker', label: 'addresses' },
{ name: 'edit', handler: 'edit', icon: 'pi-pencil', label: 'edit' },
{
name: 'delete',
handler: 'delete',
icon: 'pi-trash',
label: 'delete',
severity: 'danger',
confirm: true,
confirmMessage: 'customer_delete_confirm_message',
},
]
}
return column.actions
const fallback = [
{ name: 'addresses', handler: 'addresses', icon: 'pi-map-marker', label: 'addresses' },
{ name: 'edit', handler: 'edit', icon: 'pi-pencil', label: 'edit' },
{ ...CUSTOMER_GRID_DELETE_ACTION },
]
const raw =
!column.actions || column.actions.length === 0 ? fallback : column.actions
return applyCustomerDeleteConfirmDefaults(raw)
}

/**
Expand Down