Skip to content

Commit

Permalink
Fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
orangejenny committed Oct 21, 2024
1 parent fca2d62 commit 3ef9756
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ hqDefine("hqwebapp/js/bootstrap3/crud_paginated_list", [
});

self.isPaginatedListEmpty = ko.computed(function () {
return self.paginatedList().length == 0;
return self.paginatedList().length === 0;
});

self.isNewListVisible = ko.computed(function () {
Expand Down Expand Up @@ -88,12 +88,14 @@ hqDefine("hqwebapp/js/bootstrap3/crud_paginated_list", [
});

self.allPages = ko.computed(function () {
var last_ind = self.maxPage() + 1;
if (self.maxPage() <= 5 || self.currentPage() <= 3)
return _.range(1, Math.min(last_ind, 6));
if (self.currentPage() >= self.maxPage() - 2)
return _.range(self.maxPage() - 4, last_ind);
return _.range(self.currentPage() - 2, Math.min(last_ind, self.currentPage() + 3));
var lastIndex = self.maxPage() + 1;
if (self.maxPage() <= 5 || self.currentPage() <= 3) {
return _.range(1, Math.min(lastIndex, 6));
}
if (self.currentPage() >= self.maxPage() - 2) {
return _.range(self.maxPage() - 4, lastIndex);
}
return _.range(self.currentPage() - 2, Math.min(lastIndex, self.currentPage() + 3));
});

self.utils = {
Expand Down Expand Up @@ -196,7 +198,7 @@ hqDefine("hqwebapp/js/bootstrap3/crud_paginated_list", [
self.changePage(1);
};

self.deleteItem = function (paginatedItem, event) {
self.deleteItem = function (paginatedItem) {
var pList = self.paginatedList();
paginatedItem.dismissModals();
self.paginatedList(_(pList).without(paginatedItem));
Expand Down Expand Up @@ -245,9 +247,10 @@ hqDefine("hqwebapp/js/bootstrap3/crud_paginated_list", [
return null;
};

self.initRow = function (rowElems, paginatedItem) {
self.initRow = function () {
// Intended to be overridden with additional initialization for
// each row in the paginated list.
// Arguments: rowElems, paginatedItem
};

return self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ hqDefine("hqwebapp/js/bootstrap5/crud_paginated_list", [
});

self.isPaginatedListEmpty = ko.computed(function () {
return self.paginatedList().length == 0;
return self.paginatedList().length === 0;
});

self.isNewListVisible = ko.computed(function () {
Expand Down Expand Up @@ -90,12 +90,14 @@ hqDefine("hqwebapp/js/bootstrap5/crud_paginated_list", [
});

self.allPages = ko.computed(function () {
var last_ind = self.maxPage() + 1;
if (self.maxPage() <= 5 || self.currentPage() <= 3)
return _.range(1, Math.min(last_ind, 6));
if (self.currentPage() >= self.maxPage() - 2)
return _.range(self.maxPage() - 4, last_ind);
return _.range(self.currentPage() - 2, Math.min(last_ind, self.currentPage() + 3));
var lastIndex = self.maxPage() + 1;
if (self.maxPage() <= 5 || self.currentPage() <= 3) {
return _.range(1, Math.min(lastIndex, 6));
}
if (self.currentPage() >= self.maxPage() - 2) {
return _.range(self.maxPage() - 4, lastIndex);
}
return _.range(self.currentPage() - 2, Math.min(lastIndex, self.currentPage() + 3));
});

self.utils = {
Expand Down Expand Up @@ -249,9 +251,10 @@ hqDefine("hqwebapp/js/bootstrap5/crud_paginated_list", [
return null;
};

self.initRow = function (rowElems, paginatedItem) {
self.initRow = function () {
// Intended to be overridden with additional initialization for
// each row in the paginated list.
// Arguments: rowElems, paginatedItem
};

return self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
) {
var CRUDPaginatedListModel = function (
total,
@@ -196,8 +198,9 @@
@@ -198,8 +200,9 @@
self.changePage(1);
};

- self.deleteItem = function (paginatedItem, event) {
- self.deleteItem = function (paginatedItem) {
+ self.deleteItem = function (paginatedItem, event, button) {
var pList = self.paginatedList();
+ $(button).enableButton();
paginatedItem.dismissModals();
self.paginatedList(_(pList).without(paginatedItem));
self.deletedList.push(paginatedItem);
@@ -221,7 +224,7 @@
@@ -223,7 +226,7 @@
});
};

Expand All @@ -37,15 +37,15 @@
$.ajax({
url: '',
type: 'post',
@@ -237,6 +240,7 @@
@@ -239,6 +242,7 @@
statusCode: self.handleStatusCode,
success: function (data) {
self.utils.reloadList(data);
+ $(button).enableButton();
},
});
};
@@ -267,15 +271,9 @@
@@ -270,15 +274,9 @@
};

self.dismissModals = function () {
Expand All @@ -64,7 +64,7 @@
}
};

@@ -318,15 +316,15 @@
@@ -321,15 +319,15 @@
var $deleteButton = $(elems).find('.delete-item-confirm');
if ($deleteButton) {
$deleteButton.click(function () {
Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/users/static/users/js/edit_commcare_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ hqDefine('users/js/edit_commcare_user', [
return false;
});

$('#reset-password-form').submit(function (e) {
$('#reset-password-form').submit(function () {
$.ajax({
url: $(this).attr('action'),
method: $(this).attr('method'),
Expand Down

0 comments on commit 3ef9756

Please sign in to comment.