Skip to content
Merged
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
6 changes: 4 additions & 2 deletions assets/components/minishop3/css/mgr/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ a.x-menu-item .x-menu-item-text .icon {
box-sizing: border-box !important;
}

.p-select-filter {
width: 90% !important;
/* Select filter must fill IconField (was 90% — left a dead strip and misaligned search icon). */
.p-select-overlay .p-select-filter,
.p-multiselect-overlay .p-multiselect-filter {
width: 100% !important;
}
52 changes: 3 additions & 49 deletions core/components/minishop3/controllers/manager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,57 +105,11 @@ public function addVueModule($src)
*/
protected function registerVueCoreCheck()
{
require_once __DIR__ . '/vue_core_check.inc.php';
$alertTitle = $this->modx->lexicon('ms3_error') ?: 'Error';
$alertMessage = $this->modx->lexicon('ms3_vuetools_required')
?: 'VueTools package is required. Please install it from Package Manager.';

$script = <<<JS
<script>
(function() {
var importMap = document.querySelector('script[type="importmap"]');
var hasVueCore = false;

if (importMap) {
try {
var mapContent = JSON.parse(importMap.textContent);
hasVueCore = mapContent.imports && mapContent.imports.vue;
} catch (e) {
hasVueCore = false;
}
}

if (!hasVueCore) {
document.querySelectorAll('script[type="module"][data-vue-module]').forEach(function(el) {
el.remove();
});

if (typeof Ext !== 'undefined') {
Ext.onReady(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
});
} else {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
}, 500);
});
}

window.MS3_VUE_CORE_MISSING = true;
}
})();
</script>
JS;

$this->modx->regClientStartupHTMLBlock($script);
?: 'VueTools package (>= 1.2.0) is required. Please install or update it via Package Manager.';
ms3_register_vue_core_check($this->modx, $alertTitle, $alertMessage);
}

/**
Expand Down
52 changes: 3 additions & 49 deletions core/components/minishop3/controllers/resource_create.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,57 +81,11 @@ public function addVueModule($src)
*/
protected function registerVueCoreCheck()
{
require_once __DIR__ . '/vue_core_check.inc.php';
$alertTitle = $this->modx->lexicon('ms3_error') ?: 'Error';
$alertMessage = $this->modx->lexicon('ms3_vuetools_required')
?: 'VueTools package is required. Please install it from Package Manager.';

$script = <<<JS
<script>
(function() {
var importMap = document.querySelector('script[type="importmap"]');
var hasVueCore = false;

if (importMap) {
try {
var mapContent = JSON.parse(importMap.textContent);
hasVueCore = mapContent.imports && mapContent.imports.vue;
} catch (e) {
hasVueCore = false;
}
}

if (!hasVueCore) {
document.querySelectorAll('script[type="module"][data-vue-module]').forEach(function(el) {
el.remove();
});

if (typeof Ext !== 'undefined') {
Ext.onReady(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
});
} else {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
}, 500);
});
}

window.MS3_VUE_CORE_MISSING = true;
}
})();
</script>
JS;

$this->modx->regClientStartupHTMLBlock($script);
?: 'VueTools package (>= 1.2.0) is required. Please install or update it via Package Manager.';
ms3_register_vue_core_check($this->modx, $alertTitle, $alertMessage);
}

/**
Expand Down
52 changes: 3 additions & 49 deletions core/components/minishop3/controllers/resource_update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,57 +85,11 @@ public function addVueModule($src)
*/
protected function registerVueCoreCheck()
{
require_once __DIR__ . '/vue_core_check.inc.php';
$alertTitle = $this->modx->lexicon('ms3_error') ?: 'Error';
$alertMessage = $this->modx->lexicon('ms3_vuetools_required')
?: 'VueTools package is required. Please install it from Package Manager.';

$script = <<<JS
<script>
(function() {
var importMap = document.querySelector('script[type="importmap"]');
var hasVueCore = false;

if (importMap) {
try {
var mapContent = JSON.parse(importMap.textContent);
hasVueCore = mapContent.imports && mapContent.imports.vue;
} catch (e) {
hasVueCore = false;
}
}

if (!hasVueCore) {
document.querySelectorAll('script[type="module"][data-vue-module]').forEach(function(el) {
el.remove();
});

if (typeof Ext !== 'undefined') {
Ext.onReady(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
});
} else {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
}, 500);
});
}

