Skip to content

Commit 18bf033

Browse files
authored
FIX upload 3rd party certification (#174)
* FIX upload 3rd party certification * ADD allow adding additional certifications + filter them over the marketplace * FILTER compliance from normal chars on places that shouldnt be shown
1 parent f7ccaa6 commit 18bf033

12 files changed

Lines changed: 538 additions & 52 deletions

File tree

src/app/pages/product-details/product-details.component.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ <h3 class="text-2xl font-bold text-primary-100 dark:text-primary-50 text-left mb
262262
{{ 'PRODUCT_DETAILS._self_attestation' | translate }}
263263
</a>
264264
}
265-
265+
@if(complianceProf.length>0){
266+
<h3 class="text-2xl font-bold text-primary-100 dark:text-primary-50 text-left mb-2">
267+
3rd party certifications:
268+
</h3>
266269
<div class="flex flex-wrap -mx-4 mt-4 justify-center">
267270
@for (char of complianceProf; track char.id) {
268271
<div class="w-full md:w-1/2 lg:w-1/3 px-4 mb-8 " >
@@ -307,6 +310,23 @@ <h3 class="text-2xl font-bold mt-4 dark:text-white">{{char.name}}</h3>
307310
</div>
308311
}
309312
</div>
313+
}
314+
@if(additionalCerts.length>0){
315+
<h3 class="text-2xl font-bold text-primary-100 dark:text-primary-50 text-left mb-2">
316+
Additional certifications:
317+
</h3>
318+
<div class="flex flex-wrap -mx-4 mt-4 justify-center">
319+
@for (char of additionalCerts; track char.id) {
320+
<div class="w-full md:w-1/2 lg:w-1/3 px-4 mb-8 " >
321+
<div class="border border-2 rounded-lg shadow bg-white dark:bg-secondary-200 shadow-md p-8 h-full border-primary-100 cursor-pointer" (click)="goToLink(char.productSpecCharacteristicValue?.at(0)?.value)">
322+
<fa-icon [icon]="faAtom" class="fa-2xl text-primary-100 align-middle"></fa-icon>
323+
<h3 class="text-2xl font-bold mt-4 dark:text-white">{{normalizeName(char.name)}}</h3>
324+
325+
</div>
326+
</div>
327+
}
328+
</div>
329+
}
310330
</div>
311331

312332
<h2 class="text-4xl font-extrabold text-primary-100 dark:text-primary-50 text-center pb-8 pt-12">{{ 'PRODUCT_DETAILS._product_pricing' | translate }}</h2>

