Skip to content

Commit

Permalink
feat(admin-ui): Implement UI for entity duplication
Browse files Browse the repository at this point in the history
Relates to #627
  • Loading branch information
michaelbromley committed Feb 20, 2024
1 parent da58b0b commit 7aa0d16
Show file tree
Hide file tree
Showing 41 changed files with 703 additions and 118 deletions.
95 changes: 50 additions & 45 deletions packages/admin-ui/i18n-coverage.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,106 @@
{
"generatedOn": "2024-01-26T08:34:41.984Z",
"lastCommit": "2314ff6a392488179cd3e3c553a445bd0fd8202d",
"generatedOn": "2024-02-20T08:21:48.514Z",
"lastCommit": "752e740a338bdef4a8634260fa5a4c7379d448d5",
"translationStatus": {
"ar": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"cs": {
"tokenCount": 769,
"translatedCount": 579,
"tokenCount": 778,
"translatedCount": 587,
"percentage": 75
},
"de": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"en": {
"tokenCount": 769,
"translatedCount": 768,
"tokenCount": 778,
"translatedCount": 777,
"percentage": 100
},
"es": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"fa": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"fr": {
"tokenCount": 769,
"translatedCount": 765,
"tokenCount": 778,
"translatedCount": 773,
"percentage": 99
},
"he": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"hr": {
"tokenCount": 769,
"translatedCount": 766,
"percentage": 100
"tokenCount": 778,
"translatedCount": 774,
"percentage": 99
},
"it": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"nb": {
"tokenCount": 769,
"translatedCount": 764,
"tokenCount": 778,
"translatedCount": 772,
"percentage": 99
},
"ne": {
"tokenCount": 769,
"translatedCount": 756,
"tokenCount": 778,
"translatedCount": 764,
"percentage": 98
},
"pl": {
"tokenCount": 769,
"translatedCount": 409,
"percentage": 53
"tokenCount": 778,
"translatedCount": 417,
"percentage": 54
},
"pt_BR": {
"tokenCount": 769,
"translatedCount": 766,
"percentage": 100
"tokenCount": 778,
"translatedCount": 774,
"percentage": 99
},
"pt_PT": {
"tokenCount": 769,
"translatedCount": 614,
"tokenCount": 778,
"translatedCount": 622,
"percentage": 80
},
"ru": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"sv": {
"tokenCount": 778,
"translatedCount": 776,
"percentage": 100
},
"uk": {
"tokenCount": 769,
"translatedCount": 767,
"tokenCount": 778,
"translatedCount": 775,
"percentage": 100
},
"zh_Hans": {
"tokenCount": 769,
"translatedCount": 549,
"percentage": 71
"tokenCount": 778,
"translatedCount": 557,
"percentage": 72
},
"zh_Hant": {
"tokenCount": 769,
"translatedCount": 396,
"percentage": 51
"tokenCount": 778,
"translatedCount": 404,
"percentage": 52
}
}
}
6 changes: 6 additions & 0 deletions packages/admin-ui/src/lib/catalog/src/catalog.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { CollectionBreadcrumbPipe } from './components/collection-list/collectio
import {
assignCollectionsToChannelBulkAction,
deleteCollectionsBulkAction,
duplicateCollectionsBulkAction,
moveCollectionsBulkAction,
removeCollectionsFromChannelBulkAction,
} from './components/collection-list/collection-list-bulk-actions';
Expand All @@ -42,6 +43,7 @@ import { FacetDetailComponent } from './components/facet-detail/facet-detail.com
import {
assignFacetsToChannelBulkAction,
deleteFacetsBulkAction,
duplicateFacetsBulkAction,
removeFacetsFromChannelBulkAction,
} from './components/facet-list/facet-list-bulk-actions';
import { FacetListComponent } from './components/facet-list/facet-list.component';
Expand All @@ -53,6 +55,7 @@ import {
assignFacetValuesToProductsBulkAction,
assignProductsToChannelBulkAction,
deleteProductsBulkAction,
duplicateProductsBulkAction,
removeProductsFromChannelBulkAction,
} from './components/product-list/product-list-bulk-actions';
import { ProductListComponent } from './components/product-list/product-list.component';
Expand Down Expand Up @@ -132,17 +135,20 @@ export class CatalogModule {
bulkActionRegistryService.registerBulkAction(assignProductVariantsToChannelBulkAction);
bulkActionRegistryService.registerBulkAction(removeProductsFromChannelBulkAction);
bulkActionRegistryService.registerBulkAction(removeProductVariantsFromChannelBulkAction);
bulkActionRegistryService.registerBulkAction(duplicateProductsBulkAction);
bulkActionRegistryService.registerBulkAction(deleteProductsBulkAction);
bulkActionRegistryService.registerBulkAction(deleteProductVariantsBulkAction);
bulkActionRegistryService.registerBulkAction(assignFacetValuesToProductVariantsBulkAction);

bulkActionRegistryService.registerBulkAction(assignFacetsToChannelBulkAction);
bulkActionRegistryService.registerBulkAction(removeFacetsFromChannelBulkAction);
bulkActionRegistryService.registerBulkAction(duplicateFacetsBulkAction);
bulkActionRegistryService.registerBulkAction(deleteFacetsBulkAction);

bulkActionRegistryService.registerBulkAction(moveCollectionsBulkAction);
bulkActionRegistryService.registerBulkAction(assignCollectionsToChannelBulkAction);
bulkActionRegistryService.registerBulkAction(removeCollectionsFromChannelBulkAction);
bulkActionRegistryService.registerBulkAction(duplicateCollectionsBulkAction);
bulkActionRegistryService.registerBulkAction(deleteCollectionsBulkAction);

pageService.registerPageTab({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createBulkDeleteAction,
createBulkRemoveFromChannelAction,
DataService,
DuplicateEntityDialogComponent,
GetCollectionListQuery,
ItemOf,
ModalService,
Expand Down Expand Up @@ -106,3 +107,30 @@ export const removeCollectionsFromChannelBulkAction = createBulkRemoveFromChanne
})
.pipe(map(res => res.removeCollectionsFromChannel)),
});

