Skip to content

Commit

Permalink
add tables Description to createTable
Browse files Browse the repository at this point in the history
Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
  • Loading branch information
grnd-alt committed Apr 10, 2024
1 parent 91bc7d0 commit 1f87bac
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/Controller/ApiTablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ public function show(int $id): DataResponse {
*
* @param string $title Title of the table
* @param string|null $emoji Emoji for the table
* @param string|null $description Description for the table
* @param string $template Template to use if wanted
*
* @return DataResponse<Http::STATUS_OK, TablesTable, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Tables returned
*/
public function create(string $title, ?string $emoji, string $template = 'custom'): DataResponse {
public function create(string $title, ?string $emoji, ?string $description, string $template = 'custom'): DataResponse {
try {
return new DataResponse($this->service->create($title, $template, $emoji)->jsonSerialize());
return new DataResponse($this->service->create($title, $template, $emoji, $description)->jsonSerialize());
} catch (InternalError|Exception $e) {
return $this->handleError($e);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Service/TableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,13 @@ public function find(int $id, bool $skipTableEnhancement = false, ?string $userI
* @throws InternalError
* @noinspection DuplicatedCode
*/
public function create(string $title, string $template, ?string $emoji, ?string $userId = null): Table {
public function create(string $title, string $template, ?string $emoji, ?string $description = '', ?string $userId = null): Table {
$userId = $this->permissionsService->preCheckUserId($userId, false); // we can assume that the $userId is set

$time = new DateTime();
$item = new Table();
$item->setTitle($title);
$item->setDescription($description);
if($emoji) {
$item->setEmoji($emoji);
}
Expand Down
9 changes: 9 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5077,6 +5077,15 @@
"nullable": true
}
},
{
"name": "description",
"in": "query",
"description": "Description for the table",
"schema": {
"type": "string",
"nullable": true
}
},
{
"name": "template",
"in": "query",
Expand Down
17 changes: 17 additions & 0 deletions src/modules/modals/CreateTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
@input="titleChangedManually">
</div>
</div>
<div class="row">
<div class="col-4 mandatory">
{{ t('tables', 'Description') }}
</div>
<div class="col-4">
<TableDescription :description.sync="description" :read-only="false" />
</div>
</div>
<div class="row space-T">
<div class="col-2 block space-R space-B">
<NcTile
Expand Down Expand Up @@ -65,6 +73,7 @@ import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import NcTile from '../../shared/components/ncTile/NcTile.vue'
import displayError from '../../shared/utils/displayError.js'
import TableDescription from '../../modules/main/sections/TableDescription.vue'
export default {
name: 'CreateTable',
Expand All @@ -73,6 +82,7 @@ export default {
NcEmojiPicker,
NcButton,
NcTile,
TableDescription,
},
props: {
showModal: {
Expand All @@ -84,6 +94,7 @@ export default {
return {
title: '',
icon: '',
description: '',
errorTitle: false,
templates: null,
templateChoice: 'custom',
Expand Down Expand Up @@ -159,6 +170,7 @@ export default {
async sendNewTableToBE(template) {
const data = {
title: this.title,
description: this.description,
emoji: this.icon,
template,
}
Expand Down Expand Up @@ -190,6 +202,11 @@ export default {
</script>
<style lang="scss" scoped>
:deep(.element-description) {
padding-inline: 0 !important;
max-width: 100%;
}
.modal__content {
padding-right: 0 !important;
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default new Vuex.Store({
let res = null

try {
res = await axios.post(generateUrl('/apps/tables/table'), data)
res = (await axios.post(generateOcsUrl('/apps/tables/api/2/tables'), data)).data.ocs
} catch (e) {
displayError(e, t('tables', 'Could not insert table.'))
return false
Expand Down
2 changes: 2 additions & 0 deletions src/types/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,8 @@ export type operations = {
title: string;
/** @description Emoji for the table */
emoji?: string | null;
/** @description Description for the table */
description?: string | null;
/** @description Template to use if wanted */
template?: string;
};
Expand Down

0 comments on commit 1f87bac

Please sign in to comment.