src/app/pages/product-details/product-details.component.ts

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
5757
attatchments: AttachmentRefOrValue[] = [];
5858
prodSpec:ProductSpecification = {};
5959
complianceProf:any[] = [];
60+
additionalCerts:any[] = [];
6061
complianceLevel:string='NL';
6162
complianceDescription:string='No level. This product hasnt reached any compliance level yet.'
6263
serviceSpecs:any[] = [];
@@ -259,25 +260,48 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
259260
if(this.prodSpec.productSpecCharacteristic != undefined) {
260261
// Avoid displaying the compliance credential && Avoid showing "- enabled" chars
261262
this.prodChars = this.prodSpec.productSpecCharacteristic.filter((char: any) => {
262-
return char.name != 'Compliance:VC' && char.name != 'Compliance:SelfAtt' && !char.name?.endsWith(' - enabled')
263+
return !char.name.startsWith('Compliance:') && !char.name?.endsWith(' - enabled')
263264
})
264265

265-
for(let i=0; i<certifications.length; i++){
266-
//Now we only show the certifications that are attached when creating/updating the product
267-
let compProf = this.prodSpec.productSpecCharacteristic.find((p => {
268-
return p.name === certifications[i].name
269-
}));
270-
if(compProf){
271-
let cert:any = certifications[i]
272-
cert.href = compProf.productSpecCharacteristicValue?.at(0)?.value
273-
this.complianceProf.push(certifications[i])
266+
this.additionalCerts = this.prodSpec.productSpecCharacteristic.filter((char: any) => {
267+
const cleanedName = char.name.replace('Compliance:', '').trim();
268+
269+
return (
270+
char.name.startsWith('Compliance:') &&
271+
!certifications.some(cert => cert.name === cleanedName) && char.name != 'Compliance:SelfAtt'
272+
);
273+
});
274+
console.log('--- additional')
275+
console.log(this.additionalCerts)
276+
277+
const normalizeName = (name?: string): string =>
278+
name?.replace(/compliance:/i, '').trim() ?? '';
279+
280+
for (let i = 0; i < certifications.length; i++) {
281+
282+
// Buscar característica quitando el prefijo "Compliance:"
283+
let compProf = this.prodSpec.productSpecCharacteristic.find(p => {
284+
return normalizeName(p.name) === certifications[i].name;
285+
});
286+
287+
if (compProf) {
288+
let cert: any = certifications[i];
289+
cert.href = compProf.productSpecCharacteristicValue?.at(0)?.value;
290+
this.complianceProf.push(cert);
274291
}
275-
//Deleting certifications out of characteristics' array
276-
const index = this.prodChars.findIndex(item => item.name === certifications[i].name);
277-
if(index!==-1){
292+
293+
// Eliminar certificaciones del array de características
294+
const index = this.prodChars.findIndex(item =>
295+
normalizeName(item.name) === certifications[i].name
296+
);
297+
298+
if (index !== -1) {
278299
this.prodChars.splice(index, 1);
279300
}
280301
}
302+
303+
console.log(this.complianceProf)
304+
281305

282306
}
283307

@@ -894,4 +918,8 @@ async deleteProduct(product: Product | undefined){
894918
}
895919
}
896920

921+
normalizeName(name?: string): string {
922+
return name?.replace(/compliance:/i, '').trim() ?? '';
923+
}
924+
897925
}

src/app/pages/seller-offerings/offerings/seller-offer/new-price-plan/new-price-plan.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ export class NewPricePlanComponent implements OnInit, OnDestroy {
143143

144144
checkPriceInfo(){
145145
for(let i=0;i<this.selectedProdSpec.productSpecCharacteristic.length;i++){
146-
if (!certifications.some(certification => certification.name === this.selectedProdSpec.productSpecCharacteristic[i].name)) {
146+
//if (!certifications.some(certification => certification.name === this.selectedProdSpec.productSpecCharacteristic[i].name)) {
147+
if (!certifications.some(certification => certification.name === this.selectedProdSpec.productSpecCharacteristic[i].name) && !this.selectedProdSpec.productSpecCharacteristic[i].name.startsWith('Compliance:')) {
147148
this.createdPriceProfile.push(this.selectedProdSpec.productSpecCharacteristic[i]);
148149
this.filteredCharacteristics.push(this.selectedProdSpec.productSpecCharacteristic[i]);
149150
}

src/app/pages/seller-offerings/offerings/seller-product-spec/create-product-spec/create-product-spec.component.html

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ <h3 class="font-bold text-primary-100 dark:text-primary-50 text-left ml-4">
282282
'break-all': hasLongWord(sel.name, 20),
283283
'break-words': !hasLongWord(sel.name, 20)
284284
}" class="px-6 py-4 text-wrap break-words">
285-
{{sel.name}}
285+
{{normalizeName(sel.name)}}
286286
</td>
287287
<td class="px-6 py-4 text-wrap break-all">
288288
{{sel.url}}
@@ -347,7 +347,116 @@ <h3 class="font-bold text-primary-100 dark:text-primary-50 text-left ml-4">
347347
</button>-->
348348
</div>
349349
</div>
350-
350+
@if(additionalISOS.length>0){
351+
<h3 class="font-bold text-primary-100 dark:text-primary-50 text-left ml-4">
352+
You added the following additional certifications:
353+
</h3>
354+
<div class="relative overflow-x-auto shadow-md sm:rounded-lg w-full bg-white dark:bg-secondary-300 m-4">
355+
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-200">
356+
<thead class="text-xs text-gray-700 uppercase bg-gray-100 dark:bg-secondary-200 dark:text-white">
357+
<tr>
358+
<th scope="col" class="px-6 py-3">
359+
{{ 'UPDATE_PROD_SPEC._product_name' | translate }}
360+
</th>
361+
<th scope="col" class="px-6 py-3">
362+
{{ 'UPDATE_PROD_SPEC._value' | translate }}
363+
</th>
364+
<th scope="col" class="px-6 py-3">
365+
{{ 'UPDATE_PROD_SPEC._actions' | translate }}
366+
</th>
367+
</tr>
368+
</thead>
369+
<tbody>
370+
@for (cert of additionalISOS; track cert.name; let idx = $index) {
371+
<tr class="border-b hover:bg-gray-200 dark:bg-secondary-300 dark:border-gray-700 dark:hover:bg-secondary-200">
372+
<td [ngClass]="{
373+
'break-all': hasLongWord(cert.name, 20),
374+
'break-words': !hasLongWord(cert.name, 20)
375+
}" class="px-6 py-4 text-wrap break-words">
376+
{{normalizeName(cert.name)}}
377+
</td>
378+
<td class="px-6 py-4 text-wrap break-all">
379+
{{cert.url}}
380+
</td>
381+
<td class="px-6 py-4 inline-flex">
382+
<button (click)="removeCert(cert)" type="button" class="text-white bg-red-600 hover:bg-red-700 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-full text-sm p-1 text-center inline-flex items-center">
383+
<svg class="w-4 h-4 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
384+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18 17.94 6M18 18 6.06 6"/>
385+
</svg>
386+
</button>
387+
</td>
388+
</tr>
389+
}
390+
</tbody>
391+
</table>
392+
</div>
393+
}
394+
@if(showCert==false){
395+
<div class="flex w-full justify-items-center justify-center">
396+
<button type="button" (click)="showCert=!showCert" class="flex text-white justify-center bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
397+
Add an additional certification
398+
<svg class="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
399+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7 7V5"/>
400+
</svg>
401+
</button>
402+
</div>
403+
} @else {
404+
<div class="m-4 w-full">
405+
<h3 class="font-bold text-primary-100 dark:text-primary-50 text-left ml-4">
406+
Add an additional certification:
407+
</h3>
408+
<div class="lg:flex lg:grid lg:grid-cols-2 w-full gap-4 align-items-middle align-middle border border-gray-200 rounded-lg p-4">
409+
<div class="h-fit">
410+
<label for="cert-name" class="font-bold text-lg dark:text-white">{{ 'PROFILE._name' | translate }}</label>
411+
<input #certificationName type="text" id="cert-name" [formControl]="certFileName"
412+
[ngClass]="certFileName.invalid == true ? 'border-red-600' : 'border-gray-300'"
413+
class="mb-2 bg-gray-50 border border-gray-300 text-gray-900 dark:bg-secondary-300 dark:border-secondary-200 dark:text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" />
414+
</div>
415+
@if(isoToCreate==''){
416+
<ngx-file-drop class="p-4 w-full" dropZoneLabel="Drop files here" (onFileDrop)="dropped($event,'attach')" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
417+
<ng-template class="w-full" ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
418+
<div class="w-full flex flex-col justify-items-center justify-center">
419+
<svg class="w-12 h-12 text-primary-100 mx-auto" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
420+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h3a3 3 0 0 0 0-6h-.025a5.56 5.56 0 0 0 .025-.5A5.5 5.5 0 0 0 7.207 9.021C7.137 9.017 7.071 9 7 9a4 4 0 1 0 0 8h2.167M12 19v-9m0 0-2 2m2-2 2 2"/>
421+
</svg>
422+
<div class="flex w-full justify-center">
423+
<p class="text-gray-500 mr-2 w-fit">{{ 'UPDATE_PROD_SPEC._drop_files' | translate }}
424+
<button (click)="openFileSelector()" class="font-medium text-primary-100 dark:text-primary-50 hover:underline">{{ 'UPDATE_PROD_SPEC._select_files' | translate }}</button>
425+
</p>
426+
</div>
427+
</div>
428+
</ng-template>
429+
</ngx-file-drop>
430+
} @else {
431+
<div class="relative w-full items-center p-4 text-sm text-primary-100 rounded-lg bg-blue-50 dark:bg-secondary-200 dark:text-primary-50" role="alert">
432+
<span class="sr-only">Info</span>
433+
<label class="text-wrap break-all">
434+
{{isoToCreate}}
435+
</label>
436+
<button (click)="clearAdditionalCert(true)" class="z-10 absolute top-2 right-2 p-1 font-bold text-white bg-red-500 rounded-3xl">
437+
<svg class="w-4 h-4 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
438+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18 17.94 6M18 18 6.06 6"/>
439+
</svg>
440+
</button>
441+
</div>
442+
}
443+
</div>
444+
<div class="flex w-full justify-items-center justify-center mt-4">
445+
<button type="button" (click)="saveAdditionalCert()"
446+
[disabled]="!certFileName.valid || isoToCreate == ''" [ngClass]="!certFileName.valid || isoToCreate == '' ? 'opacity-50' : 'hover:bg-primary-50'"
447+
class="flex text-white justify-center bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
448+
Save
449+
<svg class="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
450+
<path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M11 16h2m6.707-9.293-2.414-2.414A1 1 0 0 0 16.586 4H5a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V7.414a1 1 0 0 0-.293-.707ZM16 20v-6a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v6h8ZM9 4h6v3a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V4Z"/>
451+
</svg>
452+
</button>
453+
<button type="button" (click)="clearAdditionalCert(false);showCert=false;"
454+
class="flex ml-4 text-gray-900 justify-end bg-gray-400 hover:bg-primary-50 focus:ring-4 focus:outline-none font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
455+
Discard
456+
</button>
457+
</div>
458+
</div>
459+
}
351460

352461
}
353462
@if ((currentStep === 2 && !BUNDLE_ENABLED) || (currentStep === 3 && BUNDLE_ENABLED)) {
@@ -384,6 +493,7 @@ <h3 class="font-bold text-primary-100 dark:text-primary-50 text-left ml-4">
384493
</thead>
385494
<tbody>
386495
@for (prod of prodChars; track prod;) {
496+
@if(!prod.name?.startsWith('Compliance:')){
387497
<tr class="border-b hover:bg-gray-200 dark:bg-secondary-300 dark:border-gray-700 dark:hover:bg-secondary-200">
388498
<td [ngClass]="{
389499
'break-all': hasLongWord(prod.name, 20),
@@ -430,6 +540,7 @@ <h3 class="font-bold text-primary-100 dark:text-primary-50 text-left ml-4">
430540
</button>
431541
</td>
432542
</tr>
543+
}
433544
}
434545
</tbody>
435546
</table>

0 commit comments

Comments
 (0)