Skip to content

Commit

Permalink
Merge pull request #883 from webinmd/ms-utilites-import
Browse files Browse the repository at this point in the history
Утилиты. Интерфейс для импорта
  • Loading branch information
biz87 authored Jun 20, 2023
2 parents d786057 + 47559d4 commit c536c13
Show file tree
Hide file tree
Showing 18 changed files with 944 additions and 180 deletions.
1 change: 1 addition & 0 deletions _build/build.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
'settings',
'chunks',
'statuses',
'utilites',
'setup',
];
6 changes: 3 additions & 3 deletions _build/data/transport.menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
'menuindex' => 3,
'action' => 'mgr/help',
],
'ms2_utilites' => [
'description' => 'ms2_utilites_desc',
'ms2_utilities' => [
'description' => 'ms2_utilities_desc',
'parent' => 'minishop2',
'menuindex' => 4,
'action' => 'mgr/utilites',
'action' => 'mgr/utilities',
],
];

Expand Down
11 changes: 11 additions & 0 deletions _build/data/transport.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@
'value' => '2,3',
'xtype' => 'textfield',
'area' => 'ms2_statuses',
],

'ms2_utility_import_fields' => [
'value' => 'pagetitle,parent,price,article',
'xtype' => 'textfield',
'area' => 'ms2_import',
],
'ms2_utility_import_fields_delimiter' => [
'value' => ';',
'xtype' => 'textfield',
'area' => 'ms2_import',
]
];

Expand Down
23 changes: 23 additions & 0 deletions _build/resolvers/resolve.utilites.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/** @var xPDOTransport $transport */
/** @var array $options */
/** @var modX $modx */
if ($transport->xpdo) {
$modx = $transport->xpdo;
// fix for removing installed old incorrect menu
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
case xPDOTransport::ACTION_UPGRADE:
$menu = $modx->getObject('modMenu', ['text' => 'ms2_utilites']);
if ($menu) {
$menu->remove();
unlink(MODX_ASSETS_PATH . 'components/minishop2/js/mgr/utilites/gallery/panel.js');
rmdir(MODX_ASSETS_PATH . 'components/minishop2/js/mgr/utilites/gallery/');
unlink(MODX_ASSETS_PATH . 'components/minishop2/js/mgr/utilites/panel.js');
rmdir(MODX_ASSETS_PATH . 'components/minishop2/js/mgr/utilites/');
}
break;
}
}
return true;
135 changes: 0 additions & 135 deletions assets/components/minishop2/js/mgr/utilites/gallery/panel.js

This file was deleted.

137 changes: 137 additions & 0 deletions assets/components/minishop2/js/mgr/utilities/gallery/panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
miniShop2.panel.UtilitiesGallery = function (config) {
config = config || {};

Ext.apply(config, {
cls: 'container form-with-labels',
autoHeight: true,
url: miniShop2.config.connector_url,
saveMsg: _('ms2_utilities_gallery_updating'),

progress: true,
baseParams: {
action: 'mgr/utilities/gallery/update'
},
items: [{
layout: 'form',
cls: 'main-wrapper',
labelWidth: 200,
labelAlign: 'left',
border: false,
buttonAlign: 'left',
style: 'padding: 0 0 0 7px',
items: [
{
html: String.format(
_('ms2_utilities_gallery_information'),
miniShop2.config.utility_gallery_source_name,
miniShop2.config.utility_gallery_source_id,
miniShop2.config.utility_gallery_total_products,
miniShop2.config.utility_gallery_total_products_files
),
},
{
xtype: 'fieldset',
title: _('ms2_utilities_params'),
id: 'ms2-utilities-gallery-params',
cls: 'x-fieldset-checkbox-toggle',
style: 'margin: 5px 0 15px ',
collapsible: true,
collapsed: true,
stateful: true,
labelAlign: 'top',
stateEvents: ['collapse', 'expand'],
items: [
{
html: miniShop2.config.utility_gallery_thumbnails
},
]
},
{
name: 'limit',
xtype: 'numberfield',
value: 10,
width: 80,
fieldLabel: _('ms2_utilities_gallery_for_step')
},
{
name: 'offset',
xtype: 'numberfield',
value: 0,
hidden: true,
},
{
xtype: 'button',
style: 'margin: 15px 0 0 2px',
text: '<i class="icon icon-refresh"></i> &nbsp;' + _('ms2_utilities_gallery_refresh'),
handler: function () {
var form = this.getForm();
form.setValues({
offset: 0
});
this.submit(this);
}, scope: this
},
{
style: 'padding: 15px 0',
html: '\
<div id="ms-utility-gallery-range_outer">\
<div class="ms-utility-gallery-labels"><span id="ms-utility-gallery-label">0%</span><span id="ms-utility-gallery-iteration"></span></div>\
<div id="ms-utility-gallery-progress"><span id="ms-utility-gallery-progress-bar"></span></div>\
</div>\
'
}
]
}],
listeners: {
success: {
fn: function (response) {
var data = response.result.object;
var form = this.getForm();
this.updateProgress(data);

if (!data.done) {
form.setValues({
offset: Number(data.offset)
});
this.submit(this);
}
else {
MODx.msg.status({
title: _('ms2_utilities_gallery_done'),
message: _('ms2_utilities_gallery_done_message'),
delay: 5
});
}
}, scope: this
}
}
});
miniShop2.panel.UtilitiesGallery.superclass.constructor.call(this, config);
};

Ext.extend(miniShop2.panel.UtilitiesGallery, MODx.FormPanel, {

updateProgress: function (data) {
const progressblock = document.getElementById('ms-utility-gallery-range_outer');
const progresslabel = document.getElementById('ms-utility-gallery-label');
const progressbar = document.getElementById('ms-utility-gallery-progress-bar');
const progressiteration = document.getElementById('ms-utility-gallery-iteration');
progressblock.style.visibility = 'visible';

if (data.done) {
progresslabel.innerHTML = '100%';
progressbar.style.width = '100%';
progressiteration.style.visibility = 'hidden';
} else {
let progress = (parseFloat((data.offset / data.total) * 100)).toFixed(2);
progresslabel.innerHTML = progress + '%';
progressbar.style.width = progress + '%';

// count iterations
const totalIterations = Math.ceil(data.total / data.limit);
const currentIteration = data.offset / data.limit;
progressiteration.innerHTML = currentIteration + "/" + totalIterations;
}
}
});
Ext.reg('minishop2-utilities-gallery', miniShop2.panel.UtilitiesGallery);
Loading

0 comments on commit c536c13

Please sign in to comment.