diff --git a/app/src/Controller/ApiV2Controller.php b/app/src/Controller/ApiV2Controller.php
index 6e3114c9f..613d86876 100644
--- a/app/src/Controller/ApiV2Controller.php
+++ b/app/src/Controller/ApiV2Controller.php
@@ -307,7 +307,7 @@ public function index() {
$pickerMode = false;
if($this->request->getQuery('picker') !== null
- && $this->request->is('restful')) {
+ && $this->request->is('ajax')) {
$pickerMode = filter_var($this->request->getQuery('picker'), FILTER_VALIDATE_BOOLEAN);
}
// Construct the Query
@@ -318,7 +318,7 @@ public function index() {
$this->set($this->tableName, $this->paginate($query));
// Let the view render
- $this->render('/Standard/api/v2/json/index');
+ $this->render($this->request->is('ajax') ? '/Standard/api/ajax/v2/json/index' : '/Standard/api/v2/json/index');
}
/**
diff --git a/app/src/Model/Behavior/ChangelogBehavior.php b/app/src/Model/Behavior/ChangelogBehavior.php
index 4ac8f3ff1..fad6f5610 100644
--- a/app/src/Model/Behavior/ChangelogBehavior.php
+++ b/app/src/Model/Behavior/ChangelogBehavior.php
@@ -104,9 +104,10 @@ public function beforeFind(Event $event, Query $query, \ArrayObject $options, bo
// XXX add support for archived, revision, etc
// XXX if specific id is requested, do not modify query
+ // Take into account all joined associations
if(!empty($query->clause('join'))) {
foreach($query->clause('join') as $mdl => $opts) {
- $ascParentfk = Inflector::singularize($opts['table']) . "_id";
+ $ascParentfk = Inflector::singularize($opts['table']) . '_id';
$query->where([$opts['alias'] . '.deleted IS NOT true'])
->where([$opts['alias'] . '.' . $ascParentfk . ' IS NULL']);
diff --git a/app/templates/element/autocompletePeople.php b/app/templates/element/autocompletePeople.php
index 0f735c068..c6a1bff08 100644
--- a/app/templates/element/autocompletePeople.php
+++ b/app/templates/element/autocompletePeople.php
@@ -55,16 +55,16 @@
htmlId: '= $htmlId ?>'
},
error: ''
- coId: =$vv_cur_co ?>
}
},
provide: {
- txt: JSON.parse('= json_encode($vueHelper->locales()) ?>')
+ txt: JSON.parse('= json_encode($vueHelper->locales()) ?>'),
+ coId: = $vv_cur_co->id ?>,
api: {
webroot: '= $this->request->getAttribute('webroot') ?>',
- searchPeople: `= $this->request->getAttribute('webroot') ?>/api/ajax/v2/people?co_id== $vv_cur_co ?>?PrimaryName,Identifiers,EmailAddresses&picker=on`,
+ searchPeople: `= $this->request->getAttribute('webroot') ?>api/ajax/v2/people?co_id== $vv_cur_co->id ?>&extended=PrimaryName,Identifiers,EmailAddresses&picker=on`
}
- }
+ },
components: {
AutocompletePeople
},
diff --git a/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js b/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js
index 289f98af6..12dcf9dcd 100644
--- a/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js
+++ b/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js
@@ -29,65 +29,59 @@ import { camelize } from '../utils/helpers.js';
export default {
props: {
options: Object,
- core: Object,
- txt: Object
+ core: Object
},
+ inject: ['txt', 'api'],
components: {
AutoComplete : primevue.autocomplete
},
data() {
return {
people: [],
- person: ''
+ person: '',
+ loading: false,
+ error: null
}
},
methods: {
- search() {
- this.people = [
- {
- "value": 16,
- "label": "Test J Testington IV",
- "email": "test.testington@myvo.org 1",
- "emailLabel": "Email (official): ",
- "identifier": "50010",
- "identifierLabel": "Identifier (employeenumber): "
+ async searchPeople(event) {
+ this.loading = true;
+ this.error = null;
+ debugger;
+ let queryParams = `identifier=${event.query}&mail=${event.query}&name=${event.query}`
+ const resp = await fetch(`${this.api.searchPeople}&${queryParams}`, {
+ headers: {
+ "Accept": "application/json",
},
- {
- "value": 17,
- "label": "Test JR Testington V",
- "email": "test.testington@myvo.org 1",
- "emailLabel": "Email (official): ",
- "identifier": "50002",
- "identifierLabel": "Identifier (employeenumber): "
- },
- {
- "value": 280,
- "label": "Test C Testington",
- "email": "test.testington@myvo.org 1",
- "emailLabel": "Email (official): ",
- "identifier": "50052",
- "identifierLabel": "Identifier (employeenumber): "
- }
- ];
+ method: "GET"
+ });
+ if (resp.ok) {
+ this.people = await resp.json();
+ console.log('people', this.people)
+ } else {
+ this.error = resp;
+ }
+ this.loading = false;
},
setPerson() {
const field = document.getElementById(this.options.fieldName);
+ debugger;
field.value = this.person.value;
}
},
template: `