@haus-tech/badge-plugin 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/badge.plugin.js +14 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/ui/badge-list.component.html +78 -0
- package/dist/ui/badge-list.component.js +0 -3
- package/dist/ui/badge-list.component.scss +139 -0
- package/dist/ui/badge-list.component.ts +274 -0
- package/dist/ui/badge-nav.module.d.ts +2 -0
- package/dist/ui/badge-nav.module.js +27 -0
- package/dist/ui/badge-nav.module.ts +18 -0
- package/dist/ui/badge.module.d.ts +2 -0
- package/dist/ui/badge.module.js +34 -0
- package/dist/ui/badge.module.ts +22 -0
- package/dist/ui/gql/gql.ts +62 -0
- package/dist/ui/gql/graphql.ts +6842 -0
- package/dist/ui/gql/index.ts +1 -0
- package/dist/ui/translations/en.json +8 -0
- package/dist/ui/translations/sv.json +8 -0
- package/dist/ui/update-badge.component.html +52 -0
- package/dist/ui/update-badge.component.js +0 -2
- package/dist/ui/update-badge.component.scss +16 -0
- package/dist/ui/update-badge.component.ts +91 -0
- package/package.json +2 -2
- package/dist/ui/providers.d.ts +0 -2
- package/dist/ui/providers.js +0 -11
- package/dist/ui/routes.d.ts +0 -29
- package/dist/ui/routes.js +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./gql";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<form class="form" [formGroup]="form" id="export-form">
|
|
2
|
+
<vdr-labeled-data [label]="'badge-plugin.position' | translate" class="select-wrapper">
|
|
3
|
+
<ng-select
|
|
4
|
+
[multiple]="false"
|
|
5
|
+
[clearable]="false"
|
|
6
|
+
[searchable]="false"
|
|
7
|
+
(change)="positionChanged($event)"
|
|
8
|
+
formControlName="position"
|
|
9
|
+
class="custom"
|
|
10
|
+
>
|
|
11
|
+
<ng-template ng-label-tmp let-position="item" let-clear="clear">
|
|
12
|
+
{{ position }}
|
|
13
|
+
</ng-template>
|
|
14
|
+
<ng-option *ngFor="let position of availablePositions" [value]="position">
|
|
15
|
+
{{ position }}
|
|
16
|
+
</ng-option>
|
|
17
|
+
</ng-select>
|
|
18
|
+
</vdr-labeled-data>
|
|
19
|
+
|
|
20
|
+
<vdr-labeled-data [label]="'badge-plugin.collections' | translate">
|
|
21
|
+
<ng-select
|
|
22
|
+
[multiple]="false"
|
|
23
|
+
[clearable]="true"
|
|
24
|
+
[searchable]="true"
|
|
25
|
+
[items]="allCollections$ | async"
|
|
26
|
+
bindLabel="name"
|
|
27
|
+
bindValue="id"
|
|
28
|
+
(change)="collectionValueChanged($event)"
|
|
29
|
+
formControlName="collectionId"
|
|
30
|
+
style="width: 100%"
|
|
31
|
+
>
|
|
32
|
+
<ng-template ng-label-tmp let-tag="item" let-clear="clear">
|
|
33
|
+
<vdr-chip [colorFrom]="tag.name"
|
|
34
|
+
><clr-icon shape="folder-open" class="mr2"></clr-icon> {{ tag.name }}</vdr-chip
|
|
35
|
+
>
|
|
36
|
+
</ng-template>
|
|
37
|
+
<ng-option *ngFor="let tag of allCollections$ | async" [value]="tag">
|
|
38
|
+
<vdr-chip [colorFrom]="tag.name"
|
|
39
|
+
><clr-icon shape="folder-open" class="mr2"></clr-icon> {{ tag.name }}</vdr-chip
|
|
40
|
+
>
|
|
41
|
+
</ng-option>
|
|
42
|
+
</ng-select>
|
|
43
|
+
</vdr-labeled-data>
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
(click)="updateBadge()"
|
|
47
|
+
*ngIf="form.dirty"
|
|
48
|
+
class="btn btn-primary mt-2 mb-4"
|
|
49
|
+
>
|
|
50
|
+
Update
|
|
51
|
+
</button>
|
|
52
|
+
</form>
|
|
@@ -95,8 +95,6 @@ UpdateBadgeComponent = __decorate([
|
|
|
95
95
|
templateUrl: './update-badge.component.html',
|
|
96
96
|
styleUrls: ['./update-badge.component.scss'],
|
|
97
97
|
changeDetection: core_1.ChangeDetectionStrategy.OnPush,
|
|
98
|
-
standalone: true,
|
|
99
|
-
imports: [core_2.SharedModule],
|
|
100
98
|
}),
|
|
101
99
|
__metadata("design:paramtypes", [forms_1.FormBuilder,
|
|
102
100
|
core_1.ChangeDetectorRef,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
ChangeDetectorRef,
|
|
5
|
+
Input,
|
|
6
|
+
Output,
|
|
7
|
+
OnChanges,
|
|
8
|
+
SimpleChanges,
|
|
9
|
+
EventEmitter,
|
|
10
|
+
} from '@angular/core'
|
|
11
|
+
import { FormBuilder, FormGroup } from '@angular/forms'
|
|
12
|
+
import { Observable } from 'rxjs'
|
|
13
|
+
import { DataService } from '@vendure/admin-ui/core'
|
|
14
|
+
import { Badge, Collection } from './gql/graphql'
|
|
15
|
+
import { graphql } from './gql'
|
|
16
|
+
|
|
17
|
+
const updateBadgeDocument = graphql(`
|
|
18
|
+
mutation UpdateBadge($input: UpdateBadgeInput!) {
|
|
19
|
+
updateBadge(input: $input) {
|
|
20
|
+
id
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`)
|
|
24
|
+
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'update-badge',
|
|
27
|
+
templateUrl: './update-badge.component.html',
|
|
28
|
+
styleUrls: ['./update-badge.component.scss'],
|
|
29
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
30
|
+
})
|
|
31
|
+
export class UpdateBadgeComponent implements OnChanges {
|
|
32
|
+
@Input() badge: Badge
|
|
33
|
+
@Input() availablePositions: string[] = []
|
|
34
|
+
@Output() badgeUpdated: EventEmitter<Badge> = new EventEmitter<Badge>()
|
|
35
|
+
|
|
36
|
+
form: FormGroup
|
|
37
|
+
|
|
38
|
+
allCollections$: Observable<Collection[]>
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
private formBuilder: FormBuilder,
|
|
42
|
+
private changeDetector: ChangeDetectorRef,
|
|
43
|
+
private dataService: DataService,
|
|
44
|
+
) {
|
|
45
|
+
this.form = this.formBuilder.group({
|
|
46
|
+
collectionId: [''],
|
|
47
|
+
position: [''],
|
|
48
|
+
})
|
|
49
|
+
this.allCollections$ = this.dataService.collection
|
|
50
|
+
.getCollections()
|
|
51
|
+
.mapSingle((data) => data.collections.items as Collection[])
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
55
|
+
if (changes.badge && changes.badge.currentValue) {
|
|
56
|
+
this.form.patchValue({
|
|
57
|
+
collectionId: this.badge?.collectionId,
|
|
58
|
+
position: this.badge?.position,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
collectionValueChanged(event: Collection) {
|
|
64
|
+
this.form.patchValue({ collectionId: event.id })
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
positionChanged(event: string) {
|
|
68
|
+
this.form.patchValue({ position: event })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
updateBadge() {
|
|
72
|
+
this.dataService
|
|
73
|
+
.mutate(updateBadgeDocument, {
|
|
74
|
+
input: {
|
|
75
|
+
id: this.badge.id,
|
|
76
|
+
collectionId: this.form.value.collectionId,
|
|
77
|
+
position: this.form.value.position,
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
.subscribe({
|
|
81
|
+
next: (result) => {
|
|
82
|
+
this.form.markAsPristine()
|
|
83
|
+
this.changeDetector.detectChanges()
|
|
84
|
+
this.badgeUpdated.emit({ ...this.badge, ...this.form.value })
|
|
85
|
+
},
|
|
86
|
+
error: (err) => {
|
|
87
|
+
console.error('Error updating badge:', err)
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haus-tech/badge-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Adds a badge to product images",
|
|
5
5
|
"author": "Haus Tech",
|
|
6
6
|
"repository": "https://github.com/WeAreHausTech/haus-tech-vendure-plugins",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "yarn ts-node test/dev-server.ts",
|
|
20
|
-
"build": "rimraf dist && tsc",
|
|
20
|
+
"build": "rimraf dist && tsc && copyfiles -u 1 'src/ui/**/*' dist/",
|
|
21
21
|
"test": "jest --preset=\"ts-jest\"",
|
|
22
22
|
"prepublishOnly": "yarn && yarn build"
|
|
23
23
|
},
|
package/dist/ui/providers.d.ts
DELETED
package/dist/ui/providers.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@vendure/admin-ui/core");
|
|
4
|
-
exports.default = [
|
|
5
|
-
(0, core_1.addNavMenuItem)({
|
|
6
|
-
id: 'badges',
|
|
7
|
-
label: 'Badges',
|
|
8
|
-
routerLink: ['/extensions/badges'],
|
|
9
|
-
icon: 'star',
|
|
10
|
-
}, 'catalog'),
|
|
11
|
-
];
|
package/dist/ui/routes.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
resolve: {
|
|
3
|
-
detail?: import("@angular/router").ResolveFn<{
|
|
4
|
-
entity: import("rxjs").Observable<any>;
|
|
5
|
-
result?: any;
|
|
6
|
-
}> | undefined;
|
|
7
|
-
};
|
|
8
|
-
data: {
|
|
9
|
-
breadcrumb: import("rxjs").BehaviorSubject<import("@vendure/admin-ui/core").BreadcrumbValue> | ((data: any) => any);
|
|
10
|
-
};
|
|
11
|
-
component: typeof import("@vendure/admin-ui/core").AngularRouteComponent;
|
|
12
|
-
title?: string | import("@angular/core").Type<import("@angular/router").Resolve<string>> | import("@angular/router").ResolveFn<string> | undefined;
|
|
13
|
-
path: string;
|
|
14
|
-
pathMatch?: "prefix" | "full" | undefined;
|
|
15
|
-
matcher?: import("@angular/router").UrlMatcher | undefined;
|
|
16
|
-
loadComponent?: (() => import("@angular/core").Type<unknown> | import("rxjs").Observable<import("@angular/core").Type<unknown> | import("@angular/router").DefaultExport<import("@angular/core").Type<unknown>>> | Promise<import("@angular/core").Type<unknown> | import("@angular/router").DefaultExport<import("@angular/core").Type<unknown>>>) | undefined;
|
|
17
|
-
redirectTo?: string | undefined;
|
|
18
|
-
outlet?: string | undefined;
|
|
19
|
-
canActivate?: any[] | undefined;
|
|
20
|
-
canMatch?: any[] | undefined;
|
|
21
|
-
canActivateChild?: any[] | undefined;
|
|
22
|
-
canDeactivate?: any[] | undefined;
|
|
23
|
-
canLoad?: any[] | undefined;
|
|
24
|
-
children?: import("@angular/router").Routes | undefined;
|
|
25
|
-
loadChildren?: import("@angular/router").LoadChildrenCallback | undefined;
|
|
26
|
-
runGuardsAndResolvers?: import("@angular/router").RunGuardsAndResolvers | undefined;
|
|
27
|
-
providers: (import("@angular/core").Provider | import("@angular/core").EnvironmentProviders)[];
|
|
28
|
-
}[];
|
|
29
|
-
export default _default;
|
package/dist/ui/routes.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@vendure/admin-ui/core");
|
|
4
|
-
const badge_list_component_1 = require("./badge-list.component");
|
|
5
|
-
exports.default = [
|
|
6
|
-
(0, core_1.registerRouteComponent)({
|
|
7
|
-
component: badge_list_component_1.BadgeListComponent,
|
|
8
|
-
path: '',
|
|
9
|
-
title: 'Badges',
|
|
10
|
-
breadcrumb: 'Badges',
|
|
11
|
-
}),
|
|
12
|
-
];
|