- @if(showGeneral){
-
{{ 'CREATE_PROD_SPEC._general' | translate }}
+ @if (currentStep === 0) {
}
- @if(showChars){
-
{{ 'CREATE_PROD_SPEC._chars' | translate }}
+ @if ((currentStep === 2 && !BUNDLE_ENABLED) || (currentStep === 3 && BUNDLE_ENABLED)) {
@if (prodChars.length === 0){
@@ -709,18 +606,17 @@
There's no char
}
-
-
}
-
-
+
}
- @if(showRelationships){
- {{ 'CREATE_PROD_SPEC._relationships' | translate }}
+ @if ((currentStep === 6 && !BUNDLE_ENABLED) || (currentStep === 7 && BUNDLE_ENABLED)) {
@if (prodRelationships.length === 0){
@@ -1314,17 +1207,16 @@
{{ 'CREATE_
}
-
-
+
}
- @if(showSummary){
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
+ @if ((currentStep === 7 && !BUNDLE_ENABLED) || (currentStep === 8 && BUNDLE_ENABLED)) {
@if(loading){
@@ -1641,18 +1533,59 @@
{{ 'CREATE_
}
}
-
+
}
-
+
+
+
+
+
+ {{ 'CREATE_OFFER._previous' | translate }}
+
+
+
+ {{ 'CREATE_OFFER._next_step' | translate }}
+
+
+ @if ((currentStep === 7 && !BUNDLE_ENABLED) || (currentStep === 8 && BUNDLE_ENABLED)) {
+
+ Create Product
+
+ }
+
diff --git a/src/app/pages/seller-offerings/offerings/seller-product-spec/create-product-spec/create-product-spec.component.ts b/src/app/pages/seller-offerings/offerings/seller-product-spec/create-product-spec/create-product-spec.component.ts
index efef7bac..a29636a8 100644
--- a/src/app/pages/seller-offerings/offerings/seller-product-spec/create-product-spec/create-product-spec.component.ts
+++ b/src/app/pages/seller-offerings/offerings/seller-product-spec/create-product-spec/create-product-spec.component.ts
@@ -66,6 +66,9 @@ export class CreateProductSpecComponent implements OnInit {
stepsElements:string[]=['general-info','bundle','compliance','chars','resource','service','attach','relationships','summary'];
stepsCircles:string[]=['general-circle','bundle-circle','compliance-circle','chars-circle','resource-circle','service-circle','attach-circle','relationships-circle','summary-circle'];
+ currentStep = 0;
+ highestStep = 0;
+ steps:any[] = [];
showPreview:boolean=false;
showEmoji:boolean=false;
@@ -217,6 +220,31 @@ export class CreateProductSpecComponent implements OnInit {
public files: NgxFileDropEntry[] = [];
ngOnInit() {
+ if(this.BUNDLE_ENABLED){
+ this.steps = [
+ 'General Info',
+ 'Bundle',
+ 'Compliance profile',
+ 'Characteristics',
+ 'Resource specifications',
+ 'Service specifications',
+ 'Attachments',
+ 'Relationships',
+ 'Summary'
+ ]
+ } else {
+ this.steps = [
+ 'General Info',
+ 'Compliance profile',
+ 'Characteristics',
+ 'Resource specifications',
+ 'Service specifications',
+ 'Attachments',
+ 'Relationships',
+ 'Summary'
+ ]
+ }
+ console.log(this.steps)
this.initPartyInfo();
}
@@ -525,7 +553,7 @@ export class CreateProductSpecComponent implements OnInit {
}
});
}
- if(this.showAttach){
+ if((this.currentStep === 5 && !this.BUNDLE_ENABLED) || (this.currentStep === 6 && this.BUNDLE_ENABLED)){
console.log(file)
this.attachmentService.uploadFile(fileBody).subscribe({
next: data => {
@@ -1387,4 +1415,83 @@ export class CreateProductSpecComponent implements OnInit {
}
}
+ goToStep(index: number) {
+ // Solo validar en modo creación
+ if (index > this.currentStep) {
+ // Validar el paso actual
+ const currentStepValid = this.validateCurrentStep();
+ if (!currentStepValid) {
+ return; // No permitir avanzar si el paso actual no es válido
+ }
+ }
+
+ this.currentStep = index;
+ if(this.currentStep>this.highestStep){
+ this.highestStep=this.currentStep
+ }
+ this.refreshChars();
+ //Resource
+ if((this.currentStep==4 && this.BUNDLE_ENABLED) || (this.currentStep==3 && !this.BUNDLE_ENABLED)){
+ this.getResSpecs(false);
+ }
+ //Service
+ if((this.currentStep==5 && this.BUNDLE_ENABLED) || (this.currentStep==4 && !this.BUNDLE_ENABLED)){
+ this.getServSpecs(false);
+ }
+ //Attachment
+ if((this.currentStep==6 && this.BUNDLE_ENABLED) || (this.currentStep==5 && !this.BUNDLE_ENABLED)){
+ setTimeout(() => {
+ initFlowbite();
+ }, 100);
+ }
+ //rels
+ if((this.currentStep==7 && this.BUNDLE_ENABLED) || (this.currentStep==6 && !this.BUNDLE_ENABLED)){
+ this.getProdSpecsRel(false);
+ }
+ //finish
+ if((this.currentStep==8 && this.BUNDLE_ENABLED) || (this.currentStep==7 && !this.BUNDLE_ENABLED)){
+ this.showFinish();
+ }
+ }
+
+ validateCurrentStep(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return this.generalForm?.valid || false;
+ default:
+ return true;
+ }
+ }
+
+ isStepDisabled(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return !this.generalForm?.valid || false;
+ case 1:
+ if(this.BUNDLE_ENABLED){
+ return this.prodSpecsBundle.length<2 && this.bundleChecked
+ } else {
+ return this.checkValidISOS()
+ }
+ case 2:
+ if(this.BUNDLE_ENABLED){
+ return this.checkValidISOS()
+ } else {
+ return false
+ }
+ default:
+ return false;
+ }
+ }
+
+ canNavigate(index: number) {
+ return (this.generalForm?.valid && (index <= this.currentStep)) || (this.generalForm?.valid && (index <= this.highestStep));
+ }
+
+ handleStepClick(index: number): void {
+ if (this.canNavigate(index)) {
+ this.goToStep(index);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.html b/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.html
index 1719eb19..254e1cfc 100644
--- a/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.html
+++ b/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.html
@@ -27,115 +27,27 @@
-
{{ 'UPDATE_PROD_SPEC._update_prod' | translate }}
-
-
-
-
{{ 'UPDATE_PROD_SPEC._steps' | translate }}
-
-
- 1
-
-
- {{ 'UPDATE_PROD_SPEC._general' | translate }}
- {{ 'UPDATE_PROD_SPEC._general_info' | translate }}
-
-
- @if(BUNDLE_ENABLED){
-
-
-
- 2
-
-
- {{ 'UPDATE_PROD_SPEC._bundle' | translate }}
- {{ 'UPDATE_PROD_SPEC._bundle_info' | translate }}
-
-
- }
-
-
-
- {{ BUNDLE_ENABLED ? 3 : 2 }}
-
-
- {{ 'UPDATE_PROD_SPEC._comp_profile' | translate }}
- {{ 'UPDATE_PROD_SPEC._comp_profile_info' | translate }}
-
-
-
-
-
- {{ BUNDLE_ENABLED ? 4 : 3 }}
-
-
- {{ 'UPDATE_PROD_SPEC._chars' | translate }}
- {{ 'UPDATE_PROD_SPEC._chars_info' | translate }}
-
-
-
-
-
- {{ BUNDLE_ENABLED ? 5 : 4 }}
-
-
- {{ 'UPDATE_PROD_SPEC._resource' | translate }}
- {{ 'UPDATE_PROD_SPEC._resource_info' | translate }}
-
-
-
-
-
- {{ BUNDLE_ENABLED ? 6 : 5 }}
-
-
- {{ 'UPDATE_PROD_SPEC._service' | translate }}
- {{ 'UPDATE_PROD_SPEC._service_info' | translate }}
-
-
-
-
-
- {{ BUNDLE_ENABLED ? 7 : 6 }}
-
-
- {{ 'UPDATE_PROD_SPEC._attachments' | translate }}
- {{ 'UPDATE_PROD_SPEC._attachments_info' | translate }}
-
-
-
-
-
- {{ BUNDLE_ENABLED ? 8 : 7 }}
-
-
- {{ 'UPDATE_PROD_SPEC._relationships' | translate }}
- {{ 'UPDATE_PROD_SPEC._relationships_info' | translate }}
-
-
-
-
-
- {{ BUNDLE_ENABLED ? 9 : 8 }}
-
-
- {{ 'UPDATE_PROD_SPEC._finish' | translate }}
- {{ 'UPDATE_PROD_SPEC._summary' | translate }}
-
-
-
+
{{ 'UPDATE_PROD_SPEC._update_prod' | translate }}
+
+ @for (step of steps; track i; let i = $index) {
+ -
+
+ {{ i + 1 }}
+
+ {{ step }}
+
+ }
+
+
- @if(showGeneral){
-
{{ 'UPDATE_PROD_SPEC._general' | translate }}
+ @if (currentStep === 0) {
}
- @if(showChars){
-
{{ 'UPDATE_PROD_SPEC._chars' | translate }}
+ @if ((currentStep === 2 && !BUNDLE_ENABLED) || (currentStep === 3 && BUNDLE_ENABLED)) {
@if (prodChars.length === 0){
@@ -820,18 +718,17 @@
There's no char
}
-
-
+
}
- @if(showResource){
- {{ 'UPDATE_PROD_SPEC._resource_specs' | translate }}
+ @if ((currentStep === 3 && !BUNDLE_ENABLED) || (currentStep === 4 && BUNDLE_ENABLED)) {
@if(loadingResourceSpec){
}
-
-
+
}
- @if(showService){
- {{ 'UPDATE_PROD_SPEC._service_specs' | translate }}
+ @if ((currentStep === 4 && !BUNDLE_ENABLED) || (currentStep === 5 && BUNDLE_ENABLED)) {
@if(loadingServiceSpec){
}
-
-
+
}
- @if(showAttach){
+ @if ((currentStep === 5 && !BUNDLE_ENABLED) || (currentStep === 6 && BUNDLE_ENABLED)) {
-
{{ 'UPDATE_PROD_SPEC._attachments' | translate }}
+
{{ 'UPDATE_PROD_SPEC._add_prod_img' | translate }}
-
- {{ 'UPDATE_PROD_SPEC._add_prod_img' | translate }}
+
@if(showImgPreview){

@@ -1228,17 +1123,16 @@
{{ 'UPDATE_PROD_SPEC._add_att
}
-
-
+
}
- @if(showRelationships){
- {{ 'UPDATE_PROD_SPEC._relationships' | translate }}
+ @if ((currentStep === 6 && !BUNDLE_ENABLED) || (currentStep === 7 && BUNDLE_ENABLED)) {
@if (prodRelationships.length === 0){
@@ -1404,17 +1298,16 @@
{{ 'UPDATE_
}
-
-
+
}
- @if(showSummary){
- {{ 'UPDATE_PROD_SPEC._finish' | translate }}
+ @if ((currentStep === 7 && !BUNDLE_ENABLED) || (currentStep === 8 && BUNDLE_ENABLED)) {
@if(loading){
@@ -1711,18 +1604,57 @@
{{ 'UPDATE_
}
}
-
+
}
-
+
+
+
+
+
+ {{ 'CREATE_OFFER._previous' | translate }}
+
+
+
+ {{ 'CREATE_OFFER._next_step' | translate }}
+
+
+
+ Update Product
+
+
diff --git a/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.ts b/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.ts
index a4d3e922..c6a91443 100644
--- a/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.ts
+++ b/src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.ts
@@ -60,6 +60,9 @@ export class UpdateProductSpecComponent implements OnInit {
stepsElements:string[]=['general-info','bundle','compliance','chars','resource','service','attach','relationships','summary'];
stepsCircles:string[]=['general-circle','bundle-circle','compliance-circle','chars-circle','resource-circle','service-circle','attach-circle','relationships-circle','summary-circle'];
+ currentStep = 0;
+ highestStep = 0;
+ steps:any[] = [];
showPreview:boolean=false;
showEmoji:boolean=false;
@@ -215,6 +218,30 @@ export class UpdateProductSpecComponent implements OnInit {
public files: NgxFileDropEntry[] = [];
ngOnInit() {
+ if(this.BUNDLE_ENABLED){
+ this.steps = [
+ 'General Info',
+ 'Bundle',
+ 'Compliance profile',
+ 'Characteristics',
+ 'Resource specifications',
+ 'Service specifications',
+ 'Attachments',
+ 'Relationships',
+ 'Summary'
+ ]
+ } else {
+ this.steps = [
+ 'General Info',
+ 'Compliance profile',
+ 'Characteristics',
+ 'Resource specifications',
+ 'Service specifications',
+ 'Attachments',
+ 'Relationships',
+ 'Summary'
+ ]
+ }
this.initPartyInfo();
console.log(this.prod)
this.populateProductInfo();
@@ -729,7 +756,7 @@ export class UpdateProductSpecComponent implements OnInit {
}
});
}
- if(this.showAttach){
+ if((this.currentStep === 5 && !this.BUNDLE_ENABLED) || (this.currentStep === 6 && this.BUNDLE_ENABLED)){
console.log(file)
this.attachmentService.uploadFile(fileBody).subscribe({
next: data => {
@@ -1424,6 +1451,23 @@ export class UpdateProductSpecComponent implements OnInit {
}
showFinish() {
+ this.setProductData();
+ this.selectStep('summary','summary-circle');
+ this.showBundle=false;
+ this.showGeneral=false;
+ this.showCompliance=false;
+ this.showChars=false;
+ this.showResource=false;
+ this.showService=false;
+ this.showAttach=false;
+ this.showRelationships=false;
+ this.showSummary=true;
+ this.showPreview=false;
+ this.refreshChars();
+ initFlowbite();
+ }
+
+ setProductData(){
for(let i=0; i< this.prodChars.length; i++){
const index = this.finishChars.findIndex(item => item.name === this.prodChars[i].name);
if (index == -1) {
@@ -1483,19 +1527,6 @@ export class UpdateProductSpecComponent implements OnInit {
serviceSpecification: this.selectedServiceSpecs
}
}
- this.selectStep('summary','summary-circle');
- this.showBundle=false;
- this.showGeneral=false;
- this.showCompliance=false;
- this.showChars=false;
- this.showResource=false;
- this.showService=false;
- this.showAttach=false;
- this.showRelationships=false;
- this.showSummary=true;
- this.showPreview=false;
- this.refreshChars();
- initFlowbite();
}
isProdValid(){
@@ -1515,6 +1546,7 @@ export class UpdateProductSpecComponent implements OnInit {
}
updateProduct(){
+ this.setProductData();
this.loading=true;
this.prodSpecService.updateProdSpec(this.productSpecToUpdate, this.prod.id).subscribe({
next: data => {
@@ -1539,6 +1571,27 @@ export class UpdateProductSpecComponent implements OnInit {
});
}
+ isStepDisabled(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return !this.generalForm?.valid || false;
+ case 1:
+ if(this.BUNDLE_ENABLED){
+ return this.prodSpecsBundle.length<2 && this.bundleChecked
+ } else {
+ return this.checkValidISOS()
+ }
+ case 2:
+ if(this.BUNDLE_ENABLED){
+ return this.checkValidISOS()
+ } else {
+ return false
+ }
+ default:
+ return false;
+ }
+ }
+
//Markdown actions:
addBold() {
const currentText = this.generalForm.value.description;
@@ -1620,4 +1673,54 @@ export class UpdateProductSpecComponent implements OnInit {
}
}
+ goToStep(index: number) {
+
+ this.currentStep = index;
+ if(this.currentStep>this.highestStep){
+ this.highestStep=this.currentStep
+ }
+ this.refreshChars();
+ //Resource
+ if((this.currentStep==4 && this.BUNDLE_ENABLED) || (this.currentStep==3 && !this.BUNDLE_ENABLED)){
+ this.getResSpecs(false);
+ }
+ //Service
+ if((this.currentStep==5 && this.BUNDLE_ENABLED) || (this.currentStep==4 && !this.BUNDLE_ENABLED)){
+ this.getServSpecs(false);
+ }
+ //Attachment
+ if((this.currentStep==6 && this.BUNDLE_ENABLED) || (this.currentStep==5 && !this.BUNDLE_ENABLED)){
+ setTimeout(() => {
+ initFlowbite();
+ }, 100);
+ }
+ //rels
+ if((this.currentStep==7 && this.BUNDLE_ENABLED) || (this.currentStep==6 && !this.BUNDLE_ENABLED)){
+ this.getProdSpecsRel(false);
+ }
+ //finish
+ if((this.currentStep==8 && this.BUNDLE_ENABLED) || (this.currentStep==7 && !this.BUNDLE_ENABLED)){
+ this.showFinish();
+ }
+ }
+
+ validateCurrentStep(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return this.generalForm?.valid || false;
+ default:
+ return true;
+ }
+ }
+
+ canNavigate(index: number) {
+ return this.generalForm?.valid
+ }
+
+ handleStepClick(index: number): void {
+ if (this.canNavigate(index)) {
+ this.goToStep(index);
+ }
+ }
+
}
diff --git a/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.html b/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.html
index 1d784b92..e0829101 100644
--- a/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.html
+++ b/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.html
@@ -26,47 +26,27 @@
-
{{ 'CREATE_RES_SPEC._new' | translate }}
-
-
-
-
{{ 'CREATE_RES_SPEC._steps' | translate }}
-
-
- 1
-
-
- {{ 'CREATE_RES_SPEC._general' | translate }}
- {{ 'CREATE_RES_SPEC._general_info' | translate }}
-
-
-
-
-
- 2
-
-
- {{ 'CREATE_RES_SPEC._chars' | translate }}
- {{ 'CREATE_RES_SPEC._chars_info' | translate }}
-
-
-
-
-
- 3
-
-
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
- {{ 'CREATE_PROD_SPEC._summary' | translate }}
-
-
-
+
{{ 'CREATE_RES_SPEC._new' | translate }}
+
+ @for (step of steps; track i; let i = $index) {
+ -
+
+ {{ i + 1 }}
+
+ {{ step }}
+
+ }
+
+
- @if(showGeneral){
-
{{ 'CREATE_RES_SPEC._general' | translate }}
+ @if (currentStep === 0) {
-
-
+
}
- @if(showChars){
- {{ 'CREATE_RES_SPEC._chars' | translate }}
+ @if (currentStep === 1) {
@if (prodChars.length === 0){
@@ -318,18 +297,17 @@
{{ 'CREATE_
}
-
-
+
}
- @if(showSummary){
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
+ @if (currentStep === 2) {
@if(loading){
@@ -437,18 +415,59 @@
{{ 'CREATE_
}
}
-
+
}
+
+
+
+
+ {{ 'CREATE_OFFER._previous' | translate }}
+
+
+
+ {{ 'CREATE_OFFER._next_step' | translate }}
+
+
+ @if (currentStep === 2) {
+
+ Create Resource
+
+ }
+
diff --git a/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.ts b/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.ts
index 1ac7c88c..b97f1e9c 100644
--- a/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.ts
+++ b/src/app/pages/seller-offerings/offerings/seller-resource-spec/create-resource-spec/create-resource-spec.component.ts
@@ -27,6 +27,13 @@ export class CreateResourceSpecComponent implements OnInit {
stepsElements:string[]=['general-info','chars','summary'];
stepsCircles:string[]=['general-circle','chars-circle','summary-circle'];
+ currentStep = 0;
+ highestStep = 0;
+ steps = [
+ 'General Info',
+ 'Characteristics',
+ 'Summary'
+ ];
//markdown variables:
showPreview:boolean=false;
@@ -470,4 +477,44 @@ export class CreateResourceSpecComponent implements OnInit {
return false
}
}
+
+ goToStep(index: number) {
+ // Solo validar en modo creación
+ if (index > this.currentStep) {
+ // Validar el paso actual
+ const currentStepValid = this.validateCurrentStep();
+ if (!currentStepValid) {
+ return; // No permitir avanzar si el paso actual no es válido
+ }
+ }
+
+ this.currentStep = index;
+ if(this.currentStep>this.highestStep){
+ this.highestStep=this.currentStep
+ }
+ this.refreshChars();
+ //finish
+ if(this.currentStep==2){
+ this.showFinish();
+ }
+ }
+
+ validateCurrentStep(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return this.generalForm?.valid || false;
+ default:
+ return true;
+ }
+ }
+
+ canNavigate(index: number) {
+ return (this.generalForm?.valid && (index <= this.currentStep)) || (this.generalForm?.valid && (index <= this.highestStep));
+ }
+
+ handleStepClick(index: number): void {
+ if (this.canNavigate(index)) {
+ this.goToStep(index);
+ }
+ }
}
diff --git a/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.html b/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.html
index 4b46f733..bc0fbc8a 100644
--- a/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.html
+++ b/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.html
@@ -26,47 +26,27 @@
-
{{ 'UPDATE_RES_SPEC._update_res' | translate }}
-
-
-
-
{{ 'UPDATE_RES_SPEC._steps' | translate }}
-
-
- 1
-
-
- {{ 'UPDATE_RES_SPEC._general' | translate }}
- {{ 'UPDATE_RES_SPEC._general_info' | translate }}
-
-
-
-
-
- 2
-
-
- {{ 'UPDATE_RES_SPEC._chars' | translate }}
- {{ 'UPDATE_RES_SPEC._chars_info' | translate }}
-
-
-
-
-
- 3
-
-
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
- {{ 'CREATE_PROD_SPEC._summary' | translate }}
-
-
-
+
{{ 'UPDATE_RES_SPEC._update_res' | translate }}
+
+ @for (step of steps; track i; let i = $index) {
+ -
+
+ {{ i + 1 }}
+
+ {{ step }}
+
+ }
+
+
- @if(showGeneral){
-
{{ 'UPDATE_RES_SPEC._general' | translate }}
+ @if (currentStep === 0) {
-
-
+
}
- @if(showChars){
- {{ 'UPDATE_RES_SPEC._chars' | translate }}
-
+ @if (currentStep === 1) {
@if (prodChars.length === 0){
@@ -433,18 +375,17 @@
-
+
}
- @if(showSummary){
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
+ @if (currentStep === 2) {
@if(loading){
@@ -552,18 +493,57 @@
{{ 'CREATE_
}
}
-
+
}
+
+
+
+
+ {{ 'CREATE_OFFER._previous' | translate }}
+
+
+
+ {{ 'CREATE_OFFER._next_step' | translate }}
+
+
+
+ Update Resource
+
+
diff --git a/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.ts b/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.ts
index 2156a2a8..a1bb2b75 100644
--- a/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.ts
+++ b/src/app/pages/seller-offerings/offerings/seller-resource-spec/update-resource-spec/update-resource-spec.component.ts
@@ -29,6 +29,13 @@ export class UpdateResourceSpecComponent implements OnInit {
stepsElements:string[]=['general-info','chars','summary'];
stepsCircles:string[]=['general-circle','chars-circle','summary-circle'];
+ currentStep = 0;
+ highestStep = 0;
+ steps = [
+ 'General Info',
+ 'Characteristics',
+ 'Summary'
+ ];
//markdown variables:
showPreview:boolean=false;
@@ -271,6 +278,16 @@ export class UpdateResourceSpecComponent implements OnInit {
}
showFinish(){
+ this.setResourceData();
+ this.showChars=false;
+ this.showGeneral=false;
+ this.showSummary=true;
+ this.selectStep('summary','summary-circle');
+ this.refreshChars();
+ this.showPreview=false;
+ }
+
+ setResourceData(){
if(this.generalForm.value.name!=null){
this.resourceToUpdate={
name: this.generalForm.value.name,
@@ -278,16 +295,11 @@ export class UpdateResourceSpecComponent implements OnInit {
lifecycleStatus: this.resStatus,
resourceSpecCharacteristic: this.prodChars
}
- this.showChars=false;
- this.showGeneral=false;
- this.showSummary=true;
- this.selectStep('summary','summary-circle');
- this.refreshChars();
}
- this.showPreview=false;
}
updateResource(){
+ this.setResourceData();
this.loading=true;
this.resSpecService.updateResSpec(this.resourceToUpdate,this.res.id).subscribe({
next: data => {
@@ -470,4 +482,41 @@ export class UpdateResourceSpecComponent implements OnInit {
}
}
+ goToStep(index: number) {
+ this.currentStep = index;
+ if(this.currentStep>this.highestStep){
+ this.highestStep=this.currentStep
+ }
+ this.refreshChars();
+ //chars
+ if(this.currentStep==1){
+ setTimeout(() => {
+ initFlowbite();
+ }, 100);
+ }
+ //finish
+ if(this.currentStep==2){
+ this.showFinish();
+ }
+ }
+
+ validateCurrentStep(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return this.generalForm?.valid || false;
+ default:
+ return true;
+ }
+ }
+
+ canNavigate(index: number) {
+ return this.generalForm?.valid
+ }
+
+ handleStepClick(index: number): void {
+ if (this.canNavigate(index)) {
+ this.goToStep(index);
+ }
+ }
+
}
diff --git a/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.html b/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.html
index 7b59cef0..61e8d815 100644
--- a/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.html
+++ b/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.html
@@ -26,47 +26,27 @@
-
{{ 'CREATE_SERV_SPEC._new' | translate }}
-
-
-
-
{{ 'CREATE_SERV_SPEC._steps' | translate }}
-
-
- 1
-
-
- {{ 'CREATE_SERV_SPEC._general' | translate }}
- {{ 'CREATE_SERV_SPEC._general_info' | translate }}
-
-
-
-
-
- 2
-
-
- {{ 'CREATE_SERV_SPEC._chars' | translate }}
- {{ 'CREATE_SERV_SPEC._chars_info' | translate }}
-
-
-
-
-
- 3
-
-
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
- {{ 'CREATE_PROD_SPEC._summary' | translate }}
-
-
-
+
{{ 'CREATE_SERV_SPEC._new' | translate }}
+
+ @for (step of steps; track i; let i = $index) {
+ -
+
+ {{ i + 1 }}
+
+ {{ step }}
+
+ }
+
+
- @if(showGeneral){
-
{{ 'CREATE_SERV_SPEC._general' | translate }}
+ @if (currentStep === 0) {
-
-
+
}
- @if(showChars){
- {{ 'CREATE_SERV_SPEC._chars' | translate }}
+ @if (currentStep === 1) {
@if (prodChars.length === 0){
@@ -319,18 +298,17 @@
{{ 'CREATE_
}
-
-
+
}
- @if(showSummary){
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
+ @if (currentStep === 2) {
@if(loading){
@@ -438,18 +416,59 @@
{{ 'CREATE_
}
}
-
+
}
+
+
+
+
+ {{ 'CREATE_OFFER._previous' | translate }}
+
+
+
+ {{ 'CREATE_OFFER._next_step' | translate }}
+
+
+ @if (currentStep === 2) {
+
+ Create Service
+
+ }
+
diff --git a/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.ts b/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.ts
index cbcd405d..931eccf1 100644
--- a/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.ts
+++ b/src/app/pages/seller-offerings/offerings/seller-service-spec/create-service-spec/create-service-spec.component.ts
@@ -27,6 +27,13 @@ export class CreateServiceSpecComponent implements OnInit {
stepsElements:string[]=['general-info','chars','summary'];
stepsCircles:string[]=['general-circle','chars-circle','summary-circle'];
+ currentStep = 0;
+ highestStep = 0;
+ steps = [
+ 'General Info',
+ 'Characteristics',
+ 'Summary'
+ ];
//markdown variables:
showPreview:boolean=false;
@@ -462,4 +469,44 @@ export class CreateServiceSpecComponent implements OnInit {
}
}
+ goToStep(index: number) {
+ // Solo validar en modo creación
+ if (index > this.currentStep) {
+ // Validar el paso actual
+ const currentStepValid = this.validateCurrentStep();
+ if (!currentStepValid) {
+ return; // No permitir avanzar si el paso actual no es válido
+ }
+ }
+
+ this.currentStep = index;
+ if(this.currentStep>this.highestStep){
+ this.highestStep=this.currentStep
+ }
+ this.refreshChars();
+ //finish
+ if(this.currentStep==2){
+ this.showFinish();
+ }
+ }
+
+ validateCurrentStep(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return this.generalForm?.valid || false;
+ default:
+ return true;
+ }
+ }
+
+ canNavigate(index: number) {
+ return (this.generalForm?.valid && (index <= this.currentStep)) || (this.generalForm?.valid && (index <= this.highestStep));
+ }
+
+ handleStepClick(index: number): void {
+ if (this.canNavigate(index)) {
+ this.goToStep(index);
+ }
+ }
+
}
diff --git a/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.html b/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.html
index ded8bef9..d1115190 100644
--- a/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.html
+++ b/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.html
@@ -26,47 +26,27 @@
-
{{ 'UPDATE_SERV_SPEC._update_serv' | translate }}
-
-
-
-
{{ 'UPDATE_SERV_SPEC._steps' | translate }}
-
-
- 1
-
-
- {{ 'UPDATE_SERV_SPEC._general' | translate }}
- {{ 'UPDATE_SERV_SPEC._general_info' | translate }}
-
-
-
-
-
- 2
-
-
- {{ 'UPDATE_SERV_SPEC._chars' | translate }}
- {{ 'UPDATE_SERV_SPEC._chars_info' | translate }}
-
-
-
-
-
- 3
-
-
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
- {{ 'CREATE_PROD_SPEC._summary' | translate }}
-
-
-
+
{{ 'UPDATE_SERV_SPEC._update_serv' | translate }}
+
+ @for (step of steps; track i; let i = $index) {
+ -
+
+ {{ i + 1 }}
+
+ {{ step }}
+
+ }
+
+
- @if(showGeneral){
-
{{ 'UPDATE_SERV_SPEC._general' | translate }}
+ @if (currentStep === 0) {
-
-
+
}
- @if(showChars){
- {{ 'UPDATE_SERV_SPEC._chars' | translate }}
+ @if (currentStep === 1) {
@if (prodChars.length === 0){
@@ -396,18 +375,17 @@
{{ 'UPDATE_
}
-
-
+
}
- @if(showSummary){
- {{ 'CREATE_PROD_SPEC._finish' | translate }}
+ @if (currentStep === 2) {
@if(loading){
@@ -515,18 +493,57 @@
{{ 'CREATE_
}
}
-
+
}
+
+
+
+
+ {{ 'CREATE_OFFER._previous' | translate }}
+
+
+
+ {{ 'CREATE_OFFER._next_step' | translate }}
+
+
+
+ Update Service
+
+
diff --git a/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.ts b/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.ts
index bb0c96fc..38a6ce54 100644
--- a/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.ts
+++ b/src/app/pages/seller-offerings/offerings/seller-service-spec/update-service-spec/update-service-spec.component.ts
@@ -29,6 +29,13 @@ export class UpdateServiceSpecComponent implements OnInit {
stepsElements:string[]=['general-info','chars','summary'];
stepsCircles:string[]=['general-circle','chars-circle','summary-circle'];
+ currentStep = 0;
+ highestStep = 0;
+ steps = [
+ 'General Info',
+ 'Characteristics',
+ 'Summary'
+ ];
//markdown variables:
showPreview:boolean=false;
@@ -267,6 +274,16 @@ export class UpdateServiceSpecComponent implements OnInit {
}
showFinish(){
+ this.setServiceData();
+ this.showChars=false;
+ this.showGeneral=false;
+ this.showSummary=true;
+ this.selectStep('summary','summary-circle');
+ this.refreshChars();
+ this.showPreview=false;
+ }
+
+ setServiceData(){
if(this.generalForm.value.name!=null){
this.serviceToUpdate={
name: this.generalForm.value.name,
@@ -274,16 +291,11 @@ export class UpdateServiceSpecComponent implements OnInit {
lifecycleStatus: this.servStatus,
specCharacteristic: this.prodChars
}
- this.showChars=false;
- this.showGeneral=false;
- this.showSummary=true;
- this.selectStep('summary','summary-circle');
- this.refreshChars();
}
- this.showPreview=false;
}
updateService(){
+ this.setServiceData();
this.loading=true;
this.servSpecService.updateServSpec(this.serviceToUpdate,this.serv.id).subscribe({
next: data => {
@@ -466,4 +478,41 @@ export class UpdateServiceSpecComponent implements OnInit {
}
}
+ goToStep(index: number) {
+ this.currentStep = index;
+ if(this.currentStep>this.highestStep){
+ this.highestStep=this.currentStep
+ }
+ this.refreshChars();
+ //chars
+ if(this.currentStep==1){
+ setTimeout(() => {
+ initFlowbite();
+ }, 100);
+ }
+ //finish
+ if(this.currentStep==2){
+ this.showFinish();
+ }
+ }
+
+ validateCurrentStep(): boolean {
+ switch (this.currentStep) {
+ case 0: // General Info
+ return this.generalForm?.valid || false;
+ default:
+ return true;
+ }
+ }
+
+ canNavigate(index: number) {
+ return this.generalForm?.valid
+ }
+
+ handleStepClick(index: number): void {
+ if (this.canNavigate(index)) {
+ this.goToStep(index);
+ }
+ }
+
}
diff --git a/src/app/services/app-init.service.ts b/src/app/services/app-init.service.ts
index 89a8b8cf..e9f9e7bd 100644
--- a/src/app/services/app-init.service.ts
+++ b/src/app/services/app-init.service.ts
@@ -35,7 +35,7 @@ export class AppInitService {
environment.analytics = config.analytics ?? 'https://analytics.dome-marketplace-sbx.org/',
environment.feedbackCampaign = config.feedbackCampaign ?? false,
environment.feedbackCampaignExpiration = config.feedbackCampaign ?? moment().add(1, 'week').unix()
- environment.providerThemeName = 'DOME';
+ environment.providerThemeName = config.theme ?? 'default';
environment.QUOTES_ENABLED = config.quotesEnabled ?? false
resolve(config);
}),
diff --git a/src/app/services/price-service.service.ts b/src/app/services/price-service.service.ts
index 47fdfcdf..f0cdb8e2 100644
--- a/src/app/services/price-service.service.ts
+++ b/src/app/services/price-service.service.ts
@@ -107,7 +107,7 @@ export class PriceServiceService {
if (offering?.productOfferingPrice && offering?.productOfferingPrice.length > 0) {
// Check if the first POP is a custom one
const pop = await this.getProductPrice(offering.productOfferingPrice[0].id);
- isCustom = pop.priceType.toLowerCase() === 'custom';
+ isCustom = pop.priceType?.toLowerCase() === 'custom';
}
return isCustom;
diff --git a/src/app/shared/cart-drawer/cart-drawer.component.ts b/src/app/shared/cart-drawer/cart-drawer.component.ts
index fdf16b04..59dd3d1a 100644
--- a/src/app/shared/cart-drawer/cart-drawer.component.ts
+++ b/src/app/shared/cart-drawer/cart-drawer.component.ts
@@ -26,6 +26,8 @@ export class CartDrawerComponent implements OnInit{
showBackDrop:boolean=true;
check_custom:boolean=false;
loading:boolean=false;
+ errorMessage:string='';
+ showError:boolean=false;
constructor(
private localStorage: LocalStorageService,
@@ -46,42 +48,16 @@ export class CartDrawerComponent implements OnInit{
ngOnInit(): void {
this.loading=true;
this.showBackDrop=true;
- this.cartService.getShoppingCart().then(async data => {
- console.log('---CARRITO API---')
- console.log(data)
- this.items=data;
- await this.getProviderInfo();
- this.groupItemsByOwner();
- this.loading=false;
- this.cdr.detectChanges();
- console.log('------------------')
- })
+ this.getCart();
+
this.eventMessage.messages$.subscribe(ev => {
if(ev.type === 'AddedCartItem') {
console.log('Elemento añadido')
this.loading=true;
- this.cartService.getShoppingCart().then(async data => {
- console.log('---CARRITO API---')
- console.log(data)
- this.items=data;
- await this.getProviderInfo();
- this.groupItemsByOwner();
- this.loading=false;
- this.cdr.detectChanges();
- console.log('------------------')
- })
+ this.getCart();
} else if(ev.type === 'RemovedCartItem') {
this.loading=true;
- this.cartService.getShoppingCart().then(async data => {
- console.log('---CARRITO API---')
- console.log(data)
- this.items=data;
- await this.getProviderInfo();
- this.groupItemsByOwner();
- this.loading=false;
- this.cdr.detectChanges();
- console.log('------------------')
- })
+ this.getCart();
}
})
console.log('Elementos en el carrito....')
@@ -92,6 +68,31 @@ export class CartDrawerComponent implements OnInit{
return Object.keys;
}
+ getCart(){
+ try {
+ this.cartService.getShoppingCart().then(async data => {
+ console.log('---CARRITO API---')
+ console.log(data)
+ this.items=data;
+ await this.getProviderInfo();
+ this.groupItemsByOwner();
+ this.loading=false;
+ this.cdr.detectChanges();
+ console.log('------------------')
+ })
+ } catch (error) {
+ this.loading=false;
+ this.handleError(error, 'There was an error while retrieving the cart!');
+ }
+ }
+
+ private handleError(error: any, defaultMessage: string) {
+ console.error(defaultMessage, error);
+ this.errorMessage = error?.error?.error ? `Error: ${error.error.error}` : defaultMessage;
+ this.showError = true;
+ setTimeout(() => (this.showError = false), 3000);
+ }
+
hasKey(obj: any, key: string): boolean {
return key in obj;
}
@@ -119,9 +120,22 @@ export class CartDrawerComponent implements OnInit{
async getProviderInfo(){
for(let i=0; i < this.items.length; i++){
- let offer = await this.api.getProductById(this.items[i].id);
- let product = await this.api.getProductSpecification(offer.productSpecification.id)
- this.items[i]['relatedParty']=product.relatedParty
+ try {
+ let offer = await this.api.getProductById(this.items[i].id);
+ let product = await this.api.getProductSpecification(offer.productSpecification.id)
+ this.items[i]['relatedParty']=product.relatedParty
+ } catch (error) {
+ console.log('--- not found?')
+ console.log(error)
+ if((error as any).status==404){
+ await this.cartService.removeItemShoppingCart(this.items[i].id);
+ console.log('deleted');
+ this.eventMessage.emitRemovedCartItem(this.items[i] as cartProduct);
+ }
+ this.loading=false;
+ this.handleError(error, "There was an error while retrieving cart's product information!");
+ }
+
}
}
@@ -129,7 +143,7 @@ export class CartDrawerComponent implements OnInit{
const groupedByOwner: any[][] = Object.values(
this.items.reduce((groups: any, item: any) => {
const owner = item.relatedParty
- ?.find((rp: any) => rp.role === 'Owner')
+ ?.find((rp: any) => rp.role === 'Seller')
?.id;
if (owner) {