There is a lot of custom form validation JavaScript in the budget editing template which can be handled instead by the jQuery validation plugin.
Created attachment 52463 [details] [review] Bug 16754 - Use validation plugin when adding or editing budgets This patch removes the custom javascript form validation from the budget edit template and replaces it with validation via the validation plugin. I did not reproduce the date comparison portion of the script because it didn't work correctly in many cases. The datepicker enforces the requirement that the budget start date precedes the budget end date. Also changed: I added the "Required" text next to required fields. To test, apply the patch and test the budget creation process for adding, editing, and duplicating budgets. In all cases: - The start date and end date should be required - The description should be required - The budget amount should be required to be a number
I see that the date comparison operation is handled better in other templates. I'm going to revise this patch to try to incorporate a working version.
Created attachment 52476 [details] [review] Bug 16754 - Use validation plugin in budgets, planning, and contracts This patch removes the custom javascript form validation from three templates: Budgets, budget planning, and contracts. Validation via the validation plugin is done instead. This patch also removes use of event attributes like onclick and onchange. Also changed: I added the "Required" text next to required fields as necessary. To test, apply the patch and go to Administration -> Budgets. - Test the budget creation process for adding, editing, and duplicating budgets. In all cases: - The start date and end date should be required - You should be warned if you enter an end date which falls before the start date. - The description should be required - The budget amount should be required to be a number To test the budget planning page: Note that much of the JS removed from this template was unused. It looked for inputs by the name 'est_total' which don't exist. - When viewing the table of funds for a budget, select a choice from the 'planning' toolbar menu. - Verify that after entering a numeric value in any cell, the 'remaning' value at the end of the row is correctly updated. - Verify that after entering non-numeric data an error is displayed. - Verify that clicking the 'auto-fill' button at the end of the row To test the vendor contracts page: - Go to Acquisitions -> Vendor -> Contracts - Add or edit a contract - Confirm that name, start date, and end date are required. - Confirm that you are warned if you enter an end date which falls before the start date.
There is something wrong (strange) in budget creation: - Create a new budget - Click on Save - A warning is displayed after Start date input box: This field is required. And the date picker is displayed - Pick a date. => The date is copied to the input box, but (1) it is red, and (2) the message 'This field is required' is still displayed.
(In reply to Frédéric Demians from comment #4) > - Pick a date. => The date is copied to the input box, but (1) it is red, and > (2) the message 'This field is required' is still displayed. This is a problem not with this patch but with the way the validation plugin works together with the datepicker widget. Now that I know of the problem I can find it elsewhere too, for instance aqcontract.pl. I can try to find a solution, but I would like to do so as a separate bug if that's okay with everyone.
Created attachment 54057 [details] [review] Bug 16754 - Use validation plugin in budgets, planning, and contracts This patch removes the custom javascript form validation from three templates: Budgets, budget planning, and contracts. Validation via the validation plugin is done instead. This patch also removes use of event attributes like onclick and onchange. Also changed: I added the "Required" text next to required fields as necessary. To test, apply the patch and go to Administration -> Budgets. - Test the budget creation process for adding, editing, and duplicating budgets. In all cases: - The start date and end date should be required - You should be warned if you enter an end date which falls before the start date. - The description should be required - The budget amount should be required to be a number To test the budget planning page: Note that much of the JS removed from this template was unused. It looked for inputs by the name 'est_total' which don't exist. - When viewing the table of funds for a budget, select a choice from the 'planning' toolbar menu. - Verify that after entering a numeric value in any cell, the 'remaning' value at the end of the row is correctly updated. - Verify that after entering non-numeric data an error is displayed. - Verify that clicking the 'auto-fill' button at the end of the row To test the vendor contracts page: - Go to Acquisitions -> Vendor -> Contracts - Add or edit a contract - Confirm that name, start date, and end date are required. - Confirm that you are warned if you enter an end date which falls before the start date. Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
I'm not sure how this is valid but, if you enter start date == end date, the validator tell you that it is not allowed. It's a change with before this patch. We could imagine a budget for only 1 day, which was allowed before, but not anymore. Feel free to contradict :)
(In reply to Jonathan Druart from comment #7) > We could imagine a budget for only 1 > day, which was allowed before, but not anymore. That seems very unlikely. It wouldn't be difficult to add a new validation setting to allow the two dates to match, but I'm not sure it's worth it just for this form and without an indication that it's an important feature. I think this form should match others in Koha where the end date in a date span is required to be after the start.
Created attachment 79896 [details] [review] Bug 16754: Use validation plugin in budgets, planning, and contracts This patch removes the custom javascript form validation from three templates: Budgets, budget planning, and contracts. Validation via the validation plugin is done instead. This patch also removes use of event attributes like onclick and onchange. Also changed: I added the "Required" text next to required fields as necessary. To test, apply the patch and go to Administration -> Budgets. - Test the budget creation process for adding, editing, and duplicating budgets. In all cases: - The start date and end date should be required - You should be warned if you enter an end date which falls before the start date. - The description should be required - The budget amount should be required to be a number To test the budget planning page: Note that much of the JS removed from this template was unused. It looked for inputs by the name 'est_total' which don't exist. - When viewing the table of funds for a budget, select a choice from the 'planning' toolbar menu. - Verify that after entering a numeric value in any cell, the 'remaning' value at the end of the row is correctly updated. - Verify that after entering non-numeric data an error is displayed. - Verify that clicking the 'auto-fill' button at the end of the row works to fill any empty or zero-value fields with the remaning funds available. To test the vendor contracts page: - Go to Acquisitions -> Vendor -> Contracts - Add or edit a contract - Confirm that name, start date, and end date are required. - Confirm that you are warned if you enter an end date which falls before the start date.
Created attachment 79940 [details] [review] Bug 16754: Use validation plugin in budgets, planning, and contracts This patch removes the custom javascript form validation from three templates: Budgets, budget planning, and contracts. Validation via the validation plugin is done instead. This patch also removes use of event attributes like onclick and onchange. Also changed: I added the "Required" text next to required fields as necessary. To test, apply the patch and go to Administration -> Budgets. - Test the budget creation process for adding, editing, and duplicating budgets. In all cases: - The start date and end date should be required - You should be warned if you enter an end date which falls before the start date. - The description should be required - The budget amount should be required to be a number To test the budget planning page: Note that much of the JS removed from this template was unused. It looked for inputs by the name 'est_total' which don't exist. - When viewing the table of funds for a budget, select a choice from the 'planning' toolbar menu. - Verify that after entering a numeric value in any cell, the 'remaning' value at the end of the row is correctly updated. - Verify that after entering non-numeric data an error is displayed. - Verify that clicking the 'auto-fill' button at the end of the row works to fill any empty or zero-value fields with the remaning funds available. To test the vendor contracts page: - Go to Acquisitions -> Vendor -> Contracts - Add or edit a contract - Confirm that name, start date, and end date are required. - Confirm that you are warned if you enter an end date which falls before the start date. Signed-off-by: Michal Denar <black23@gmail.com>
Created attachment 80169 [details] [review] Bug 16754: Use validation plugin in budgets, planning, and contracts This patch removes the custom javascript form validation from three templates: Budgets, budget planning, and contracts. Validation via the validation plugin is done instead. This patch also removes use of event attributes like onclick and onchange. Also changed: I added the "Required" text next to required fields as necessary. To test, apply the patch and go to Administration -> Budgets. - Test the budget creation process for adding, editing, and duplicating budgets. In all cases: - The start date and end date should be required - You should be warned if you enter an end date which falls before the start date. - The description should be required - The budget amount should be required to be a number To test the budget planning page: Note that much of the JS removed from this template was unused. It looked for inputs by the name 'est_total' which don't exist. - When viewing the table of funds for a budget, select a choice from the 'planning' toolbar menu. - Verify that after entering a numeric value in any cell, the 'remaning' value at the end of the row is correctly updated. - Verify that after entering non-numeric data an error is displayed. - Verify that clicking the 'auto-fill' button at the end of the row works to fill any empty or zero-value fields with the remaning funds available. To test the vendor contracts page: - Go to Acquisitions -> Vendor -> Contracts - Add or edit a contract - Confirm that name, start date, and end date are required. - Confirm that you are warned if you enter an end date which falls before the start date. Signed-off-by: Michal Denar <black23@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Awesome work all! Pushed to master for 18.11
Nice bit of code tidying. Pushed to 18.05.x for 18.05.06
I prefer not to push to oldstable 17.11.x to avoid behavior and display changes
It looks like this change actually broke aqplan.pl because it accidentally removed the Javascript that was used to add the "op" parameter, and the test plan didn't include testing saving budget plans. Oops!