Skip to content

Commit

Permalink
More spa file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnewcomer committed May 9, 2023
1 parent d09c33b commit a48f674
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 39 deletions.
2 changes: 1 addition & 1 deletion temba/contacts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ def get_context_data(self, *args, **kwargs):
def build_content_menu(self, menu):
if self.has_org_perm("contacts.contact_delete"):
menu.add_js(
"contacts_delete_all", _("Delete All"), "handleDeleteAllContacts(event)", "contacts-btn-delete-all"
"contacts_delete_all", _("Delete All"), "handleDeleteAllConfirmation()", "contacts-btn-delete-all"
)

class Filter(OrgObjPermsMixin, ContentMenuMixin, ContactListView):
Expand Down
14 changes: 1 addition & 13 deletions templates/contacts/contact_archived.haml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
-extends "contacts/contact_list_spa.haml"
-extends "contacts/contact_list.haml"
-load i18n

-block extra-script
{{block.super}}

:javascript
var menu = document.querySelector("temba-content-menu");
menu.addEventListener("temba-selection", function(event) {
var item = event.detail;
if (item.id == "contacts_delete_all") {
handleDeleteAllConfirmation_spa();
}
});

-block title-text
.title.leading-tight
-trans "Archived Contacts"
Expand Down
2 changes: 1 addition & 1 deletion templates/contacts/contact_blocked.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-extends "contacts/contact_list_spa.haml"
-extends "contacts/contact_list.haml"
-load i18n

-block subtitle
Expand Down
2 changes: 1 addition & 1 deletion templates/contacts/contact_filter.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-extends "contacts/contact_list_spa.html"
-extends "contacts/contact_list.html"
-load smartmin i18n

-block title
Expand Down
26 changes: 4 additions & 22 deletions templates/contacts/contact_list.haml
Original file line number Diff line number Diff line change
Expand Up @@ -336,36 +336,18 @@
}

{% if org_perms.contacts.contact_delete %}
function handleDeleteAllContacts() {
var deleteAllConfirmation = document.querySelector('#delete-all-confirmation');
deleteAllConfirmation.classList.remove("hide");
deleteAllConfirmation.open = true;

deleteAllConfirmation.addEventListener("temba-button-clicked", function(event){
if (event.detail.button.attributes.destructive){
jQuery.ajaxSettings.traditional = true;
fetchPJAXContent(document.location.href, '#pjax', {
postData: { action: "delete", all: 'true', pjax: 'true' },
forceReload: true
});

}
deleteAllConfirmation.classList.add("hide");
deleteAllConfirmation.open = false;
});
}

function handleDeleteAllConfirmation_spa() {
function handleDeleteAllConfirmation() {
var deleteAllConfirmation = document.querySelector('#delete-all-confirmation');

deleteAllConfirmation.classList.remove("hide");
deleteAllConfirmation.open = true;

deleteAllConfirmation.removeEventListener("temba-button-clicked", handleDeleteAllContacts_spa);
deleteAllConfirmation.addEventListener("temba-button-clicked", handleDeleteAllContacts_spa);
deleteAllConfirmation.removeEventListener("temba-button-clicked", handleDeleteAllContacts);
deleteAllConfirmation.addEventListener("temba-button-clicked", handleDeleteAllContacts);
}

function handleDeleteAllContacts_spa(event){
function handleDeleteAllContacts(event){
var deleteAllConfirmation = document.querySelector('#delete-all-confirmation');

if (event.detail.button.attributes.destructive){
Expand Down
2 changes: 1 addition & 1 deletion templates/contacts/contact_stopped.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-extends "contacts/contact_list_spa.haml"
-extends "contacts/contact_list.haml"
-load i18n

-block subtitle
Expand Down

0 comments on commit a48f674

Please sign in to comment.