Dependent service selectboxes (manual)

Moderator: crythias

Locked
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Dependent service selectboxes (manual)

Post by artjoms15 »

Hello!
I have noticed, that parent-child dependency in otrs services and queues is made based only on parent prefix in the name of child service. I understand that PERL is perfect for working with text, but...
Wouldn't it be more convenient to set one more column with the ID of the parent to the child and don't look for full text matches, while building tree views...
Yeah that was offtopic,

THE QUESTION:
I am trying to realise dependent selectboxes functionality into OTRS (Feature add-on lookalike) and I have no idea how to make selectboxes based on these prefixes...
So I want to share some ideas how to implement it and maybe some more experienced programmer could point to week spots of an algorithm

IDEA A - firstly fill selectboxes with everything and then limit what is shown
1) Look for service without "::"
2) Add it as an option to selectboxLVL1
3) Recursively look for service which parent is the service from (1) and which have only 1 "::" into the string
4) add it to selectboxLVL2
5) recursively look for children services, until none are found
6) go to point (1) until all services without "::" are drawn into the selectbox
7) Show only NOTEMPTY selectboxes
8) Change shown values based on the selected value in previous selectbox

Of course I would like to implement this on server side and send to client, but maybe will try to implement it via JavaScript on client side.

IDEA B - fill selectboxes only with required data
1) fill selectboxLVL1 with services without "::"
2) wait till user selects the value in LVL1
3) Search for services with the prefix (before "::") equal to selectboxLVL1 value
4) Remove the prefix add those services to selectbox LVL2
5) Recursively continue doing it untill no descendands are found

Don' t know, these are just my thoughts that might be useful for me or maybe someone else, and if I get any comments on this this will be even better
Bye!
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Dependent service selectboxes (manual)

Post by crythias »

or just ACL what you want to do.
http://forums.otrs.org/viewtopic.php?f=60&t=11235
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: Dependent service selectboxes (manual)

Post by artjoms15 »

Well, ACLs will just tie our hands with static Service list. If i add some additional services, than I will have to rebuild the ACL lists manually. And my realisation will take everything dynamically. At least I already started working and I think it is going to work really smoothly 8)

BR,
A.
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Dependent service selectboxes (manual)

Post by crythias »

It's perl, though, so you can build acls via regular expressions.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: Dependent service selectboxes (manual)

Post by artjoms15 »

Yep, it is PERL :)
So here is a plan for the best solution based on ACLs and javascript+CSS formatting. I won' t remake my code, but here are some hints for coders who have plenty of free time to play with OTRS

a) Reserve some freetexts for dependent services (In my case 3)
b) Assign services to those freetexts (As I know it should be achieved via General Catalog, or source can be hardcoded (I still wasn' t able to connect freetext with a General Catalog) )
c) Make all selectboxes (except the first one) invisible
d) Set ACL for the first selectbox - *No '::' occurance possible
e) Set ACL for the second selectbox - * One '::' occurance possible *String part before '::' equal to the first selectbox value
f) Javascript formatting - Trim the parent part and the '::'
g) JS+CSS - if selectbox isn' t empty then make it visible
h) the same for the third selectbox
j) In descending order check which selectbox isn' t empty and save it's value in some variable (e.g. ServiceIDx) and then feed this variable instead of default selectbox(ServiceID) value- that will allow you to make only changes in middlelayer, without changing further logics
k) ???
l) PROFIT

By The way Crythias, Have I told You, that your ideas always are the best? :D Thank You ;)
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
Locked