Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapted module URLs for new routing #9215

Merged
merged 3 commits into from Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 4 additions & 18 deletions admin-dev/themes/default/js/bundle/module/module.js
Expand Up @@ -19,7 +19,6 @@ var AdminModuleController = function() {
this.pstaggerInput = null;
this.lastBulkAction = null;
this.isUploadStarted = false;
this.baseAdminDir = '';

/**
* Loaded modules list.
Expand Down Expand Up @@ -175,13 +174,11 @@ var AdminModuleController = function() {
};

this.ajaxLoadPage = function() {
var token = window.location.search;
var urlToCall = this.baseAdminDir+'module/catalog/refresh' + token;
var self = this;

$.ajax({
method: 'GET',
url: urlToCall
url: moduleURLs.catalogRefresh
}).done(function (response) {
if (response.status === true) {
if (typeof response.domElements === 'undefined') response.domElements = null;
Expand Down Expand Up @@ -512,7 +509,7 @@ var AdminModuleController = function() {

// @see: dropzone.js
var dropzoneOptions = {
url: 'import' + window.location.search,
url: moduleURLs.moduleImport,
acceptedFiles: '.zip, .tar',
// The name that will be used to transfer the file
paramName: 'file_uploaded',
Expand Down Expand Up @@ -567,7 +564,7 @@ var AdminModuleController = function() {
self.animateEndUpload(function() {
if (result.status === true) {
if (result.is_configurable === true) {
var configureLink = self.baseAdminDir + 'module/manage/action/configure/' + result.module_name + window.location.search;
var configureLink = moduleURLs.configurationPage.replace('1', result.module_name);
$(self.moduleImportSuccessConfigureBtnSelector).attr('href', configureLink);
$(self.moduleImportSuccessConfigureBtnSelector).show();
}
Expand Down Expand Up @@ -643,13 +640,6 @@ var AdminModuleController = function() {

this.loadVariables = function () {
this.initCurrentDisplay();

// If index.php found in the current URL, we need it also in the baseAdminDir
//noinspection JSUnresolvedVariable
this.baseAdminDir = baseAdminDir;
if (window.location.href.indexOf('index.php') != -1) {
this.baseAdminDir += 'index.php/';
}
};

this.getModuleItemSelector = function () {
Expand All @@ -668,7 +658,7 @@ var AdminModuleController = function() {
return;
}
var token = window.location.search;
var urlToCall = this.baseAdminDir+'module/notifications/count' + token;
var urlToCall = moduleURLs.notificationsCount;

$.getJSON(urlToCall, function(badge) {
// TODO: This HTML code comes from an already specific template.
Expand Down Expand Up @@ -759,9 +749,6 @@ var AdminModuleController = function() {
'bulk-reset': 'reset'
};

// char is used only to be easy to replace by the end of this function
var baseActionUrl = this.baseAdminDir + 'module/manage/action/@/';

// Note no grid selector used yet since we do not needed it at dev time
// Maybe useful to implement this kind of things later if intended to
// use this functionality elsewhere but "manage my module" section
Expand All @@ -788,7 +775,6 @@ var AdminModuleController = function() {
var moduleTechName = data.techName;

var urlActionSegment = bulkActionToUrl[requestedBulkAction];
baseActionUrl.replace('@', urlActionSegment);

if (typeof module_card_controller !== 'undefined') {
// We use jQuery to get the specific link for this action. If found, we send it.
Expand Down
Expand Up @@ -22,14 +22,10 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}
{% extends '@PrestaShop/Admin/Module/common.html.twig' %}

{% block javascripts %}
{{ parent() }}
<script src="{{ asset('themes/default/js/bundle/plugins/jquery.pstagger.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/loader.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module_card.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module.js') }}"></script>
{% if app.request.get('filterCategoryTab') %}
<script>
$('body').on('moduleCatalogLoaded', function() {
Expand Down
@@ -0,0 +1,41 @@
{#**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% block javascripts %}
{{ parent() }}
<script>
var moduleURLs = {
'catalogRefresh': '{{ url('admin_module_catalog_refresh')|e('js') }}',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use path instead of url, absolute link is useful only when using cross-domain ajax or generating emails, because the hostname won't be the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go

'configurationPage': '{{ url('admin_module_configure_action', {'module_name': '1'})|e('js') }}',
'moduleImport': '{{ url('admin_module_import')|e('js') }}',
'notificationsCount': '{{ url('admin_module_notification_count')|e('js') }}',
};
</script>
<script src="{{ asset('themes/default/js/bundle/plugins/jquery.pstagger.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/loader.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module_card.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module.js') }}"></script>
{% endblock %}
Expand Up @@ -22,15 +22,7 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% block javascripts %}
{{ parent() }}
<script src="{{ asset('themes/default/js/bundle/plugins/jquery.pstagger.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/loader.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module_card.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module.js') }}"></script>
{% endblock %}
{% extends '@PrestaShop/Admin/Module/common.html.twig' %}

{% block content %}
<div class="row justify-content-center">
Expand Down
Expand Up @@ -22,15 +22,7 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% block javascripts %}
{{ parent() }}
<script src="{{ asset('themes/default/js/bundle/plugins/jquery.pstagger.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/loader.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module_card.js') }}"></script>
<script src="{{ asset('themes/default/js/bundle/module/module.js') }}"></script>
{% endblock %}
{% extends '@PrestaShop/Admin/Module/common.html.twig' %}

{% block content %}
{# Addons connect modal #}
Expand Down