Implement maintenance view (#235)

* implement backend to query maintenances

* improve backend API for maintenances

* add itemId and itemName (v1/maintenances)

* fix remaining todo in backend (/v1/maintenances)

* refactor: extract MaintenanceEditModal

* first draft (to be cleaned)

* revert dependency updates (not required)

* translation + fix deletion

* fix main menu css issues

* fix main menu "create" button (css)

* enhancement: make item name clickable

* fix: add page title (+ translate existing ones)

* fix: missing toast translation (when updating)

* bug fix: missing group check in backend (for new endpoint)

* backport from following PR (to avoid useless changes)

* maintenances => maintenance
This commit is contained in:
mcarbonne
2024-09-23 19:07:27 +02:00
committed by GitHub
parent 897f3842e0
commit a85c42b539
21 changed files with 1165 additions and 445 deletions

View File

@@ -10,7 +10,6 @@ import type {
ItemUpdate,
MaintenanceEntry,
MaintenanceEntryCreate,
MaintenanceEntryUpdate,
MaintenanceLog,
} from "../types/data-contracts";
import type { AttachmentTypes, PaginationResult } from "../types/non-generated";
@@ -71,7 +70,7 @@ type MaintenanceEntryQuery = {
completed?: boolean;
};
export class MaintenanceAPI extends BaseAPI {
export class ItemMaintenanceAPI extends BaseAPI {
getLog(itemId: string, q: MaintenanceEntryQuery = {}) {
return this.http.get<MaintenanceLog>({ url: route(`/items/${itemId}/maintenance`, q) });
}
@@ -82,29 +81,18 @@ export class MaintenanceAPI extends BaseAPI {
body: data,
});
}
delete(itemId: string, entryId: string) {
return this.http.delete<void>({ url: route(`/items/${itemId}/maintenance/${entryId}`) });
}
update(itemId: string, entryId: string, data: MaintenanceEntryUpdate) {
return this.http.put<MaintenanceEntryUpdate, MaintenanceEntry>({
url: route(`/items/${itemId}/maintenance/${entryId}`),
body: data,
});
}
}
export class ItemsApi extends BaseAPI {
attachments: AttachmentsAPI;
maintenance: MaintenanceAPI;
maintenance: ItemMaintenanceAPI;
fields: FieldsAPI;
constructor(http: Requests, token: string) {
super(http, token);
this.fields = new FieldsAPI(http);
this.attachments = new AttachmentsAPI(http);
this.maintenance = new MaintenanceAPI(http);
this.maintenance = new ItemMaintenanceAPI(http);
}
fullpath(id: string) {