window.MS3_VUE_CORE_MISSING = true;
}
})();
</script>
JS;

$this->modx->regClientStartupHTMLBlock($script);
?: 'VueTools package (>= 1.2.0) is required. Please install or update it via Package Manager.';
ms3_register_vue_core_check($this->modx, $alertTitle, $alertMessage);
}

/**
Expand Down
65 changes: 65 additions & 0 deletions core/components/minishop3/controllers/vue_core_check.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* Register startup HTML that requires VueTools Import Map with theme support (>= 1.2.0).
*
* Signal key `vuetools/theme` is present only in VueTools builds that ship
* `@vuetools/useTheme` / getActiveTheme(). Without it, remove data-vue-module
* scripts and show a MODX alert instead of a silent ES module link error.
*
* @param \MODX\Revolution\modX $modx
* @param string $alertTitle
* @param string $alertMessage
*/
function ms3_register_vue_core_check($modx, string $alertTitle, string $alertMessage): void
{
$script = <<<JS
<script>
(function() {
var importMap = document.querySelector('script[type="importmap"]');
var hasVueToolsTheme = false;

if (importMap) {
try {
var mapContent = JSON.parse(importMap.textContent);
hasVueToolsTheme = mapContent.imports
&& mapContent.imports.vue
&& mapContent.imports['vuetools/theme'];
} catch (e) {
hasVueToolsTheme = false;
}
}

if (!hasVueToolsTheme) {
document.querySelectorAll('script[type="module"][data-vue-module]').forEach(function(el) {
el.remove();
});

if (typeof Ext !== 'undefined') {
Ext.onReady(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
});
} else {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
if (typeof MODx !== 'undefined' && MODx.msg) {
MODx.msg.alert('{$alertTitle}', '{$alertMessage}');
} else {
alert('{$alertMessage}');
}
}, 500);
});
}

window.MS3_VUE_CORE_MISSING = true;
}
})();
</script>
JS;

$modx->regClientStartupHTMLBlock($script);
}
2 changes: 1 addition & 1 deletion core/components/minishop3/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
$_lang['ms3_help_desc'] = 'Useful links and information';

$_lang['ms3_error'] = 'Error';
$_lang['ms3_vuetools_required'] = 'VueTools package is required for MiniShop3. Please install it via Package Manager.';
$_lang['ms3_vuetools_required'] = 'VueTools package (>= 1.2.0) is required for MiniShop3. Please install or update it via Package Manager.';

$_lang['ms3_mgr_order_recalc_invalid_mode'] = 'Invalid order cost recalculation mode.';
$_lang['ms3_mgr_order_recalc_manual_delivery_missing'] = 'Manual delivery cost (manual_delivery_cost) is required in manual mode.';
Expand Down
2 changes: 1 addition & 1 deletion core/components/minishop3/lexicon/ru/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
$_lang['ms3_help_desc'] = 'Полезные ссылки и информация';

$_lang['ms3_error'] = 'Ошибка';
$_lang['ms3_vuetools_required'] = 'Для работы MiniShop3 требуется пакет VueTools. Установите его через Менеджер пакетов.';
$_lang['ms3_vuetools_required'] = 'Для работы MiniShop3 требуется пакет VueTools (>= 1.2.0). Установите или обновите его через Менеджер пакетов.';

$_lang['ms3_mgr_order_recalc_invalid_mode'] = 'Недопустимый режим пересчёта стоимости заказа.';
$_lang['ms3_mgr_order_recalc_manual_delivery_missing'] = 'В режиме manual обязательно укажите manual_delivery_cost (стоимость доставки).';
Expand Down
3 changes: 3 additions & 0 deletions vueManager/src/components/ActionsEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Button, Checkbox, Column, DataTable, Dialog, InputText, Select } from '
import { computed, ref, watch } from 'vue'

