Author: meynier Date: 2013-07-29 16:51:52 +0200 (Mon, 29 Jul 2013) New Revision: 378 Url: http://chorem.org/projects/chorem/repository/revisions/378 Log: Added buttons in employee edit page to edit/validate/cancel all rows \(and various other small improvments\) Added: trunk/chorem-webmotion/src/main/webapp/css/employeeEdit.css trunk/chorem-webmotion/src/main/webapp/img/ajax-loader.gif Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/EmployeeEditAction.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employeeEdit.jsp trunk/chorem-webmotion/src/main/webapp/js/employeeEdit.js Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/EmployeeEditAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/EmployeeEditAction.java 2013-07-26 14:28:28 UTC (rev 377) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/EmployeeEditAction.java 2013-07-29 14:51:52 UTC (rev 378) @@ -128,9 +128,14 @@ } public Render requestAdc(ChoremClient client, String employeeId) { - EmployeeHR e = new EmployeeHRImpl(client.restore(employeeId)); + Wikitty w = client.restore(employeeId); + EmployeeHR e = new EmployeeHRImpl(w); AdcCalculation adcCalc = new AdcCalculation(e, client); double adc = adcCalc.getAdc(); + + w.setField("EmployeeHR", "dailyReturn", adc); + client.store(w); + int iadc = (int)(adc*100); return renderJSON("adc", (double)(iadc/100.0)); @@ -262,6 +267,10 @@ int x = (int)(client.getDailyHoursWorked(e)*100); double y = x/100.0; this.dailyHoursWorked = y; + + x = (int)(this.dailyReturn*100); + y = x/100.0; + this.dailyReturn = y; this.e = e; } Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-07-26 14:28:28 UTC (rev 377) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-07-29 14:51:52 UTC (rev 378) @@ -112,7 +112,7 @@ <table class="table table-striped table-bordered table-condensed"> <thead> <tr> - <th>Responsable Code Lutin</th> + <th>Responsable ${q.object.getSupplier(false).getCompany(false)}</th> <th>Responsable entreprise</th> <th>Jours estimés</th> <th>Jours réels</th> Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employeeEdit.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employeeEdit.jsp 2013-07-26 14:28:28 UTC (rev 377) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employeeEdit.jsp 2013-07-29 14:51:52 UTC (rev 378) @@ -28,8 +28,8 @@ <f:setLocale value="${locale}" /> +<link rel="stylesheet" href="<c:url value='/css/employeeEdit.css'/>" /> - <h1>${title}</h1> <form method="GET" id="companyForm"> @@ -67,16 +67,30 @@ </c:if> </form> - - -<table class="table table-striped table-bordered table-condensed"> +<button class="btn btn-success" id="editAllBtn"> + <i class="icon-edit icon-white"></i> + Tout éditer + </button> + + <button class="editBtn btn btn-success" id="validateAllBtn" disabled> + <i class="icon-ok icon-white"></i> + Tout valider + </button> + + <button class="editBtn btn btn-danger" id="cancelAllBtn" disabled> + <i class="icon-remove icon-white"></i> + Tout annuler + </button> +<img class="spinner" style="display:none" src="<c:url value='/img/ajax-loader.gif'/>"/> +<table class="table table-striped table-bordered table-condensed tableEdit"> <thead> <th>Employé</th> <th>Salaire</th> <th>Heures par jour</th> <th>Taux de productivité</th> <th>Temps partiel</th> - <th>CJM</th> + <th>CJM <a class="allCjmRefresh" style="cursor:pointer"> + <i class="icon icon-refresh"></i></a></th> <th>Edit</th> </thead> <tbody> @@ -86,7 +100,7 @@ <td class="person"><w:display wikitty="${employee.object.wikitty}" fqfield="Employee.person" label="" /> </td> - <td class="salary"> + <td class="edit salary"> ${employee.salary} </td> <td class="dailyHoursWorked"><f:formatNumber type="number" Added: trunk/chorem-webmotion/src/main/webapp/css/employeeEdit.css =================================================================== --- trunk/chorem-webmotion/src/main/webapp/css/employeeEdit.css (rev 0) +++ trunk/chorem-webmotion/src/main/webapp/css/employeeEdit.css 2013-07-29 14:51:52 UTC (rev 378) @@ -0,0 +1,4 @@ +.tableEdit tbody tr td input { + width:80%; +} + Added: trunk/chorem-webmotion/src/main/webapp/img/ajax-loader.gif =================================================================== (Binary files differ) Property changes on: trunk/chorem-webmotion/src/main/webapp/img/ajax-loader.gif ___________________________________________________________________ Added: svn:mime-type + image/gif Modified: trunk/chorem-webmotion/src/main/webapp/js/employeeEdit.js =================================================================== --- trunk/chorem-webmotion/src/main/webapp/js/employeeEdit.js 2013-07-26 14:28:28 UTC (rev 377) +++ trunk/chorem-webmotion/src/main/webapp/js/employeeEdit.js 2013-07-29 14:51:52 UTC (rev 378) @@ -3,6 +3,8 @@ $(document).ready(function() { + var editCounter = 0; + var blockCounter = 0; $("#companySelect").change(function() { $("#companyForm").submit(); @@ -11,7 +13,23 @@ $(".employeeEdit").click(employeeEdit); $(".cjmRefresh").click(calculateAdc); + $('.allCjmRefresh').click(function() { + $('.cjmRefresh').click(); + }); + $('#editAllBtn').click(function() { + $('.employeeEdit').click(); + }); + + $('#validateAllBtn').click(function() { + $('.editOk').click(); + }); + + $('#cancelAllBtn').click(function() { + $('.editCancel').click(); + }); + + function employeeEdit() { var row = $(this).parent().parent(); var salary = row.find(".salary"); @@ -29,6 +47,11 @@ cjm.html("<input type = 'text' size='3' value='"+$.trim(cjm.find('.adc').html()).replace('%','')+"'/>"); displayConfirmation(row); + editCounter++; + if(editCounter === 1) + $('.editBtn').removeAttr('disabled'); + + } @@ -51,6 +74,10 @@ if(cjm.attr("refresh") === "true") refresh = true; displayDailyReturn(row, $.trim(cjm.attr('oldVal')), refresh); + editCounter--; + if(editCounter === 0) + $('.editBtn').attr('disabled', 'disabled'); + } @@ -69,6 +96,12 @@ var cjmVal = $.trim(cjm.find("input").attr('value')); blockEdit(row); + blockCounter++; + if(blockCounter === 1) { + $('.editBtn').attr('disabled', 'disabled'); + $('#editAllBtn').attr('disabled', 'disabled'); + $('.spinner').show(); + } $.get(createUrl("/admin/employeeEdit/json/editEmployeeValues/",row.attr("id"), "?salaryStr=", salaryVal, "&productivityRateStr=", prodVal, "&partialTimeStr=", timeVal, "&dailyReturnStr=", cjmVal), @@ -85,6 +118,11 @@ "<span class='errorMessage'>"+errors[i]["errorMessage"]+"</span>"); } displayConfirmation(row); + blockCounter--; + if(blockCounter === 0) { + $('.editBtn').removeAttr('disabled'); + $('.spinner').hide(); + } } else { @@ -96,7 +134,17 @@ displayEdit(row); if(cell.attr("refresh") !== "true") cell.attr('refresh', 'true'); - + editCounter--; + blockCounter--; + //Only case where the butotn should be reactivated + if(editCounter !== 0 && blockCounter === 0) + $('.editBtn').removeAttr('disabled'); + else + $('.editBtn').attr('disabled', 'disabled'); + if(blockCounter === 0) { + $('.spinner').hide(); + $('#editAllBtn').removeAttr('disabled'); + } } @@ -121,11 +169,11 @@ } function blockEdit(row) { - row.find('.cellEdit').html('wait...'); + row.find('.cellEdit').html('<img src="../img/ajax-loader.gif"/>'); } function blockDailyReturn(row) { - row.find('.dailyReturn').html('wait...'); + row.find('.dailyReturn').html('<img src="../img/ajax-loader.gif"/>'); } function displayConfirmation(row) { @@ -146,9 +194,9 @@ function displayDailyReturn(row, val, icon) { var cell = row.find('.dailyReturn'); - var str = '<span class="adc">' + val + ' </span><a class="cjmRefresh" style="cursor:pointer">' + var str = '<span class="adc">' + val + ' </span>' if(icon) - str += '<i class="icon icon-refresh"></i></a>' + str += '<a class="cjmRefresh" style="cursor:pointer"><i class="icon icon-refresh"></i></a>' cell.html(str); row.find(".cjmRefresh").click(calculateAdc); }