Skip to content
Snippets Groups Projects
Commit cedcbf7b authored by Kawtar Laariche's avatar Kawtar Laariche
Browse files

#19: add disableEdit function

parent ecc28fd9
No related branches found
No related tags found
No related merge requests found
...@@ -306,74 +306,6 @@ ul { ...@@ -306,74 +306,6 @@ ul {
text-transform: none; text-transform: none;
} }
.c-breadcrumb {
list-style-type: none;
clear: both;
padding: 0;
margin: 0;
}
.c-breadcrumb li:first-child {
margin-left: 0;
padding-left: 0;
}
.c-breadcrumb li {
display: inline-block;
padding: 0 5px;
}
.c-breadcrumb li:first-child:before {
content: "";
}
.c-breadcrumb li:before {
content: "/";
position: relative;
left: -6px;
}
.c-breadcrumb li a {
color: #2e2f2f;
text-decoration: none;
font-weight: 600;
font-size: 13px;
}
.c-breadcrumb.solution_id_top li:last-child::before {
content: "-" !important;
}
.c-breadcrumb li span.md-breadcrumb-item {
max-width: 300px;
position: relative;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: inline-block;
float: right;
}
.c-breadcrumb li:last-child,
.c-breadcrumb li:last-child a {
font-weight: normal;
color: #8f8f8f;
font-size: 13px;
}
.c-breadcrumb li {
display: inline-block;
padding: 0 5px;
}
.solution_id_top .solution_id_bg {
background-color: #f1f1f1;
border: 1px solid #ccc;
font-size: 10px;
border-radius: 15px;
padding: 0 5px;
}
.md-lbl1 { .md-lbl1 {
margin-right: 3px; margin-right: 3px;
margin-top: 0; margin-top: 0;
...@@ -433,6 +365,8 @@ ul { ...@@ -433,6 +365,8 @@ ul {
font-size: 12px; font-size: 12px;
font-weight: normal; font-weight: normal;
border: 1px solid #671c9d; border: 1px solid #671c9d;
background: #671c9d;
color: #fff;
text-transform: none; text-transform: none;
line-height: 24px; line-height: 24px;
height: 25px; height: 25px;
......
...@@ -49,6 +49,8 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; ...@@ -49,6 +49,8 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { JwtTokenService } from 'src/app/core/services/auth/jwt-token.service'; import { JwtTokenService } from 'src/app/core/services/auth/jwt-token.service';
import { apiConfig } from 'src/app/core/config'; import { apiConfig } from 'src/app/core/config';
import { PrivateCatalogsService } from 'src/app/core/services/private-catalogs.service'; import { PrivateCatalogsService } from 'src/app/core/services/private-catalogs.service';
import { SolutionIdComponent } from 'src/app/shared/components/solution-id/solution-id.component';
import { BreadcrumbNavigationComponent } from 'src/app/shared/components/breadcrumb-navigation/breadcrumb-navigation.component';
interface SolutionData { interface SolutionData {
solutionId: string; solutionId: string;
...@@ -86,6 +88,8 @@ interface SolutionData { ...@@ -86,6 +88,8 @@ interface SolutionData {
MatSelectModule, MatSelectModule,
ReactiveFormsModule, ReactiveFormsModule,
FormsModule, FormsModule,
SolutionIdComponent,
BreadcrumbNavigationComponent,
], ],
templateUrl: './model-details.component.html', templateUrl: './model-details.component.html',
styleUrl: './model-details.component.scss', styleUrl: './model-details.component.scss',
...@@ -107,7 +111,6 @@ export class ModelDetailsComponent implements OnInit { ...@@ -107,7 +111,6 @@ export class ModelDetailsComponent implements OnInit {
version: string; version: string;
revisionId: string; revisionId: string;
}; };
editModel: boolean = false;
averageRatings!: AverageRatings; averageRatings!: AverageRatings;
allRatings: AllUserRating[] = []; allRatings: AllUserRating[] = [];
totalRatingsCount: number = 0; totalRatingsCount: number = 0;
...@@ -125,6 +128,7 @@ export class ModelDetailsComponent implements OnInit { ...@@ -125,6 +128,7 @@ export class ModelDetailsComponent implements OnInit {
.getUserDetails() .getUserDetails()
.pipe(map((details) => details?.userId)); .pipe(map((details) => details?.userId));
isLoggedIn$: Observable<boolean>; isLoggedIn$: Observable<boolean>;
userId!: string;
data$: Observable<SolutionData>; data$: Observable<SolutionData>;
defaultSolutionData: SolutionData = { defaultSolutionData: SolutionData = {
...@@ -145,6 +149,7 @@ export class ModelDetailsComponent implements OnInit { ...@@ -145,6 +149,7 @@ export class ModelDetailsComponent implements OnInit {
comments!: CommentReplyModel[]; comments!: CommentReplyModel[];
firstName: string = ''; firstName: string = '';
lastName: string = ''; lastName: string = '';
editModel: boolean = false;
constructor( constructor(
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
...@@ -218,7 +223,13 @@ export class ModelDetailsComponent implements OnInit { ...@@ -218,7 +223,13 @@ export class ModelDetailsComponent implements OnInit {
// Handle the case where userId is not available // Handle the case where userId is not available
return of(null); return of(null);
} }
this.userId = userId;
this.solutionId = params['solutionId']; this.solutionId = params['solutionId'];
this.publicSolutionsService
.getSolutionDetails(params['solutionId'], params['revisionId'])
.subscribe((res) => {
this.disableEdit(userId, res);
});
return this.privateCatalogsService.getSolutionRatings( return this.privateCatalogsService.getSolutionRatings(
this.solutionId, this.solutionId,
userId, userId,
...@@ -535,7 +546,6 @@ export class ModelDetailsComponent implements OnInit { ...@@ -535,7 +546,6 @@ export class ModelDetailsComponent implements OnInit {
this.privateCatalogsService this.privateCatalogsService
.getComments(solutionId, revisionId) .getComments(solutionId, revisionId)
.subscribe((res) => { .subscribe((res) => {
console.log({ res });
this.comments = this.transformComments(res); this.comments = this.transformComments(res);
}); });
} }
...@@ -554,7 +564,7 @@ export class ModelDetailsComponent implements OnInit { ...@@ -554,7 +564,7 @@ export class ModelDetailsComponent implements OnInit {
} }
}); });
// Now, associate each comment with its parent. // associate each comment with its parent.
const rootComments: CommentReplyModel[] = []; const rootComments: CommentReplyModel[] = [];
comments.forEach((comment) => { comments.forEach((comment) => {
if ( if (
...@@ -574,4 +584,35 @@ export class ModelDetailsComponent implements OnInit { ...@@ -574,4 +584,35 @@ export class ModelDetailsComponent implements OnInit {
return rootComments; return rootComments;
} }
disableEdit(userId: string, solution: PublicSolutionDetailsModel) {
// Allow editing if the solution is not active.
if (!solution.active) {
this.editModel = true;
return; // No further checks needed if the solution is inactive.
}
// If the solution is active and the user is the owner, allow editing.
if (solution.ownerId === userId) {
this.editModel = true;
return;
}
// If there are other owners and the user is one of them, allow editing.
const isCoOwner = solution.ownerListForSol?.some(
(owner) => owner.userId === userId,
);
if (isCoOwner) {
this.editModel = true;
}
}
OnlClickManageMyModel() {
this.router.navigate([
'/dashboard/manageMyModel/solutionId',
this.solutionId,
'revisionId',
this.revisionId,
]);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment