Reorder values in selectboxes

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

Reorder values in selectboxes

Post by artjoms15 »

Hello
I understand that this question is more connected with web-design, but where is ordering set up for otrs selectboxes in Customer view? I mean Ticket Type and Services
It would be really convenient not to sort options in alphabetical order, but e.g. in order the service (or Type) is mostly used, so customers shouldn' t pull the mouse all over the table to reach neccessary value :)
Thanks in advance :)
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
yuri0001
Znuny superhero
Posts: 630
Joined: 17 Mar 2011, 14:40
Znuny Version: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Reorder values in selectboxes

Post by yuri0001 »

Try to add number to before type or service name such as - 01_Incident, 02_rfc, 03_problem ets.
It's saw not very nice but work properly.
Best regards Yuri Kolesnikov
OTRS 5.0.14, ITSM 5.0.14
SUSE 13.2, MariaDB 10.0.22(productive)
OTRS 5.0.14, ITSM 5.0.14(test)
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: Reorder values in selectboxes

Post by artjoms15 »

Thank You for advice, but I think that users won' t be too happy to see these numbers, so today will try to go into the OTRS code and find where is the sorting made, maybe will be able to implement some kind of manual ordering list... e.g. will make a field in a database for each service with the service priority number and will arrange services based on it. I already have vision what I want to achieve, but still lack some technical knowledge to implement it :(
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
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: Reorder values in selectboxes

Post by artjoms15 »

Found a workaround implemented in OTRS API. For example, while building service dropbox in CustomerTicketMessage.pm I changed Sort order from 'AlphanumericValue' to 'AlphanumericKey' and that allowed me to show services arranged based on their ID. In reality it might be enough for some unchangeable service list... but still right now I think of hacking the code and implementing one more Sort option based on new column in Service table

BR,
A.
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
yuri0001
Znuny superhero
Posts: 630
Joined: 17 Mar 2011, 14:40
Znuny Version: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Reorder values in selectboxes

Post by yuri0001 »

It's very interesting. While implement it, please post it here :?
Sorry my bad English!
Best regards Yuri Kolesnikov
OTRS 5.0.14, ITSM 5.0.14
SUSE 13.2, MariaDB 10.0.22(productive)
OTRS 5.0.14, ITSM 5.0.14(test)
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: Reorder values in selectboxes

Post by artjoms15 »

Hello, Yuri!
Well, only some time ago had implemented this functionality in more or less useful way.
So steps for reproducing:

1) add new xml file to Kernel/Config/Files/...

Code: Select all

<ConfigItem Name="ServicePriority" Required="0" Valid="1">
        <Description Translatable="1">Allows to set sorting (by priority) for Services in Customer Interface (Artjoms@UCB).</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Customer::Ticket::ViewNew</SubGroup>
        <Setting>        
            <Hash>

            </Hash>
        </Setting>
    </ConfigItem>
This is a hash, which will connect desirable service with the priority (position) into the dropbox

2) In Customer Interface (CustomerTicketMessage.pm) change the generation of the Services string to this one:

Code: Select all

           $Param{ServiceStrg} = $Self->{LayoutObject}->BuildSelection(
            Data         => \%Service,
            Name         => 'ServiceID',
            SelectedID   => $Param{ServiceID},
            PossibleNone => 1,
            TreeView     => $TreeView,
            Sort         => 'IndividualValue',
            SortIndividual => \@ServicePriorityString,
		   Translation  => 0,
            Max          => 200,
            Class        => "Validate_RequiredDropdown ",
        );
Of course you will need the array ServicePriorityString and it can be get by receiving and transforming the hash from the Sysconfig options just before the generation of selectbox
Like this:

Code: Select all

    # services
	#generate emty string
	my @ServicePriorityString = (); 
	#if option is received
	if ( $Self->{ConfigObject}->Get('ServicePriority') ) {
       foreach my $ServCount (sort (keys %{ $Self->{ConfigObject}->Get('ServicePriority') } )) {
			push(@ServicePriorityString, $Self->{ConfigObject}->{ServicePriority}->{$ServCount}) ;
	}
	}
	
Here you go, hope it will help someone ;)
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
Locked