[26856] Mentions only work in the scope of the project (#6112)

* Hand over WP project id to autocompleter.

* Watch the project id in op-auto-complete

* enable autocompletion at least once and not only on change


[ci skip]
pull/6121/head
Wieland Lindenthal 7 years ago committed by Oliver Günther
parent 83e605e63c
commit 36c396787c
  1. 17
      frontend/app/components/input/op-auto-complete.directive.ts
  2. 8
      frontend/app/components/wp-edit-form/work-package-edit-field-handler.ts
  3. 1
      frontend/app/components/wp-edit/field-types/wp-edit-wiki-textarea-field.directive.html

@ -34,10 +34,21 @@ function opAutoComplete(AutoCompleteHelper:AutoCompleteHelperService, currentPro
return {
restrict: 'AC',
scope: false,
link: function(scope:ng.IScope, element:ng.IAugmentedJQuery) {
var projectId:string|null = currentProject.id;
link: function(scope:any, element:ng.IAugmentedJQuery, attrs:any) {
let projectId:string|null = attrs['opAutoCompleteProjectId'] || currentProject.id;
// Ensure the autocompleter gets enabled at least once.
AutoCompleteHelper.enableTextareaAutoCompletion(element, projectId);
},
// The project id might change at a later point in time. Then re-enable the autocompleter.
scope.$watch(
() => attrs['opAutoCompleteProjectId'] || currentProject.id,
(newVal:string, oldVal:string) => {
if (newVal !== oldVal) {
AutoCompleteHelper.enableTextareaAutoCompletion(element, newVal);
}
}
);
}
};
}

@ -190,6 +190,14 @@ export class WorkPackageEditFieldHandler {
return this.form.workPackage;
}
/**
* Reference the current set project
*/
public get project() {
const changeset = this.form.changeset;
return changeset.value('project');
}
/**
* Return a unique ID for this edit field
*/

@ -2,6 +2,7 @@
<textarea
wiki-toolbar
op-auto-complete
op-auto-complete-project-id="{{vm.project.id}}"
msd-elastic="\n"
preview-toggle="vm.field.togglePreview()"
style="min-height: 114px"

Loading…
Cancel
Save