Skip to content

Commit

Permalink
ATLDEV-256 solved column bug at edit entryID
Browse files Browse the repository at this point in the history
ATLDEV-238 Added select yes/no Teamroom to Timesheet entries
  • Loading branch information
kamppa committed Oct 15, 2018
1 parent c39dbc8 commit 91756c3
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public interface TimesheetEntry extends Entity {

boolean getIsGoogleDocImport();
void setIsGoogleDocImport(boolean isGoogleDocImport);

boolean getTeamroom();
void setTeamroom(boolean teamroom);

String getDescription();
void setDescription(String description);
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/org/catrobat/jira/timesheet/rest/TimesheetRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public Response getTimesheetEntriesOfAllTeamMembers(@Context HttpServletRequest
String owner_name = ComponentAccessor.getUserManager().getUserByKey(owner_key).getName();

if (owner_key == null || owner_name == null) {
return Response.serverError().entity("Now user was found for timesheet id: " + timesheetID).build();
return Response.serverError().entity("No user was found for timesheet id: " + timesheetID).build();
}

if (!permissionService.userCanViewTimesheet(loggedInUser, ownerSheet)) {
Expand All @@ -149,6 +149,11 @@ public Response getTimesheetEntriesOfAllTeamMembers(@Context HttpServletRequest

//calculating data only for most active team
Team team = teamService.getMostActiveTeamForUser(owner_name, ownerSheet);

if (team == null) {
return Response.serverError().entity("User has no team: " + owner_name).build();
}

LOGGER.trace("In getTeamEntries calculating for team: " + team.getTeamName());

for (String teamMembersAndGroups : teamService.getGroupsForRole(team.getTeamName(), TeamToGroup.Role.DEVELOPER)) {
Expand Down Expand Up @@ -481,7 +486,8 @@ public Response postTimesheetEntry(@Context HttpServletRequest request,
try {
newEntry = entryService.add(sheet, entry.getBeginDate(), entry.getEndDate(), category,
entry.getDescription(), entry.getPauseMinutes(), team, entry.IsGoogleDocImport(),
entry.getInactiveEndDate(), entry.getTicketID(), entry.getPairProgrammingUserName());
entry.getInactiveEndDate(), entry.getTicketID(), entry.getPairProgrammingUserName(),
entry.getTeamroom());
} catch (ServiceException e) {
return Response.status(Response.Status.FORBIDDEN).entity(e.getMessage()).build();
}
Expand Down Expand Up @@ -589,7 +595,8 @@ public Response postTimesheetEntries(@Context HttpServletRequest request,

TimesheetEntry newEntry = entryService.add(sheet, entry.getBeginDate(), entry.getEndDate(), category,
entry.getDescription(), entry.getPauseMinutes(), team, entry.IsGoogleDocImport(),
entry.getInactiveEndDate(), entry.getTicketID(), entry.getPairProgrammingUserName());
entry.getInactiveEndDate(), entry.getTicketID(), entry.getPairProgrammingUserName(),
entry.getTeamroom());
entry.setEntryID(newEntry.getID());
errorMap.get("correct").add(entry);
} catch (ParseException | ServiceException | PermissionException e) {
Expand Down Expand Up @@ -752,7 +759,8 @@ public Response putTimesheetEntry(@Context HttpServletRequest request,
try {
entryService.edit(entryID, entry.getTimeSheet(), jsonEntry.getBeginDate(), jsonEntry.getEndDate(), category,
jsonEntry.getDescription(), jsonEntry.getPauseMinutes(), team, jsonEntry.IsGoogleDocImport(),
jsonEntry.getInactiveEndDate(), jsonEntry.getTicketID(), jsonEntry.getPairProgrammingUserName());
jsonEntry.getInactiveEndDate(), jsonEntry.getTicketID(), jsonEntry.getPairProgrammingUserName(),
jsonEntry.getTeamroom());
} catch (ServiceException e) {
return Response.status(Response.Status.CONFLICT).entity(e.getMessage()).build();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/catrobat/jira/timesheet/rest/UserRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ public Response getUsersForCoordinator(@Context HttpServletRequest request, @Pat
}

if (!(permissionService.isUserTeamCoordinator(user) || permissionService.isReadOnlyUser(user) || isAdmin)) {
return Response.status(Response.Status.UNAUTHORIZED).entity("Access Forbidden: You are neither a team " +
"coordinator nor a read only user nor a administrator!").build();
return Response.status(Response.Status.UNAUTHORIZED).entity("Access Forbidden: " + user.getDisplayName() + " is neither a team " +
"coordinator nor a read only user nor an administrator!").build();
}

Set<Team> teamsOfCoordinator = teamService.getTeamsOfCoordinator(user.getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public final class JsonTimesheetEntry {
private String partner;
@XmlElement
private boolean isGoogleDocImport;
@XmlElement
private boolean teamroom;


public JsonTimesheetEntry() {
}
Expand Down Expand Up @@ -96,13 +99,15 @@ public JsonTimesheetEntry(TimesheetEntry timesheetEntry, boolean anonymously) {
this.ticketID = timesheetEntry.getJiraTicketID();
this.partner = timesheetEntry.getPairProgrammingUserName();
this.isGoogleDocImport = timesheetEntry.getIsGoogleDocImport();
this.teamroom = timesheetEntry.getTeamroom();
} else {
this.entryID = 0;
this.inactiveEndDate = null;
this.description = null;
this.ticketID = null;
this.partner = null;
this.isGoogleDocImport = false;
this.teamroom = false;
}
}

Expand Down Expand Up @@ -191,6 +196,12 @@ public void setPairProgrammingUserName(String partner) {
public void setIsGoogleDocImport(boolean isGoogleDocImport) {
this.isGoogleDocImport = isGoogleDocImport;
}

public boolean getTeamroom() {return teamroom;}

public void setTeamroom(boolean teamroom) {
this.teamroom = teamroom;
}

public String getCategoryName() {return categoryName;}

Expand All @@ -212,6 +223,7 @@ public boolean equals(Object o) {
if (teamID != that.teamID) return false;
if (categoryID != that.categoryID) return false;
if (isGoogleDocImport != that.isGoogleDocImport) return false;
if (teamroom != that.teamroom) return false;
if (!beginDate.equals(that.beginDate)) return false;
if (!endDate.equals(that.endDate)) return false;
if (!inactiveEndDate.equals(that.inactiveEndDate)) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ private void setAutoInactive(Timesheet timesheet) {
false,
end,
"",
""
"",
false
);
} catch (ServiceException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
@Transactional
public interface TimesheetEntryService {
TimesheetEntry add(Timesheet sheet, Date begin, Date end, Category category, String description, int pause,
Team team, boolean isGoogleDocImport, Date inactiveEndDate, String jiraTicketID, String userName) throws ServiceException;
Team team, boolean isGoogleDocImport, Date inactiveEndDate, String jiraTicketID,
String userName, boolean teamroom) throws ServiceException;

TimesheetEntry edit(int entryID, Timesheet sheet, Date begin, Date end, Category category, String description,
int pause, Team team, boolean isGoogleDocImport, Date inactiveEndDate, String jiraTicketID, String userName) throws ServiceException;
int pause, Team team, boolean isGoogleDocImport, Date inactiveEndDate, String jiraTicketID,
String userName, boolean teamroom) throws ServiceException;

TimesheetEntry getEntryByID(int entryID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ public TimesheetEntryServiceImpl(ActiveObjects ao, TimesheetService timesheetSer
@Override
public TimesheetEntry add(Timesheet sheet, Date begin, Date end, Category category, String description, int pause,
Team team, boolean isGoogleDocImport, Date inactiveEndDate, String jiraTicketID,
String userName) throws ServiceException {
String userName, boolean teamroom) throws ServiceException {

if (ao.find(TimesheetEntry.class, "TIME_SHEET_ID = ? AND BEGIN_DATE < ? AND END_DATE > ?", sheet.getID(), end, begin).length != 0) {
throw new ServiceException("TimesheetEntries are not allowed to overlap.");
}

TimesheetEntry entry = ao.create(TimesheetEntry.class);
return setTimesheetEntryData(sheet, begin, end, category, description, pause, team, isGoogleDocImport, inactiveEndDate, jiraTicketID, userName, entry);
return setTimesheetEntryData(sheet, begin, end, category, description, pause, team, isGoogleDocImport,
inactiveEndDate, jiraTicketID, userName, teamroom, entry);
}

private TimesheetEntry setTimesheetEntryData(Timesheet sheet, Date begin, Date end, Category category, String description,
int pause, Team team, boolean isGoogleDocImport, Date inactiveEndDate, String jiraTicketID, String userName,
TimesheetEntry entry) throws ServiceException {
boolean teamroom, TimesheetEntry entry) throws ServiceException {

checkParams(begin, end, category, description, team, jiraTicketID, userName);

Expand All @@ -72,6 +73,7 @@ private TimesheetEntry setTimesheetEntryData(Timesheet sheet, Date begin, Date e
entry.setPauseMinutes(pause);
entry.setTeam(team);
entry.setIsGoogleDocImport(isGoogleDocImport);
entry.setTeamroom(teamroom);
entry.setInactiveEndDate(inactiveEndDate);
entry.setJiraTicketID(jiraTicketID);
entry.setPairProgrammingUserName(userName);
Expand Down Expand Up @@ -159,14 +161,15 @@ public TimesheetEntry getEntryByID(int entryID) {
@Nullable
public TimesheetEntry edit(int entryId, Timesheet sheet, Date begin, Date end, Category category,
String description, int pause, Team team, boolean isGoogleDocImport,
Date inactiveEndDate, String jiraTicketID, String userName) throws ServiceException {
Date inactiveEndDate, String jiraTicketID, String userName, boolean teamroom) throws ServiceException {

TimesheetEntry entry = getEntryByID(entryId);

if (entry == null) {
throw new ServiceException("Entry not found");
}
return setTimesheetEntryData(sheet, begin, end, category, description, pause, team, isGoogleDocImport, inactiveEndDate, jiraTicketID, userName, entry);
return setTimesheetEntryData(sheet, begin, end, category, description, pause, team, isGoogleDocImport,
inactiveEndDate, jiraTicketID, userName, teamroom, entry);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
}
timesheetEntryService.add(sheet, entry.getBeginDate(), entry.getEndDate(), category, entry.getDescription(),
entry.getPauseMinutes(), team, entry.IsGoogleDocImport(), entry.getInactiveEndDate(),
entry.getTicketID(), entry.getPairProgrammingUserName());
entry.getTicketID(), entry.getPairProgrammingUserName(), entry.getTeamroom());

} catch (ServiceException e) {
errorString.append(e.getMessage()).append(" Entry ignored.\n");
Expand Down
12 changes: 4 additions & 8 deletions src/main/resources/js/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ AJS.toInit(function () {
targetHoursCompleted: toFixed(AJS.$("#timesheet-hours-practical").val() - AJS.$("#timesheet-hours-substract").val(), 2),
targetHoursRemoved: toFixed(AJS.$("#timesheet-hours-substract").val(), 2),
latestEntryDate: existingTimesheetData.latestEntryDate,

state: existingTimesheetData.state
};

Expand Down Expand Up @@ -230,6 +229,7 @@ function checkConstrains() {
}

function projectedFinishDate(timesheetData, entryData) {

var timesheet = timesheetData[0];
var entries = entryData[0];
var rem = timesheet.targetHours - timesheet.targetHoursCompleted + timesheet.targetHoursRemoved;
Expand Down Expand Up @@ -259,15 +259,13 @@ function setOwnerLabel(timesheet) {
AJS.$("#timesheet-owner").empty();
AJS.$("#timesheet-owner").append("Timesheet of: " + timesheet.displayName);
AJS.$("#timesheet-owner-private").empty();
AJS.$("#timesheet-owner-private").append("My Timesheet (" + timesheet.displayName + ")");

AJS.$("#timesheet-owner-private").append("My Timesheet (" + timesheet.displayName + ")");
}

function setDownloadLink(timesheet) {

AJS.$("#download-csv").attr("href", "download/timesheet");
AJS.$("#download-json").attr("href", "download/timesheet/json");

AJS.$("#download-json").attr("href", "download/timesheet/json");
}

function fetchData(timesheetID) {
Expand Down Expand Up @@ -488,8 +486,6 @@ function assembleTimesheetData(timesheetReply, categoriesReply, teamsReply, entr
});

initTimesheetInformationValues(timesheetData_);
//updateTimesheetInformationValues(timesheetData_);

return timesheetData_;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/js/timesheet/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ function parseEntryFromGoogleDocRow(row, timesheetData) {
isGoogleDocImport: true,
ticketID: "",
partner: "",
inactiveEndDate: beginDate
inactiveEndDate: beginDate,
teamroom: false
};
}

Expand Down
28 changes: 21 additions & 7 deletions src/main/resources/js/timesheet/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ function populateTable(timesheetDataReply) {
duration: "",
ticketID: "",
isGoogleDocImport: false,
partner: ""
partner: "",
teamroom: false
};

var addNewEntryOptions = {
Expand Down Expand Up @@ -218,6 +219,13 @@ function editEntryCallback(entry, timesheetData, form) {
oldViewRow.after(newViewRow);
oldViewRow.remove();

var categoryIndex = form.categorySelect.val();

var categoryName = getNameFromCategoryIndex(categoryIndex, timesheetData);
if (!(categoryName.includes("(pp)") || categoryName.includes("pair"))) {
AJS.$(".partner").hide();
}

form.row.hide();
}

Expand Down Expand Up @@ -260,7 +268,7 @@ function renderFormRow(timesheetData, entry, saveOptions, isModified) {
submit(timesheetData, saveOptions, form, entry.entryID,
entry.isGoogleDocImport);
}
//AJS.$(".entry-form").show();

});

return form.row;
Expand Down Expand Up @@ -294,7 +302,8 @@ function prepareForm(entry, timesheetData, isModified) {
ticketSelect: row.find('input.ticket_'),
categorySelect: row.find('span.category_'),
partnerSelect: row.find('span.partner_'),
teamSelect: row.find('select.team')
teamSelect: row.find('select.team'),
teamroomField: row.find('select.room_')
};

form.ticketSelect.show();
Expand Down Expand Up @@ -329,6 +338,7 @@ function prepareForm(entry, timesheetData, isModified) {
form.durationField.val('00:00');
form.ticketSelect.select2("val", "");
form.partnerSelect.select2("val", "");
form.teamroomField.select2("val", "");

AJS.$(".ticket").fadeOut(2000);
AJS.$(".partner").fadeOut(2000);
Expand All @@ -337,6 +347,7 @@ function prepareForm(entry, timesheetData, isModified) {
AJS.$(".pause").fadeOut(2000);
AJS.$(".end").fadeOut(2000);
AJS.$(".start").fadeOut(2000);
AJS.$(".room").fadeOut(2000);

var date = form.inactiveEndDateField.val();
checkIfDateIsInRange(date, form);
Expand All @@ -358,6 +369,7 @@ function prepareForm(entry, timesheetData, isModified) {
AJS.$(".pause").fadeIn(2000);
AJS.$(".duration").fadeIn(2000);
AJS.$(".ticket").fadeIn(2000);
AJS.$(".room").fadeIn(2000);

// define special behaviour
setTimeout(function () { //little hack we have to do
Expand Down Expand Up @@ -1028,7 +1040,7 @@ function augmentEntry(timesheetData, entry) {


var pauseDate = new Date(entry.pauseMinutes * 1000 * 60);

return {
date: toDateString(new Date(entry.beginDate)),
begin: toTimeString(new Date(entry.beginDate)),
Expand All @@ -1047,7 +1059,8 @@ function augmentEntry(timesheetData, entry) {
isGoogleDocImport: entry.isGoogleDocImport,
inactiveEndDate: toDateString(new Date(entry.inactiveEndDate)),
ticketID: entry.ticketID,
partner: entry.partner
partner: entry.partner,
teamroom: entry.teamroom
};
}

Expand Down Expand Up @@ -1195,7 +1208,7 @@ function submit(timesheetData, saveOptions, form, existingEntryID,

if (ticketString.includes(",")) {
ticketString = ticketString.replace(/,/g," --- ");
}
}

timesheetEntry = {
beginDate: beginDate,
Expand All @@ -1207,7 +1220,8 @@ function submit(timesheetData, saveOptions, form, existingEntryID,
categoryID: form.categorySelect.val(),
isGoogleDocImport: existingIsGoogleDocImportValue,
partner: form.partnerSelect.val(),
ticketID: ticketString
ticketID: ticketString,
teamroom: form.teamroomField.val()
};

if (existingEntryID !== "new-id") {
Expand Down
Loading

0 comments on commit 91756c3

Please sign in to comment.