Multiple wishlist widget mixin

Viewed 553

I'm trying to make a mixin of widget from multiple-wishlist.js. But after create it looks like i break some dependencies because button edit wish list is not responding, there is no errors in console etc.

requirejs-config.js

var config = {
  config: {
    mixins: {
      "Magento_MultipleWishlist/js/multiple-wishlist": {
        "Magento_MultipleWishlist/js/prompt-edit-wishlist-mixin": true
      },
    }
  }
};

prompt-edit-wishlist-mixin.js

define([
    'jquery',
], function ($) {
    'use strict';
    return function (widget) {
        $.widget('mage.promptEditWithList', widget, {
            getNoticeTemplate: function () {
                var template = $('<div class="custom classes">' +
                    '<input id="wishlist-public" type="checkbox" name="' + this.options.isPublicFieldAttributeName + '">' +
                    '<label for="wishlist-public" class="label">' +
                    '<span>' + this.options.isPublicFieldLabel + '</span>' +
                    '</label>' +
                    '<input name="form_key" type="hidden" value="' + this.options.hiddenFieldValue + '">' +
                    '</div>');

                if (this.options.isPublicFieldChecked) {
                    template.find('input[type = checkbox]').attr('checked', 'checked');
                }

                return template;
            }
        });

        return $.mage.promptEditWithList;
    };
});

vendor/magento/module-multiple-wishlist/view/frontend/web/js/multiple-wishlist.js (only 1 widget, file is to big)

$.widget('mage.promptEditWithList', $.mage.prompt, {
        options: {
            label: '',
            isPublicFieldLabel: '',
            isPublicFieldAttributeName: '',
            isPublicFieldChecked: false,
            hiddenFieldValue: ''
        },

        /**
         * @private
         */
        _create: function () {
            this._super();
            this.modal.find(this.options.modalContent).find('fieldset').append(this.getNoticeTemplate());
        },

        /**
         * @return {*|jQuery|HTMLElement}
         */
        getNoticeTemplate: function () {
            var template = $('<div class="field choice">' +
                '<input id="wishlist-public" type="checkbox" name="' + this.options.isPublicFieldAttributeName + '">' +
                '<label for="wishlist-public" class="label">' +
                '<span>' + this.options.isPublicFieldLabel + '</span>' +
                '</label>' +
                '<input name="form_key" type="hidden" value="' + this.options.hiddenFieldValue + '">' +
                '</div>');

            if (this.options.isPublicFieldChecked) {
                template.find('input[type = checkbox]').attr('checked', 'checked');
            }

            return template;
        }
    });

Is there different way to override/extend that widget without breaking popup?

0 Answers
Related