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

Edit ticket page #32

Merged
merged 28 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5535d46
basic edit ticket functionality
Val-Bustamante May 3, 2023
4ac1011
fixed edit and make ticket bugs
Val-Bustamante May 3, 2023
dc0c895
add owners in makeTicket functionality
Val-Bustamante May 3, 2023
751990f
fix adding owners bug
Val-Bustamante May 4, 2023
a4bd74a
add required to form fields
Val-Bustamante May 4, 2023
67659bc
change deadline to datetime object and add default values to edit tic…
Val-Bustamante May 4, 2023
05dbe71
fix default values in edit ticket form
Val-Bustamante May 4, 2023
62e272b
fix default value for deadline in edit form
Val-Bustamante May 4, 2023
1adc9b5
take out console.logs
Val-Bustamante May 4, 2023
c80ef26
fix default value for owners in edit Ticket form
Val-Bustamante May 4, 2023
2c8d1e0
merged changes in main into branch
Val-Bustamante May 4, 2023
8ba337c
fix filterResults to not add tickets twice
Val-Bustamante May 5, 2023
7c16c85
fix edit ticket form- name and description now fills in
Val-Bustamante May 5, 2023
78bfa41
fix error caused by seed file: refrence error
Val-Bustamante May 5, 2023
e114a6e
fix owners list editing rights
Val-Bustamante May 5, 2023
e17bf96
fix select bug in edit page
Val-Bustamante May 5, 2023
3c56436
add status change ability for admin in edit ticket
Val-Bustamante May 5, 2023
fd6ecba
Fixed bug where owners weren't being updated
bigguyhere May 5, 2023
782c9ef
Removed unecessary logging
bigguyhere May 5, 2023
7ce2f38
Made dates consistent with edit ticket date
bigguyhere May 5, 2023
c03275c
fix merge
Val-Bustamante May 5, 2023
2a75b2d
have default values in edit form not go away after an error occurs
Val-Bustamante May 5, 2023
a953e39
Fixed error where using same date for a deadline that is already past…
bigguyhere May 5, 2023
c696bb0
Merge branch 'edit-ticket' of https://github.com/MAPReiff/Tikit into …
bigguyhere May 5, 2023
337863a
Fixed issues with date and deleting owners
bigguyhere May 5, 2023
5588390
Removed some logging
bigguyhere May 5, 2023
051f8d7
Fixed redundant ticket getting
bigguyhere May 5, 2023
a16cd6c
Merge branch 'main' into edit-ticket
bigguyhere May 5, 2023
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
Prev Previous commit
Next Next commit
fixed edit and make ticket bugs
  • Loading branch information
Val-Bustamante committed May 3, 2023
commit 4ac1011fc2c1e6b77b04ce25915c2b4f22407c94
23 changes: 12 additions & 11 deletions data/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ const create = async (
// validate description
description = helpers.checkString(description, "Description");

if (description.length < 10) {
throw new Error(`${type} must be atleast 10 characters long`);
} else if (description.length > 200) {
throw new Error(`${type} must be no longer than 200 characters`);
}

// validate status
status = helpers.checkString(status, "Status");
if (status != "To Do" && status != "In Progress" && status != "Completed") {
Expand Down Expand Up @@ -63,15 +57,12 @@ const create = async (
} else if (new Date(deadline).getTime() < createdOn) {
throw new Error("provided dealine in the past");
}
deadline = new Date(deadline);
}

// validate customerID
customerID = helpers.checkId(customerID, "Customer ID");

//validate owners
if (owners.length != 0) {
owners = helpers.checkIdArray(owners, "Owners ID Array");
}


// validate category
category = helpers.checkString(category, "Category");
Expand All @@ -88,6 +79,12 @@ const create = async (

customerID = new ObjectId(helpers.validateID(customerID));

//validate owners
if (owners.length != 0) {
owners = helpers.checkIdArray(owners, "Owners ID Array");
}


if (owners && Array.isArray(owners)) {
for (let [index, user] of owners.entries()) {
owners[index] = new ObjectId(helpers.validateID(user));
Expand All @@ -96,6 +93,10 @@ const create = async (
throw "Owners is not a valid array";
}

if(owners){
owners.push(customerID);
}

// check if tags are provided
if (!tags) {
tags = [];
Expand Down
10 changes: 6 additions & 4 deletions routes/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ router
renderError(res, 404, 'Issue Retrieving ticket');
}

console.log('ticket', ticket);
console.log('description', req.body["ticketDescription"]);


try{
Expand All @@ -167,6 +167,8 @@ router
req.body.hasOwnProperty("ticketPriority")
){

console.log('in if');

let ticketName = checkString(
req.body["ticketName"],
"ticket name"
Expand Down Expand Up @@ -203,12 +205,13 @@ router
}

}else{
res.status(400).render("editTicket", { title: "Edit Ticket", error: 'All fields must be filled out'});
console.log("in ekse");
res.status(400).render("editTicket", { title: "Edit Ticket", error: 'All fields must be filled out', _id: req.params.id});
}

} catch (e) {
// render form with 400 code
res.status(400).render("editTicket", { title: "Edit Ticket", error: `${e}`});
res.status(400).render("editTicket", { title: "Edit Ticket", error: `${e}`, _id: req.params.id});
}


Expand Down Expand Up @@ -275,7 +278,6 @@ router
req.session.user._id,
[],
ticketCategory
//[]
);

if (createdTicket) {
Expand Down
1 change: 0 additions & 1 deletion views/editTicket.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
</span>
</div>
</div>
<p>{{category}}</p>
<select class="form-control" id="ticketCategory" name="ticketCategory" placeholder={{category}}>
<option value="Service Request" selected="selected">Service Request</option>
<option value="Incident">Incident</option>
Expand Down