Fix keyword webservice, take all keyword list from field_metadata
parent
c059342976
commit
0fdb364160
|
@ -60,10 +60,9 @@ sub get_by_match
|
|||
}
|
||||
if (@match_items)
|
||||
{
|
||||
my $joined = join(' OR ', @match_items);
|
||||
$keywords = $dbh->selectall_arrayref("SELECT * FROM keywords WHERE ".$joined, {Slice => {}});
|
||||
return [] unless $keywords;
|
||||
return $self->_do_list_select(join(' OR ', @match_items));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
|
@ -25,7 +23,7 @@ use base qw(Bugzilla::WebService);
|
|||
use Bugzilla;
|
||||
use Bugzilla::Constants;
|
||||
use Bugzilla::Error;
|
||||
use Bugzilla::Util qw(trim);
|
||||
use Bugzilla::Util;
|
||||
use Bugzilla::WebService::Util qw(filter validate);
|
||||
|
||||
# Function to return keywords by passing either keyword ids or
|
||||
|
@ -36,37 +34,42 @@ use Bugzilla::WebService::Util qw(filter validate);
|
|||
# Can be also used to match keywords based on their name:
|
||||
# $call = $rpc->call( 'Keyword.get', { match => [ 'testkeyworda', 'testkeywordb' ]});
|
||||
#
|
||||
sub get {
|
||||
sub get
|
||||
{
|
||||
my ($self, $params) = validate(@_, 'names', 'ids');
|
||||
|
||||
# Make them arrays if they aren't
|
||||
if ($params->{names} && !ref $params->{names}) {
|
||||
if ($params->{names} && !ref $params->{names})
|
||||
{
|
||||
$params->{names} = [ $params->{names} ];
|
||||
}
|
||||
if ($params->{ids} && !ref $params->{ids}) {
|
||||
if ($params->{ids} && !ref $params->{ids})
|
||||
{
|
||||
$params->{ids} = [ $params->{ids} ];
|
||||
}
|
||||
if ($params->{match} && !ref $params->{match}) {
|
||||
if ($params->{match} && !ref $params->{match})
|
||||
{
|
||||
$params->{match} = [ $params->{match} ];
|
||||
}
|
||||
warn Dumper $params;
|
||||
|
||||
my @keyword_list;
|
||||
if ($params->{names})
|
||||
{
|
||||
my $keyword_objects = Bugzilla::Keyword->match( { name => @{$params->{names}} } );
|
||||
@keyword_list = map { { name => $_->{name} } } @$keyword_objects;
|
||||
my $keyword_objects = Bugzilla::Keyword->match({ value => @{$params->{names}} });
|
||||
@keyword_list = map { { name => $_->name } } @$keyword_objects;
|
||||
}
|
||||
|
||||
if ($params->{ids})
|
||||
{
|
||||
my $keyword_objects = Bugzilla::Keyword->match( { id => @{$params->{ids}} } );
|
||||
@keyword_list = map { { name => $_->{name} } } @$keyword_objects;
|
||||
my $keyword_objects = Bugzilla::Keyword->match({ id => @{$params->{ids}} });
|
||||
@keyword_list = map { { name => $_->name } } @$keyword_objects;
|
||||
}
|
||||
|
||||
if ($params->{match})
|
||||
{
|
||||
my $keyword_objects = Bugzilla::Keyword->get_by_match( @{$params->{match}} );
|
||||
@keyword_list = map { { name => $_->{name} } } @$keyword_objects;
|
||||
my $keyword_objects = Bugzilla::Keyword->get_by_match(@{$params->{match}});
|
||||
@keyword_list = map { { name => $_->name } } @$keyword_objects;
|
||||
}
|
||||
|
||||
return { keywords => \@keyword_list };
|
||||
|
|
|
@ -559,12 +559,6 @@ foreach my $row (@$grouplist)
|
|||
|
||||
$vars->{group} = \@groups;
|
||||
|
||||
# Custis Bug 66910
|
||||
my @keyword_list = Bugzilla::Keyword->get_all();
|
||||
my @keyword_list_out = map { { name => $_->{name} } } @keyword_list;
|
||||
$vars->{keyword_list} = \@keyword_list_out;
|
||||
# END Custis Bug 66910
|
||||
|
||||
Bugzilla::Hook::process('enter_bug_entrydefaultvars', { vars => $vars });
|
||||
|
||||
$vars->{default} = \%default;
|
||||
|
|
|
@ -46,10 +46,13 @@ function getSelectedIds(sel)
|
|||
{
|
||||
var opt = {};
|
||||
var lm = sel.id.length+2;
|
||||
if (sel.type == 'hidden' && sel.name == 'product')
|
||||
if (sel.nodeName != 'SELECT')
|
||||
{
|
||||
// product is a special case - it is preselected as hidden field on bug creation form
|
||||
opt[product_id] = true;
|
||||
if (sel.name == 'product')
|
||||
{
|
||||
// product is a special case - it is preselected as hidden field on bug creation form
|
||||
opt[product_id] = true;
|
||||
}
|
||||
return opt;
|
||||
}
|
||||
for (var i = 0; i < sel.options.length; i++)
|
||||
|
|
13
js/field.js
13
js/field.js
|
@ -277,6 +277,19 @@ function _value_id(field_name, id)
|
|||
return 'v' + id + '_' + field_name;
|
||||
}
|
||||
|
||||
function addKeywordsAutocomplete()
|
||||
{
|
||||
var emptyKeywordsOptions = [];
|
||||
for (var i = 0; i < field_metadata.keywords.legal.length; i++)
|
||||
{
|
||||
emptyKeywordsOptions.push({ name: field_metadata.keywords.legal[i][1] });
|
||||
}
|
||||
new SimpleAutocomplete("keywords",
|
||||
function(h) { keywordAutocomplete(h, emptyKeywordsOptions); },
|
||||
{ emptyText: 'No keywords found', multipleDelimiter: "," }
|
||||
);
|
||||
}
|
||||
|
||||
// CustIS bug 66910 - check new keywords and requery description for its
|
||||
function check_new_keywords(form)
|
||||
{
|
||||
|
|
10
js/global.js
10
js/global.js
|
@ -180,13 +180,9 @@ function convertSimpleList(k)
|
|||
{
|
||||
var data = [];
|
||||
for (var i = 0; i < k.length; i++)
|
||||
data.push([
|
||||
'<span class="hintRealname">' + k[i].name +
|
||||
'</span>',
|
||||
k[i].name
|
||||
]);
|
||||
data.push([ '<span class="hintRealname">' + k[i].name + '</span>', k[i].name ]);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// Data loader for keyword autocomplete
|
||||
function keywordAutocomplete(hint, emptyOptions)
|
||||
|
@ -221,7 +217,7 @@ function keywordAutocomplete(hint, emptyOptions)
|
|||
hint.replaceItems(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Data loader for field in buglist autocomplete
|
||||
function fieldBuglistAutocomplete(hint, field, emptyOptions)
|
||||
|
|
|
@ -2,14 +2,10 @@
|
|||
// License: Dual-license GPL 3.0+ or MPL 1.1+
|
||||
// Author(s): Vitaliy Filippov <vitalif@mail.ru>
|
||||
|
||||
// Requires global vars: queryform, allKeywords, checkwidths, userAutocomplete
|
||||
// Requires global vars: queryform, checkwidths, userAutocomplete
|
||||
addListener(window, 'load', function()
|
||||
{
|
||||
document.forms[queryform].content.focus();
|
||||
new SimpleAutocomplete("keywords",
|
||||
function(h) { keywordAutocomplete(h, allKeywords); },
|
||||
{ emptyText: 'No keywords found', multipleDelimiter: "," }
|
||||
);
|
||||
if (document.getElementById('deadlinefrom'))
|
||||
{
|
||||
Calendar.set('deadlinefrom');
|
||||
|
@ -20,6 +16,7 @@ addListener(window, 'load', function()
|
|||
Calendar.set('chfieldfrom');
|
||||
Calendar.set('chfieldto');
|
||||
new SimpleAutocomplete("chfieldwho", userAutocomplete, { emptyText: 'No users found' });
|
||||
addKeywordsAutocomplete();
|
||||
|
||||
var lim = 250;
|
||||
function checkw(e)
|
||||
|
|
|
@ -304,13 +304,6 @@ if ($vars->{query_format} eq "create-series")
|
|||
$vars->{category} = Bugzilla::Chart::getVisibleSeries();
|
||||
}
|
||||
|
||||
# Custis Bug 66910
|
||||
my @keyword_list = Bugzilla::Keyword->get_all();
|
||||
my @keyword_list_out = map { { name => $_->{name} } } @keyword_list;
|
||||
$vars->{keyword_list} = \@keyword_list_out;
|
||||
# END Custis Bug 66910
|
||||
|
||||
|
||||
# Set cookie to current format as default, but only if the format
|
||||
# one that we should remember.
|
||||
if (defined $vars->{format} && IsValidQueryType($vars->{format}))
|
||||
|
|
|
@ -149,9 +149,6 @@ if ($ARGS->{includefield} || $ARGS->{field})
|
|||
|
||||
$vars->{displayfields} = \%displayfields;
|
||||
|
||||
# CustIS Bug 66910 - Autocomplete for keywords
|
||||
$vars->{keyword_list} = [ map { { name => $_->name } } Bugzilla::Keyword->get_all() ];
|
||||
|
||||
Bugzilla->cgi->send_header($format->{ctype});
|
||||
$template->process($format->{template}, $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
|
|
|
@ -446,13 +446,7 @@ var close_status_array = [
|
|||
[% END %]
|
||||
<input id="keywords" name="keywords" size="40" value="[% default.keywords | html %]">
|
||||
<script type="text/javascript">
|
||||
var emptyKeywordsOptions = [% keyword_list ? json(keyword_list) : "null" %];
|
||||
addListener(window, 'load', function() {
|
||||
new SimpleAutocomplete("keywords",
|
||||
function(h) { keywordAutocomplete(h, emptyKeywordsOptions); },
|
||||
{ emptyText: 'No keywords found', multipleDelimiter: "," }
|
||||
);
|
||||
});
|
||||
addListener(window, 'load', addKeywordsAutocomplete);
|
||||
</script>
|
||||
<div id="keywords_description_container"></div>
|
||||
</td>
|
||||
|
|
|
@ -534,19 +534,12 @@ document.changeform = document.[% cfname %];
|
|||
[% IF use_keywords %]
|
||||
<tr>
|
||||
<td class="field_label">
|
||||
<script type="text/javascript">
|
||||
var emptyKeywordsOptions = [% keyword_list ? json(keyword_list) : "null" %];
|
||||
addListener(window, 'load', function() {
|
||||
new SimpleAutocomplete("keywords",
|
||||
function(h) { keywordAutocomplete(h, emptyKeywordsOptions); },
|
||||
{ emptyText: 'No keywords found', multipleDelimiter: "," }
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<label for="keywords" accesskey="k">
|
||||
<b><a href="describekeywords.cgi"><u>K</u>eywords</a></b></label>:
|
||||
<label for="keywords" accesskey="k"><b><a href="describekeywords.cgi"><u>K</u>eywords</a></b></label>:
|
||||
</td>
|
||||
[% PROCESS input inputname => "keywords" size => 40 colspan => 2 %]
|
||||
<script>
|
||||
addListener(window, 'load', addKeywordsAutocomplete);
|
||||
</script>
|
||||
</tr>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
|
|
@ -422,5 +422,4 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
var checkwidths = [% json(checkwidths) %];
|
||||
var allKeywords = [% keyword_list ? json(keyword_list) : "null" %];
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue