fabiocaccamo/django-admin-interface

View on GitHub
admin_interface/static/streamfield/js/admin_popup_response.js

Summary

Maintainability
B
6 hrs
Test Coverage
// IMPORTANT: used by django-streamfield >= 2.0.0

(function() {

    'use strict';

    var windowRef = window;
    var openerRef = windowRef.parent;

    var initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse);
    switch (initData.action) {
        case 'change':
            openerRef.streamapps[initData.app_id].updateBlock(initData.block_id, initData.instance_id);
            openerRef.dismissRelatedObjectModal();
            break;
        case 'delete':
            break;
        default:
            openerRef.streamapps[initData.app_id].updateBlock(initData.block_id, initData.instance_id);
            openerRef.dismissRelatedObjectModal();
            break;
    }

})();