init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery'
|
||||
], function (jQuery) {
|
||||
|
||||
var categorySubmit = function () {
|
||||
var activeTab = $('active_tab_id');
|
||||
if (activeTab) {
|
||||
if (activeTab.tabsJsObject && activeTab.tabsJsObject.tabs('activeAnchor')) {
|
||||
activeTab.value = activeTab.tabsJsObject.tabs('activeAnchor').prop('id');
|
||||
}
|
||||
}
|
||||
|
||||
// Submit form
|
||||
jQuery('#category_edit_form').trigger('submit');
|
||||
};
|
||||
|
||||
return function (config, element) {
|
||||
config = config || {};
|
||||
jQuery(element).on('click', function (event) {
|
||||
categorySubmit(config.url, config.ajax);
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
/*jshint jquery:true browser:true*/
|
||||
/*global Ajax:true alert:true*/
|
||||
define([
|
||||
"jquery",
|
||||
"mage/backend/form",
|
||||
"jquery/ui",
|
||||
"prototype"
|
||||
], function ($) {
|
||||
"use strict";
|
||||
|
||||
$.widget("mage.categoryForm", $.mage.form, {
|
||||
options: {
|
||||
categoryIdSelector: 'input[name="category[category_id]"]',
|
||||
categoryPathSelector: 'input[name="category[path]"]'
|
||||
},
|
||||
|
||||
/**
|
||||
* Form creation
|
||||
* @protected
|
||||
*/
|
||||
_create: function () {
|
||||
this._super();
|
||||
$('body').on('categoryMove.tree', $.proxy(this.refreshPath, this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Sending ajax to server to refresh field 'category[path]'
|
||||
* @protected
|
||||
*/
|
||||
refreshPath: function () {
|
||||
var that = this;
|
||||
if (!this.element.find(this.options.categoryIdSelector).prop('value')) {
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: this.options.refreshUrl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
form_key: FORM_KEY
|
||||
}
|
||||
}).success(function (data) {
|
||||
that._refreshPathSuccess(data);
|
||||
});
|
||||
},
|
||||
_refreshPathSuccess: function (response) {
|
||||
if (response.error) {
|
||||
alert(response.message);
|
||||
} else {
|
||||
if (this.element.find(this.options.categoryIdSelector).prop('value') == response.id) {
|
||||
this.element.find(this.options.categoryPathSelector)
|
||||
.prop('value', response.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $.mage.categoryForm;
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
.page-actions {
|
||||
overflow-x: visible !important;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
.admin__menu #menu-magento-backend-content .item-blog.parent.level-1 > strong:before {
|
||||
content: '\e900';
|
||||
font-family: 'Mageplaza Icons';
|
||||
font-size: 1.5rem;
|
||||
margin-right: .8rem;
|
||||
}
|
||||
[data-role='modal'] ._required>.admin__field-label>label:after {
|
||||
content: unset !important;
|
||||
}
|
||||
#post_grid_table .admin__grid-control .admin__grid-control-value {
|
||||
display: none;
|
||||
}
|
||||
#menu-magento-backend-content .submenu-group-title {
|
||||
display: block;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
define([
|
||||
'underscore',
|
||||
'Magento_Catalog/js/components/new-category'
|
||||
], function (_, Category) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Processing options list
|
||||
*
|
||||
* @param {Array} array - Property array
|
||||
* @param {String} separator - Level separator
|
||||
* @param {Array} created - list to add new options
|
||||
*
|
||||
* @return {Array} Plain options list
|
||||
*/
|
||||
function flattenCollection(array, separator, created) {
|
||||
var i = 0,
|
||||
length,
|
||||
childCollection;
|
||||
|
||||
array = _.compact(array);
|
||||
length = array.length;
|
||||
created = created || [];
|
||||
|
||||
for (i; i < length; i++) {
|
||||
created.push(array[i]);
|
||||
|
||||
if (array[i].hasOwnProperty(separator)) {
|
||||
childCollection = array[i][separator];
|
||||
delete array[i][separator];
|
||||
flattenCollection.call(this, childCollection, separator, created);
|
||||
}
|
||||
}
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
return Category.extend({
|
||||
/**
|
||||
* Get path to current option
|
||||
*
|
||||
* @param {Object} data - option data
|
||||
* @returns {String} path
|
||||
*/
|
||||
getPath: function (data) {
|
||||
var pathParts,
|
||||
createdPath = '';
|
||||
|
||||
if (this.renderPath && typeof data.path !== "undefined") {
|
||||
pathParts = data.path.split('.');
|
||||
_.each(pathParts, function (curData) {
|
||||
createdPath = createdPath ? createdPath + ' / ' + curData : curData;
|
||||
});
|
||||
|
||||
return createdPath;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set option to options array.
|
||||
*
|
||||
* @param {Object} option
|
||||
* @param {Array} options
|
||||
*/
|
||||
setOption: function (option, options) {
|
||||
// eslint-disable-next-line radix
|
||||
var parent = parseInt(option.parent),
|
||||
copyOptionsTree;
|
||||
|
||||
if (_.contains([0, 1], parent)) {
|
||||
options = options || this.cacheOptions.tree;
|
||||
options.push(option);
|
||||
|
||||
copyOptionsTree = JSON.parse(JSON.stringify(this.cacheOptions.tree));
|
||||
this.cacheOptions.plain = flattenCollection(copyOptionsTree, this.separator);
|
||||
this.options(this.cacheOptions.tree);
|
||||
} else {
|
||||
this._super(option, options);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license sliderConfig is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
define([
|
||||
'Magento_Ui/js/grid/columns/select'
|
||||
], function (Column) {
|
||||
'use strict';
|
||||
|
||||
return Column.extend({
|
||||
defaults: {
|
||||
bodyTmpl: 'ui/grid/cells/html'
|
||||
},
|
||||
getLabel: function (record) {
|
||||
var label = this._super(record);
|
||||
|
||||
if (label !== '') {
|
||||
switch (record.enabled) {
|
||||
case '1':
|
||||
label = '<span class="grid-severity-notice"><span>' + label + '</span></span>';
|
||||
break;
|
||||
case '0':
|
||||
label = '<span class="grid-severity-critical"><span>' + label + '</span></span>';
|
||||
break;
|
||||
case '2':
|
||||
label = '<span class="grid-severity-critical"><span>' + label + '</span></span>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license sliderConfig is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
define([
|
||||
'Magento_Ui/js/grid/columns/select'
|
||||
], function (Column) {
|
||||
'use strict';
|
||||
|
||||
return Column.extend({
|
||||
defaults: {
|
||||
bodyTmpl: 'ui/grid/cells/html'
|
||||
},
|
||||
getLabel: function (record) {
|
||||
var label = this._super(record);
|
||||
|
||||
if (label !== '') {
|
||||
switch (record.status) {
|
||||
case '1':
|
||||
label = '<span class="grid-severity-notice"><span>' + label + '</span></span>';
|
||||
break;
|
||||
case '2':
|
||||
label = '<span class="grid-severity-critical"><span>' + label + '</span></span>';
|
||||
break;
|
||||
case '3':
|
||||
label = '<span class="grid-severity-minor"><span>' + label + '</span></span>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/modal',
|
||||
'mage/translate'
|
||||
], function ($, modal, $t) {
|
||||
"use strict";
|
||||
|
||||
$.widget('mageplaza.mpBlogAuthor', {
|
||||
options: {
|
||||
url: ''
|
||||
},
|
||||
isloaded: false,
|
||||
|
||||
/**
|
||||
* This method constructs a new widget.
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
this.initCustomerGrid();
|
||||
this.selectCustomer();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init popup
|
||||
* Popup will automatic open
|
||||
*/
|
||||
initPopup: function () {
|
||||
var options = {
|
||||
type: 'popup',
|
||||
responsive: true,
|
||||
innerScroll: true,
|
||||
title: $t('Select Customer'),
|
||||
buttons: []
|
||||
},
|
||||
customerGridEl = $('#customer-grid');
|
||||
|
||||
modal(options, customerGridEl);
|
||||
customerGridEl.modal('openModal');
|
||||
},
|
||||
|
||||
/**
|
||||
* Init select customer
|
||||
*/
|
||||
selectCustomer: function () {
|
||||
$('body').delegate('#customer-grid_table tbody tr', 'click', function () {
|
||||
var first_name = $(this).find('td:nth-child(3)').text().trim(),
|
||||
last_name = $(this).find('td:nth-child(4)').text().trim();
|
||||
|
||||
$("#author_customer_id").val($(this).find('input').val().trim());
|
||||
$("#author_customer").val(first_name+' '+last_name);
|
||||
$('#customer-grid').data('mageModal').closeModal();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Init customer grid
|
||||
*/
|
||||
initCustomerGrid: function () {
|
||||
var self = this;
|
||||
|
||||
$("#author_customer").click(function () {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: self.options.url,
|
||||
data: {form_key: window.FORM_KEY},
|
||||
showLoader: true
|
||||
}).done(function (response) {
|
||||
$('#customer-grid').html(response);
|
||||
self.initPopup();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $.mageplaza.mpBlogAuthor;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user