Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Feb 1, 2023
1 parent efda779 commit fead135
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*/
'namespace' => env('LODATA_NAMESPACE', 'com.example.odata'),

/*
* The default version of the OData protocol to support for every request.
*/
'version' => env('LODATA_VERSION', '4.01'),

/*
* The name of the Laravel disk to use to store asynchronously processed requests.
* In a multi-server shared hosting environment, all hosts should be able to access this disk
Expand Down
1 change: 1 addition & 0 deletions doc/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ module.exports = {
'clients/dataverse',
'clients/salesforce',
'clients/sap',
'clients/devextreme',
],
},
{
Expand Down
55 changes: 55 additions & 0 deletions doc/clients/devextreme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# DevExtreme

DevExtreme (by DevExpress) supports OData as a [data source](https://js.devexpress.com/Documentation/Guide/Data_Binding/Specify_a_Data_Source/OData/).
However, it supports only OData 4.0, not OData 4.01. To support Lodata you must send the "OData-Version" header with every request.

Alternatively, you can configure Lodata to default to OData 4.0 if the client does not specify a version by modifying the
[configuration](/getting-started/configuration.md)

This Vue example shows how to send the header, and load data into a DxDataGrid.

```vue
<template>
<DxDataGrid
:data-source="dataSource"
:show-borders="true"
>
<DxColumn data-field="id"/>
<DxColumn data-field="name"/>
<DxColumn data-field="email"/>
</DxDataGrid>
</template>
<script>
import 'devextreme/data/odata/store';
import { DxDataGrid, DxColumn } from 'devextreme-vue/data-grid';
export default {
components: {
DxDataGrid,
DxColumn,
},
data() {
return {
dataSource: {
store: {
type: 'odata',
url: 'http://localhost:8000/odata/Users',
beforeSend: function (e) {
e.headers = {
'OData-Version': '4.0'
};
},
key: 'id',
version: 4
},
select: [
'id',
'name',
'email'
]
},
};
},
};
</script>
```
2 changes: 1 addition & 1 deletion src/Transaction/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct($version, $maxVersion)
);
}

$this->version = ($maxVersion ?: $version) ?: self::v4_01;
$this->version = ($maxVersion ?: $version) ?: config('lodata.version', self::v4_01);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Protocol/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Flat3\Lodata\Helper\Constants;
use Flat3\Lodata\Tests\Helpers\Request;
use Flat3\Lodata\Tests\TestCase;
use Flat3\Lodata\Transaction\Version;

class VersionTest extends TestCase
{
Expand Down Expand Up @@ -46,5 +47,12 @@ public function test_accepts_maxversion_header()
->header(Constants::odataMaxVersion, '4.0')
);
}

public function test_config_default_version()
{
config(['lodata.version' => Version::v4_0]);

$this->assertResponseSnapshot((new Request));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"headers": {
"cache-control": [
"no-cache, private"
],
"content-type": [
"application/json;odata.metadata=minimal"
],
"odata-version": [
"4.0"
]
},
"status": 200
}

0 comments on commit fead135

Please sign in to comment.