casperiv 1 год назад
Родитель
Сommit
17b3b54743

+ 14 - 11
packages/admin-ui/src/lib/core/src/common/utilities/bulk-action-utils.ts

@@ -211,23 +211,26 @@ export function createBulkAssignToChannelAction<ItemType>(
                 .pipe(
                     switchMap(result => {
                         if (result) {
-                            return config
-                                .bulkAssignToChannel(
-                                    dataService,
-                                    selection.map(c => c.id),
-                                    result.map(c => c.id),
-                                )
-                                .map(result => result.pipe(mapTo(result)));
+                            const observables = config.bulkAssignToChannel(
+                                dataService,
+                                selection.map(c => c.id),
+                                result.map(c => c.id),
+                            );
+
+                            return from(observables).pipe(
+                                switchMap(res => res),
+                                mapTo(result),
+                            );
                         } else {
                             return EMPTY;
                         }
                     }),
                 )
                 .subscribe(result => {
-                    // notificationService.success(_('common.notify-assign-to-channel-success-with-count'), {
-                    //     count: selection.length,
-                    //     channelCode: result.code,
-                    // });
+                    notificationService.success(_('common.notify-assign-to-channel-success-with-count'), {
+                        count: selection.length,
+                        channelCode: result.map(c => c.code).join(', '),
+                    });
                     clearSelection();
                 });
         },

+ 1 - 1
packages/admin-ui/src/lib/core/src/shared/components/assign-to-channel-dialog/assign-to-channel-dialog.component.html

@@ -29,7 +29,7 @@
 
 <ng-template vdrDialogButtons>
     <button type="button" class="btn" (click)="cancel()">{{ 'common.cancel' | translate }}</button>
-    <button type="submit" (click)="assign()" [disabled]="selectedChannels.length > 0" class="btn btn-primary">
+    <button type="submit" (click)="assign()" [disabled]="selectedChannels.length <= 0" class="btn btn-primary">
         <ng-template [ngIf]="selectedChannels.length > 0" [ngIfElse]="noSelection">
             {{ 'catalog.assign-to-channel' | translate }}
         </ng-template>

+ 33 - 3
packages/admin-ui/src/lib/marketing/src/components/promotion-list/promotion-list-bulk-actions.ts

@@ -8,8 +8,27 @@ import {
     Permission,
     RemovePromotionsFromChannelDocument,
 } from '@vendure/admin-ui/core';
+import { gql } from 'apollo-angular';
 import { map } from 'rxjs/operators';
 
+const ASSIGN_PROMOTIONS_TO_CHANNEL = gql`
+    mutation AssignPromotionsToChannel($input: AssignPromotionsToChannelInput!) {
+        assignPromotionsToChannel(input: $input) {
+            id
+            name
+        }
+    }
+`;
+
+const REMOVE_PROMOTIONS_FROM_CHANNEL = gql`
+    mutation RemovePromotionsFromChannel($input: RemovePromotionsFromChannelInput!) {
+        removePromotionsFromChannel(input: $input) {
+            id
+            name
+        }
+    }
+`;
+
 export const deletePromotionsBulkAction = createBulkDeleteAction<ItemOf<GetPromotionListQuery, 'promotions'>>(
     {
         location: 'promotion-list',
@@ -26,8 +45,18 @@ export const assignPromotionsToChannelBulkAction = createBulkAssignToChannelActi
     location: 'promotion-list',
     requiresPermission: Permission.UpdatePromotion,
     getItemName: item => item.name,
-    bulkAssignToChannel: (dataService, promotionIds, channelIds) =>
-        channelIds.map(channelId =>
+    bulkAssignToChannel: (dataService, promotionIds, channelIds) => {
+        console.log({ channelIds });
+        dataService
+            .mutate(AssignPromotionsToChannelDocument, {
+                input: {
+                    channelId: channelIds[0],
+                    promotionIds,
+                },
+            })
+            .pipe(map(res => res.assignPromotionsToChannel));
+
+        return channelIds.map(channelId =>
             dataService
                 .mutate(AssignPromotionsToChannelDocument, {
                     input: {
@@ -36,7 +65,8 @@ export const assignPromotionsToChannelBulkAction = createBulkAssignToChannelActi
                     },
                 })
                 .pipe(map(res => res.assignPromotionsToChannel)),
-        ),
+        );
+    },
 });
 
 export const removePromotionsFromChannelBulkAction = createBulkRemoveFromChannelAction<

+ 5 - 5
packages/dev-server/dev-config.ts

@@ -77,8 +77,8 @@ export const devConfig: VendureConfig = {
             assetUploadDir: path.join(__dirname, 'assets'),
         }),
         DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: false }),
-        BullMQJobQueuePlugin.init({}),
-        // DefaultJobQueuePlugin.init({}),
+        // BullMQJobQueuePlugin.init({}),
+        DefaultJobQueuePlugin.init({}),
         // JobQueueTestPlugin.init({ queueCount: 10 }),
         // ElasticsearchPlugin.init({
         //     host: 'http://localhost',
@@ -133,9 +133,9 @@ function getDbConfig(): DataSourceOptions {
                 type: 'postgres',
                 host: process.env.DB_HOST || 'localhost',
                 port: Number(process.env.DB_PORT) || 5432,
-                username: process.env.DB_USERNAME || 'postgres',
-                password: process.env.DB_PASSWORD || 'postgres',
-                database: process.env.DB_NAME || 'vendure',
+                username: process.env.DB_USERNAME || 'admin',
+                password: process.env.DB_PASSWORD || 'secret',
+                database: process.env.DB_NAME || 'postgres',
                 schema: process.env.DB_SCHEMA || 'public',
             };
         case 'sqlite':