Skip to content

Commit

Permalink
Move format function to mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGraml11 committed Apr 15, 2024
1 parent bfd9092 commit 403554b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import template from './nosto-grouped-view.html.twig';
import JobHelper from '../../util/job.helper';
import './nosto-grouped-view.scss';

const { Component } = Shopware;
const { Component, Mixin } = Shopware;
const { Criteria } = Shopware.Data;

/** @private */
Expand All @@ -14,7 +14,8 @@ Component.register('nosto-grouped-view', {
],

mixins: [
'notification',
Mixin.getByName('notification'),
Mixin.getByName('nosto-scheduler-utils'),
],

props: {
Expand Down Expand Up @@ -284,9 +285,5 @@ Component.register('nosto-grouped-view', {
this.currentJobMessages = job.messages;
this.showMessagesModal = true;
},

formatDate(date) {
return date ? (new Date(date)).toLocaleString() : '';
},
},
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import template from './nosto-job-info.html.twig';

const { Component } = Shopware;
const { Component, Mixin } = Shopware;
const { Criteria } = Shopware.Data;

/** @private */
Expand All @@ -13,7 +13,8 @@ Component.register('nosto-job-info', {
],

mixins: [
'notification',
Mixin.getByName('notification'),
Mixin.getByName('nosto-scheduler-utils'),
],

props: {
Expand Down Expand Up @@ -46,9 +47,5 @@ Component.register('nosto-job-info', {
this.jobItem = jobItem;
});
},

formatDate(date) {
return date ? (new Date(date)).toLocaleString() : '';
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import template from './nosto-job-sub-jobs.html.twig';
import JobHelper from '../../util/job.helper';
import './nosto-job-sub-jobs.scss';

const { Component } = Shopware;
const { Component, Mixin } = Shopware;
const { Criteria } = Shopware.Data;

/** @private */
Expand All @@ -15,7 +15,8 @@ Component.register('nosto-job-sub-jobs', {
],

mixins: [
'notification',
Mixin.getByName('notification'),
Mixin.getByName('nosto-scheduler-utils'),
],

props: {
Expand Down Expand Up @@ -133,9 +134,5 @@ Component.register('nosto-job-sub-jobs', {
return item.type === `${type}-message`;
}).length;
},

formatDate(date) {
return date ? (new Date(date)).toLocaleString() : '';
},
},
});
1 change: 1 addition & 0 deletions src/Resources/app/administration/src/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './mixins/nosto-scheduler-utils';
import './component/nosto-entity-listing';
import './component/nosto-job-status-badge';
import './module/nosto-job';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { Mixin, Utils } = Shopware;

Mixin.register('nosto-scheduler-utils', {
methods: {
formatDate(date) {
return Utils.format.date(date)

Check failure on line 6 in src/Resources/app/administration/src/mixins/nosto-scheduler-utils.js

View workflow job for this annotation

GitHub Actions / ESLint

Missing semicolon
}

Check failure on line 7 in src/Resources/app/administration/src/mixins/nosto-scheduler-utils.js

View workflow job for this annotation

GitHub Actions / ESLint

Missing trailing comma
}

Check failure on line 8 in src/Resources/app/administration/src/mixins/nosto-scheduler-utils.js

View workflow job for this annotation

GitHub Actions / ESLint

Missing trailing comma
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import template from './nosto-job-listing-index.html.twig';
import JobHelper from '../../../../util/job.helper';
import './nosto-job-listing-index.scss';

const { Component } = Shopware;
const { Component, Mixin } = Shopware;
const { Criteria } = Shopware.Data;

/** @private */
Expand All @@ -17,7 +17,8 @@ Component.register('nosto-job-listing-index', {
],

mixins: [
'notification',
Mixin.getByName('notification'),
Mixin.getByName('nosto-scheduler-utils'),
],

props: {
Expand Down Expand Up @@ -289,9 +290,5 @@ Component.register('nosto-job-listing-index', {
this.autoLoadIsActive = false;
clearInterval(this.reloadInterval);
},

formatDate(date) {
return date ? (new Date(date)).toLocaleString() : '';
},
},
});
2 changes: 1 addition & 1 deletion src/Resources/public/administration/js/nosto-scheduler.js

Large diffs are not rendered by default.

0 comments on commit 403554b

Please sign in to comment.