Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(milestone-card):Added delete functionality #964

Merged
merged 6 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion functions/model/milestone/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ exports.getMilestoneData = function(orgDomain, milestoneId) {
* @return {any}
*/
exports.getAllMilestonesData = function(orgDomain, teamId="") {
let query = db.collection("Organizations").doc(orgDomain).collection("Milestones");
let query = db.collection("Organizations").doc(orgDomain).collection("Milestones").where("Deleted", "==", false);
if (teamId != "") {
Aditya3034 marked this conversation as resolved.
Show resolved Hide resolved
query = query.where("TeamId", "==", teamId);
}
Expand Down
12 changes: 12 additions & 0 deletions functions/model/milestone/milestone.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const { getAllMilestones } = require("../milestone/tark/getAllMilestones");
const { getMilestone } = require("../milestone/tark/getMilestone");
const { editMilestone } = require("../milestone/tark/editMilestone");
const { addTaskToMilestone } = require("../milestone/tark/addTask");
const { deleteMilestone } = require("../milestone/tark/deleteMilestone");

/**
* Description
Expand Down Expand Up @@ -78,6 +79,17 @@ fastify.post("/addTask", (req, res) => {
addTaskToMilestone(req, res);
});

/**
* Description
* @param {any} "/addTask"
* @param {any} req
* @param {any} res
* @returns {any}
*/
fastify.post("/deleteMilestone", (req, res) => {
deleteMilestone(req, res);
});

/**
* Description
* @param {any} req
Expand Down
54 changes: 54 additions & 0 deletions functions/model/milestone/tark/deleteMilestone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* eslint-disable linebreak-style */
/* eslint-disable object-curly-spacing */
/* eslint-disable eol-last */
/* eslint-disable max-len */

/** *********************************************************
* Copyright (C) 2022
* Worktez
* Author : Aditya Khedekar <aditya3034@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the MIT License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the MIT License for more details.
***********************************************************/

const { getMilestoneData, updateMilestone } = require("../lib");

exports.deleteMilestone = function(request, response) {
const deleted = true;
const milestoneID = request.body.data.MilestoneId;
const orgDomain = request.body.data.OrganizationDomain;
let result;
let status = 200;
console.log(deleted, milestoneID, orgDomain);

Aditya3034 marked this conversation as resolved.
Show resolved Hide resolved
const promise = getMilestoneData(orgDomain, milestoneID).then((mDoc) => {
if (mDoc) {
const updateJson = {
MilestoneStatus: "Deleted",
};
updateMilestone(updateJson, orgDomain, milestoneID);
result = { data: "Milestone deleted Successfully" };
console.log("Milestone deleted Successfully");
} else {
status = 500;
result = { data: "Milestone: Milestone doesn't exist" };
console.log("Milestone: Milestone doesn't exist");
}
}).catch((error) => {
status = 500;
console.log("Error: ", error);
}); return Promise.all(promise).then(() => {
return response.status(status).send(result);
})
.catch((error) => {
result = { data: error };
console.error("Error deleting Milestone", error);
return response.status(status).send(result);
});
};
1 change: 1 addition & 0 deletions src/app/Interface/MilestoneInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export interface Milestones {
StartDate: string;
EndDate: string;
ColorCode: string;
Deleted: boolean;
}
Aditya3034 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
width:1rem;
height:1rem;
border-radius: 50px;
margin-top: 5px;
}

.milestone{
Expand Down
102 changes: 55 additions & 47 deletions src/app/body/milestone/milestone-card/milestone-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,65 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the MIT License for more details.
***********************************************************/ -->
<div class="card p-3" (click)="getMilestoneDetails(milestone.MilestoneId)">
<div class="milestone d-flex justify-content-between">
<span class="heading py-2" >
<span class="headId px-2">
{{milestone.MilestoneId}}
</span>
<span>
{{milestone.Title}}
</span>
</span>
<div id="milColor" [ngStyle]="{'background-color': color}"></div>
<div class="card p-3" id="milestoneCard" *ngIf="milestone.MilestoneStatus != 'Deleted'">
<div class="milestone d-flex justify-content-between">
<span class="heading py-2">
<span class="headId px-2">
{{milestone.MilestoneId}}
</span>
<span>
{{milestone.Title}}
</span>
</span>
<div id="milColor" [ngStyle]="{'background-color': color}"></div>
<div class="col">
<mat-icon fontSet="material-icons-outlined" class="align-middle" title="Delete Milestone" type="button"
(click)="deleteMilestone(milestone.MilestoneId)">
delete
</mat-icon>
</div>
</div>
<div (click)="getMilestoneDetails(milestone.MilestoneId)">
<div class="row py-2">
<div class="col">
<mat-icon fontSet="material-icons-outlined" class="align-middle mr-2">
toc
</mat-icon>
<span class="align-middle"> {{milestone.Description}}</span>
</div>
<div class="row py-2">
<div class="col">
<mat-icon fontSet="material-icons-outlined" class="align-middle mr-2">
toc
</mat-icon>
<span class="align-middle"> {{milestone.Description}}</span>
</div>
</div>
<div class="row py-2">
<div class="col-md-3 col-4">
<span class="teamId">
<mat-icon fontSet="material-icons-outlined" class="align-middle mr-2">
groups_3
</mat-icon><span class="align-middle ">{{milestone.TeamId}}</span>
</span>
</div>
<div class="row py-2">
<div class="col-md-3 col-4">
<span class="teamId">
<mat-icon fontSet="material-icons-outlined" class="align-middle mr-2">
groups_3
</mat-icon><span class="align-middle ">{{milestone.TeamId}}</span>
</span>
</div>
<div class="col-md-9 col-8">
<span class="teamId">
Status:<span> {{milestone.MilestoneStatus}}</span>
</span>
</div>
<div class="col-md-9 col-8">
<span class="teamId">
Status:<span> {{milestone.MilestoneStatus}}</span>
</span>
</div>
<div class="row py-2">
<div class="col"id="dateAlign">
<span type="button" class="btn align-bottom p-0 m-0" id="StartDate">
<mat-icon fontSet="material-icons-outlined" class="align-middle">
date_range
</mat-icon>
Start Date: <span id="sprintStartDate">{{ milestone.StartDate }}</span>
</span>
</div>
</div>
<div class="row py-2">
<div class="col" id="dateAlign">
<span type="button" class="btn align-bottom p-0 m-0" id="StartDate">
<mat-icon fontSet="material-icons-outlined" class="align-middle">
date_range
</mat-icon>
Start Date: <span id="sprintStartDate">{{ milestone.StartDate }}</span>
</span>
</div>
<div class="row py-2">
<div class="col"id="dateAlign">
<span type="button" class="btn align-bottom p-0 m-0" id="EndDate">
<mat-icon fontSet="material-icons-outlined" class="align-middle">date_range
</mat-icon>
End Date: <span id="sprintStartDate">{{ milestone.EndDate }}</span>
</div>
<div class="row py-2">
<div class="col"id="dateAlign">
<span type="button" class="btn align-bottom p-0 m-0" id="EndDate">
<mat-icon fontSet="material-icons-outlined" class="align-middle">date_range
</mat-icon>
End Date: <span id="sprintStartDate">{{ milestone.EndDate }}</span>
</span>
</div>
</div>
</div>
</div>
</div>
23 changes: 21 additions & 2 deletions src/app/body/milestone/milestone-card/milestone-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
* See the MIT License for more details.
***********************************************************/
import { Component, Input, OnInit } from '@angular/core';
import { AngularFireFunctions } from '@angular/fire/compat/functions';
import { ActivatedRoute, Router } from '@angular/router';
import { Milestones } from 'src/app/Interface/MilestoneInterface';
import { BackendService } from 'src/app/services/backend/backend.service';
import { ErrorHandlerService } from 'src/app/services/error-handler/error-handler.service';

@Component({
selector: 'app-milestone-card',
Expand All @@ -23,9 +26,9 @@ import { Milestones } from 'src/app/Interface/MilestoneInterface';
export class MilestoneCardComponent implements OnInit {

@Input("milestone") milestone:Milestones
constructor( private router: Router) { }
constructor( private router: Router, private backendService: BackendService, private functions: AngularFireFunctions, public errorHandlerService: ErrorHandlerService) { }
color: string;
ngOnInit(): void {
ngOnInit(): void {
this.color="#"+this.milestone.ColorCode;
if(this.milestone.ColorCode==null || this.milestone.ColorCode==""){
this.color="#ffffff"
Expand All @@ -36,4 +39,20 @@ export class MilestoneCardComponent implements OnInit {
this.router.navigate(['MilestoneDetails/', milestoneId]);
}

deleteMilestone(milestoneId: string) {
const mId = milestoneId;
const orgDomain = this.backendService.getOrganizationDomain();
const callable = this.functions.httpsCallable('milestone/deleteMilestone');

callable({OrganizationDomain: orgDomain, MilestoneId: mId}).subscribe({
next: (data) => {
this.milestone.MilestoneStatus = "Deleted";
},
error: (error) => {
console.error("Error", error);
this.errorHandlerService.showError = true;
},
complete: () => console.info('Successful ')
});
}
}