kopia lustrzana https://github.com/wagtail/wagtail
Use standard modal step names (choose / chosen) for image chooser
rodzic
386a7d7c95
commit
e831d8e6cc
|
@ -42,7 +42,7 @@ function ajaxifyImageUploadForm(modal) {
|
|||
}
|
||||
|
||||
window.IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
||||
chooser: (modal) => {
|
||||
choose: (modal) => {
|
||||
let searchController;
|
||||
|
||||
function ajaxifyLinks(context) {
|
||||
|
@ -83,7 +83,7 @@ window.IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
|||
// Reinitialize tabs to hook up tab event listeners in the modal
|
||||
initTabs();
|
||||
},
|
||||
image_chosen: (modal, jsonData) => {
|
||||
chosen: (modal, jsonData) => {
|
||||
modal.respond('chosen', jsonData.result);
|
||||
modal.close();
|
||||
},
|
||||
|
|
|
@ -1096,7 +1096,7 @@ class TestImageChooserView(TestCase, WagtailTestUtils):
|
|||
response = self.get()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertEqual(response_json["step"], "chooser")
|
||||
self.assertEqual(response_json["step"], "choose")
|
||||
self.assertTemplateUsed(response, "wagtailimages/chooser/chooser.html")
|
||||
|
||||
# draftail should NOT be a standard JS include on this page
|
||||
|
@ -1189,7 +1189,7 @@ class TestImageChooserView(TestCase, WagtailTestUtils):
|
|||
response = self.get()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertEqual(response_json["step"], "chooser")
|
||||
self.assertEqual(response_json["step"], "choose")
|
||||
self.assertTemplateUsed(response, "wagtailimages/chooser/chooser.html")
|
||||
|
||||
# custom form fields should be present
|
||||
|
@ -1313,7 +1313,7 @@ class TestImageChooserChosenView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertEqual(response_json["step"], "image_chosen")
|
||||
self.assertEqual(response_json["step"], "chosen")
|
||||
|
||||
|
||||
class TestImageChooserSelectFormatView(TestCase, WagtailTestUtils):
|
||||
|
@ -1373,7 +1373,7 @@ class TestImageChooserSelectFormatView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response["Content-Type"], "application/json")
|
||||
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertEqual(response_json["step"], "image_chosen")
|
||||
self.assertEqual(response_json["step"], "chosen")
|
||||
result = response_json["result"]
|
||||
|
||||
self.assertEqual(result["id"], self.image.id)
|
||||
|
|
|
@ -30,8 +30,6 @@ permission_checker = PermissionPolicyChecker(permission_policy)
|
|||
|
||||
|
||||
class ImageChosenResponseMixin(ChosenResponseMixin):
|
||||
chosen_response_name = "image_chosen"
|
||||
|
||||
def get_chosen_response_data(self, image):
|
||||
"""
|
||||
Given an image, return the json data to pass back to the image chooser panel
|
||||
|
@ -175,7 +173,6 @@ class ImageChooseViewMixin(ChooseViewMixin):
|
|||
|
||||
def get_response_json_data(self):
|
||||
json_data = super().get_response_json_data()
|
||||
json_data["step"] = "chooser"
|
||||
json_data["tag_autocomplete_url"] = reverse("wagtailadmin_tag_autocomplete")
|
||||
return json_data
|
||||
|
||||
|
@ -340,7 +337,7 @@ def chooser_select_format(request, image_id):
|
|||
None,
|
||||
None,
|
||||
None,
|
||||
json_data={"step": "image_chosen", "result": image_data},
|
||||
json_data={"step": "chosen", "result": image_data},
|
||||
)
|
||||
else:
|
||||
initial = {"alt_text": image.default_alt_text}
|
||||
|
|
Ładowanie…
Reference in New Issue