Skip to content

Commit

Permalink
Merge pull request #274 from Pinelab-studio/feat/configure-primary-co…
Browse files Browse the repository at this point in the history
…llection-plugin

Configure Primary Collection Plugin
  • Loading branch information
martijnvdbrug authored Oct 24, 2023
2 parents 04efd5c + e45a022 commit c6f7cbf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/vendure-plugin-primary-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.3.0 (2023-10-20)

- Config option `customFieldUITabName` added

# 1.2.2 (2023-10-01)

- Renamed admin ui extention `NgModule` from `SharedExtensionModule` to `PrimaryCollectionSharedExtensionModule`
Expand Down
4 changes: 3 additions & 1 deletion packages/vendure-plugin-primary-collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Add the plugin to your `vendure-config.ts`:

```ts
plugins: [
PrimaryCollectionPlugin,
PrimaryCollectionPlugin.init({
customFieldUITabName: 'Primary Collection',
}),
AdminUiPlugin.init({
port: 3002,
route: 'admin',
Expand Down
4 changes: 2 additions & 2 deletions packages/vendure-plugin-primary-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pinelab/vendure-plugin-primary-collection",
"version": "1.2.2",
"description": "Adds a primary collection to all Products by extending vendure's graphql api",
"version": "1.3.0",
"description": "Adds a primary collection to all Products by extending Vendure's graphql api",
"author": "Surafel Melese Tariku <[email protected]>",
"homepage": "https://pinelab-plugins.com/",
"repository": "https://github.com/Pinelab-studio/pinelab-vendure-plugins",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
LanguageCode,
PluginCommonModule,
RuntimeVendureConfig,
Type,
VendurePlugin,
} from '@vendure/core';
import { gql } from 'graphql-tag';
Expand All @@ -11,6 +12,13 @@ import { AdminUiExtension } from '@vendure/ui-devkit/compiler';
import path from 'path';
import { PrimaryCollectionHelperService } from './api/primary-collections-helper.service';

export interface PrimaryCollectionPluginConfig {
/**
* This specifies the admin ui tab name under which the collection dropdown appears
*/
customFieldUITabName?: string;
}

@VendurePlugin({
imports: [PluginCommonModule],
providers: [PrimaryCollectionHelperService],
Expand All @@ -34,13 +42,15 @@ import { PrimaryCollectionHelperService } from './api/primary-collections-helper
nullable: true,
ui: {
component: 'select-primary-collection',
tab: PrimaryCollectionPlugin?.config?.customFieldUITabName,
},
label: [{ languageCode: LanguageCode.en, value: 'Primary Collection' }],
});
return config;
},
})
export class PrimaryCollectionPlugin {
static config: PrimaryCollectionPluginConfig;
static ui: AdminUiExtension = {
extensionPath: path.join(__dirname, 'ui'),
ngModules: [
Expand All @@ -51,4 +61,11 @@ export class PrimaryCollectionPlugin {
},
],
};

static init(
config: PrimaryCollectionPluginConfig
): Type<PrimaryCollectionPlugin> {
this.config = config;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class SelectPrimaryCollectionComponent
private activatedRoute: ActivatedRoute
) {}
ngOnInit(): void {
console.log(this.formControl.value, 'value');
this.formControl.parent?.parent?.statusChanges.subscribe((s) => {
if (
this.formControl.pristine &&
Expand Down

0 comments on commit c6f7cbf

Please sign in to comment.