export const duplicateCollectionsBulkAction: BulkAction<
ItemOf<GetCollectionListQuery, 'collections'>,
CollectionListComponent
> = {
location: 'collection-list',
label: _('common.duplicate'),
icon: 'copy',
onClick: ({ injector, selection, hostComponent, clearSelection }) => {
const modalService = injector.get(ModalService);
modalService
.fromComponent(DuplicateEntityDialogComponent<ItemOf<GetCollectionListQuery, 'collections'>>, {
locals: {
entities: selection,
entityName: 'Collection',
title: _('catalog.duplicate-collections'),
getEntityName: entity => entity.name,
},
})
.subscribe(result => {
if (result) {
clearSelection();
hostComponent.refresh();
}
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createBulkRemoveFromChannelAction,
currentChannelIsNotDefault,
DataService,
DuplicateEntityDialogComponent,
getChannelCodeFromUserStatus,
GetFacetListQuery,
ItemOf,
Expand Down Expand Up @@ -179,3 +180,30 @@ export const removeFacetsFromChannelBulkAction2: BulkAction<
});
},
};

export const duplicateFacetsBulkAction: BulkAction<
ItemOf<GetFacetListQuery, 'facets'>,
FacetListComponent
> = {
location: 'facet-list',
label: _('common.duplicate'),
icon: 'copy',
onClick: ({ injector, selection, hostComponent, clearSelection }) => {
const modalService = injector.get(ModalService);
modalService
.fromComponent(DuplicateEntityDialogComponent<ItemOf<GetFacetListQuery, 'facets'>>, {
locals: {
entities: selection,
entityName: 'Facet',
title: _('catalog.duplicate-facets'),
getEntityName: entity => entity.name,
},
})
.subscribe(result => {
if (result) {
clearSelection();
hostComponent.refresh();
}
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</div>
<button class="button-small" (click)="assignToChannel()">
<clr-icon shape="layers"></clr-icon>
{{ 'catalog.assign-to-channel' | translate }}
{{ 'common.assign-to-channel' | translate }}
</button>
</div>
</vdr-form-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createBulkRemoveFromChannelAction,
DataService,
DeletionResult,
DuplicateEntityDialogComponent,
GetProductListQuery,
isMultiChannel,
ItemOf,
Expand Down Expand Up @@ -80,7 +81,7 @@ export const assignProductsToChannelBulkAction: BulkAction<
ProductListComponent
> = {
location: 'product-list',
label: _('catalog.assign-to-channel'),
label: _('common.assign-to-channel'),
icon: 'layers',
requiresPermission: userPermissions =>
userPermissions.includes(Permission.UpdateCatalog) ||
Expand Down Expand Up @@ -155,3 +156,30 @@ export const assignFacetValuesToProductsBulkAction: BulkAction<
});
},
};

export const duplicateProductsBulkAction: BulkAction<
ItemOf<GetProductListQuery, 'products'>,
ProductListComponent
> = {
location: 'product-list',
label: _('common.duplicate'),
icon: 'copy',
onClick: ({ injector, selection, hostComponent, clearSelection }) => {
const modalService = injector.get(ModalService);
modalService
.fromComponent(DuplicateEntityDialogComponent<ItemOf<GetProductListQuery, 'products'>>, {
locals: {
entities: selection,
entityName: 'Product',
title: _('catalog.duplicate-products'),
getEntityName: entity => entity.name,
},
})
.subscribe(result => {
if (result) {
clearSelection();
hostComponent.refresh();
}
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const assignProductVariantsToChannelBulkAction: BulkAction<
ProductVariantListComponent
> = {
location: 'product-variant-list',
label: _('catalog.assign-to-channel'),
label: _('common.assign-to-channel'),
icon: 'layers',
requiresPermission: userPermissions =>
userPermissions.includes(Permission.UpdateCatalog) ||
Expand Down
Loading

0 comments on commit 7aa0d16

Please sign in to comment.