Skip to content

Commit

Permalink
first get request
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Mar 13, 2024
1 parent aa73e23 commit 1311315
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 40 deletions.
4 changes: 2 additions & 2 deletions app/src/Controller/ApiV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/src/Model/Behavior/ChangelogBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
8 changes: 4 additions & 4 deletions app/templates/element/autocompletePeople.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
<label :for="this.inputId">{{ this.txt['autocomplete.people.label'] }}</label>
<AutoComplete
v-model="person"
v-model="person"
@complete="searchPeople"
inputClass="cm-autocomplete"
panelClass="cm-autocomplete-panel"
:inputId="this.options.htmlId"
:suggestions="this.people"
optionLabel="label"
@complete="search"
:minLength="this.options.minLength"
:placeholder="this.txt['autocomplete.people.placeholder']"
forceSelection
:loading="loading"
:delay="500"
@item-select="setPerson">
<template #option="slotProps">
<div class="cm-ac-item">
Expand Down

0 comments on commit 1311315

Please sign in to comment.