Skip to content

Commit

Permalink
clean up code,
Browse files Browse the repository at this point in the history
release version 2.3
  • Loading branch information
kamppa committed Oct 16, 2018
1 parent 91756c3 commit ac6ba05
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 94 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.catrobat.jira</groupId>
<artifactId>timesheet</artifactId>
<version>2.3-SNAPSHOT</version>
<version>2.3</version>

<organization>
<name>Catrobat</name>
Expand Down
26 changes: 2 additions & 24 deletions src/main/resources/js/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ AJS.toInit(function () {
}
else {
fetchData(timesheetID);
AJS.$("#reset-timesheet-settings").hide();

}

hideGoogleDocsImportButtonWhenDisabled();
Expand Down Expand Up @@ -364,28 +364,6 @@ function loadMostActiveTeamForUser(){
});
}

function saveTimesheetIDOfUserInSession(selectedUser) {

var user;
user = selectedUser[0];

AJS.$.ajax({
type: 'GET',
url: restBaseUrl + 'timesheet/timesheetID/' + user,
contentType: "application/json",
success: function (timesheetID) {
sessionStorage.setItem('timesheetID', timesheetID); // defining the session variable
},
error: function (error) {
AJS.messages.error({
title: 'There was an error while getting timesheet data of another user.',
body: '<p>Reason: ' + error.responseText + '</p>'
});
console.log(error);
}
});
}


function fetchUsers() {
var config = AJS.$.ajax({
Expand All @@ -408,7 +386,7 @@ function fetchUsers() {

AJS.$.when(config, jsonUser, userList)
.done(initCoordinatorTimesheetSelect)
.done(initTimesheetAdminTimesheetSelect)

.fail(function (error) {
AJS.messages.error({
title: 'There was an error while fetching user data.',
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/js/timesheet/coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ function initCoordinatorTimesheetSelect(jsonConfig, jsonUser, userInformation) {
for (var j = 0; j < team['coordinatorGroups'].length; j++) {
if (team['coordinatorGroups'][j].localeCompare(userName) == 0) {
var teamNameForTeamInformation = team.teamName;
AJS.$("#team-information-teamname").append(teamNameForTeamInformation);
isTeamCoordinator = true;
}
}
}

if (isTeamCoordinator && !isSupervisedUser && !isAdmin) {
initSelectTimesheetButton();
AJS.$("#visualizationTeamSelect").show();
} else if(isSupervisedUser && !isTeamCoordinator) {
AJS.$("#visualizationTeamSelect").show();
Expand Down
56 changes: 0 additions & 56 deletions src/main/resources/js/timesheet/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,62 +35,6 @@ function getNameFromCategoryIndex(categoryID, timesheetData) {
return "";
}


function initSelectTimesheetButton() {
AJS.$("#timesheet-settings").submit(function (e) {
e.preventDefault();

if (AJS.$("#user-select2-field").val()) {
selectedUser = AJS.$("#user-select2-field").val().split(',');
} else if (AJS.$("#approved-user-select2-field").val()) {
selectedUser = AJS.$("#approved-user-select2-field").val().split(',');
}

if(typeof selectedUser === "undefined"){
console.log("you have not select a user !!");

AJS.messages.error({
title:"Error!",
body: "Please select a user and try again!"
});
return;
}

require('aui/flag')({
type: 'info',
title: 'Page will be reloaded',
body: '<p>Page will be loaded soon. Please wait...</p>' +
'You can <a href="javascript:window.location.reload();">quick reload</a> by pressing the F5 key.',
close: 'auto'
});

var selectedUser;

// TODO: why even 2 different fields??? simplify to 1

if (selectedUser[0] !== "") {
saveTimesheetIDOfUserInSession(selectedUser);
}

//browser reload
window.setTimeout(function () {
location.reload()
}, 4000);
});
AJS.$("#reset-timesheet-settings").submit(function (e) {
e.preventDefault();

sessionStorage.removeItem('timesheetID');
location.reload();
});
AJS.$("#reset-timesheet-settings-coord").submit(function (e) {
e.preventDefault();

sessionStorage.removeItem('timesheetID');
location.reload();
});
}

function toFixed(value, precision) {
var power = Math.pow(10, precision || 0);
return Math.round(value * power) / power;
Expand Down
10 changes: 0 additions & 10 deletions src/main/resources/js/timesheet/supervisor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,3 @@ function initTimesheetAdminUserList (totalUserList) {
allUsersList = allUsersList + "<option value=\"" + sortedUserList[i] + "\"/>";

}

function initTimesheetAdminTimesheetSelect(jsonConfig, jsonUser, userList) {
var config = jsonConfig[0];
var userName = jsonUser[0]['userName'];
var isSupervisedUser = isReadOnlyUser(userName, config);

if (isSupervisedUser || isAdmin) {
initSelectTimesheetButton();
}
}
1 change: 0 additions & 1 deletion src/main/resources/timesheet.vm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
<div class="aui-page-panel">
<div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<h3 id="team-information-teamname">Team: </h3>
<table id="team-information-table" class="aui aui-table-interactive aui-table-sortable">
<thead>
<tr>
Expand Down

0 comments on commit ac6ba05

Please sign in to comment.