Patch #44793 » 0002-Replace-jquery.autocomplete-with-Tribute.patch
| app/assets/javascripts/application-legacy.js | ||
|---|---|---|
|
});
|
||
|
}
|
||
|
function setPredecessorFieldsVisibility() {
|
||
|
var relationType = $('#relation_relation_type');
|
||
|
if (relationType.val() == "precedes" || relationType.val() == "follows") {
|
||
|
$('#predecessor_fields').show();
|
||
|
} else {
|
||
|
$('#predecessor_fields').hide();
|
||
|
}
|
||
|
}
|
||
|
function showModal(id, width, title) {
|
||
|
var el = $('#'+id).first();
|
||
|
if (el.length === 0 || el.is(':visible')) {return;}
|
||
| ... | ... | |
|
});
|
||
|
}
|
||
|
function observeAutocompleteField(fieldId, url, options) {
|
||
|
$(document).ready(function() {
|
||
|
$('#'+fieldId).autocomplete($.extend({
|
||
|
source: url,
|
||
|
minLength: 2,
|
||
|
position: {collision: "flipfit"},
|
||
|
search: function(){$('#'+fieldId).addClass('ajax-loading');},
|
||
|
response: function(){$('#'+fieldId).removeClass('ajax-loading');}
|
||
|
}, options));
|
||
|
$('#'+fieldId).addClass('autocomplete');
|
||
|
});
|
||
|
}
|
||
|
function multipleAutocompleteField(fieldId, url, options) {
|
||
|
function split(val) {
|
||
|
return val.split(/,\s*/);
|
||
|
}
|
||
|
function extractLast(term) {
|
||
|
return split(term).pop();
|
||
|
}
|
||
|
$(document).ready(function () {
|
||
|
$('#' + fieldId).autocomplete($.extend({
|
||
|
source: function (request, response) {
|
||
|
$.getJSON(url, {
|
||
|
term: extractLast(request.term)
|
||
|
}, response);
|
||
|
},
|
||
|
minLength: 2,
|
||
|
position: {collision: "flipfit"},
|
||
|
search: function () {
|
||
|
$('#' + fieldId).addClass('ajax-loading');
|
||
|
},
|
||
|
response: function () {
|
||
|
$('#' + fieldId).removeClass('ajax-loading');
|
||
|
},
|
||
|
select: function (event, ui) {
|
||
|
var terms = split(this.value);
|
||
|
// remove the current input
|
||
|
terms.pop();
|
||
|
// add the selected item
|
||
|
terms.push(ui.item.value);
|
||
|
// add placeholder to get the comma-and-space at the end
|
||
|
terms.push("");
|
||
|
this.value = terms.join(", ");
|
||
|
return false;
|
||
|
}
|
||
|
}, options));
|
||
|
$('#' + fieldId).addClass('autocomplete');
|
||
|
});
|
||
|
}
|
||
|
function observeSearchfield(fieldId, targetId, url, options) {
|
||
|
$('#'+fieldId).each(function() {
|
||
|
var $this = $(this);
|
||
| app/javascript/controllers/issue_relations/autocomplete_controller.js | ||
|---|---|---|
|
/**
|
||
|
* Redmine - project management software
|
||
|
* Copyright (C) 2006- Jean-Philippe Lang
|
||
|
* This code is released under the GNU General Public License.
|
||
|
*/
|
||
|
import { Controller } from "@hotwired/stimulus"
|
||
|
import Tribute from '@redmine-ui/tributejs'
|
||
|
import { autocompleteField } from 'helper'
|
||
|
// Connects to data-controller="issue-ralations--autocomplete"
|
||
|
export default class extends Controller {
|
||
|
static values = { path: String }
|
||
|
connect() {
|
||
|
if (this.element.classList.contains('autocomplete')) return;
|
||
|
const option = {
|
||
|
autocompleteSeparator: /,\s*/,
|
||
|
selectTemplate: (item) => `${item.original.value},`
|
||
|
}
|
||
|
this.tribute = autocompleteField(this.element, this.pathValue, option);
|
||
|
this.element.classList.add('autocomplete');
|
||
|
}
|
||
|
disconnect() {
|
||
|
this.tribute?.detach(this.element);
|
||
|
}
|
||
|
}
|
||
| app/javascript/controllers/issue_relations/form_controller.js | ||
|---|---|---|
|
/**
|
||
|
* Redmine - project management software
|
||
|
* Copyright (C) 2006- Jean-Philippe Lang
|
||
|
* This code is released under the GNU General Public License.
|
||
|
*/
|
||
|
import { Controller } from "@hotwired/stimulus"
|
||
|
import { setDisplay } from "helper"
|
||
|
// Connects to data-controller="issue-relations--form"
|
||
|
export default class extends Controller {
|
||
|
static targets = ['predecessor', 'select']
|
||
|
static values = {'condition': Array}
|
||
|
connect() {
|
||
|
this.setPredecessorFieldsVisibility()
|
||
|
}
|
||
|
set(e) {
|
||
|
this.setPredecessorFieldsVisibility()
|
||
|
}
|
||
|
get isMatched() {
|
||
|
const value = this.selectTarget.value
|
||
|
return this.conditionValue.includes(value)
|
||
|
}
|
||
|
setPredecessorFieldsVisibility() {
|
||
|
setDisplay(this.predecessorTarget, this.isMatched)
|
||
|
}
|
||
|
}
|
||
| app/javascript/controllers/observe_autocomplete_controller.js | ||
|---|---|---|
|
/**
|
||
|
* Redmine - project management software
|
||
|
* Copyright (C) 2006- Jean-Philippe Lang
|
||
|
* This code is released under the GNU General Public License.
|
||
|
*/
|
||
|
import { Controller } from "@hotwired/stimulus"
|
||
|
import { autocompleteField } from 'helper'
|
||
|
// Connects to data-controller="observe-autocomplete-field"
|
||
|
export default class extends Controller {
|
||
|
static values = { path: String }
|
||
|
connect() {
|
||
|
if (this.element.classList.contains('autocomplete')) return;
|
||
|
this.tribute = autocompleteField(this.element, this.pathValue)
|
||
|
this.element.classList.add('autocomplete')
|
||
|
}
|
||
|
disconnect() {
|
||
|
this.tribute?.detach(this.element)
|
||
|
}
|
||
|
}
|
||
| app/javascript/controllers/timelog/bulk_edit_controller.js | ||
|---|---|---|
|
/**
|
||
|
* Redmine - project management software
|
||
|
* Copyright (C) 2006- Jean-Philippe Lang
|
||
|
* This code is released under the GNU General Public License.
|
||
|
*/
|
||
|
import { Controller } from "@hotwired/stimulus"
|
||
|
import { autocompleteField, URLInfo } from 'helper'
|
||
|
// Connects to data-controller="timelog--bulk-edit"
|
||
|
export default class extends Controller {
|
||
|
static values = { url: String, project: { type: String, default: undefined }}
|
||
|
static targets = [ 'field', 'select', 'projectId' ];
|
||
|
fieldTargetConnected(element) {
|
||
|
if (element.classList.contains('autocomplete')) return;
|
||
|
const source = getSource(this.urlValue, this.projectValue, this.projectIdTarget);
|
||
|
this.tribute = autocompleteField(element, source);
|
||
|
element.classList.add('autocomplete')
|
||
|
}
|
||
|
fieldTargetDisconnected(element) {
|
||
|
this.tribute?.detach(element);
|
||
|
}
|
||
|
replace(e) {
|
||
|
const label = e.detail.item.original.label;
|
||
|
this.selectTarget.textContent = label;
|
||
|
}
|
||
|
}
|
||
|
function getSource(url, project_id, element) {
|
||
|
return (term) => {
|
||
|
const urlInfo = new URLInfo(url);
|
||
|
urlInfo.setParam('term', term)
|
||
|
const current_project_id = element.value;
|
||
|
const value = current_project_id !== '' ? current_project_id
|
||
|
: project_id;
|
||
|
urlInfo.setParam('project_id', value)
|
||
|
return urlInfo.toString()
|
||
|
}
|
||
|
}
|
||
| app/javascript/controllers/timelog/form_controller.js | ||
|---|---|---|
|
/**
|
||
|
* Redmine - project management software
|
||
|
* Copyright (C) 2006- Jean-Philippe Lang
|
||
|
* This code is released under the GNU General Public License.
|
||
|
*/
|
||
|
import { Controller } from "@hotwired/stimulus"
|
||
|
import { autocompleteField, URLInfo } from 'helper'
|
||
|
// Connects to data-controller="timelog--form"
|
||
|
export default class extends Controller {
|
||
|
static values = { url: String, project: { type: String, default: undefined }}
|
||
|
static targets = [ 'field', 'select', 'projectId' ];
|
||
|
fieldTargetConnected(element) {
|
||
|
if (element.classList.contains('autocomplete')) return;
|
||
|
const source = getSource(this.urlValue, this.projectValue, this.projectIdTarget);
|
||
|
this.tribute = autocompleteField(element, source);
|
||
|
element.classList.add('autocomplete')
|
||
|
}
|
||
|
fieldTargetDisconnected(element) {
|
||
|
this.tribute?.detach(element);
|
||
|
}
|
||
|
replace(e) {
|
||
|
this.selectTarget.textContent = '';
|
||
|
const item = e.detail.item
|
||
|
this.fieldTarget.value = item.original.value;
|
||
|
const event = new Event('change');
|
||
|
this.fieldTarget.dispatchEvent(event);
|
||
|
}
|
||
|
}
|
||
|
function getSource(url, project_id, element) {
|
||
|
return (term) => {
|
||
|
const urlInfo = new URLInfo(url);
|
||
|
urlInfo.setParam('term', term)
|
||
|
const value = typeof project === 'undefined' ? element.value
|
||
|
: project_id;
|
||
|
if (value) {
|
||
|
urlInfo.setParam('project_id', value)
|
||
|
} else {
|
||
|
urlInfo.setParam('scope', 'all')
|
||
|
}
|
||
|
return urlInfo.toString()
|
||
|
}
|
||
|
}
|
||
| app/javascript/helper.js | ||
|---|---|---|
|
* This code is released under the GNU General Public License.
|
||
|
*/
|
||
|
import { FetchRequest } from '@rails/request.js'
|
||
|
import Tribute from "@redmine-ui/tributejs"
|
||
|
export function createQuery(element, source) {
|
||
|
if (typeof source === 'undefined') return;
|
||
| ... | ... | |
|
return this.url + '?' + this.query.toString();
|
||
|
}
|
||
|
}
|
||
|
export function autocompleteField(element, source, options={}) {
|
||
|
if (element.dataset.tribute === 'true') return;
|
||
|
const tribute = new Tribute(Object.assign({
|
||
|
autocompleteMode: true,
|
||
|
autocompleteSeparator: null,
|
||
|
allowSpaces: true,
|
||
|
menuShowMinLength: 2,
|
||
|
noMatchTemplate: '',
|
||
|
lookup: 'label',
|
||
|
values: createQuery(element, source),
|
||
|
menuOption: {
|
||
|
position: 'absolute'
|
||
|
},
|
||
|
debounce: 200
|
||
|
}, options));
|
||
|
tribute.attach(element);
|
||
|
return tribute
|
||
|
}
|
||
|
export function setDisplay(element, visible) {
|
||
|
if (visible) {
|
||
|
element.style.display = '';
|
||
|
} else {
|
||
|
element.style.display = 'none';
|
||
|
}
|
||
|
}
|
||
| app/views/issue_relations/_form.html.erb | ||
|---|---|---|
|
</ul>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<p><%= f.select :relation_type, collection_for_relation_type_select, {}, :onchange => "setPredecessorFieldsVisibility();" %>
|
||
|
<%= l(:label_issue) %> #<%= f.text_field :issue_to_id, :value => unsaved_relations_ids, :size => 10 %>
|
||
|
<span id="predecessor_fields" style="display:none;">
|
||
|
<%= l(:field_delay) %>: <%= f.text_field :delay, :size => 3 %> <%= l(:label_day_plural) %>
|
||
|
</span>
|
||
|
<%= submit_tag l(:button_add) %>
|
||
|
<%= link_to_function l(:button_cancel), '$("#new-relation-form").hide();'%>
|
||
|
<em class="info"><%= l(:text_comma_separated) %></em>
|
||
|
<p data-controller="issue-relations--form" data-issue-relations--form-condition-value='["precedes", "follows"]'>
|
||
|
<%= f.select :relation_type, collection_for_relation_type_select, {}, data: { action: 'issue-relations--form#set', issue_relations__form_target: 'select'} %>
|
||
|
<%= l(:label_issue) %> #<%= f.text_field :issue_to_id, value: unsaved_relations_ids, autocomplete: 'off', size: 10,
|
||
|
data: {
|
||
|
controller: 'issue-relations--autocomplete',
|
||
|
issue_relations__autocomplete_path_value: auto_complete_issues_path(project_id: @project, scope: (Setting.cross_project_issue_relations? ? 'all' : nil), issue_id: @issue.id)
|
||
|
} %>
|
||
|
<span id="predecessor_fields" style="display:none;" data-issue-relations--form-target="predecessor">
|
||
|
<%= l(:field_delay) %>: <%= f.text_field :delay, size: 3 %> <%= l(:label_day_plural) %>
|
||
|
</span>
|
||
|
<%= submit_tag l(:button_add) %>
|
||
|
<%= link_to_function l(:button_cancel), '$("#new-relation-form").hide();'%>
|
||
|
<em class="info"><%= l(:text_comma_separated) %></em>
|
||
|
</p>
|
||
|
<%= javascript_tag "multipleAutocompleteField('relation_issue_to_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil), :issue_id => @issue.id)}')" %>
|
||
|
<%= javascript_tag "setPredecessorFieldsVisibility();" %>
|
||
| app/views/issues/_attributes.html.erb | ||
|---|---|---|
|
<div class="splitcontentright">
|
||
|
<% if @issue.safe_attribute? 'parent_issue_id' %>
|
||
|
<p id="parent_issue"><%= f.text_field :parent_issue_id, :size => 10,
|
||
|
:required => @issue.required_attribute?('parent_issue_id'),
|
||
|
:onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %></p>
|
||
|
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript(auto_complete_issues_path(:project_id => @issue.project, :scope => Setting.cross_project_subtasks, :status => @issue.closed? ? 'c' : 'o', :issue_id => @issue.id))}')" %>
|
||
|
<p id="parent_issue"><%= f.text_field :parent_issue_id, size: 10,
|
||
|
required: @issue.required_attribute?('parent_issue_id'),
|
||
|
data: {
|
||
|
controller: 'observe-autocomplete',
|
||
|
observe_autocomplete_path_value: auto_complete_issues_path(project_id: @issue.project, scope: Setting.cross_project_subtasks, status: @issue.closed? ? 'c' : 'o', issue_id: @issue.id)
|
||
|
} %></p>
|
||
|
<% end %>
|
||
|
<% if @issue.safe_attribute? 'start_date' %>
|
||
| app/views/issues/bulk_edit.html.erb | ||
|---|---|---|
|
<% if @safe_attributes.include?('parent_issue_id') && @project %>
|
||
|
<p>
|
||
|
<label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
|
||
|
<%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
|
||
|
<label class="inline"><%= check_box_tag 'issue[parent_issue_id]', 'none', (@issue_params[:parent_issue_id] == 'none'), :id => nil, :data => {:disables => '#issue_parent_issue_id'} %><%= l(:button_clear) %></label>
|
||
|
<%= text_field_tag 'issue[parent_issue_id]', '', value: @issue_params[:parent_issue_id], size: 10,
|
||
|
data: {
|
||
|
controller: 'observe-autocomplete',
|
||
|
observe_autocomplete_path_value: auto_complete_issues_path(project_id: @project, scope: Setting.cross_project_subtasks)
|
||
|
} %>
|
||
|
<label class="inline"><%= check_box_tag 'issue[parent_issue_id]', 'none', (@issue_params[:parent_issue_id] == 'none'), id: nil, data: {disables: '#issue_parent_issue_id'} %><%= l(:button_clear) %></label>
|
||
|
</p>
|
||
|
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => Setting.cross_project_subtasks)}')" %>
|
||
|
<% end %>
|
||
|
<% if @safe_attributes.include?('start_date') %>
|
||
| app/views/issues/destroy.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
<% if @project %>
|
||
|
<label><%= radio_button_tag 'todo', 'reassign', false, :onchange => 'if (this.checked) { $("#reassign_to_id").focus(); }' %> <%= l(:text_reassign_time_entries) %></label>
|
||
|
<%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("#todo_reassign").attr("checked", true);' %>
|
||
|
<%= javascript_tag "observeAutocompleteField('reassign_to_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %>
|
||
|
<%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("#todo_reassign").attr("checked", true);',
|
||
|
:data => { :controller => 'observe-autocomplete', :observe_autocomplete_path_value => auto_complete_issues_path(:project_id => @project) }%>
|
||
|
<% end %>
|
||
|
</p>
|
||
|
</div>
|
||
| app/views/repositories/_related_issues.html.erb | ||
|---|---|---|
|
:remote => true,
|
||
|
:method => :post,
|
||
|
:id => 'new-relation-form', :style => (@issue ? '' : 'display: none;')) do |f| %>
|
||
|
<%= l(:label_issue) %> #<%= text_field_tag 'issue_id', '', :size => 10 %>
|
||
|
<%= l(:label_issue) %> #<%= text_field_tag 'issue_id', '', :size => 10,
|
||
|
data: {
|
||
|
controller: 'observe-autocomplete',
|
||
|
observe_autocomplete_path_value: auto_complete_issues_path(project_id: @project, scope: 'all')
|
||
|
} %>
|
||
|
<%= submit_tag l(:button_add) %>
|
||
|
<%= toggle_link l(:button_cancel), 'new-relation-form'%>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<%= javascript_tag "observeAutocompleteField('issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => 'all')}')" %>
|
||
| app/views/timelog/_form.html.erb | ||
|---|---|---|
|
<%= error_messages_for 'time_entry' %>
|
||
|
<%= back_url_hidden_field_tag %>
|
||
|
<div class="box tabular">
|
||
|
<%= tag.div class: "box tabular", data: {controller: 'timelog--form',
|
||
|
timelog__form_url_value: auto_complete_issues_path,
|
||
|
timelog__form_project_value: @time_entry.new_record? && @project ? @project.id : nil} do %>
|
||
|
<% if @time_entry.new_record? && params[:project_id] %>
|
||
|
<%= hidden_field_tag 'project_id', params[:project_id] %>
|
||
|
<% elsif @time_entry.new_record? && params[:issue_id] %>
|
||
|
<%= hidden_field_tag 'issue_id', params[:issue_id] %>
|
||
|
<% else %>
|
||
|
<p><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).to_a, :selected => @time_entry.project, :include_blank => true), :required => true %></p>
|
||
|
<p>
|
||
|
<%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).to_a, selected: @time_entry.project, include_blank: true),
|
||
|
{ required: true },
|
||
|
data: { timelog__form_target: 'projectId' } %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
<p>
|
||
|
<%= f.text_field :issue_id, :size => 6, :required => Setting.timelog_required_fields.include?('issue_id') %>
|
||
|
<span id="time_entry_issue">
|
||
|
<%= f.text_field :issue_id, size: 6, required: Setting.timelog_required_fields.include?('issue_id'),
|
||
|
data: { action: 'tribute-replaced->timelog--form#replace', timelog__form_target: 'field' } %>
|
||
|
<span id="time_entry_issue" data-timelog--form-target='select'>
|
||
|
<%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
|
||
|
</span>
|
||
|
</p>
|
||
| ... | ... | |
|
</div>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<%= javascript_tag do %>
|
||
|
$(document).ready(function(){
|
||
| ... | ... | |
|
});
|
||
|
});
|
||
|
});
|
||
|
observeAutocompleteField('time_entry_issue_id',
|
||
|
function(request, callback) {
|
||
|
var url = '<%= j auto_complete_issues_path %>';
|
||
|
var data = {
|
||
|
term: request.term
|
||
|
};
|
||
|
var project_id;
|
||
|
<% if @time_entry.new_record? && @project %>
|
||
|
project_id = '<%= @project.id %>';
|
||
|
<% else %>
|
||
|
project_id = $('#time_entry_project_id').val();
|
||
|
<% end %>
|
||
|
if(project_id){
|
||
|
data['project_id'] = project_id;
|
||
|
} else {
|
||
|
data['scope'] = 'all';
|
||
|
}
|
||
|
$.get(url, data, null, 'json')
|
||
|
.done(function(data){
|
||
|
callback(data);
|
||
|
})
|
||
|
.fail(function(jqXHR, status, error){
|
||
|
callback([]);
|
||
|
});
|
||
|
},
|
||
|
{
|
||
|
select: function(event, ui) {
|
||
|
$('#time_entry_issue').text('');
|
||
|
$('#time_entry_issue_id').val(ui.item.value).change();
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
<% end %>
|
||
| app/views/timelog/bulk_edit.html.erb | ||
|---|---|---|
|
<%= form_tag(bulk_update_time_entries_path, :id => 'bulk_edit_form') do %>
|
||
|
<%= @time_entries.collect {|i| hidden_field_tag('ids[]', i.id, :id => nil)}.join.html_safe %>
|
||
|
<div class="box tabular">
|
||
|
<div>
|
||
|
<% data = @project || @target_project ? {
|
||
|
controller: 'timelog--bulk-edit',
|
||
|
timelog__bulk_edit_url_value: auto_complete_issues_path,
|
||
|
timelog__bulk_edit_project_value: @project.id,
|
||
|
} : nil %>
|
||
|
<%= tag.div data: data do %>
|
||
|
<p>
|
||
|
<label><%= l(:field_project) %></label>
|
||
|
<%= select_tag('time_entry[project_id]', project_tree_options_for_select(@target_projects,
|
||
|
:include_blank => l(:label_no_change_option), :selected => @target_project),
|
||
|
:onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')" ) %>
|
||
|
<%= select_tag 'time_entry[project_id]', project_tree_options_for_select(@target_projects, include_blank: l(:label_no_change_option), selected: @target_project),
|
||
|
onchange: "updateBulkEditFrom('#{escape_javascript url_for(action: 'bulk_edit', format: 'js')}')",
|
||
|
data: { timelog__bulk_edit_target: 'projectId' } %>
|
||
|
</p>
|
||
|
<p>
|
||
|
<label for="time_entry_issue_id"><%= l(:field_issue) %></label>
|
||
|
<%= text_field :time_entry, :issue_id, :size => 6 %>
|
||
|
<%= text_field :time_entry, :issue_id, size: 6, data: {timelog__bulk_edit_target: 'field', action: 'tribute-replaced->timelog--bulk-edit#replace'} %>
|
||
|
<label class="inline"><%= check_box_tag 'time_entry[issue_id]', 'none', (@time_entry_params[:issue_id] == 'none'), :id => nil, :data => {:disables => '#time_entry_issue_id'} %><%= l(:button_clear) %></label>
|
||
|
<span id="time_entry_issue"></span>
|
||
|
<%= tag.span id: 'time_entry_issue', data: { timelog__bulk_edit_target: 'select' } %>
|
||
|
</p>
|
||
|
<p>
|
||
| ... | ... | |
|
<% end %>
|
||
|
<%= call_hook(:view_time_entries_bulk_edit_details_bottom, { :time_entries => @time_entries }) %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<p><%= submit_tag l(:button_submit) %></p>
|
||
| ... | ... | |
|
$('#time_entry_issue').text('');
|
||
|
});
|
||
|
});
|
||
|
<% if @project || @target_project %>
|
||
|
observeAutocompleteField('time_entry_issue_id',
|
||
|
function(request, callback) {
|
||
|
var url = '<%= j auto_complete_issues_path %>';
|
||
|
var data = {
|
||
|
term: request.term
|
||
|
};
|
||
|
var project_id;
|
||
|
<% if @project %>
|
||
|
project_id = '<%= @project.id %>';
|
||
|
<% end %>
|
||
|
current_project_id = $('#time_entry_project_id').val();
|
||
|
if(current_project_id === ''){
|
||
|
data['project_id'] = project_id;
|
||
|
} else {
|
||
|
data['project_id'] = current_project_id;
|
||
|
}
|
||
|
$.get(url, data, null, 'json')
|
||
|
.done(function(data){
|
||
|
callback(data);
|
||
|
})
|
||
|
.fail(function(jqXHR, status, error){
|
||
|
callback([]);
|
||
|
});
|
||
|
},
|
||
|
{
|
||
|
select: function(event, ui, data) {
|
||
|
$('#time_entry_issue').text(ui.item.label);
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
<% end %>
|
||
|
<% end %>
|
||
| test/system/issues_test.rb | ||
|---|---|---|
|
page.find('#relations .contextual a').click
|
||
|
page.fill_in 'relation[issue_to_id]', :with => 'issue'
|
||
|
within('ul.ui-autocomplete') do
|
||
|
within('.tribute-container') do
|
||
|
assert page.has_text? 'Bug #12: Closed issue on a locked version'
|
||
|
assert page.has_text? 'Bug #11: Closed issue on a closed version'
|
||
|
first('li.ui-menu-item').click
|
||
|
first('li').click
|
||
|
end
|
||
|
assert_equal '12, ', find('#relation_issue_to_id').value
|
||
|
find('#relation_issue_to_id').click.send_keys('issue due')
|
||
|
within('ul.ui-autocomplete') do
|
||
|
within('.tribute-container') do
|
||
|
assert page.has_text? 'Bug #7: Issue due today'
|
||
|
find('li.ui-menu-item').click
|
||
|
find('li').click
|
||
|
end
|
||
|
assert_equal '12, 7, ', find('#relation_issue_to_id').value
|
||
- « Previous
- 1
- 2
- Next »