Add auto-complete directive

pull/4450/head
Oliver Günther 9 years ago
parent e18a4de6d3
commit 95541c1715
  1. 40
      frontend/app/components/input/op-auto-complete.directive.ts
  2. 1
      frontend/app/components/wp-edit/field-types/wp-edit-wiki-textarea-field.directive.html
  3. 11
      spec/features/work_packages/details/inplace_editor/description_editor_spec.rb

@ -0,0 +1,40 @@
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
// ++
import {openprojectModule} from "../../angular-modules";
function opAutoComplete(AutoCompleteHelper) {
return {
restrict: 'A',
scope: false,
link: function(scope, element) {
AutoCompleteHelper.enableTextareaAutoCompletion(element);
},
};
}
openprojectModule.directive('opAutoComplete', opAutoComplete);

@ -1,6 +1,7 @@
<div class="textarea-wrapper" ng-class="{'-preview': vm.field.isPreview}">
<textarea
wiki-toolbar
op-auto-complete
msd-elastic="\n"
preview-toggle="vm.field.togglePreview()"
style="min-height: 114px"

@ -71,5 +71,16 @@ describe 'description inplace editor', js: true, selenium: true do
end
end
context 'autocomplete' do
let!(:wp2) { FactoryGirl.create(:work_package, project: project, subject: 'AutoFoo') }
let(:description_text) { '' }
it 'autocompletes the other work package' do
field.activate!
field.input_element.send_keys("##{wp2.id}")
expect(page).to have_selector('.atwho-view-ul li', text: wp2.to_s)
end
end
it_behaves_like 'a cancellable field'
end

Loading…
Cancel
Save