Skip to content

Commit cda0319

Browse files
committed
CatalogAPI refactoring
1 parent c3d48a3 commit cda0319

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

src/api/catalogApi.js

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,63 @@ import { server } from "./config";
33

44
class CatalogApi {
55

6+
// get list of all available catalogs
67
static getAllCatalogs() {
7-
return axios(
8-
{
9-
method: 'get',
10-
url: `${server}/form/info`,
11-
params: {
12-
size: 5000
13-
}
8+
return axios({
9+
method: 'get',
10+
url: `${server}/form/info`,
11+
params: {
12+
size: 5000
1413
}
15-
);
14+
});
1615
}
1716

17+
// get full metadata of specified catalog
1818
static getCatalogInfo(catalogClass) {
19-
return axios.get(`${server}/form/info/${catalogClass}`);
19+
return axios({
20+
method: 'get',
21+
url: `${server}/form/info/${catalogClass}`
22+
});
2023
}
2124

25+
// get <size> objects of specified catalog
2226
static getCatalogExtent(catalogClass) {
23-
return axios.get(`${server}/form/objects/${catalogClass}/info?size=500`);
27+
return axios({
28+
method: 'get',
29+
url: `${server}/form/objects/${catalogClass}/info`,
30+
params: {
31+
size: 5000
32+
}
33+
});
2434
}
2535

36+
// get <size> objects of specified catalog with _class property
2637
static getCatalogExtendWithClass(catalogClass) {
27-
return axios.get(`${server}/form/objects/${catalogClass}/infoclass?size=500&orderby=name`);
38+
return axios({
39+
method: 'get',
40+
url: `${server}/form/objects/${catalogClass}/infoclass`,
41+
params: {
42+
size: 5000,
43+
orderby: 'name'
44+
}
45+
});
2846
}
2947

48+
// get object by catalog and id
3049
static getFormObjectById(catalogClass, id) {
31-
return axios.get(`${server}/form/object/${catalogClass}/${id}`);
50+
return axios({
51+
method: 'get',
52+
url: `${server}/form/object/${catalogClass}/${id}`
53+
});
3254
}
3355

56+
3457
static saveCatalog(catalogClass, id, catalog) {
35-
return axios.put(`${server}/form/object/${catalogClass}/${id}`, catalog);
58+
return axios({
59+
method: 'put',
60+
url: `${server}/form/object/${catalogClass}/${id}`,
61+
data: catalog
62+
});
3663
}
3764
}
3865

src/api/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// should be changed to actual rest application
12
export const server = 'http://localhost:57773/sah/rest';

src/components/catalog/ManageCatalogPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class ManageCatalogPage extends React.Component {
133133
<Breadcrumb.Item>
134134
<a onClick={this.goPathOnClick(`/catalog/${this.props.match.params.name}`)}>{this.state.catalog.name}</a>
135135
</Breadcrumb.Item>
136-
<Breadcrumb.Item>{this.state.form.name || 'Создание объекта'}</Breadcrumb.Item>
136+
<Breadcrumb.Item>{this.state.form.name || 'Object creating'}</Breadcrumb.Item>
137137
</Breadcrumb>
138138

139139
<div style={{background: '#fff', padding: 24, minHeight: 280}}>
@@ -145,7 +145,7 @@ export class ManageCatalogPage extends React.Component {
145145

146146
{!this.state.loading &&
147147
<div>
148-
{!this.props.match.params.id && <h1>Создание объекта справочника '{this.state.catalog.name}'</h1>}
148+
{!this.props.match.params.id && <h1>'{this.state.catalog.name}: creating new object'</h1>}
149149

150150
{this.props.match.params.id &&
151151
(this.state.catalog.objpermissions.indexOf('U') !== -1) &&

0 commit comments

Comments
 (0)