diff --git a/packages/vendure-plugin-stock-monitoring/CHANGELOG.md b/packages/vendure-plugin-stock-monitoring/CHANGELOG.md index 4fe6df86..14353853 100644 --- a/packages/vendure-plugin-stock-monitoring/CHANGELOG.md +++ b/packages/vendure-plugin-stock-monitoring/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.3.0 (2023-11-09) + +- Fixed `reduceSum` function call bug +- Made `StockWidgetComponent` standalone and removed `StockWidgetSharedModule` and `StockWidgetModule` + # 1.2.0 (2023-10-26) - Fix broken links as described [here](https://github.com/Pinelab-studio/pinelab-vendure-plugins/issues/277) diff --git a/packages/vendure-plugin-stock-monitoring/package.json b/packages/vendure-plugin-stock-monitoring/package.json index 448fcb2b..7556d44e 100644 --- a/packages/vendure-plugin-stock-monitoring/package.json +++ b/packages/vendure-plugin-stock-monitoring/package.json @@ -1,6 +1,6 @@ { "name": "@pinelab/vendure-plugin-stock-monitoring", - "version": "1.2.0", + "version": "1.3.0", "description": "Vendure plugin for monitoring stock levels through a widget or by email", "author": "Martijn van de Brug <martijn@pinelab.studio>", "homepage": "https://pinelab-plugins.com/", diff --git a/packages/vendure-plugin-stock-monitoring/src/stock-monitoring.plugin.ts b/packages/vendure-plugin-stock-monitoring/src/stock-monitoring.plugin.ts index 308e050b..1e47f879 100644 --- a/packages/vendure-plugin-stock-monitoring/src/stock-monitoring.plugin.ts +++ b/packages/vendure-plugin-stock-monitoring/src/stock-monitoring.plugin.ts @@ -28,13 +28,7 @@ export interface StockMonitoringPlugin { export class StockMonitoringPlugin { static ui: AdminUiExtension = { extensionPath: path.join(__dirname, 'ui'), - ngModules: [ - { - type: 'shared', - ngModuleFileName: 'stock-widget.shared-module.ts', - ngModuleName: 'StockWidgetSharedModule', - }, - ], + providers: ['providers.ts'], }; static threshold = 10; static init(options: StockMonitoringPlugin): typeof StockMonitoringPlugin { diff --git a/packages/vendure-plugin-stock-monitoring/src/ui/providers.ts b/packages/vendure-plugin-stock-monitoring/src/ui/providers.ts new file mode 100644 index 00000000..a6175dd9 --- /dev/null +++ b/packages/vendure-plugin-stock-monitoring/src/ui/providers.ts @@ -0,0 +1,18 @@ +import { + registerDashboardWidget, + setDashboardWidgetLayout, +} from '@vendure/admin-ui/core'; +export default [ + registerDashboardWidget('stock-levels', { + title: 'Low stock', + supportedWidths: [4, 6, 8, 12], + loadComponent: () => + import('./stock-widget').then((m) => m.StockWidgetComponent), + }), + setDashboardWidgetLayout([ + { id: 'welcome', width: 12 }, + { id: 'orderSummary', width: 6 }, + { id: 'reviews', width: 6 }, + { id: 'latestOrders', width: 12 }, + ]), +]; diff --git a/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.shared-module.ts b/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.shared-module.ts deleted file mode 100644 index e69cf5cc..00000000 --- a/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.shared-module.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { NgModule } from '@angular/core'; -import { - registerDashboardWidget, - setDashboardWidgetLayout, -} from '@vendure/admin-ui/core'; -import { StockWidgetModule } from './stock-widget'; - -@NgModule({ - imports: [StockWidgetModule], - declarations: [], - providers: [ - registerDashboardWidget('stock-levels', { - title: 'Low stock', - supportedWidths: [4, 6, 8, 12], - loadComponent: () => - import('./stock-widget').then((m) => m.StockWidgetComponent), - }), - setDashboardWidgetLayout([ - { id: 'welcome', width: 12 }, - { id: 'orderSummary', width: 6 }, - { id: 'reviews', width: 6 }, - { id: 'latestOrders', width: 12 }, - ]), - ], -}) -export class StockWidgetSharedModule {} diff --git a/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.ts b/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.ts index 447a81ae..934772e7 100644 --- a/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.ts +++ b/packages/vendure-plugin-stock-monitoring/src/ui/stock-widget.ts @@ -5,6 +5,8 @@ import { Observable } from 'rxjs'; import gql from 'graphql-tag'; @Component({ + standalone: true, + imports: [SharedModule], selector: 'stock-widget', template: ` <vdr-data-table [items]="variant$ | async" class="stock-widget-overflow"> @@ -63,13 +65,7 @@ export class StockWidgetComponent implements OnInit { ) .mapStream((data) => (data as any).productVariantsWithLowStock); } -} -@NgModule({ - imports: [SharedModule], - declarations: [StockWidgetComponent], -}) -export class StockWidgetModule { reduceSum(stockLevels: any[]): number { return stockLevels.reduce((acc, val) => (acc += val.stockOnHand), 0); }