Custom JS in new Customer portal module not displaying

Moderator: crythias

Locked
troykay
Znuny newbie
Posts: 5
Joined: 03 Jul 2016, 21:18
Znuny Version: -5.0.11-01
Real Name: Troy

Custom JS in new Customer portal module not displaying

Post by troykay »

Hi all,

I'm sure this is a frequently asked question, but none of my searching is proving fruitful.

I'm taking my first stab at writing an OTRS module. It's basically a file repository to allow someone on the Customer portal to download a file.

I'd like to use a jquery-ui based tree like:

jstree: https://www.jstree.com/ or fancytree: https://github.com/mar10/fancytree

I've added the appropriate Loader entries into the .xml file:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<otrs_config version="1.0" init="Application">
        <ConfigItem Name="CustomerFrontend::Module###CustomerFileRepository" Required="0" Valid="1">
        <Description Translatable="1">FrontendModuleRegistration for CustomerFileRepository module.</Description>
        <Group>Framework</Group>
        <SubGroup>Frontend::Customer::ModuleRegistration</SubGroup>
        <Setting>
            <FrontendModuleReg>
                <NavBarName>CustomerFileRepository</NavBarName>
                <Description>Customer File Repository</Description>
                <Title>Customer File Repository</Title>
                <NavBar>
                    <Description>Customer File Repository Description</Description>
                    <Name>Software Downloads</Name>
                    <Block></Block>
                    <Type>Menu</Type>
                    <Link>Action=CustomerFileRepository;Subaction=List;Repo=SW</Link>
                    <NavBar>CustomerFileRepository</NavBar>
                    <Prio>200</Prio>
                </NavBar>
                <Loader>
                        <JavaScript>/otrs-web/FileRepo/jstree/dist/jstree.min.js</JavaScript>
                        <JavaScript>/otrs-web/FileRepo/custom.js</JavaScript>
                        <CSS>/otrs-web/FileRepo/jstree/dist/themes/default/style.min.css</CSS>
                </Loader>
            </FrontendModuleReg>
        </Setting>
    </ConfigItem>
</otrs_config>
The files get loaded into CommonJS; there are no errors on the JS console, and yet it doesn't display. Help me, Obi-Otters, you're my only hope.

(I'm hoping this is a really easy thing to do that I"ve just overlooked, but if any of you have a hint, please let me know!)

With thanks,
Troy
troykay
Znuny newbie
Posts: 5
Joined: 03 Jul 2016, 21:18
Znuny Version: -5.0.11-01
Real Name: Troy

Re: Custom JS in new Customer portal module not displaying

Post by troykay »

I should add that I've tried this with and without extra <JavaScript></Javascript> entries for jquery and jquery-ui.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Custom JS in new Customer portal module not displaying

Post by reneeb »

Remove the "/otrs-web/" in each path
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
troykay
Znuny newbie
Posts: 5
Joined: 03 Jul 2016, 21:18
Znuny Version: -5.0.11-01
Real Name: Troy

Re: Custom JS in new Customer portal module not displaying

Post by troykay »

Thanks for the suggestion, Reneeb!

I removed the '/otrs-web/' portion from each path:

Code: Select all

		<Loader>
                       <JavaScript>FileRepo/jstree/dist/jstree.min.js</JavaScript>
                        <JavaScript>FileRepo/custom-jstree.js</JavaScript>
                        <CSS>FileRepo/jstree/dist/themes/default/style.min.css</CSS>
		<Loader>
Sadly, I'm still having the same problem. If I inspect the js-cache file that gets included from Chrome's dev tool interface, the jstree data is there. The CSS does get pulled into the css-cache. (Funnily enough, if I switch to fancytree, its JS never gets pulled into the cache.)

I *am* working in a dev tree, and I run a module-linker.pl install after I add files to my dev tree; and I *do* run a otrs.Console.pl Maint::Config::Rebuild after every change

At this point I'm looking through code to see if there's a "It's Troy, and he's an idiot" config setting. :)
Last edited by troykay on 04 Jul 2016, 18:32, edited 1 time in total.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Custom JS in new Customer portal module not displaying

Post by reneeb »

Are file permissions set correctly? Is your css stored in a skin-subfolder?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
troykay
Znuny newbie
Posts: 5
Joined: 03 Jul 2016, 21:18
Znuny Version: -5.0.11-01
Real Name: Troy

Re: Custom JS in new Customer portal module not displaying

Post by troykay »

At the moment, I'm using the stock Customer skin. The files I'm using (and their permissions):

Code: Select all

-rw-r--r--   1 otrs     apache       1435 Jul  4 11:33 ./Kernel/Config/Files/CustomerFileRepo.xml
-rw-r--r--   1 otrs     apache       2604 Jul  4 11:27 ./Kernel/Modules/CustomerFileRepo.pm
-rw-r--r--   1 otrs     apache       7152 Jul  4 11:25 ./Kernel/System/tk/FileRepo.pm
-rw-r--r--   1 otrs     apache        638 Jul  4 11:06 ./Kernel/Output/HTML/Templates/Standard/CustomerFileRepo.tt
These are the JS files I'm feeding to Loader:

Code: Select all

-rw-r--r--   1 otrs     apache     132418 May  4 17:21 ./var/httpd/htdocs/FileRepo/jstree/dist/jstree.min.js
-rw-r--r--   1 otrs     apache        508 Jul  4 11:43 ./var/httpd/htdocs/FileRepo/custom-jstree.js
And this is the CSS file that I'm feeding to Loader:

Code: Select all

-rw-r--r--   1 otrs     apache      26183 May  4 17:21 ./var/httpd/htdocs/FileRepo/jstree/dist/themes/default/style.min.css
I wanted to test whether the jstree demo would work in /otrs-web/, and it does: http://fizzle.yort.ca:557/otrs-web/File ... emo/basic/. It also works when I use the module outside of OTRS. (So, there's something I'm doing wrong in the integration.)

BTW, thanks for the assistance!
Locked