Commit f6bf810e authored by Yorrd's avatar Yorrd
Browse files

feat: allow input of multiple questions

parent 07c45ff4
import { element, html, rerender } from '@adornis/base';
import { AdornisDBView, AttributeField } from '@adornis/adornis-components/a-dbview';
import { Content, Country } from 'imports/db/contents';
import { BehaviorSubject, of, combineLatest } from 'rxjs';
import { ifDefined } from 'lit-html/directives/if-defined';
import { takeUntil, distinctUntilChanged, map, switchMap, startWith } from 'rxjs/operators';
import '@adornis/adornis-components/a-drop-wrapper';
import { element, html, rerender } from '@adornis/base';
import { RenderProps } from '@adornis/base/reactive-lit-element';
import { rxRepeat } from '@adornis/base/rx-repeat';
import { spacing } from '@adornis/design/generate-base/tokens';
import { AdornisUser } from '@adornis/users/db';
const moment = require('moment');
import '@material/mwc-textfield';
import '@material/mwc-icon-button';
import '@adornis/forms/a-file-input';
import '@adornis/adornis-components/a-drop-wrapper';
import { AdornisUser } from '@adornis/users/db';
import '@material/mwc-checkbox';
import { virtualize } from '@adornis/base/when-seen';
import '@material/mwc-icon-button';
import '@material/mwc-textfield';
import { Content, Country } from 'imports/db/contents';
import { AdornisDialog } from 'imports/git_modules/adornis-components/a-dialog';
import { listenDevice, BreakPoint } from 'imports/git_modules/base/window-size';
import { BreakPoint, listenDevice } from 'imports/git_modules/base/window-size';
import { ifDefined } from 'lit-html/directives/if-defined';
import { repeat } from 'lit-html/directives/repeat';
import { BehaviorSubject, combineLatest } from 'rxjs';
import { distinctUntilChanged, map, switchMap, takeUntil } from 'rxjs/operators';
const moment = require('moment');
@element('ccb-contents-admin')
export class CCBContentsAdmin extends AdornisDBView<Content> {
......@@ -136,7 +135,8 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
),
)}"
>
${this.opened.pipe(
${entity.whenChanging.pipe(
switchMap(() => this.opened),
map(opened =>
opened !== index
? html`
......@@ -165,6 +165,12 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
</a-box>
${this.fieldDisplays(this.getField('Frage')!, entity, index)}
</a-stack>
${this.fieldDisplays(this.getField('AlternativFragen')!, entity, index)}
<mwc-button icon="add" @click=${() => (entity.AlternativFragen = [...entity.AlternativFragen, ''])}>
Alternativfrage hinzufügen
</mwc-button>
${this.fieldDisplays(this.getField('Antwort')!, entity, index)}
${this.fieldDisplays(this.getField('Quelle')!, entity, index)}
${this.fieldDisplays(this.getField('intent')!, entity, index)}
......@@ -214,8 +220,9 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
entity.upload(fileToUpload);
}
}}"
>Datei hochladen</ccb-button
>
Datei hochladen
</ccb-button>
<ccb-button
@click="${() =>
AdornisDialog.showPopup(
......@@ -270,7 +277,7 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
this.entities.next(
this.baseQLClass.getValue().find({
Rechtsgebiet: this.chosenRechtsgebiet.getValue() || undefined,
$or: this.selectedFields.getValue().map(f => ({ [f]: { $regex: newValue } })),
$or: this.selectedFields.getValue().map(f => ({ [f]: { $regex: newValue, $options: 'gi' } })),
}).whenReady,
);
}
......@@ -340,6 +347,37 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
}}"
></a-writer>
`;
case 'AlternativFragen':
return html`
${repeat(
data.AlternativFragen,
(frage, i) => html`
<a-inline centered size="md">
<mwc-icon
@click=${() => {
data[field.name].splice(i, 1);
data[field.name] = data[field.name];
}}
>
delete
</mwc-icon>
<mwc-textfield
style=${{ flex: '1' }}
label="Alternativfrage"
.value="${ifDefined(data[field.name][i])}"
@input="${e => {
const value = e.currentTarget.value;
if (data[field.name][i] === value) return;
data[field.name][i] = value;
data.dirty.next(true);
data.whenChanging.next(data);
}}"
></mwc-textfield>
</a-inline>
`,
)}
`;
default:
return super.fieldDisplays(field, data, index);
}
......@@ -371,16 +409,23 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
@click="${async () => {
const contents = await this.askForFile('*.csv');
const array2d = contents.split('\n').map(line => line.split(';'));
console.log(array2d[0][0]);
console.log(array2d[0 + 1][0]);
for (var i = 0; i <= 0; i++) {
for (var j = 0; j < 21; j++) {
if (array2d[i][j].startsWith('#')) {
console.log('Ein Geschenk mit Schleife und Hashtag. Wow!');
console.log('Client Log');
Content.csvImport(contents).subscribe();
/*
if (array2d[0][0] === 'A.1') {
console.log('Richtige Versionsnummer');
if (array2d[24][0].startsWith('#')) {
console.log('Formatierung scheint nicht geändert worden zu sein. Gut so!');
for (var i = 0; i <= 14; i++) {
console.log(array2d[24][i]);
if (array2d[24][i] !== ('' || undefined)) {
console.log('Fortschritt');
}
}
}
}
console.log('Ende Gelände.');
}*/
// await Promise.all(
// contents
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment