Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | 1110x 1110x 1x 1x 1125x 1125x 1125x 40x 1085x 40x 40x 40x 40x 40x 1125x 1125x 40x 40x 1125x 1165x | define(
[
'jquery',
'underscore',
'oro/translator',
'pim/router',
'pim/dashboard/abstract-widget',
'pim/importexport/template/widget/last-operations-widget',
'pim/importexport/template/widget/view-all-btn'
],
function ($, _, __, router, AbstractWidget, template, viewAllBtnTemplate) {
'use strict';
return AbstractWidget.extend({
viewAllTitle: 'Show job tracker',
options: {
contentLoaded: false
},
template: _.template(template),
jobTrackerBtnTemplate: _.template(viewAllBtnTemplate),
events: {
'click .show-details-btn': 'showOperationDetails'
},
/**
* Redirect to the clicked operation page
*
* @param {Object} event
*/
showOperationDetails: function (event) {
event.preventDefault();
var operationType = $(event.currentTarget).data('operation-type');
switch (operationType) {
case 'import':
case 'export':
router.redirectToRoute(
'pim_importexport_' + operationType + '_execution_show',
{ id: $(event.currentTarget).data('id') }
);
break;
default:
router.redirectToRoute(
'pim_enrich_job_tracker_show',
{ id: $(event.currentTarget).data('id') }
);
break;
}
},
/**
* Call when user clicks on the show job tracker button. Redirect to the Job tracker.
*
* @param {Object} event
*/
showTracker: function (event) {
event.preventDefault();
router.redirectToRoute('pim_enrich_job_tracker_index');
},
/**
* {@inheritdoc}
*/
_afterLoad: function () {
AbstractWidget.prototype._afterLoad.apply(this, arguments);
var $btn = this._getViewAllBtn();
if (!_.isEmpty(this.data)) {
this._addShowTrackerBtn();
} else Iif (0 > $btn.length) {
$btn.hide();
}
},
/**
* Add the button which show the job tracker
*/
_addShowTrackerBtn: function () {
var $btn = this._getViewAllBtn();
Iif (0 < $btn.length) {
return;
}
var $jobTrackerBtn = $(this.jobTrackerBtnTemplate({ title: this.viewAllTitle }));
this.$el.closest('.AknWidget').find('.widget-actions').prepend($jobTrackerBtn);
$jobTrackerBtn.on('click', this.showTracker.bind(this));
},
/**
* {@inheritdoc}
*/
_processResponse: function (data) {
this.options.contentLoaded = true;
_.each(data, function (operation) {
const statusLabel = __(operation.statusLabel);
operation.statusLabel = statusLabel.slice(0, 1).toUpperCase() +
statusLabel.slice(1).toLowerCase();
}, this);
return data;
},
/**
* Returns the view all button
*
* @return {jQuery}
*/
_getViewAllBtn: function () {
return $('.view-all-btn[title="' + this.viewAllTitle + '"]');
}
});
}
);
|