Skip to content

Commit 331d0b6

Browse files
feat(import): change column format during import
Signed-off-by: Luka Trovic <[email protected]>
1 parent 9452082 commit 331d0b6

File tree

9 files changed

+433
-551
lines changed

9 files changed

+433
-551
lines changed

lib/Controller/Api1Controller.php

Lines changed: 72 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCA\Tables\Api\V1Api;
1414
use OCA\Tables\AppInfo\Application;
1515
use OCA\Tables\Db\ViewMapper;
16+
use OCA\Tables\Dto\Column as ColumnDto;
1617
use OCA\Tables\Errors\InternalError;
1718
use OCA\Tables\Errors\NotFoundError;
1819
use OCA\Tables\Errors\PermissionError;
@@ -816,34 +817,30 @@ public function createColumn(
816817
$this->userId,
817818
$tableId,
818819
$viewId,
819-
$type,
820-
$subtype,
821-
$title,
822-
$mandatory,
823-
$description,
824-
825-
$textDefault,
826-
$textAllowedPattern,
827-
$textMaxLength,
828-
829-
$numberPrefix,
830-
$numberSuffix,
831-
$numberDefault,
832-
$numberMin,
833-
$numberMax,
834-
$numberDecimals,
835-
836-
$selectionOptions,
837-
$selectionDefault,
838-
839-
$datetimeDefault,
840-
841-
$usergroupDefault,
842-
$usergroupMultipleItems,
843-
$usergroupSelectUsers,
844-
$usergroupSelectGroups,
845-
$usergroupShowUserStatus,
846-
820+
new ColumnDto(
821+
title: $title,
822+
type: $type,
823+
subtype: $subtype,
824+
mandatory: $mandatory,
825+
description: $description,
826+
textDefault: $textDefault,
827+
textAllowedPattern: $textAllowedPattern,
828+
textMaxLength: $textMaxLength,
829+
numberDefault: $numberDefault,
830+
numberMin: $numberMin,
831+
numberMax: $numberMax,
832+
numberDecimals: $numberDecimals,
833+
numberPrefix: $numberPrefix,
834+
numberSuffix: $numberSuffix,
835+
selectionOptions: $selectionOptions,
836+
selectionDefault: $selectionDefault,
837+
datetimeDefault: $datetimeDefault,
838+
usergroupDefault: $usergroupDefault,
839+
usergroupMultipleItems: $usergroupMultipleItems,
840+
usergroupSelectUsers: $usergroupSelectUsers,
841+
usergroupSelectGroups: $usergroupSelectGroups,
842+
showUserStatus: $usergroupShowUserStatus
843+
),
847844
$selectedViewIds
848845
)->jsonSerialize());
849846
} catch (PermissionError $e) {
@@ -930,32 +927,29 @@ public function updateColumn(
930927
$columnId,
931928
null,
932929
$this->userId,
933-
null,
934-
$subtype,
935-
$title,
936-
$mandatory,
937-
$description,
938-
939-
$textDefault,
940-
$textAllowedPattern,
941-
$textMaxLength,
942-
943-
$numberPrefix,
944-
$numberSuffix,
945-
$numberDefault,
946-
$numberMin,
947-
$numberMax,
948-
$numberDecimals,
949-
950-
$selectionOptions,
951-
$selectionDefault,
952-
$datetimeDefault,
953-
954-
$usergroupDefault,
955-
$usergroupMultipleItems,
956-
$usergroupSelectUsers,
957-
$usergroupSelectGroups,
958-
$usergroupShowUserStatus,
930+
new ColumnDto(
931+
title: $title,
932+
subtype: $subtype,
933+
mandatory: $mandatory,
934+
description: $description,
935+
textDefault: $textDefault,
936+
textAllowedPattern: $textAllowedPattern,
937+
textMaxLength: $textMaxLength,
938+
numberDefault: $numberDefault,
939+
numberMin: $numberMin,
940+
numberMax: $numberMax,
941+
numberDecimals: $numberDecimals,
942+
numberPrefix: $numberPrefix,
943+
numberSuffix: $numberSuffix,
944+
selectionOptions: $selectionOptions,
945+
selectionDefault: $selectionDefault,
946+
datetimeDefault: $datetimeDefault,
947+
usergroupDefault: $usergroupDefault,
948+
usergroupMultipleItems: $usergroupMultipleItems,
949+
usergroupSelectUsers: $usergroupSelectUsers,
950+
usergroupSelectGroups: $usergroupSelectGroups,
951+
showUserStatus: $usergroupShowUserStatus
952+
)
959953
);
960954
return new DataResponse($item->jsonSerialize());
961955
} catch (InternalError $e) {
@@ -1533,34 +1527,30 @@ public function createTableColumn(
15331527
$this->userId,
15341528
$tableId,
15351529
null,
1536-
$type,
1537-
$subtype,
1538-
$title,
1539-
$mandatory,
1540-
$description,
1541-
1542-
$textDefault,
1543-
$textAllowedPattern,
1544-
$textMaxLength,
1545-
1546-
$numberPrefix,
1547-
$numberSuffix,
1548-
$numberDefault,
1549-
$numberMin,
1550-
$numberMax,
1551-
$numberDecimals,
1552-
1553-
$selectionOptions,
1554-
$selectionDefault,
1555-
1556-
$datetimeDefault,
1557-
1558-
$usergroupDefault,
1559-
$usergroupMultipleItems,
1560-
$usergroupSelectUsers,
1561-
$usergroupSelectGroups,
1562-
$usergroupShowUserStatus,
1563-
1530+
new ColumnDto(
1531+
title: $title,
1532+
type: $type,
1533+
subtype: $subtype,
1534+
mandatory: $mandatory,
1535+
description: $description,
1536+
textDefault: $textDefault,
1537+
textAllowedPattern: $textAllowedPattern,
1538+
textMaxLength: $textMaxLength,
1539+
numberDefault: $numberDefault,
1540+
numberMin: $numberMin,
1541+
numberMax: $numberMax,
1542+
numberDecimals: $numberDecimals,
1543+
numberPrefix: $numberPrefix,
1544+
numberSuffix: $numberSuffix,
1545+
selectionOptions: $selectionOptions,
1546+
selectionDefault: $selectionDefault,
1547+
datetimeDefault: $datetimeDefault,
1548+
usergroupDefault: $usergroupDefault,
1549+
usergroupMultipleItems: $usergroupMultipleItems,
1550+
usergroupSelectUsers: $usergroupSelectUsers,
1551+
usergroupSelectGroups: $usergroupSelectGroups,
1552+
showUserStatus: $usergroupShowUserStatus
1553+
),
15641554
$selectedViewIds
15651555
);
15661556
return new DataResponse($item->jsonSerialize());

lib/Controller/ApiColumnsController.php

Lines changed: 52 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
namespace OCA\Tables\Controller;
88

9+
use OCA\Tables\Dto\Column as ColumnDto;
910
use OCA\Tables\Errors\InternalError;
1011
use OCA\Tables\Errors\NotFoundError;
1112
use OCA\Tables\Errors\PermissionError;
@@ -127,28 +128,19 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
127128
$this->userId,
128129
$tableId,
129130
$viewId,
130-
'number',
131-
$subtype,
132-
$title,
133-
$mandatory,
134-
$description,
135-
null,
136-
null,
137-
null,
138-
$numberPrefix,
139-
$numberSuffix,
140-
$numberDefault,
141-
$numberMin,
142-
$numberMax,
143-
$numberDecimals,
144-
null,
145-
null,
146-
null,
147-
null,
148-
null,
149-
null,
150-
null,
151-
null,
131+
new ColumnDto(
132+
title: $title,
133+
type: 'number',
134+
subtype: $subtype,
135+
mandatory: $mandatory,
136+
description: $description,
137+
numberDefault: $numberDefault,
138+
numberMin: $numberMin,
139+
numberMax: $numberMax,
140+
numberDecimals: $numberDecimals,
141+
numberPrefix: $numberPrefix,
142+
numberSuffix: $numberSuffix
143+
),
152144
$selectedViewIds
153145
);
154146
return new DataResponse($column->jsonSerialize());
@@ -187,28 +179,16 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
187179
$this->userId,
188180
$tableId,
189181
$viewId,
190-
'text',
191-
$subtype,
192-
$title,
193-
$mandatory,
194-
$description,
195-
$textDefault,
196-
$textAllowedPattern,
197-
$textMaxLength,
198-
null,
199-
null,
200-
null,
201-
null,
202-
null,
203-
null,
204-
null,
205-
null,
206-
null,
207-
null,
208-
null,
209-
null,
210-
null,
211-
null,
182+
new ColumnDto(
183+
title: $title,
184+
type: 'text',
185+
subtype: $subtype,
186+
mandatory: $mandatory,
187+
description: $description,
188+
textDefault: $textDefault,
189+
textAllowedPattern: $textAllowedPattern,
190+
textMaxLength: $textMaxLength
191+
),
212192
$selectedViewIds
213193
);
214194
return new DataResponse($column->jsonSerialize());
@@ -246,28 +226,15 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
246226
$this->userId,
247227
$tableId,
248228
$viewId,
249-
'selection',
250-
$subtype,
251-
$title,
252-
$mandatory,
253-
$description,
254-
null,
255-
null,
256-
null,
257-
null,
258-
null,
259-
null,
260-
null,
261-
null,
262-
null,
263-
$selectionOptions,
264-
$selectionDefault,
265-
null,
266-
null,
267-
null,
268-
null,
269-
null,
270-
null,
229+
new ColumnDto(
230+
title: $title,
231+
type: 'selection',
232+
subtype: $subtype,
233+
mandatory: $mandatory,
234+
description: $description,
235+
selectionOptions: $selectionOptions,
236+
selectionDefault: $selectionDefault
237+
),
271238
$selectedViewIds
272239
);
273240
return new DataResponse($column->jsonSerialize());
@@ -304,28 +271,14 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
304271
$this->userId,
305272
$tableId,
306273
$viewId,
307-
'text',
308-
$subtype,
309-
$title,
310-
$mandatory,
311-
$description,
312-
null,
313-
null,
314-
null,
315-
null,
316-
null,
317-
null,
318-
null,
319-
null,
320-
null,
321-
null,
322-
null,
323-
$datetimeDefault,
324-
null,
325-
null,
326-
null,
327-
null,
328-
null,
274+
new ColumnDto(
275+
title: $title,
276+
type: 'datetime',
277+
subtype: $subtype,
278+
mandatory: $mandatory,
279+
description: $description,
280+
datetimeDefault: $datetimeDefault
281+
),
329282
$selectedViewIds
330283
);
331284
return new DataResponse($column->jsonSerialize());
@@ -363,28 +316,17 @@ public function createUsergroupColumn(int $baseNodeId, string $title, ?string $u
363316
$this->userId,
364317
$tableId,
365318
$viewId,
366-
'usergroup',
367-
null,
368-
$title,
369-
$mandatory,
370-
$description,
371-
null,
372-
null,
373-
null,
374-
null,
375-
null,
376-
null,
377-
null,
378-
null,
379-
null,
380-
null,
381-
null,
382-
null,
383-
$usergroupDefault,
384-
$usergroupMultipleItems,
385-
$usergroupSelectUsers,
386-
$usergroupSelectGroups,
387-
$showUserStatus,
319+
new ColumnDto(
320+
title: $title,
321+
type: 'usergroup',
322+
mandatory: $mandatory,
323+
description: $description,
324+
usergroupDefault: $usergroupDefault,
325+
usergroupMultipleItems: $usergroupMultipleItems,
326+
usergroupSelectUsers: $usergroupSelectUsers,
327+
usergroupSelectGroups: $usergroupSelectGroups,
328+
showUserStatus: $showUserStatus
329+
),
388330
$selectedViewIds
389331
);
390332
return new DataResponse($column->jsonSerialize());

0 commit comments

Comments
 (0)