import actionRegistry from '../actionRegistry.js'
import { getPrimarySaveSeverity } from '../utils/primevueTheme.js'

const props = defineProps({
/**
Expand All @@ -31,6 +32,7 @@ const props = defineProps({
const emit = defineEmits(['update:modelValue'])

const { _ } = useLexicon()
const primarySaveSeverity = getPrimarySaveSeverity()

const localActions = ref([])

Expand Down Expand Up @@ -370,6 +372,7 @@ function closeDialog() {
<Button
:label="_('save')"
icon="pi pi-check"
:severity="primarySaveSeverity"
:disabled="!editingAction?.name"
@click="saveAction"
/>
Expand Down
3 changes: 3 additions & 0 deletions vueManager/src/components/CategoryOptionsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { onMounted, ref, watch } from 'vue'

import { useGroupedToast, useUiGroup } from '../composables/uiGroup.js'
import request from '../request.js'
import { getPrimarySaveSeverity } from '../utils/primevueTheme.js'

const props = defineProps({
categoryId: { type: Number, required: true },
})

const confirm = useConfirm()
const { _ } = useLexicon()
const primarySaveSeverity = getPrimarySaveSeverity()

// From entry provideUiGroup('category-options'); fallback for non-entry mounts (#538/#539).
const UI_GROUP = useUiGroup() || 'category-options'
Expand Down Expand Up @@ -510,6 +512,7 @@ onMounted(() => {
/>
<Button
:label="_('save') || 'Сохранить'"
:severity="primarySaveSeverity"
:loading="addSaving"
:disabled="!addOptionId"
@click="addOption"
Expand Down
4 changes: 4 additions & 0 deletions vueManager/src/components/CustomersGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { computed, nextTick, onMounted, ref } from 'vue'
import { useGridFilterParams } from '../composables/useGridFilterParams.js'
import { useSelection } from '../composables/useSelection.js'
import request from '../request.js'
import { getPrimarySaveSeverity } from '../utils/primevueTheme.js'
import ActionsColumn from './ActionsColumn.vue'

const toast = useToast()
const confirm = useConfirm()
const { _ } = useLexicon()
const primarySaveSeverity = getPrimarySaveSeverity()

// Bulk selection
const {
Expand Down Expand Up @@ -933,6 +935,7 @@ onMounted(async () => {
type="button"
:label="_('save')"
icon="pi pi-check"
:severity="primarySaveSeverity"
:loading="saving"
@click="saveCustomer"
/>
Expand Down Expand Up @@ -1105,6 +1108,7 @@ onMounted(async () => {
<Button
:label="_('save')"
icon="pi pi-check"
:severity="primarySaveSeverity"
:loading="savingAddress"
@click="saveAddress"
/>
Expand Down
4 changes: 3 additions & 1 deletion vueManager/src/components/DeliveriesGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import request from '../request.js'
import { resolveAddCostPriceBadgeKind } from '../utils/addCostPriceBadgeKind.js'
import { formatValue, getDisplayName, normalizeImagePath } from '../utils/displayFormatters.js'
import { applyDeleteConfirmDefaults, gridDeleteAction } from '../utils/gridDeleteAction.js'
import { getPrimarySaveSeverity } from '../utils/primevueTheme.js'
import ActionsColumn from './ActionsColumn.vue'
import FileBrowser from './FileBrowser.vue'
import ValidationRulesEditor from './ValidationRulesEditor.vue'

const toast = useToast()
const { _ } = useLexicon()
const primarySaveSeverity = getPrimarySaveSeverity()

const CONFIRM_GROUP = 'settings-deliveries'

Expand Down Expand Up @@ -755,7 +757,7 @@ onMounted(async () => {

<template #footer>
<Button :label="_('cancel')" icon="pi pi-times" severity="secondary" @click="close" />
<Button :label="_('save')" icon="pi pi-check" :loading="saving" @click="saveDelivery" />
<Button :label="_('save')" icon="pi pi-check" :severity="primarySaveSeverity" :loading="saving" @click="saveDelivery" />
</template>
</Dialog>
</div>
Expand Down
Loading