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
add status change ability for admin in edit ticket
  • Loading branch information
Val-Bustamante committed May 5, 2023
commit 3c564366d7ef8f043ff69d2d75fe5a2ff363db2d
22 changes: 16 additions & 6 deletions data/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const create = async (

// validate status
status = helpers.checkString(status, "Status");
if (status != "To Do" && status != "In Progress" && status != "Completed") {
if (status != "To Do" && status != "In Progress" && status != "Completed" && status != "Problem") {
throw new Error(
"status must be a string equal to To Do, In Progress, or Completed"
);
Expand Down Expand Up @@ -80,7 +80,6 @@ const create = async (
customerID = new ObjectId(helpers.validateID(customerID));

//validate owners

if (owners && Array.isArray(owners)) {
if(owners.length > 0){
owners = helpers.checkIdArray(owners, "Owners ID Array");
Expand All @@ -97,8 +96,6 @@ const create = async (
owners = [];
}



// check if tags are provided
if (!tags) {
tags = [];
Expand Down Expand Up @@ -203,6 +200,7 @@ const update = async (
customerID,
id,
name,
status,
description,
priority,
deadline,
Expand All @@ -224,6 +222,8 @@ const update = async (
// validate description
description = helpers.checkString(description, "Description");

const curTicket = await get(id);
bigguyhere marked this conversation as resolved.
Show resolved Hide resolved


// validate priority
priority = helpers.checkString(priority, "Priority");
Expand All @@ -239,6 +239,17 @@ const update = async (
);
}

// validate status
if(status){
status = helpers.checkString(status, "Status");
if (status != "To Do" && status != "In Progress" && status != "Completed" && status != "Problem") {
throw new Error(
"status must be a string equal to To Do, In Progress, or Completed"
);
}
}else{
status = curTicket.status;
}


// check if dadline is provided
Expand All @@ -263,8 +274,6 @@ const update = async (
customerID = new ObjectId(helpers.validateID(customerID));


const curTicket = await get(id);

//validate owners
if (owners && Array.isArray(owners)) {
if(owners.length > 0){
Expand Down Expand Up @@ -310,6 +319,7 @@ const update = async (
name: name,
description: description,
priority: priority,
status: status,
createdOn: curTicket.createdOn,
deadline: new Date(deadline),
customerID: curTicket.customerID,
Expand Down
1 change: 1 addition & 0 deletions routes/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ router
req.session.user._id,
req.params.id,
ticketName,
req.body["ticketStatus"],
ticketDescription,
ticketPriority,
req.body["ticketDeadline"],
Expand Down
15 changes: 15 additions & 0 deletions views/editTicket.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
<label class="" for="ticketDescription">Description</label>
<input class="form-control" type="text" id="ticketDescription" name="ticketDescription" placeholder="{{description}}" value="{{description}}"> <br>

{{#ifEquals role "admin"}}
<label class="" for="ticketStatus">Status</label>
<select class="form-control" id="ticketStatus" name="ticketStatus">
{{#select status}}
<option value="To Do">To Do</option>

<option value="In Progress">In Progress</option>

<option value="Problem">Problem</option>

<option value="Completed">Completed</option>
{{/select}}
</select><br>
{{/ifEquals}}

<label class="" for="ticketCategory">Category</label>
<div class="col-md-12"></div>
<div class="infoCategory">
Expand Down