Bugzilla – Attachment 112359 Details for
Bug 25353
Correct eslint errors in additems.js
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25353: Correct eslint errors in additems.js
Bug-25353-Correct-eslint-errors-in-additemsjs.patch (text/plain), 8.87 KB, created by
Nick Clemens (kidclamp)
on 2020-10-24 02:13:48 UTC
(
hide
)
Description:
Bug 25353: Correct eslint errors in additems.js
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-10-24 02:13:48 UTC
Size:
8.87 KB
patch
obsolete
>From 34e2e54ab967b8d095b13310ed11805f8b37a90e Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 19 Oct 2020 18:32:18 +0000 >Subject: [PATCH] Bug 25353: Correct eslint errors in additems.js > >This patch makes minor changes to additem.js to correct errors >highlighted by eslint: > >- Consistent indentation >- Notation of global and exported variables and functions >- Consistent use of the "var" declaration for all new variables >- Remove variables from function calls which aren't used > >To test, apply the patch and use your preferred eslint-enabled tool to >check for errors. There should be none. > >If you don't have eslint integrated in your development environment you >could use the online ESLint demo at https://eslint.org/demo. > >The demo isn't configured to assume a browser environment with jQuery >present, so you'll have to modify the top line after pasting the >contents of additem.js: > >/* global $ alert window __ */ > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > koha-tmpl/intranet-tmpl/prog/js/additem.js | 52 +++++++++++++++--------------- > 1 file changed, 26 insertions(+), 26 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/additem.js b/koha-tmpl/intranet-tmpl/prog/js/additem.js >index d6f95772a6..960ffc36dd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/additem.js >@@ -1,4 +1,5 @@ > /* global __ */ >+/* exported addItem checkCount showItem deleteItemBlock clearItemBlock check_additem */ > function addItem( node, unique_item_fields ) { > var index = $(node).closest("div").attr('id'); > var current_qty = parseInt($("#quantity").val()); >@@ -36,15 +37,15 @@ function addMulti( count, node, unique_item_fields){ > $("#procModal").modal('show'); > $("#" + index).hide(); > for(var i=0;i<count;i++){ >- cloneItemBlock(index, unique_item_fields, function(cloneIndex){ >+ cloneItemBlock(index, unique_item_fields, function(cloneIndex){ > addItemInList(cloneIndex,unique_item_fields, function(){ >- if( ($("#items_list tbody tr").length-countItemsBefore)==(count)){ >- $("#multiValue").val(''); >- $('#'+index).appendTo('#outeritemblock'); >- $('#'+index).show(); >- $('#'+index + ' #add_multiple_copies' ).css("visibility","hidden"); >- $("#procModal").modal('hide'); >- } >+ if( ($("#items_list tbody tr").length-countItemsBefore)==(count)){ >+ $("#multiValue").val(''); >+ $('#'+index).appendTo('#outeritemblock'); >+ $('#'+index).show(); >+ $('#'+index + ' #add_multiple_copies' ).css("visibility","hidden"); >+ $("#procModal").modal('hide'); >+ } > }); > $("#" + cloneIndex).find("input[name='buttonPlus']").val( ( __("Update item") ) ); > $("#" + cloneIndex).find("input[name='buttonPlusMulti']").remove(); >@@ -52,11 +53,10 @@ function addMulti( count, node, unique_item_fields){ > $("#" + cloneIndex).hide(); > current_qty++; > $('#quantity').val( current_qty ); >- }); >+ }); > } > } > >- > function checkCount(node, unique_item_fields){ > var count = parseInt( $("#multiValue").val(), 10 ); > if ( isNaN( count ) || count <=0) { >@@ -93,7 +93,7 @@ function constructTrNode(index, unique_item_fields) { > + "onclick='deleteItemBlock(this, \"" + index + "\", \"" + unique_item_fields + "\");' class='btn btn-default btn-xs'><i class='fa fa-trash'></i> " > + ( __("Delete") ) + "</a>"; > result += "<td class='actions'>" + edit_link + " " + del_link + "</td>"; >- for(i in fields) { >+ for(var i in fields) { > var field = fields[i]; > var field_elt = $("#" + index) > .find("[name='kohafield'][value='items."+field+"']") >@@ -154,8 +154,8 @@ function cloneItemBlock(index, unique_item_fields, callback) { > } > var dont_copy_fields = new Array(); > if(unique_item_fields) { >- var dont_copy_fields = unique_item_fields.split('|'); >- for(i in dont_copy_fields) { >+ dont_copy_fields = unique_item_fields.split('|'); >+ for(var i in dont_copy_fields) { > dont_copy_fields[i] = "items." + dont_copy_fields[i]; > } > } >@@ -166,7 +166,7 @@ function cloneItemBlock(index, unique_item_fields, callback) { > data: { > frameworkcode: 'ACQ' > }, >- success: function(data, textStatus, jqXHR) { >+ success: function(data) { > /* Create the item block */ > var random = Math.floor(Math.random()*100000); // get a random itemid. > var clone = $("<div/>", { id: 'itemblock'+random }); >@@ -178,15 +178,15 @@ function cloneItemBlock(index, unique_item_fields, callback) { > }); > /* Add buttons + and Clear */ > var buttonPlus = "<fieldset class=\"action\">"; >- buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + ( __("Add item") )+ '" />'; >- buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + __("Clear") + '" />'; >- buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" onclick="javascript:this.nextSibling.style.display=\'inline\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + __("Add multiple items") + '" />'; >- buttonPlus += '<span id="add_multiple_copies" style="display:none">' >- + '<input type="number" class="addItemControl" id="multiValue" name="multiValue" placeholder="' + __("Number of items to add") + '" />' >- + '<input type="button" class="addItemControl" name=buttonAddMulti" style="cursor:pointer; margin:0 1em;" onclick="checkCount( this ,\'' + unique_item_fields + '\')" value="' + __("Add") + '" />' >- + '<div class="dialog message">' + __("NOTE: Fields listed in the 'UniqueItemsFields' system preference will not be copied") + '</div>' >- + '</span>'; >- buttonPlus += "</fieldset>"; >+ buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + ( __("Add item") )+ '" />'; >+ buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + __("Clear") + '" />'; >+ buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" onclick="javascript:this.nextSibling.style.display=\'inline\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + __("Add multiple items") + '" />'; >+ buttonPlus += '<span id="add_multiple_copies" style="display:none">' >+ + '<input type="number" class="addItemControl" id="multiValue" name="multiValue" placeholder="' + __("Number of items to add") + '" />' >+ + '<input type="button" class="addItemControl" name=buttonAddMulti" style="cursor:pointer; margin:0 1em;" onclick="checkCount( this ,\'' + unique_item_fields + '\')" value="' + __("Add") + '" />' >+ + '<div class="dialog message">' + __("NOTE: Fields listed in the 'UniqueItemsFields' system preference will not be copied") + '</div>' >+ + '</span>'; >+ buttonPlus += "</fieldset>"; > $(clone).append(buttonPlus); > /* Copy values from the original block (input) */ > $(original).find("input[name='field_value']").each(function(){ >@@ -227,7 +227,7 @@ function BindPluginEvents(data) { > for(var i=0; i<events.length; i++) { > window[events[i]](); > if( i<events.length-1 && events[i]==events[i+1] ) { i++; } >- // normally we find the function name twice >+ // normally we find the function name twice > } > } > >@@ -251,7 +251,7 @@ function check_additem(unique_item_fields) { > $(".order_error").empty(); // Clear error div > > // Check if a value is duplicated in form >- for ( field in array_fields ) { >+ for ( var field in array_fields ) { > var fieldname = array_fields[field]; > if (fieldname == '') { > continue; >@@ -290,7 +290,7 @@ function check_additem(unique_item_fields) { > dataType: 'json', > data: data, > success: function(data) { >- for (field in data) { >+ for (var field in data) { > success = false; > for (var i=0; i < data[field].length; i++) { > var value = data[field][i]; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25353
:
112007
|
112260
| 112359