Override js file from admin

Hello guys,
How I can override the file /AdminBundle/Resources/public/js/pimcore/object/helpers/import/configDialog.js ?
Thx in advance

1 Like

Check http://prototypejs.org/learn/class-inheritance.html

You should be able to use

var newDialog = Class.create(pimcore.object.helpers.import.configDialog, {
 // your redefined methods
});

Disclaimer: Never tried that and beware you may break things.

Had the same requirement today, it’s quite easy.
In my case, I wanted to override:

  • vendor/pimcore/pimcore/bundles/AdminBundle/Resources/public/js/pimcore/element/selector/asset.js

So, I added a copy of that file to:

  • src/AppBundle/Resources/public/js/pimcore/element/selector/asset.js

Next, I added the getJsPaths() method to my src/AppBundle/AppBundle.php

    public function getJsPaths() {
        return [
            '/bundles/app/js/pimcore/element/selector/asset.js'
        ];
    }

Last, I cleared the cache et voila, it works.

Adding to this, I found out, that there are apparently two different types of js overrides, one for editmode and on for everything else:

    public function getJsPaths()
    {
        return [
            '/bundles/app/js/pimcore/helpers.js',
            '/bundles/app/js/pimcore/element/selector/selector.js',
            '/bundles/app/js/pimcore/element/selector/asset.js',
        ];
    }

    public function getEditmodeJsPaths()
    {
        return [
            '/bundles/app/js/pimcore/document/tags/image.js',
        ];
    }

edit: typo