#11 Finally align structure of question on category in db

This commit is contained in:
Christoph Lienhard 2020-12-29 17:58:20 +01:00
parent 3bb827b963
commit 9a1dc02a7f
Signed by: christoph.lienhard
GPG key ID: 6B98870DDC270884
5 changed files with 20 additions and 20 deletions

View file

@ -2,8 +2,8 @@
create table candymat_data.category
(
row_id serial primary key,
title character varying(300) UNIQUE NOT NULL,
description character varying(5000)
title character varying(300) UNIQUE NOT NULL check ( title <> '' ),
description character varying(15000)
);
grant select on table candymat_data.category to candymat_person;
-- the following line is only necessary as long as the candymat should be publicly accessible
@ -16,8 +16,8 @@ create table candymat_data.question
(
row_id serial primary key,
category_row_id integer REFERENCES candymat_data.category (row_id) ON UPDATE CASCADE ON DELETE SET NULL,
text character varying(3000) NOT NULL,
description character varying(5000)
title character varying(3000) UNIQUE NOT NULL check ( title <> '' ),
description character varying(15000)
);
grant select on table candymat_data.question to candymat_person;
-- the following line is only necessary as long as the candymat should be publicly accessible
@ -31,7 +31,7 @@ create table candymat_data.answer
question_row_id integer REFERENCES candymat_data.question (row_id) ON UPDATE CASCADE ON DELETE CASCADE,
person_row_id integer REFERENCES candymat_data.person (row_id) ON UPDATE CASCADE ON DELETE CASCADE,
position integer NOT NULL,
text character varying(5000),
text character varying(15000),
created_at timestamp default now(),
primary key (question_row_id, person_row_id)
);

View file

@ -3,7 +3,7 @@ insert into candymat_data.category (title, description) values
insert into candymat_data.category (title, description) values
('Sonstiges', '');
insert into candymat_data.question (category_row_id, text, description) values
insert into candymat_data.question (category_row_id, title, description) values
(1, 'Was sagen Sie zur 10H Regel?', 'In Bayern dürfen Windräder nur ...');
insert into candymat_data.question (category_row_id, text, description) values
insert into candymat_data.question (category_row_id, title, description) values
(2, 'Umgehungsstraße XY?', 'Zur Entlastung der Hauptstraße ...');

View file

@ -2,8 +2,8 @@ import {gql} from "@apollo/client";
import {BasicQuestionFragment, BasicQuestionResponse} from "../queries/question";
export const EDIT_QUESTION = gql`
mutation UpdateQuestion($id: ID!, $text: String, $description: String, $categoryRowId: Int) {
updateQuestion(input: {id: $id, questionPatch: {categoryRowId: $categoryRowId, description: $description, text: $text}}) {
mutation UpdateQuestion($id: ID!, $title: String, $description: String, $categoryRowId: Int) {
updateQuestion(input: {id: $id, questionPatch: {categoryRowId: $categoryRowId, description: $description, title: $title}}) {
question {
...BasicQuestionFragment
}
@ -18,14 +18,14 @@ export interface EditQuestionResponse {
export interface EditQuestionVariables {
id: string,
text?: string,
title?: string,
description?: string,
categoryRowId?: number | null,
}
export const ADD_QUESTION = gql`
mutation AddQuestion($text: String!, $description: String, $categoryRowId: Int) {
createQuestion(input: {question: {text: $text, categoryRowId: $categoryRowId, description: $description}}) {
mutation AddQuestion($title: String!, $description: String, $categoryRowId: Int) {
createQuestion(input: {question: {title: $title, categoryRowId: $categoryRowId, description: $description}}) {
question {
...BasicQuestionFragment
}
@ -41,7 +41,7 @@ export interface AddQuestionResponse {
}
export interface AddQuestionVariables {
text: string,
title: string,
description?: string,
categoryRowId?: number | null
}

View file

@ -17,7 +17,7 @@ interface GetQuestionsCategoryResponse {
export const BasicQuestionFragment = gql`
fragment BasicQuestionFragment on Question {
id
text
title
description
categoryByCategoryRowId {
...QuestionCategoryFragment
@ -28,7 +28,7 @@ export const BasicQuestionFragment = gql`
export interface BasicQuestionResponse {
id: string,
text: string,
title: string,
description?: string,
categoryByCategoryRowId?: GetQuestionsCategoryResponse
}

View file

@ -134,7 +134,7 @@ export default function QuestionList() {
if (changeDialogContent.id !== question.id) {
setChangeDialogContent({
id: question.id,
title: question.text,
title: question.title,
details: question.description,
categoryId: question.categoryByCategoryRowId ? question.categoryByCategoryRowId.rowId : null,
})
@ -146,7 +146,7 @@ export default function QuestionList() {
setDeleteDialogContent({
...deleteDialogContent,
id: question.id,
title: question.text,
title: question.title,
});
setDeleteDialogOpen(true);
}
@ -160,7 +160,7 @@ export default function QuestionList() {
editQuestion({
variables: {
id: changeDialogContent.id,
text: changeDialogContent.title,
title: changeDialogContent.title,
description: changeDialogContent.details,
categoryRowId: changeDialogContent.categoryId,
}
@ -168,7 +168,7 @@ export default function QuestionList() {
} else {
addQuestion({
variables: {
text: changeDialogContent.title,
title: changeDialogContent.title,
description: changeDialogContent.details,
categoryRowId: changeDialogContent.categoryId,
}
@ -189,7 +189,7 @@ export default function QuestionList() {
{questions?.map(question => {
return <AccordionWithEdit
key={question.id}
title={question.text}
title={question.title}
subTitle={question.categoryByCategoryRowId?.title}
description={question.description}
onEditButtonClick={() => handleEditButtonClick(question)}